xkb::SelectEvents is wrong
The request function is generated as:
```rust
pub fn select_events<'c, Conn>(conn: &'c Conn, device_spec: DeviceSpec, clear: u16, select_all: u16, affect_map: u16, map: u16, details: &SelectEventsAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
where Conn: RequestConnection + ?Sized
{
    let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
        .ok_or(ConnectionError::UnsupportedExtension)?;
    let affect_which = details.value_mask();
    let details_bytes = details.serialize();
    let length: usize = (16 + details_bytes.len() + 3) / 4;
    let length_bytes = TryInto::<u16>::try_into(length).unwrap_or(0).serialize();
    let device_spec_bytes = device_spec.serialize();
    let affect_which_bytes = affect_which.serialize();
    let clear_bytes = clear.serialize();
    let select_all_bytes = select_all.serialize();
    let affect_map_bytes = affect_map.serialize();
    let map_bytes = map.serialize();
    let request0 = [
        extension_information.major_opcode,
        SELECT_EVENTS_REQUEST,
        length_bytes[0],
        length_bytes[1],
        device_spec_bytes[0],
        device_spec_bytes[1],
        affect_which_bytes[0],
        affect_which_bytes[1],
        clear_bytes[0],
        clear_bytes[1],
        select_all_bytes[0],
        select_all_bytes[1],
        affect_map_bytes[0],
        affect_map_bytes[1],
        map_bytes[0],
        map_bytes[1],
    ];
    let length_so_far = (&request0).len();
    let length_so_far = length_so_far + (&details_bytes).len();
    let padding1 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
    let length_so_far = length_so_far + (&padding1).len();
    assert_eq!(length_so_far, length * 4);
    Ok(conn.send_request_without_reply(&[IoSlice::new(&request0), IoSlice::new(&details_bytes), IoSlice::new(&padding1)], Vec::new())?)
}
```

But the XML definition is:
```xml
<request name="SelectEvents" opcode="1">
	<field name="deviceSpec" type="DeviceSpec" />
	<field name="affectWhich" type="CARD16" mask="EventType" />
	<field name="clear" type="CARD16" mask="EventType" />
	<field name="selectAll" type="CARD16" mask="EventType" />
	<field name="affectMap" type="CARD16" mask="MapPart" />
	<field name="map" type="CARD16" mask="MapPart" />
	<switch name="details">
		<op op="&amp;">
			<fieldref>affectWhich</fieldref>
			<op op="&amp;">
				<unop op="~"><fieldref>clear</fieldref></unop>
				<unop op="~"><fieldref>selectAll</fieldref></unop>
			</op>
		</op>
		<bitcase>
			<enumref ref="EventType">NewKeyboardNotify</enumref>
			<field name="affectNewKeyboard" type="CARD16" mask="NKNDetail" />
			<field name="newKeyboardDetails" type="CARD16" mask="NKNDetail" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">StateNotify</enumref>
			<field name="affectState" type="CARD16" mask="StatePart" />
			<field name="stateDetails" type="CARD16" mask="StatePart" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">ControlsNotify</enumref>
			<field name="affectCtrls" type="CARD32" mask="Control" />
			<field name="ctrlDetails" type="CARD32" mask="Control" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">IndicatorStateNotify</enumref>
			<field name="affectIndicatorState" type="CARD32" />
			<field name="indicatorStateDetails" type="CARD32" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">IndicatorMapNotify</enumref>
			<field name="affectIndicatorMap" type="CARD32" />
			<field name="indicatorMapDetails" type="CARD32" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">NamesNotify</enumref>
			<field name="affectNames" type="CARD16" mask="NameDetail" />
			<field name="namesDetails" type="CARD16" mask="NameDetail" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">CompatMapNotify</enumref>
			<field name="affectCompat" type="CARD8" mask="CMDetail" />
			<field name="compatDetails" type="CARD8" mask="CMDetail" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">BellNotify</enumref>
			<field name="affectBell" type="CARD8" />
			<field name="bellDetails" type="CARD8" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">ActionMessage</enumref>
			<field name="affectMsgDetails" type="CARD8" />
			<field name="msgDetails" type="CARD8" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">AccessXNotify</enumref>
			<field name="affectAccessX" type="CARD16" mask="AXNDetail" />
			<field name="accessXDetails" type="CARD16" mask="AXNDetail" />
		</bitcase>
		<bitcase>
			<enumref ref="EventType">ExtensionDeviceNotify</enumref>
			<field name="affectExtDev" type="CARD16" mask="XIFeature" />
			<field name="extdevDetails" type="CARD16" mask="XIFeature" />
		</bitcase>
	</switch>
</request>
```

More specifically:
```xml
<op op="&amp;">
	<fieldref>affectWhich</fieldref>
	<op op="&amp;">
		<unop op="~"><fieldref>clear</fieldref></unop>
		<unop op="~"><fieldref>selectAll</fieldref></unop>
	</op>
</op>
```

The `affectWhich` field value cannot be deduced only from `details`.

diff --git a/code_generator_helpers/module.py b/code_generator_helpers/module.py
index e10e7d3..ed051cf 100644
--- a/code_generator_helpers/module.py
+++ b/code_generator_helpers/module.py
@@ -1342,9 +1342,13 @@ class Module(object):
     def _lower_snake_name(self, name):
         """Convert a name tuple to a lowercase snake name. MonitorInfo is turned
         into monitor_info."""
+
         name = self._name(name)
-        name = re.sub('([a-z0-9])([A-Z])', '\\1_\\2', name)
-        return name.lower()
+        # Based on _cname_re from libxcb's c_client.py
+        pattern = re.compile('([A-Z][a-z0-9]+|[A-Z]+(?![a-z0-9])|[a-z0-9]+)')
+        split = pattern.finditer(name)
+        name_parts = [match.group(0) for match in split]
+        return '_'.join(name_parts).lower()
 
     def _upper_snake_name(self, name):
         """Convert a name tuple to a uppercase snake name. MonitorInfo is turned
diff --git a/src/rust_connection/id_allocator.rs b/src/rust_connection/id_allocator.rs
index b448338..b3d816d 100644
--- a/src/rust_connection/id_allocator.rs
+++ b/src/rust_connection/id_allocator.rs
@@ -50,7 +50,7 @@ impl IDAllocator {
                 return Err(ReplyOrIdError::IdsExhausted);
             }
             // Send an XC-MISC GetXIDRange request.
-            let xidrange = conn.xc_misc_get_xidrange()?.reply()?;
+            let xidrange = conn.xc_misc_get_xid_range()?.reply()?;
             let (start, count) = (xidrange.start_id, xidrange.count);
             // Apparently (0, 1) is how the server signals "I am out of IDs".
             // The second case avoids an underflow below and should never happen.
['code_generator_helpers/module.py', 'src/rust_connection/id_allocator.rs']