diff --git a/proto/xcb-proto/Makefile b/proto/xcb-proto/Makefile index ac6d35f11..85c4b0f5d 100644 --- a/proto/xcb-proto/Makefile +++ b/proto/xcb-proto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 2010/04/18 19:55:51 matthieu Exp $ +# $OpenBSD: Makefile,v 1.5 2012/03/27 19:12:47 matthieu Exp $ PKGCONFIG= xcb-proto.pc @@ -21,6 +21,7 @@ FILES= \ sync.xml \ xc_misc.xml \ xevie.xml \ + xkb.xml \ xf86dri.xml \ xfixes.xml \ xinerama.xml \ diff --git a/proto/xcb-proto/NEWS b/proto/xcb-proto/NEWS index e6028d602..32bcc6924 100644 --- a/proto/xcb-proto/NEWS +++ b/proto/xcb-proto/NEWS @@ -1,5 +1,37 @@ +Release 1.7 (2012-01-11) +======================== +* Add missing padding bytes to ChangeKeyboardMapping request +* Corrected type of FakeInput rootX & rootY fields +* Changed Exception message in case of unknown/unhandled XML tags +* xcbgen: perform lenfield lookup within all anchestors +* Add support for new expr tags popcount, enumref, sumof +* Changed handling of anchestor types +* Assign switch name to bitcases +* Support name attribute for bitcases and set BitcaseType.has_name accordingly +* Use absolute imports in xcbgen for Python 3 compatibilit +* dri2: Update to version 1.3 (v2) +* glx: Replace some 'reserved' fields with explicit padding +* glx: Use glx:CONTEXT for share_list parameter of CreateNewContext +* glx: Use FBCONFIG type for fbconfig parameter of CreateNewContext and CreatePixmap +* glx: Add protocol for GLX_ARB_create_context and GLX_ARB_create_context_profile +* Add support for fence sync objects +* xf86dri: fix GetDrawableInfo reply +* xproto: fix TranslateCoordinates reply +* xcbgen: Add unop support +* xf86vidmode: Fix padding expressions +* dri2: Add proper padding before driver_name +* Add libdir/exec_prefix to xcb-xproto.pc +* Revive support for hex literals in protocol +* Add description of new protocol elements +* Add XKEYBOARD protocol description +* Fix ChangeHosts address string +* Fix SetFontPath path string encoding +* Fix some fields name +* Fix XKB GetState missing lookupMods field +* Add RENDER 0.11 definitions + Release 1.6 (2009-12-02) -======================= +======================== * Add DRI2 protocol, based off of dri2proto.h and the server code. (v2) * xf86dri.xml seems to have been wrong forever. Fixes bug #16894. * shape: add missing padding bytes to GetRectangles diff --git a/proto/xcb-proto/configure.ac b/proto/xcb-proto/configure.ac index 1a6ca0152..5368e2a05 100644 --- a/proto/xcb-proto/configure.ac +++ b/proto/xcb-proto/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ(2.57) AC_INIT([XCB Proto], - 1.6, + 1.7, [xcb@lists.freedesktop.org]) AC_CONFIG_SRCDIR([xcb-proto.pc.in]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) diff --git a/proto/xcb-proto/doc/xml-xcb.txt b/proto/xcb-proto/doc/xml-xcb.txt index feb99844f..3c6a15519 100644 --- a/proto/xcb-proto/doc/xml-xcb.txt +++ b/proto/xcb-proto/doc/xml-xcb.txt @@ -225,8 +225,17 @@ enum; the value is restricted to one of the constants named in the enum. defining the set of values included, and a list containing these values. value-mask-type gives the type of the bitmask; this must be CARD16 or CARD32. value-mask-name gives the field name of the bitmask, and - value-list-name gives the field name of the list of values. + value-list-name gives the field name of the list of values. Please use + instead for new protocol definitions. + switch expression + bitcase expression, fields + + This element represents conditional inclusion of fields. It can be viewed + as sequence of multiple ifs: if ( switch expression & bitcase expression ) + is equal to bitcase expression, bitcase fields are included in structure. + It can be used only as the last field of structure. New protocol definitions + should prefer to use this instead of . Expressions ----------- @@ -256,3 +265,22 @@ Expressions The bit element represents a literal bitmask value in an expression. The integer must be in the range 0..31, expanding to (1<enum item identifier + + This element represents a reference to item of enum. + +expression + + This element represents a unary operator, with the op attribute specifying + which operator. The only supported operation so far is ~, and its semantic + is identical to the corresponding operator in C. + + + + This element represents a sumation of the elements of the referenced list. + +expression + + This element represents the number of bits set in the expression. + diff --git a/proto/xcb-proto/src/Makefile.am b/proto/xcb-proto/src/Makefile.am index 0f0dfbcda..e1e2743be 100644 --- a/proto/xcb-proto/src/Makefile.am +++ b/proto/xcb-proto/src/Makefile.am @@ -21,6 +21,7 @@ xcbinclude_HEADERS = \ xfixes.xml \ xinerama.xml \ xinput.xml \ + xkb.xml \ xprint.xml \ xselinux.xml \ xtest.xml \ diff --git a/proto/xcb-proto/src/dri2.xml b/proto/xcb-proto/src/dri2.xml index 7fea94839..3af160066 100644 --- a/proto/xcb-proto/src/dri2.xml +++ b/proto/xcb-proto/src/dri2.xml @@ -28,7 +28,7 @@ authorization from the authors. --> + major-version="1" minor-version="3"> xproto @@ -42,10 +42,18 @@ authorization from the authors. + + + + + + 1 + 2 + 3 @@ -85,6 +93,20 @@ authorization from the authors. driver_name_length + + + + + driver_name_length + 3 + + + 3 + + + driver_name_length + + device_name_length @@ -149,4 +171,94 @@ authorization from the authors. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proto/xcb-proto/src/glx.xml b/proto/xcb-proto/src/glx.xml index 544b543a1..53c926737 100644 --- a/proto/xcb-proto/src/glx.xml +++ b/proto/xcb-proto/src/glx.xml @@ -89,6 +89,7 @@ The patch that fixed this server bug in X.org CVS is here: + @@ -348,7 +349,7 @@ The patch that fixed this server bug in X.org CVS is here: - + @@ -366,13 +367,12 @@ The patch that fixed this server bug in X.org CVS is here: - + - + - - + @@ -463,6 +463,64 @@ The patch that fixed this server bug in X.org CVS is here: + + + + + + + + + + num_versions + 2 + + + + gl_str_len + + + glx_str_len + + + + + + + + + + + + + + num_attribs + 2 + + + + + + + + + + + + + num_versions + 3 + + + + gl_str_len + + + glx_str_len + + + diff --git a/proto/xcb-proto/src/render.xml b/proto/xcb-proto/src/render.xml index 59cc8e0bb..9667fbeb6 100644 --- a/proto/xcb-proto/src/render.xml +++ b/proto/xcb-proto/src/render.xml @@ -5,8 +5,8 @@ All Rights Reserved. See the file COPYING in this directory for licensing information. --> - + major-version="0" minor-version="11"> + xproto @@ -20,6 +20,7 @@ for licensing information. + @@ -61,6 +62,23 @@ for licensing information. + + + 48 + + + + + + + + + + + + + + diff --git a/proto/xcb-proto/src/sync.xml b/proto/xcb-proto/src/sync.xml index e30923325..516d149ab 100644 --- a/proto/xcb-proto/src/sync.xml +++ b/proto/xcb-proto/src/sync.xml @@ -5,7 +5,7 @@ All Rights Reserved. See the file COPYING in this directory for licensing information. --> + major-version="3" minor-version="1"> xproto @@ -18,6 +18,8 @@ for licensing information. + + @@ -173,6 +175,37 @@ for licensing information. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proto/xcb-proto/src/xcb.xsd b/proto/xcb-proto/src/xcb.xsd index f3fcb6fe2..7fdf1259c 100644 --- a/proto/xcb-proto/src/xcb.xsd +++ b/proto/xcb-proto/src/xcb.xsd @@ -55,6 +55,37 @@ authorization from the authors. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -89,7 +120,40 @@ authorization from the authors. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -126,7 +190,12 @@ authorization from the authors. - + + + + + + @@ -166,12 +235,20 @@ authorization from the authors. + + + - - - - + + + + + + + + + diff --git a/proto/xcb-proto/src/xf86dri.xml b/proto/xcb-proto/src/xf86dri.xml index 981c9682f..5bfc5727a 100644 --- a/proto/xcb-proto/src/xf86dri.xml +++ b/proto/xcb-proto/src/xf86dri.xml @@ -132,10 +132,15 @@ authorization from the authors. - + + + num_clip_rects + + num_back_clip_rects + diff --git a/proto/xcb-proto/src/xkb.xml b/proto/xcb-proto/src/xkb.xml new file mode 100644 index 000000000..e8f4c021d --- /dev/null +++ b/proto/xcb-proto/src/xkb.xml @@ -0,0 +1,2775 @@ + + + + + xproto + + + + 255 + + 32 + + + 4 + + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + + + + 0 + 1 + 2 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + + + 0 + 1 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + + + + + 27 + 28 + 29 + 30 + 31 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 6 + 7 + + + + + + + + + + + 0 + 4 + + + + 768 + 1280 + + + + + 0 + 5 + + + + 768 + + + + + 256 + 512 + 768 + 1024 + 1280 + 1536 + 65280 + + + + + 0 + 1 + 2 + 3 + + + + 254 + 255 + + + + 0 + 1 + 2 + 3 + + + + 7 + + + + 0 + 6 + 7 + + + + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 + + + + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 + + + + 15 + 14 + 13 + 12 + 11 + 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 + + + + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 + + + + 0 + 1 + 2 + 3 + 4 + + + + 7 + 127 + + + + 7 + 6 + 5 + + + + 4 + 3 + 2 + 1 + 0 + + + + 4 + 3 + 2 + 1 + 0 + + + + + + + + + + + + + + + 0 + 1 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + + + 0 + 1 + 2 + 3 + 4 + + + + 0 + 1 + 2 + 3 + 4 + + + + + + + + + + + 4 + + + + + + 4 + + + 4 + + + + + + + length + + + + + + + length + + + + + + + + + + + + + + + + + + + + + + + + nMapEntries + + + + hasPreserve + nMapEntries + + + + + + + 4 + + + + + + nSyms + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + 129 + 130 + 131 + 132 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + nMapEntries + + + + preserve + nMapEntries + + + + + + + + + + nameLength + + + + valueLength + + + + + + + + + nPoints + + + + + + + + + + + nOutlines + + + + + + 4 + + + + + + + + + 4 + + + 4 + + + + + + + + + nKeys + + + + + + + + + nRows + + + + + + + + + + + nKeys + + + + + 1 + 2 + 3 + 4 + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + nRows + + + nDoodads + + + nOverlays + + + + + + + + length + + + + + + + + + + + + + namesPresent + + + + + mapsPresent + + + + + + + + 255 + 254 + 253 + + + + + + + + + + + + + 0 + 1 + 2 + 2 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + + + + + + + + + + + + 0 + 1 + 2 + 2 + 3 + + + + 3 + 4 + 5 + 6 + + + + + + + + + + + + + + + + + + + + 0 + 2 + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + + + + + + + + + + + + + 0 + 1 + 2 + + + + + + + 6 + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + affectWhich + + clear + selectAll + + + + NewKeyboardNotify + + + + + StateNotify + + + + + ControlsNotify + + + + + IndicatorStateNotify + + + + + IndicatorMapNotify + + + + + NamesNotify + + + + + CompatMapNotify + + + + + BellNotify + + + + + ActionMessage + + + + + AccessXNotify + + + + + ExtensionDeviceNotify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + present + + KeyTypes + + nTypes + + + + KeySyms + + nKeySyms + + + + KeyActions + + nKeyActions + + + totalActions + + + + KeyBehaviors + + totalKeyBehaviors + + + + VirtualMods + + nVModMapKeys + + + + ExplicitComponents + + totalKeyExplicit + + + + ModifierMap + + totalModMapKeys + + + + VirtualModMap + + totalVModMapKeys + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + present + + KeyTypes + + nTypes + + + + KeySyms + + nKeySyms + + + + KeyActions + + nKeyActions + + + totalActions + + + + KeyBehaviors + + totalKeyBehaviors + + + + VirtualMods + + nVModMapKeys + + + + ExplicitComponents + + totalKeyExplicit + + + + ModifierMap + + totalModMapKeys + + + + VirtualModMap + + totalVModMapKeys + + + + + + + + + + + + + + + + + + + + + + 16 + nSIRtrn + + + + + groupsRtrn + + + + + + + + + + + + + + + + + 16 + nSI + + + + + groups + + + + + + + + + + + + + + + + + + + + + + + + + + nIndicators + + + + + + + + + + + which + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + which + + Keycodes + + + + Geometry + + + + Symbols + + + + PhysSymbols + + + + Types + + + + Compat + + + + KeyTypeNames + + nTypes + + + + KTLevelNames + + + nTypes + + + + + + + IndicatorNames + + + indicators + + + + + VirtualModNames + + + virtualMods + + + + + GroupNames + + + groupNames + + + + + KeyNames + + nKeys + + + + KeyAliases + + nKeyAliases + + + + RGNames + + nRadioGroups + + + + + + + + + + + + + + + + + + + + + + + + which + + Keycodes + + + + Geometry + + + + Symbols + + + + PhysSymbols + + + + Types + + + + Compat + + + + KeyTypeNames + + nTypes + + + + KTLevelNames + + nKTLevels + + + + + + + IndicatorNames + + + indicators + + + + + VirtualModNames + + + virtualMods + + + + + GroupNames + + + groupNames + + + + + KeyNames + + nKeys + + + + KeyAliases + + nKeyAliases + + + + RGNames + + nRadioGroups + + + + + + + + + + + + + + + + + + + + + + + + + + + nProperties + + + nColors + + + nShapes + + + nSections + + + nDoodads + + + nKeyAliases + + + + + + + + + + + + + + + + + + + + + nProperties + + + nColors + + + nShapes + + + nSections + + + nDoodads + + + nKeyAliases + + + + + + + + + + + + + + + + + + + + + + + + + + + keymapsSpecLen + + + + keycodesSpecLen + + + + typesSpecLen + + + + compatMapSpecLen + + + + symbolsSpecLen + + + + geometrySpecLen + + + + + + + + + + + + + nKeymaps + + + nKeycodes + + + nTypes + + + nCompatMaps + + + nSymbols + + + nGeometries + + + + + + + + + + + + + keymapsSpecLen + + + + keycodesSpecLen + + + + typesSpecLen + + + + compatMapSpecLen + + + + symbolsSpecLen + + + + geometrySpecLen + + + + + + + + + + + + reported + + Types + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + present + + KeyTypes + + nTypes + + + + KeySyms + + nKeySyms + + + + KeyActions + + nKeyActions + + + totalActions + + + + KeyBehaviors + + totalKeyBehaviors + + + + VirtualMods + + nVModMapKeys + + + + ExplicitComponents + + totalKeyExplicit + + + + ModifierMap + + totalModMapKeys + + + + VirtualModMap + + totalVModMapKeys + + + + + + CompatMap + + + + + + + + + + 16 + nSIRtrn + + + + + groupsRtrn + + + + + ClientSymbols + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + present + + KeyTypes + + nTypes + + + + KeySyms + + nKeySyms + + + + KeyActions + + nKeyActions + + + totalActions + + + + KeyBehaviors + + totalKeyBehaviors + + + + VirtualMods + + nVModMapKeys + + + + ExplicitComponents + + totalKeyExplicit + + + + ModifierMap + + totalModMapKeys + + + + VirtualModMap + + totalVModMapKeys + + + + + + ServerSymbols + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + present + + KeyTypes + + nTypes + + + + KeySyms + + nKeySyms + + + + KeyActions + + nKeyActions + + + totalActions + + + + KeyBehaviors + + totalKeyBehaviors + + + + VirtualMods + + nVModMapKeys + + + + ExplicitComponents + + totalKeyExplicit + + + + ModifierMap + + totalModMapKeys + + + + VirtualModMap + + totalVModMapKeys + + + + + + IndicatorMaps + + + + + + + nIndicators + + + + KeyNames + + + + + + + + + + + + + + + + which + + Keycodes + + + + Geometry + + + + Symbols + + + + PhysSymbols + + + + Types + + + + Compat + + + + KeyTypeNames + + nTypes + + + + KTLevelNames + + nKTLevels + + + + + + + IndicatorNames + + + indicators + + + + + VirtualModNames + + + virtualMods + + + + + GroupNames + + + groupNames + + + + + KeyNames + + nKeys + + + + KeyAliases + + nKeyAliases + + + + RGNames + + nRadioGroups + + + + + + OtherNames + + + + + + + + + + + + + + + + which + + Keycodes + + + + Geometry + + + + Symbols + + + + PhysSymbols + + + + Types + + + + Compat + + + + KeyTypeNames + + nTypes + + + + KTLevelNames + + nKTLevels + + + + + + + IndicatorNames + + + indicators + + + + + VirtualModNames + + + virtualMods + + + + + GroupNames + + + groupNames + + + + + KeyNames + + nKeys + + + + KeyAliases + + nKeyAliases + + + + RGNames + + nRadioGroups + + + + + + Geometry + + + + + + + + + + + + + + + + + nProperties + + + nColors + + + nShapes + + + nSections + + + nDoodads + + + nKeyAliases + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + nameLen + + + nBtnsRtrn + + + nDeviceLedFBs + + + + + + + + + + + + + nBtns + + + nDeviceLedFBs + + + + + + + + + + + + msgLength + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proto/xcb-proto/src/xproto.xml b/proto/xcb-proto/src/xproto.xml index b6521c3d7..42a6852a1 100644 --- a/proto/xcb-proto/src/xproto.xml +++ b/proto/xcb-proto/src/xproto.xml @@ -1296,8 +1296,8 @@ authorization from the authors. - - + + @@ -1482,7 +1482,10 @@ authorization from the authors. - + + + font_qty + @@ -2155,6 +2158,7 @@ authorization from the authors. + keycode_count @@ -2294,7 +2298,7 @@ authorization from the authors. - + address_len diff --git a/proto/xcb-proto/src/xtest.xml b/proto/xcb-proto/src/xtest.xml index e481929b7..7f0b2623c 100644 --- a/proto/xcb-proto/src/xtest.xml +++ b/proto/xcb-proto/src/xtest.xml @@ -88,8 +88,8 @@ authorization from the authors. - - + + diff --git a/proto/xcb-proto/xcb-proto.pc.in b/proto/xcb-proto/xcb-proto.pc.in index 6cbcf2779..d312e6e5d 100644 --- a/proto/xcb-proto/xcb-proto.pc.in +++ b/proto/xcb-proto/xcb-proto.pc.in @@ -1,6 +1,8 @@ prefix=@prefix@ +exec_prefix=@exec_prefix@ datarootdir=@datarootdir@ datadir=@datadir@ +libdir=@libdir@ xcbincludedir=@xcbincludedir@ pythondir=@pythondir@ diff --git a/proto/xcb-proto/xcbgen/expr.py b/proto/xcb-proto/xcbgen/expr.py index 522e17d09..274c29089 100644 --- a/proto/xcb-proto/xcbgen/expr.py +++ b/proto/xcb-proto/xcbgen/expr.py @@ -26,7 +26,7 @@ class Expression(object): Represents a mathematical expression for a list length or exprfield. Public fields: - op is the operation (text +,*,/,<<) or None. + op is the operation (text +,*,/,<<,~) or None. lhs and rhs are the sub-Expressions if op is set. lenfield_name is the name of the length field, or None for request lists. lenfield is the Field object for the length field, or None. @@ -40,6 +40,7 @@ class Expression(object): self.lenfield_name = None self.lenfield_type = None + self.lenfield_parent = None self.lenfield = None self.lenwire = False self.bitfield = False @@ -75,14 +76,52 @@ class Expression(object): if self.lenfield_name == None: self.lenfield_name = self.rhs.lenfield_name + elif elt.tag == 'unop': + # Op field. Need to recurse. + self.op = elt.get('op') + self.rhs = Expression(list(elt)[0], parent) + + self.lenfield_name = self.rhs.lenfield_name + elif elt.tag == 'value': # Constant expression - self.nmemb = int(elt.text) + self.nmemb = int(elt.text, 0) + + elif elt.tag == 'popcount': + self.op = 'popcount' + self.rhs = Expression(list(elt)[0], parent) + self.lenfield_name = self.rhs.lenfield_name + # xcb_popcount returns 'int' - handle the type in the language-specific part + + elif elt.tag == 'enumref': + self.op = 'enumref' + self.lenfield_name = (elt.get('ref'), elt.text) + + elif elt.tag == 'sumof': + self.op = 'sumof' + self.lenfield_name = elt.get('ref') else: # Notreached - raise Exception('XXX') - + raise Exception("undefined tag '%s'" % elt.tag) def fixed_size(self): return self.nmemb != None + + def resolve(self, module, parents): + if self.op == 'enumref': + self.lenfield_type = module.get_type(self.lenfield_name[0]) + self.lenfield_name = self.lenfield_name[1] + elif self.op == 'sumof': + # need to find the field with lenfield_name + for p in reversed(parents): + fields = dict([(f.field_name, f) for f in p.fields]) + if self.lenfield_name in fields.keys(): + if p.is_bitcase: + # switch is the anchestor + self.lenfield_parent = p.parents[-1] + else: + self.lenfield_parent = p + self.lenfield_type = fields[self.lenfield_name].field_type + break + diff --git a/proto/xcb-proto/xcbgen/matcher.py b/proto/xcb-proto/xcbgen/matcher.py index e7958fa44..6e45b236c 100644 --- a/proto/xcb-proto/xcbgen/matcher.py +++ b/proto/xcb-proto/xcbgen/matcher.py @@ -9,14 +9,15 @@ we do not create a new type object, we just record the existing one under a new from os.path import join from xml.etree.cElementTree import parse -import state -from xtypes import * +from xcbgen.xtypes import * def import_(node, module, namespace): ''' For imports, we load the file, create a new namespace object, execute recursively, then record the import (for header files, etc.) ''' + # To avoid circular import error + from xcbgen import state new_file = join(namespace.dir, '%s.xml' % node.text) new_root = parse(new_file).getroot() new_namespace = state.Namespace(new_file) diff --git a/proto/xcb-proto/xcbgen/state.py b/proto/xcb-proto/xcbgen/state.py index 51efc9480..ae3d2d45f 100644 --- a/proto/xcb-proto/xcbgen/state.py +++ b/proto/xcb-proto/xcbgen/state.py @@ -4,9 +4,9 @@ This module contains the namespace class and the singleton module class. from os.path import dirname, basename from xml.etree.cElementTree import parse -import matcher -from error import * -from xtypes import * +from xcbgen import matcher +from xcbgen.error import * +from xcbgen.xtypes import * import __main__ diff --git a/proto/xcb-proto/xcbgen/xtypes.py b/proto/xcb-proto/xcbgen/xtypes.py index 01d765e59..14c318ac3 100644 --- a/proto/xcb-proto/xcbgen/xtypes.py +++ b/proto/xcb-proto/xcbgen/xtypes.py @@ -1,7 +1,7 @@ ''' This module contains the classes which represent XCB data types. ''' -from expr import Field, Expression +from xcbgen.expr import Field, Expression import __main__ class Type(object): @@ -32,6 +32,8 @@ class Type(object): self.is_reply = False self.is_union = False self.is_pad = False + self.is_switch = False + self.is_bitcase = False def resolve(self, module): ''' @@ -73,6 +75,7 @@ class Type(object): complex_type.fields.append(new_field) + class SimpleType(Type): ''' Derived class which represents a cardinal type like CARD32 or char. @@ -131,7 +134,7 @@ class Enum(SimpleType): if value.tag == 'value': self.values.append((item.get('name'), value.text)) elif value.tag == 'bit': - self.values.append((item.get('name'), '%u' % (1 << int(value.text)))) + self.values.append((item.get('name'), '%u' % (1 << int(value.text, 0)))) self.bits.append((item.get('name'), value.text)) def resolve(self, module): @@ -152,11 +155,11 @@ class ListType(Type): parent is the structure type containing the list. expr is an Expression object containing the length information, for variable-sized lists. ''' - def __init__(self, elt, member, parent): + def __init__(self, elt, member, *parent): Type.__init__(self, member.name) self.is_list = True self.member = member - self.parent = parent + self.parents = list(parent) if elt.tag == 'list': elts = list(elt) @@ -177,9 +180,10 @@ class ListType(Type): needlen = True # See if the length field is already in the structure. - for field in self.parent.fields: - if field.field_name == lenfield_name: - needlen = False + for parent in self.parents: + for field in parent.fields: + if field.field_name == lenfield_name: + needlen = False # It isn't, so we need to add it to the structure ourself. if needlen: @@ -194,15 +198,17 @@ class ListType(Type): if self.resolved: return self.member.resolve(module) + self.expr.resolve(module, self.parents) # Find my length field again. We need the actual Field object in the expr. # This is needed because we might have added it ourself above. if not self.fixed_size(): - for field in self.parent.fields: - if field.field_name == self.expr.lenfield_name and field.wire: - self.expr.lenfield = field - break - + for parent in self.parents: + for field in parent.fields: + if field.field_name == self.expr.lenfield_name and field.wire: + self.expr.lenfield = field + break + self.resolved = True def fixed_size(self): @@ -215,7 +221,7 @@ class ExprType(Type): Public fields added: expr is an Expression object containing the value of the field. ''' - def __init__(self, elt, member, parent): + def __init__(self, elt, member, *parent): Type.__init__(self, member.name) self.is_expr = True self.member = member @@ -243,7 +249,7 @@ class PadType(Type): Type.__init__(self, tcard8.name) self.is_pad = True self.size = 1 - self.nmemb = 1 if (elt == None) else int(elt.get('bytes')) + self.nmemb = 1 if (elt == None) else int(elt.get('bytes'), 0) def resolve(self, module): self.resolved = True @@ -266,6 +272,7 @@ class ComplexType(Type): self.fields = [] self.nmemb = 1 self.size = 0 + self.lenfield_parent = [self] def resolve(self, module): if self.resolved: @@ -288,18 +295,27 @@ class ComplexType(Type): elif child.tag == 'exprfield': field_name = child.get('name') fkey = child.get('type') - type = ExprType(child, module.get_type(fkey), self) + type = ExprType(child, module.get_type(fkey), *self.lenfield_parent) visible = False elif child.tag == 'list': field_name = child.get('name') fkey = child.get('type') - type = ListType(child, module.get_type(fkey), self) + type = ListType(child, module.get_type(fkey), *self.lenfield_parent) visible = True elif child.tag == 'valueparam': field_name = child.get('value-list-name') fkey = 'CARD32' - type = ListType(child, module.get_type(fkey), self) + type = ListType(child, module.get_type(fkey), *self.lenfield_parent) visible = True + elif child.tag == 'switch': + field_name = child.get('name') + # construct the switch type name from the parent type and the field name + field_type = self.name + (field_name,) + type = SwitchType(field_type, child, *self.lenfield_parent) + visible = True + type.make_member_of(module, self, field_type, field_name, visible, True, False) + type.resolve(module) + continue else: # Hit this on Reply continue @@ -331,6 +347,109 @@ class ComplexType(Type): return False return True +class SwitchType(ComplexType): + ''' + Derived class which represents a List of Items. + + Public fields added: + bitcases is an array of Bitcase objects describing the list items + ''' + + def __init__(self, name, elt, *parents): + ComplexType.__init__(self, name, elt) + self.parents = parents + # FIXME: switch cannot store lenfields, so it should just delegate the parents + self.lenfield_parent = list(parents) + [self] + # self.fields contains all possible fields collected from the Bitcase objects, + # whereas self.items contains the Bitcase objects themselves + self.bitcases = [] + + self.is_switch = True + elts = list(elt) + self.expr = Expression(elts[0] if len(elts) else elt, self) + + def resolve(self, module): + if self.resolved: + return +# pads = 0 + + parents = list(self.parents) + [self] + + # Resolve all of our field datatypes. + for index, child in enumerate(list(self.elt)): + if child.tag == 'bitcase': + field_name = child.get('name') + if field_name is None: + field_type = self.name + ('bitcase%d' % index,) + else: + field_type = self.name + (field_name,) + + # use self.parent to indicate anchestor, + # as switch does not contain named fields itself + type = BitcaseType(index, field_type, child, *parents) + # construct the switch type name from the parent type and the field name + if field_name is None: + type.has_name = False + # Get the full type name for the field + field_type = type.name + visible = True + + # add the field to ourself + type.make_member_of(module, self, field_type, field_name, visible, True, False) + + # recursively resolve the type (could be another structure, list) + type.resolve(module) + inserted = False + for new_field in type.fields: + # We dump the _placeholder_byte if any fields are added. + for (idx, field) in enumerate(self.fields): + if field == _placeholder_byte: + self.fields[idx] = new_field + inserted = True + break + if False == inserted: + self.fields.append(new_field) + + self.calc_size() # Figure out how big we are + self.resolved = True + + def make_member_of(self, module, complex_type, field_type, field_name, visible, wire, auto): + if not self.fixed_size(): + # We need a length field. + # Ask our Expression object for it's name, type, and whether it's on the wire. + lenfid = self.expr.lenfield_type + lenfield_name = self.expr.lenfield_name + lenwire = self.expr.lenwire + needlen = True + + # See if the length field is already in the structure. + for parent in self.parents: + for field in parent.fields: + if field.field_name == lenfield_name: + needlen = False + + # It isn't, so we need to add it to the structure ourself. + if needlen: + type = module.get_type(lenfid) + lenfield_type = module.get_type_name(lenfid) + type.make_member_of(module, complex_type, lenfield_type, lenfield_name, True, lenwire, False) + + # Add ourself to the structure by calling our original method. + Type.make_member_of(self, module, complex_type, field_type, field_name, visible, wire, auto) + + # size for switch can only be calculated at runtime + def calc_size(self): + pass + + # note: switch is _always_ of variable size, but we indicate here wether + # it contains elements that are variable-sized themselves + def fixed_size(self): + return False +# for m in self.fields: +# if not m.type.fixed_size(): +# return False +# return True + class Struct(ComplexType): ''' @@ -350,6 +469,48 @@ class Union(ComplexType): out = __main__.output['union'] +class BitcaseType(ComplexType): + ''' + Derived class representing a struct data type. + ''' + def __init__(self, index, name, elt, *parent): + elts = list(elt) + self.expr = Expression(elts[0] if len(elts) else elt, self) + ComplexType.__init__(self, name, elts[1:]) + self.has_name = True + self.index = 1 + self.lenfield_parent = list(parent) + [self] + self.parents = list(parent) + self.is_bitcase = True + + def make_member_of(self, module, switch_type, field_type, field_name, visible, wire, auto): + ''' + register BitcaseType with the corresponding SwitchType + + module is the global module object. + complex_type is the structure object. + see Field for the meaning of the other parameters. + ''' + new_field = Field(self, field_type, field_name, visible, wire, auto) + + # We dump the _placeholder_byte if any bitcases are added. + for (idx, field) in enumerate(switch_type.bitcases): + if field == _placeholder_byte: + switch_type.bitcases[idx] = new_field + return + + switch_type.bitcases.append(new_field) + + def resolve(self, module): + if self.resolved: + return + + self.expr.resolve(module, self.parents+[self]) + + # Resolve the bitcase expression + ComplexType.resolve(self, module) + + class Reply(ComplexType): ''' Derived class representing a reply. Only found as a field of Request.