Notes on the Implementation of X Protocol Wire Encoding, Specifically the Representation of the Types of Fields in Requests and Responses. Alastair Bridgewater, May 2008. The original implementation of a "wire type" system in CLXS was predicated on single symbols as type specifiers in request and response field definitions, with additional parameters such as an error type or specific required value associated with the slot. Enumerated types in this system were a special case. They could either be defined as a named wire type, in which case the wire type definition did a conversion between the wire encoded value and a symbolic name for the value, or in the request handler, in which case a :typecheck option was added to the slot that would cause the value to be checked against a Lisp type specifier, and the request handler would then be responsible for converting the resulting integer to a suitable symbolic name. The :typecheck slot option was a clear sign of the breakdown of this system, but the situation did not become untenable until the CreateWindow request was examined in detail. The background-pixmap field is specified as being a PIXMAP or having the value None or ParentRelative. The existing system could not handle what was essentially the union of an enumerated type and an X resource type. This prompted a review of the actual definition of the wire encoding for the base protocol. The actual breakdown of types is: * Integers of various widths and signedness. * X Resource IDs of various associated resource types. * Other IDs (ATOMs, for example) which are not X Resources, but have their own namespaces. * Enumerations of various values, starting from 0 or 1 depending on the enumeration in question. * Unions of X Resource IDs and Enumerations. Additionally, most of the enumerations are anonymous enumeration types. The specific cases that need fixing are anonymous enumerations and unions. In order to support these cases, we need to be able to use field type specifiers that are more complex than a single symbol. Enumerated types need to know their base type (always an integer type), the names of each of the enumerated values, and whether they start from 0 or 1. The easiest method to indicate the (relatively rare) case of starting from 1 is to allow a special value of NIL as the name for an invalid index 0. The typespecifier is (:enum ) A union type is always between an enumeration and an X resource type. It always takes the error code from the X resource type, but checks for membership in the enumeration before checkin for a suitable X resource. The type specifier is (:union ). As an implementation convenience for named enumeration types such as WINGRAVITY, the DEFINE-WIRE-TYPE will accept an enumeration type specifier as a base type. EOF