diff options
author | marha <marha@users.sourceforge.net> | 2010-05-15 16:36:39 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-05-15 16:36:39 +0000 |
commit | 7a18a7256f3f206d2e45783759131f53ef09b2ac (patch) | |
tree | bd2cc16d9fefa8ee1dac36c2b741aeae558e59b6 /libxcb | |
parent | c38dead3ea7e177728d90cd815cf4eead0c9f534 (diff) | |
download | vcxsrv-7a18a7256f3f206d2e45783759131f53ef09b2ac.tar.gz vcxsrv-7a18a7256f3f206d2e45783759131f53ef09b2ac.tar.bz2 vcxsrv-7a18a7256f3f206d2e45783759131f53ef09b2ac.zip |
xcb-proto git update 15/5/2010
Diffstat (limited to 'libxcb')
-rw-r--r-- | libxcb/xcb-proto/src/dri2.xml | 318 | ||||
-rw-r--r-- | libxcb/xcb-proto/src/xf86vidmode.xml | 942 | ||||
-rw-r--r-- | libxcb/xcb-proto/xcbgen/expr.py | 183 | ||||
-rw-r--r-- | libxcb/xcb-proto/xcbgen/xtypes.py | 942 |
4 files changed, 1210 insertions, 1175 deletions
diff --git a/libxcb/xcb-proto/src/dri2.xml b/libxcb/xcb-proto/src/dri2.xml index 7fea94839..62e16ed17 100644 --- a/libxcb/xcb-proto/src/dri2.xml +++ b/libxcb/xcb-proto/src/dri2.xml @@ -1,152 +1,166 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -Copyright (C) 2005 Jeremy Kolb. -Copyright © 2009 Intel Corporation -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the names of the authors or their -institutions shall not be used in advertising or otherwise to promote the -sale, use or other dealings in this Software without prior written -authorization from the authors. ---> - -<xcb header="dri2" extension-xname="DRI2" extension-name="DRI2" - major-version="1" minor-version="1"> - <import>xproto</import> - - <enum name="Attachment"> - <item name="BufferFrontLeft" /> - <item name="BufferBackLeft" /> - <item name="BufferFrontRight" /> - <item name="BufferBackRight" /> - <item name="BufferDepth" /> - <item name="BufferStencil" /> - <item name="BufferAccum" /> - <item name="BufferFakeFrontLeft" /> - <item name="BufferFakeFrontRight" /> - <item name="BufferDepthStencil" /> - </enum> - - <enum name="DriverType"> - <item name="DRI" /> - </enum> - - <!-- Types --> - - <struct name="DRI2Buffer"> - <field type="CARD32" name="attachment" enum="Attachment" /> - <field type="CARD32" name="name" /> - <field type="CARD32" name="pitch" /> - <field type="CARD32" name="cpp" /> - <field type="CARD32" name="flags" /> - </struct> - - <struct name="AttachFormat"> - <field type="CARD32" name="attachment" enum="Attachment" /> - <field type="CARD32" name="format" /> - </struct> - - <!-- Requests --> - <request name="QueryVersion" opcode="0"> - <field type="CARD32" name="major_version" /> - <field type="CARD32" name="minor_version" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="major_version" /> - <field type="CARD32" name="minor_version" /> - </reply> - </request> - - <request name="Connect" opcode="1"> - <field type="WINDOW" name="window" /> - <field type="CARD32" name="driver_type" enum="DriverType" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="driver_name_length" /> - <field type="CARD32" name="device_name_length" /> - <pad bytes="16" /> - <list type="char" name="driver_name"> - <fieldref>driver_name_length</fieldref> - </list> - <list type="char" name="device_name"> - <fieldref>device_name_length</fieldref> - </list> - </reply> - </request> - - <request name="Authenticate" opcode="2"> - <field type="WINDOW" name="window" /> - <field type="CARD32" name="magic" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="authenticated" /> - </reply> - </request> - - <request name="CreateDrawable" opcode="3"> - <field type="DRAWABLE" name="drawable" /> - </request> - - <request name="DestroyDrawable" opcode="4"> - <field type="DRAWABLE" name="drawable" /> - </request> - - <request name="GetBuffers" opcode="5"> - <field type="DRAWABLE" name="drawable" /> - <field type="CARD32" name="count" /> - <list type="CARD32" name="attachments" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="width" /> - <field type="CARD32" name="height" /> - <field type="CARD32" name="count" /> - <pad bytes="12" /> - <list type="DRI2Buffer" name="buffers"> - <fieldref>count</fieldref> - </list> - </reply> - </request> - - <request name="CopyRegion" opcode="6"> - <field type="DRAWABLE" name="drawable" /> - <field type="CARD32" name="region" /> - <field type="CARD32" name="dest" /> - <field type="CARD32" name="src" /> - <reply> - <pad bytes="1" /> - </reply> - </request> - - <request name="GetBuffersWithFormat" opcode="7"> - <field type="DRAWABLE" name="drawable" /> - <field type="CARD32" name="count" /> - <list type="AttachFormat" name="attachments" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="width" /> - <field type="CARD32" name="height" /> - <field type="CARD32" name="count" /> - <pad bytes="12" /> - <list type="DRI2Buffer" name="buffers"> - <fieldref>count</fieldref> - </list> - </reply> - </request> -</xcb> +<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright (C) 2005 Jeremy Kolb.
+Copyright © 2009 Intel Corporation
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the authors or their
+institutions shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization from the authors.
+-->
+
+<xcb header="dri2" extension-xname="DRI2" extension-name="DRI2"
+ major-version="1" minor-version="1">
+ <import>xproto</import>
+
+ <enum name="Attachment">
+ <item name="BufferFrontLeft" />
+ <item name="BufferBackLeft" />
+ <item name="BufferFrontRight" />
+ <item name="BufferBackRight" />
+ <item name="BufferDepth" />
+ <item name="BufferStencil" />
+ <item name="BufferAccum" />
+ <item name="BufferFakeFrontLeft" />
+ <item name="BufferFakeFrontRight" />
+ <item name="BufferDepthStencil" />
+ </enum>
+
+ <enum name="DriverType">
+ <item name="DRI" />
+ </enum>
+
+ <!-- Types -->
+
+ <struct name="DRI2Buffer">
+ <field type="CARD32" name="attachment" enum="Attachment" />
+ <field type="CARD32" name="name" />
+ <field type="CARD32" name="pitch" />
+ <field type="CARD32" name="cpp" />
+ <field type="CARD32" name="flags" />
+ </struct>
+
+ <struct name="AttachFormat">
+ <field type="CARD32" name="attachment" enum="Attachment" />
+ <field type="CARD32" name="format" />
+ </struct>
+
+ <!-- Requests -->
+ <request name="QueryVersion" opcode="0">
+ <field type="CARD32" name="major_version" />
+ <field type="CARD32" name="minor_version" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="major_version" />
+ <field type="CARD32" name="minor_version" />
+ </reply>
+ </request>
+
+ <request name="Connect" opcode="1">
+ <field type="WINDOW" name="window" />
+ <field type="CARD32" name="driver_type" enum="DriverType" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="driver_name_length" />
+ <field type="CARD32" name="device_name_length" />
+ <pad bytes="16" />
+ <list type="char" name="driver_name">
+ <fieldref>driver_name_length</fieldref>
+ </list>
+ <list type="void" name="alignment_pad">
+ <op op="-">
+ <op op="&">
+ <op op="+">
+ <fieldref>driver_name_length</fieldref>
+ <value> 3 </value>
+ </op>
+ <unop op="~">
+ <value>3</value>
+ </unop>
+ </op>
+ <fieldref>driver_name_length</fieldref>
+ </op>
+ </list>
+ <list type="char" name="device_name">
+ <fieldref>device_name_length</fieldref>
+ </list>
+ </reply>
+ </request>
+
+ <request name="Authenticate" opcode="2">
+ <field type="WINDOW" name="window" />
+ <field type="CARD32" name="magic" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="authenticated" />
+ </reply>
+ </request>
+
+ <request name="CreateDrawable" opcode="3">
+ <field type="DRAWABLE" name="drawable" />
+ </request>
+
+ <request name="DestroyDrawable" opcode="4">
+ <field type="DRAWABLE" name="drawable" />
+ </request>
+
+ <request name="GetBuffers" opcode="5">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="count" />
+ <list type="CARD32" name="attachments" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="width" />
+ <field type="CARD32" name="height" />
+ <field type="CARD32" name="count" />
+ <pad bytes="12" />
+ <list type="DRI2Buffer" name="buffers">
+ <fieldref>count</fieldref>
+ </list>
+ </reply>
+ </request>
+
+ <request name="CopyRegion" opcode="6">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="region" />
+ <field type="CARD32" name="dest" />
+ <field type="CARD32" name="src" />
+ <reply>
+ <pad bytes="1" />
+ </reply>
+ </request>
+
+ <request name="GetBuffersWithFormat" opcode="7">
+ <field type="DRAWABLE" name="drawable" />
+ <field type="CARD32" name="count" />
+ <list type="AttachFormat" name="attachments" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="width" />
+ <field type="CARD32" name="height" />
+ <field type="CARD32" name="count" />
+ <pad bytes="12" />
+ <list type="DRI2Buffer" name="buffers">
+ <fieldref>count</fieldref>
+ </list>
+ </reply>
+ </request>
+</xcb>
diff --git a/libxcb/xcb-proto/src/xf86vidmode.xml b/libxcb/xcb-proto/src/xf86vidmode.xml index 718240cd5..4a193f58d 100644 --- a/libxcb/xcb-proto/src/xf86vidmode.xml +++ b/libxcb/xcb-proto/src/xf86vidmode.xml @@ -1,464 +1,478 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -Copyright (C) 2009 Open Text Corporation. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the names of the authors or their -institutions shall not be used in advertising or otherwise to promote the -sale, use or other dealings in this Software without prior written -authorization from the authors. ---> - -<xcb header="xf86vidmode" extension-xname="XFree86-VidModeExtension" extension-name="XF86VidMode" - major-version="2" minor-version="2"> - - <!-- In places where there are multiple versions of the protocol, this - describes version 2.2. If you do not call xcb_xf86vidmode_set_client_version() - then some requests may fail and some replies may not be what you expect. --> - - <typedef oldname="CARD32" newname="SYNCRANGE" /> <!-- Min and Max fixed-decimal-point values --> - <typedef oldname="CARD32" newname="DOTCLOCK" /> <!-- A single fixed-decimal-point value --> - - <enum name="ModeFlag"> - <item name="Positive_HSync"> <bit>0</bit></item> - <item name="Negative_HSync"> <bit>1</bit></item> - <item name="Positive_VSync"> <bit>2</bit></item> - <item name="Negative_VSync"> <bit>3</bit></item> - <item name="Interlace"> <bit>4</bit></item> - <item name="Composite_Sync"> <bit>5</bit></item> - <item name="Positive_CSync"> <bit>6</bit></item> - <item name="Negative_CSync"> <bit>7</bit></item> - <item name="HSkew"> <bit>8</bit></item> - <item name="Broadcast"> <bit>9</bit></item> - <item name="Pixmux"> <bit>10</bit></item> - <item name="Double_Clock"> <bit>11</bit></item> - <item name="Half_Clock"> <bit>12</bit></item> - </enum> - - <enum name="ClockFlag"> - <item name="Programable"> <bit>0</bit></item> - </enum> - - <enum name="Permission"> - <item name="Read"> <bit>0</bit></item> - <item name="Write"> <bit>1</bit></item> - </enum> - - <struct name="ModeInfo"> - <field type="DOTCLOCK" name="dotclock" /> - <field type="CARD16" name= "hdisplay" /> - <field type="CARD16" name= "hsyncstart" /> - <field type="CARD16" name= "hsyncend" /> - <field type="CARD16" name= "htotal" /> - <field type="CARD32" name= "hskew" /> - <field type="CARD16" name= "vdisplay" /> - <field type="CARD16" name= "vsyncstart" /> - <field type="CARD16" name= "vsyncend" /> - <field type="CARD16" name= "vtotal" /> - <pad bytes="4" /> - <field type="CARD32" name="flags" mask="ModeFlag" /> - <pad bytes="12" /> - <field type="CARD32" name="privsize" /> - </struct> - - <request name="QueryVersion" opcode="0"> - <reply> - <pad bytes="1" /> - <field type="CARD16" name="major_version" /> - <field type="CARD16" name="minor_version" /> - </reply> - </request> - - <request name="GetModeLine" opcode="1"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <reply> - <pad bytes="1" /> - <field type="DOTCLOCK" name="dotclock" /> - <field type="CARD16" name= "hdisplay" /> - <field type="CARD16" name= "hsyncstart" /> - <field type="CARD16" name= "hsyncend" /> - <field type="CARD16" name= "htotal" /> - <field type="CARD16" name= "hskew" /> - <field type="CARD16" name= "vdisplay" /> - <field type="CARD16" name= "vsyncstart" /> - <field type="CARD16" name= "vsyncend" /> - <field type="CARD16" name= "vtotal" /> - <pad bytes="2" /> - <field type="CARD32" name="flags" mask="ModeFlag" /> - <pad bytes="12" /> - <field type="CARD32" name="privsize" /> - <list type="CARD8" name="private"> - <fieldref>privsize</fieldref> - </list> - </reply> - </request> - - <request name="ModModeLine" opcode="2"> - <field type="CARD32" name="screen" /> - <field type="CARD16" name= "hdisplay" /> - <field type="CARD16" name= "hsyncstart" /> - <field type="CARD16" name= "hsyncend" /> - <field type="CARD16" name= "htotal" /> - <field type="CARD16" name= "hskew" /> - <field type="CARD16" name= "vdisplay" /> - <field type="CARD16" name= "vsyncstart" /> - <field type="CARD16" name= "vsyncend" /> - <field type="CARD16" name= "vtotal" /> - <pad bytes="2" /> - <field type="CARD32" name="flags" mask="ModeFlag" /> - <pad bytes="12" /> - <field type="CARD32" name="privsize" /> - <list type="CARD8" name="private"> - <fieldref>privsize</fieldref> - </list> - </request> - - <request name="SwitchMode" opcode="3"> - <field type="CARD16" name="screen" /> - <field type="CARD16" name="zoom" /> - </request> - - <request name="GetMonitor" opcode="4"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <reply> - <pad bytes="1" /> - <field type="CARD8" name="vendor_length" /> - <field type="CARD8" name="model_length" /> - <field type="CARD8" name="num_hsync" /> - <field type="CARD8" name="num_vsync" /> - <pad bytes="20" /> - <list type="SYNCRANGE" name="hsync"> - <fieldref>num_hsync</fieldref> - </list> - <list type="SYNCRANGE" name="vsync"> - <fieldref>num_vsync</fieldref> - </list> - <list type="char" name="vendor"> - <fieldref>vendor_length</fieldref> - </list> - <list type="void" name="alignment_pad"> - <op op="-"> - <op op="&"> - <op op="+"> - <fieldref>vendor_length</fieldref> - <value> 3 </value> - </op> - <value>0xFFFFFFFC</value> - </op> - <fieldref>vendor_length</fieldref> - </op> - </list> - <list type="char" name="model"> - <fieldref>model_length</fieldref> - </list> - </reply> - </request> - - <request name="LockModeSwitch" opcode="5"> - <field type="CARD16" name="screen" /> - <field type="CARD16" name="lock" /> - </request> - - <request name="GetAllModeLines" opcode="6"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="modecount" /> - <pad bytes="20" /> - <list type="ModeInfo" name="modeinfo"> - <fieldref>modecount</fieldref> - </list> - </reply> - </request> - - <request name="AddModeLine" opcode="7"> - <field type="CARD32" name="screen" /> - <field type="DOTCLOCK" name="dotclock" /> - <field type="CARD16" name= "hdisplay" /> - <field type="CARD16" name= "hsyncstart" /> - <field type="CARD16" name= "hsyncend" /> - <field type="CARD16" name= "htotal" /> - <field type="CARD16" name= "hskew" /> - <field type="CARD16" name= "vdisplay" /> - <field type="CARD16" name= "vsyncstart" /> - <field type="CARD16" name= "vsyncend" /> - <field type="CARD16" name= "vtotal" /> - <pad bytes="2" /> - <field type="CARD32" name="flags" mask="ModeFlag" /> - <pad bytes="12" /> - <field type="CARD32" name="privsize" /> - <field type="DOTCLOCK" name="after_dotclock" /> - <field type="CARD16" name= "after_hdisplay" /> - <field type="CARD16" name= "after_hsyncstart" /> - <field type="CARD16" name= "after_hsyncend" /> - <field type="CARD16" name= "after_htotal" /> - <field type="CARD16" name= "after_hskew" /> - <field type="CARD16" name= "after_vdisplay" /> - <field type="CARD16" name= "after_vsyncstart" /> - <field type="CARD16" name= "after_vsyncend" /> - <field type="CARD16" name= "after_vtotal" /> - <pad bytes="2" /> - <field type="CARD32" name="after_flags" mask="ModeFlag" /> - <pad bytes="12" /> - <list type="CARD8" name="private"> - <fieldref>privsize</fieldref> - </list> - </request> - - <request name="DeleteModeLine" opcode="8"> - <field type="CARD32" name="screen" /> - <field type="DOTCLOCK" name="dotclock" /> - <field type="CARD16" name= "hdisplay" /> - <field type="CARD16" name= "hsyncstart" /> - <field type="CARD16" name= "hsyncend" /> - <field type="CARD16" name= "htotal" /> - <field type="CARD16" name= "hskew" /> - <field type="CARD16" name= "vdisplay" /> - <field type="CARD16" name= "vsyncstart" /> - <field type="CARD16" name= "vsyncend" /> - <field type="CARD16" name= "vtotal" /> - <pad bytes="2" /> - <field type="CARD32" name="flags" mask="ModeFlag" /> - <pad bytes="12" /> - <field type="CARD32" name="privsize" /> - <list type="CARD8" name="private"> - <fieldref>privsize</fieldref> - </list> - </request> - - <request name="ValidateModeLine" opcode="9"> - <field type="CARD32" name="screen" /> - <field type="DOTCLOCK" name="dotclock" /> - <field type="CARD16" name= "hdisplay" /> - <field type="CARD16" name= "hsyncstart" /> - <field type="CARD16" name= "hsyncend" /> - <field type="CARD16" name= "htotal" /> - <field type="CARD16" name= "hskew" /> - <field type="CARD16" name= "vdisplay" /> - <field type="CARD16" name= "vsyncstart" /> - <field type="CARD16" name= "vsyncend" /> - <field type="CARD16" name= "vtotal" /> - <pad bytes="2" /> - <field type="CARD32" name="flags" mask="ModeFlag" /> - <pad bytes="12" /> - <field type="CARD32" name="privsize" /> - <list type="CARD8" name="private"> - <fieldref>privsize</fieldref> - </list> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="status" /> - <pad bytes="20" /> - </reply> - </request> - - <request name="SwitchToMode" opcode="10"> - <field type="CARD32" name="screen" /> - <field type="DOTCLOCK" name="dotclock" /> - <field type="CARD16" name= "hdisplay" /> - <field type="CARD16" name= "hsyncstart" /> - <field type="CARD16" name= "hsyncend" /> - <field type="CARD16" name= "htotal" /> - <field type="CARD16" name= "hskew" /> - <field type="CARD16" name= "vdisplay" /> - <field type="CARD16" name= "vsyncstart" /> - <field type="CARD16" name= "vsyncend" /> - <field type="CARD16" name= "vtotal" /> - <pad bytes="2" /> - <field type="CARD32" name="flags" mask="ModeFlag" /> - <pad bytes="12" /> - <field type="CARD32" name="privsize" /> - <list type="CARD8" name="private"> - <fieldref>privsize</fieldref> - </list> - </request> - - <request name="GetViewPort" opcode="11"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="x" /> - <field type="CARD32" name="y" /> - <pad bytes="16" /> - </reply> - </request> - - <request name="SetViewPort" opcode="12"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <field type="CARD32" name="x" /> - <field type="CARD32" name="y" /> - </request> - - <!-- new for version 2.x --> - <request name="GetDotClocks" opcode="13"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="flags" mask="ClockFlag" /> - <field type="CARD32" name="clocks" /> - <field type="CARD32" name="maxclocks" /> - <pad bytes="12" /> - <list type="CARD32" name="clock"> - <!-- Only if flags does not include Programable: - (1 - (flags & 1)) * clocks - --> - <op op="*"> - <op op = "-"> - <value>1</value> - <op op="&"> - <fieldref>flags</fieldref> - <value>1</value> - </op> - </op> - <fieldref>clocks</fieldref> - </op> - </list> - </reply> - </request> - - <request name="SetClientVersion" opcode="14"> - <field type="CARD16" name="major" /> - <field type="CARD16" name="minor" /> - </request> - - <request name="SetGamma" opcode="15"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <field type="CARD32" name="red" /> - <field type="CARD32" name="green" /> - <field type="CARD32" name="blue" /> - <pad bytes="12" /> - </request> - - <request name="GetGamma" opcode="16"> - <field type="CARD16" name="screen" /> - <pad bytes="26" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="red" /> - <field type="CARD32" name="green" /> - <field type="CARD32" name="blue" /> - <pad bytes="12" /> - </reply> - </request> - - <request name="GetGammaRamp" opcode="17"> - <field type="CARD16" name="screen" /> - <field type="CARD16" name="size" /> - <reply> - <pad bytes="1" /> - <field type="CARD16" name="size" /> - <pad bytes="22" /> - <list type="CARD16" name="red"> - <op op="&"> - <op op = "+"> - <fieldref>size</fieldref> - <value>1</value> - </op> - <value>0xFFFFFFFE</value> - </op> - </list> - <list type="CARD16" name="green"> - <op op="&"> - <op op = "+"> - <fieldref>size</fieldref> - <value>1</value> - </op> - <value>0xFFFFFFFE</value> - </op> - </list> - <list type="CARD16" name="blue"> - <op op="&"> - <op op = "+"> - <fieldref>size</fieldref> - <value>1</value> - </op> - <value>0xFFFFFFFE</value> - </op> - </list> - </reply> - </request> - - <request name="SetGammaRamp" opcode="18"> - <field type="CARD16" name="screen" /> - <field type="CARD16" name="size" /> - <list type="CARD16" name="red"> - <op op="&"> - <op op = "+"> - <fieldref>size</fieldref> - <value>1</value> - </op> - <value>0xFFFFFFFE</value> - </op> - </list> - <list type="CARD16" name="green"> - <op op="&"> - <op op = "+"> - <fieldref>size</fieldref> - <value>1</value> - </op> - <value>0xFFFFFFFE</value> - </op> - </list> - <list type="CARD16" name="blue"> - <op op="&"> - <op op = "+"> - <fieldref>size</fieldref> - <value>1</value> - </op> - <value>0xFFFFFFFE</value> - </op> - </list> - </request> - - <request name="GetGammaRampSize" opcode="19"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <reply> - <pad bytes="1" /> - <field type="CARD16" name="size" /> - <pad bytes="22" /> - </reply> - </request> - - <request name="GetPermissions" opcode="20"> - <field type="CARD16" name="screen" /> - <pad bytes="2" /> - <reply> - <pad bytes="1" /> - <field type="CARD32" name="permissions" mask="Permission" /> - <pad bytes="20" /> - </reply> - </request> - - <error name="BadClock" number="0" /> - <error name="BadHTimings" number="1" /> - <error name="BadVTimings" number="2" /> - <error name="ModeUnsuitable" number="3" /> - <error name="ExtensionDisabled" number="4" /> - <error name="ClientNotLocal" number="5" /> - <error name="ZoomLocked" number="6" /> - -</xcb> +<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright (C) 2009 Open Text Corporation. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the authors or their
+institutions shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization from the authors.
+-->
+
+<xcb header="xf86vidmode" extension-xname="XFree86-VidModeExtension" extension-name="XF86VidMode"
+ major-version="2" minor-version="2">
+
+ <!-- In places where there are multiple versions of the protocol, this
+ describes version 2.2. If you do not call xcb_xf86vidmode_set_client_version()
+ then some requests may fail and some replies may not be what you expect. -->
+
+ <typedef oldname="CARD32" newname="SYNCRANGE" /> <!-- Min and Max fixed-decimal-point values -->
+ <typedef oldname="CARD32" newname="DOTCLOCK" /> <!-- A single fixed-decimal-point value -->
+
+ <enum name="ModeFlag">
+ <item name="Positive_HSync"> <bit>0</bit></item>
+ <item name="Negative_HSync"> <bit>1</bit></item>
+ <item name="Positive_VSync"> <bit>2</bit></item>
+ <item name="Negative_VSync"> <bit>3</bit></item>
+ <item name="Interlace"> <bit>4</bit></item>
+ <item name="Composite_Sync"> <bit>5</bit></item>
+ <item name="Positive_CSync"> <bit>6</bit></item>
+ <item name="Negative_CSync"> <bit>7</bit></item>
+ <item name="HSkew"> <bit>8</bit></item>
+ <item name="Broadcast"> <bit>9</bit></item>
+ <item name="Pixmux"> <bit>10</bit></item>
+ <item name="Double_Clock"> <bit>11</bit></item>
+ <item name="Half_Clock"> <bit>12</bit></item>
+ </enum>
+
+ <enum name="ClockFlag">
+ <item name="Programable"> <bit>0</bit></item>
+ </enum>
+
+ <enum name="Permission">
+ <item name="Read"> <bit>0</bit></item>
+ <item name="Write"> <bit>1</bit></item>
+ </enum>
+
+ <struct name="ModeInfo">
+ <field type="DOTCLOCK" name="dotclock" />
+ <field type="CARD16" name= "hdisplay" />
+ <field type="CARD16" name= "hsyncstart" />
+ <field type="CARD16" name= "hsyncend" />
+ <field type="CARD16" name= "htotal" />
+ <field type="CARD32" name= "hskew" />
+ <field type="CARD16" name= "vdisplay" />
+ <field type="CARD16" name= "vsyncstart" />
+ <field type="CARD16" name= "vsyncend" />
+ <field type="CARD16" name= "vtotal" />
+ <pad bytes="4" />
+ <field type="CARD32" name="flags" mask="ModeFlag" />
+ <pad bytes="12" />
+ <field type="CARD32" name="privsize" />
+ </struct>
+
+ <request name="QueryVersion" opcode="0">
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD16" name="major_version" />
+ <field type="CARD16" name="minor_version" />
+ </reply>
+ </request>
+
+ <request name="GetModeLine" opcode="1">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <reply>
+ <pad bytes="1" />
+ <field type="DOTCLOCK" name="dotclock" />
+ <field type="CARD16" name= "hdisplay" />
+ <field type="CARD16" name= "hsyncstart" />
+ <field type="CARD16" name= "hsyncend" />
+ <field type="CARD16" name= "htotal" />
+ <field type="CARD16" name= "hskew" />
+ <field type="CARD16" name= "vdisplay" />
+ <field type="CARD16" name= "vsyncstart" />
+ <field type="CARD16" name= "vsyncend" />
+ <field type="CARD16" name= "vtotal" />
+ <pad bytes="2" />
+ <field type="CARD32" name="flags" mask="ModeFlag" />
+ <pad bytes="12" />
+ <field type="CARD32" name="privsize" />
+ <list type="CARD8" name="private">
+ <fieldref>privsize</fieldref>
+ </list>
+ </reply>
+ </request>
+
+ <request name="ModModeLine" opcode="2">
+ <field type="CARD32" name="screen" />
+ <field type="CARD16" name= "hdisplay" />
+ <field type="CARD16" name= "hsyncstart" />
+ <field type="CARD16" name= "hsyncend" />
+ <field type="CARD16" name= "htotal" />
+ <field type="CARD16" name= "hskew" />
+ <field type="CARD16" name= "vdisplay" />
+ <field type="CARD16" name= "vsyncstart" />
+ <field type="CARD16" name= "vsyncend" />
+ <field type="CARD16" name= "vtotal" />
+ <pad bytes="2" />
+ <field type="CARD32" name="flags" mask="ModeFlag" />
+ <pad bytes="12" />
+ <field type="CARD32" name="privsize" />
+ <list type="CARD8" name="private">
+ <fieldref>privsize</fieldref>
+ </list>
+ </request>
+
+ <request name="SwitchMode" opcode="3">
+ <field type="CARD16" name="screen" />
+ <field type="CARD16" name="zoom" />
+ </request>
+
+ <request name="GetMonitor" opcode="4">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD8" name="vendor_length" />
+ <field type="CARD8" name="model_length" />
+ <field type="CARD8" name="num_hsync" />
+ <field type="CARD8" name="num_vsync" />
+ <pad bytes="20" />
+ <list type="SYNCRANGE" name="hsync">
+ <fieldref>num_hsync</fieldref>
+ </list>
+ <list type="SYNCRANGE" name="vsync">
+ <fieldref>num_vsync</fieldref>
+ </list>
+ <list type="char" name="vendor">
+ <fieldref>vendor_length</fieldref>
+ </list>
+ <list type="void" name="alignment_pad">
+ <op op="-">
+ <op op="&">
+ <op op="+">
+ <fieldref>vendor_length</fieldref>
+ <value> 3 </value>
+ </op>
+ <unop op="~">
+ <value>3</value>
+ </unop>
+ </op>
+ <fieldref>vendor_length</fieldref>
+ </op>
+ </list>
+ <list type="char" name="model">
+ <fieldref>model_length</fieldref>
+ </list>
+ </reply>
+ </request>
+
+ <request name="LockModeSwitch" opcode="5">
+ <field type="CARD16" name="screen" />
+ <field type="CARD16" name="lock" />
+ </request>
+
+ <request name="GetAllModeLines" opcode="6">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="modecount" />
+ <pad bytes="20" />
+ <list type="ModeInfo" name="modeinfo">
+ <fieldref>modecount</fieldref>
+ </list>
+ </reply>
+ </request>
+
+ <request name="AddModeLine" opcode="7">
+ <field type="CARD32" name="screen" />
+ <field type="DOTCLOCK" name="dotclock" />
+ <field type="CARD16" name= "hdisplay" />
+ <field type="CARD16" name= "hsyncstart" />
+ <field type="CARD16" name= "hsyncend" />
+ <field type="CARD16" name= "htotal" />
+ <field type="CARD16" name= "hskew" />
+ <field type="CARD16" name= "vdisplay" />
+ <field type="CARD16" name= "vsyncstart" />
+ <field type="CARD16" name= "vsyncend" />
+ <field type="CARD16" name= "vtotal" />
+ <pad bytes="2" />
+ <field type="CARD32" name="flags" mask="ModeFlag" />
+ <pad bytes="12" />
+ <field type="CARD32" name="privsize" />
+ <field type="DOTCLOCK" name="after_dotclock" />
+ <field type="CARD16" name= "after_hdisplay" />
+ <field type="CARD16" name= "after_hsyncstart" />
+ <field type="CARD16" name= "after_hsyncend" />
+ <field type="CARD16" name= "after_htotal" />
+ <field type="CARD16" name= "after_hskew" />
+ <field type="CARD16" name= "after_vdisplay" />
+ <field type="CARD16" name= "after_vsyncstart" />
+ <field type="CARD16" name= "after_vsyncend" />
+ <field type="CARD16" name= "after_vtotal" />
+ <pad bytes="2" />
+ <field type="CARD32" name="after_flags" mask="ModeFlag" />
+ <pad bytes="12" />
+ <list type="CARD8" name="private">
+ <fieldref>privsize</fieldref>
+ </list>
+ </request>
+
+ <request name="DeleteModeLine" opcode="8">
+ <field type="CARD32" name="screen" />
+ <field type="DOTCLOCK" name="dotclock" />
+ <field type="CARD16" name= "hdisplay" />
+ <field type="CARD16" name= "hsyncstart" />
+ <field type="CARD16" name= "hsyncend" />
+ <field type="CARD16" name= "htotal" />
+ <field type="CARD16" name= "hskew" />
+ <field type="CARD16" name= "vdisplay" />
+ <field type="CARD16" name= "vsyncstart" />
+ <field type="CARD16" name= "vsyncend" />
+ <field type="CARD16" name= "vtotal" />
+ <pad bytes="2" />
+ <field type="CARD32" name="flags" mask="ModeFlag" />
+ <pad bytes="12" />
+ <field type="CARD32" name="privsize" />
+ <list type="CARD8" name="private">
+ <fieldref>privsize</fieldref>
+ </list>
+ </request>
+
+ <request name="ValidateModeLine" opcode="9">
+ <field type="CARD32" name="screen" />
+ <field type="DOTCLOCK" name="dotclock" />
+ <field type="CARD16" name= "hdisplay" />
+ <field type="CARD16" name= "hsyncstart" />
+ <field type="CARD16" name= "hsyncend" />
+ <field type="CARD16" name= "htotal" />
+ <field type="CARD16" name= "hskew" />
+ <field type="CARD16" name= "vdisplay" />
+ <field type="CARD16" name= "vsyncstart" />
+ <field type="CARD16" name= "vsyncend" />
+ <field type="CARD16" name= "vtotal" />
+ <pad bytes="2" />
+ <field type="CARD32" name="flags" mask="ModeFlag" />
+ <pad bytes="12" />
+ <field type="CARD32" name="privsize" />
+ <list type="CARD8" name="private">
+ <fieldref>privsize</fieldref>
+ </list>
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="status" />
+ <pad bytes="20" />
+ </reply>
+ </request>
+
+ <request name="SwitchToMode" opcode="10">
+ <field type="CARD32" name="screen" />
+ <field type="DOTCLOCK" name="dotclock" />
+ <field type="CARD16" name= "hdisplay" />
+ <field type="CARD16" name= "hsyncstart" />
+ <field type="CARD16" name= "hsyncend" />
+ <field type="CARD16" name= "htotal" />
+ <field type="CARD16" name= "hskew" />
+ <field type="CARD16" name= "vdisplay" />
+ <field type="CARD16" name= "vsyncstart" />
+ <field type="CARD16" name= "vsyncend" />
+ <field type="CARD16" name= "vtotal" />
+ <pad bytes="2" />
+ <field type="CARD32" name="flags" mask="ModeFlag" />
+ <pad bytes="12" />
+ <field type="CARD32" name="privsize" />
+ <list type="CARD8" name="private">
+ <fieldref>privsize</fieldref>
+ </list>
+ </request>
+
+ <request name="GetViewPort" opcode="11">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="x" />
+ <field type="CARD32" name="y" />
+ <pad bytes="16" />
+ </reply>
+ </request>
+
+ <request name="SetViewPort" opcode="12">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <field type="CARD32" name="x" />
+ <field type="CARD32" name="y" />
+ </request>
+
+ <!-- new for version 2.x -->
+ <request name="GetDotClocks" opcode="13">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="flags" mask="ClockFlag" />
+ <field type="CARD32" name="clocks" />
+ <field type="CARD32" name="maxclocks" />
+ <pad bytes="12" />
+ <list type="CARD32" name="clock">
+ <!-- Only if flags does not include Programable:
+ (1 - (flags & 1)) * clocks
+ -->
+ <op op="*">
+ <op op = "-">
+ <value>1</value>
+ <op op="&">
+ <fieldref>flags</fieldref>
+ <value>1</value>
+ </op>
+ </op>
+ <fieldref>clocks</fieldref>
+ </op>
+ </list>
+ </reply>
+ </request>
+
+ <request name="SetClientVersion" opcode="14">
+ <field type="CARD16" name="major" />
+ <field type="CARD16" name="minor" />
+ </request>
+
+ <request name="SetGamma" opcode="15">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <field type="CARD32" name="red" />
+ <field type="CARD32" name="green" />
+ <field type="CARD32" name="blue" />
+ <pad bytes="12" />
+ </request>
+
+ <request name="GetGamma" opcode="16">
+ <field type="CARD16" name="screen" />
+ <pad bytes="26" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="red" />
+ <field type="CARD32" name="green" />
+ <field type="CARD32" name="blue" />
+ <pad bytes="12" />
+ </reply>
+ </request>
+
+ <request name="GetGammaRamp" opcode="17">
+ <field type="CARD16" name="screen" />
+ <field type="CARD16" name="size" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD16" name="size" />
+ <pad bytes="22" />
+ <list type="CARD16" name="red">
+ <op op="&">
+ <op op = "+">
+ <fieldref>size</fieldref>
+ <value>1</value>
+ </op>
+ <unop op="~">
+ <value>1</value>
+ </unop>
+ </op>
+ </list>
+ <list type="CARD16" name="green">
+ <op op="&">
+ <op op = "+">
+ <fieldref>size</fieldref>
+ <value>1</value>
+ </op>
+ <unop op="~">
+ <value>1</value>
+ </unop>
+ </op>
+ </list>
+ <list type="CARD16" name="blue">
+ <op op="&">
+ <op op = "+">
+ <fieldref>size</fieldref>
+ <value>1</value>
+ </op>
+ <unop op="~">
+ <value>1</value>
+ </unop>
+ </op>
+ </list>
+ </reply>
+ </request>
+
+ <request name="SetGammaRamp" opcode="18">
+ <field type="CARD16" name="screen" />
+ <field type="CARD16" name="size" />
+ <list type="CARD16" name="red">
+ <op op="&">
+ <op op = "+">
+ <fieldref>size</fieldref>
+ <value>1</value>
+ </op>
+ <unop op="~">
+ <value>1</value>
+ </unop>
+ </op>
+ </list>
+ <list type="CARD16" name="green">
+ <op op="&">
+ <op op = "+">
+ <fieldref>size</fieldref>
+ <value>1</value>
+ </op>
+ <unop op="~">
+ <value>1</value>
+ </unop>
+ </op>
+ </list>
+ <list type="CARD16" name="blue">
+ <op op="&">
+ <op op = "+">
+ <fieldref>size</fieldref>
+ <value>1</value>
+ </op>
+ <unop op="~">
+ <value>1</value>
+ </unop>
+ </op>
+ </list>
+ </request>
+
+ <request name="GetGammaRampSize" opcode="19">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD16" name="size" />
+ <pad bytes="22" />
+ </reply>
+ </request>
+
+ <request name="GetPermissions" opcode="20">
+ <field type="CARD16" name="screen" />
+ <pad bytes="2" />
+ <reply>
+ <pad bytes="1" />
+ <field type="CARD32" name="permissions" mask="Permission" />
+ <pad bytes="20" />
+ </reply>
+ </request>
+
+ <error name="BadClock" number="0" />
+ <error name="BadHTimings" number="1" />
+ <error name="BadVTimings" number="2" />
+ <error name="ModeUnsuitable" number="3" />
+ <error name="ExtensionDisabled" number="4" />
+ <error name="ClientNotLocal" number="5" />
+ <error name="ZoomLocked" number="6" />
+
+</xcb>
diff --git a/libxcb/xcb-proto/xcbgen/expr.py b/libxcb/xcb-proto/xcbgen/expr.py index 522e17d09..9b1855425 100644 --- a/libxcb/xcb-proto/xcbgen/expr.py +++ b/libxcb/xcb-proto/xcbgen/expr.py @@ -1,88 +1,95 @@ -''' -This module contains helper classes for structure fields and length expressions. -''' -class Field(object): - ''' - Represents a field of a structure. - - type is the datatype object for the field. - field_type is the name of the type (string tuple) - field_name is the name of the structure field. - visible is true iff the field should be in the request API. - wire is true iff the field should be in the request structure. - auto is true iff the field is on the wire but not in the request API (e.g. opcode) - ''' - def __init__(self, type, field_type, field_name, visible, wire, auto): - self.type = type - self.field_type = field_type - self.field_name = field_name - self.visible = visible - self.wire = wire - self.auto = auto - - -class Expression(object): - ''' - Represents a mathematical expression for a list length or exprfield. - - Public fields: - 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. - bitfield is True if the length field is a bitmask instead of a number. - nmemb is the fixed size (value)of the expression, or None - ''' - def __init__(self, elt, parent): - self.parent = parent - - self.nmemb = None - - self.lenfield_name = None - self.lenfield_type = None - self.lenfield = None - self.lenwire = False - self.bitfield = False - - self.op = None - self.lhs = None - self.rhs = None - - if elt.tag == 'list': - # List going into a request, which has no length field (inferred by server) - self.lenfield_name = elt.get('name') + '_len' - self.lenfield_type = 'CARD32' - - elif elt.tag == 'fieldref': - # Standard list with a fieldref - self.lenfield_name = elt.text - - elif elt.tag == 'valueparam': - # Value-mask. The length bitmask is described by attributes. - self.lenfield_name = elt.get('value-mask-name') - self.lenfield_type = elt.get('value-mask-type') - self.lenwire = True - self.bitfield = True - - elif elt.tag == 'op': - # Op field. Need to recurse. - self.op = elt.get('op') - self.lhs = Expression(list(elt)[0], parent) - self.rhs = Expression(list(elt)[1], parent) - - # Hopefully we don't have two separate length fields... - self.lenfield_name = self.lhs.lenfield_name - if self.lenfield_name == None: - self.lenfield_name = self.rhs.lenfield_name - - elif elt.tag == 'value': - # Constant expression - self.nmemb = int(elt.text) - - else: - # Notreached - raise Exception('XXX') - - - def fixed_size(self): - return self.nmemb != None +'''
+This module contains helper classes for structure fields and length expressions.
+'''
+class Field(object):
+ '''
+ Represents a field of a structure.
+
+ type is the datatype object for the field.
+ field_type is the name of the type (string tuple)
+ field_name is the name of the structure field.
+ visible is true iff the field should be in the request API.
+ wire is true iff the field should be in the request structure.
+ auto is true iff the field is on the wire but not in the request API (e.g. opcode)
+ '''
+ def __init__(self, type, field_type, field_name, visible, wire, auto):
+ self.type = type
+ self.field_type = field_type
+ self.field_name = field_name
+ self.visible = visible
+ self.wire = wire
+ self.auto = auto
+
+
+class Expression(object):
+ '''
+ Represents a mathematical expression for a list length or exprfield.
+
+ Public fields:
+ 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.
+ bitfield is True if the length field is a bitmask instead of a number.
+ nmemb is the fixed size (value)of the expression, or None
+ '''
+ def __init__(self, elt, parent):
+ self.parent = parent
+
+ self.nmemb = None
+
+ self.lenfield_name = None
+ self.lenfield_type = None
+ self.lenfield = None
+ self.lenwire = False
+ self.bitfield = False
+
+ self.op = None
+ self.lhs = None
+ self.rhs = None
+
+ if elt.tag == 'list':
+ # List going into a request, which has no length field (inferred by server)
+ self.lenfield_name = elt.get('name') + '_len'
+ self.lenfield_type = 'CARD32'
+
+ elif elt.tag == 'fieldref':
+ # Standard list with a fieldref
+ self.lenfield_name = elt.text
+
+ elif elt.tag == 'valueparam':
+ # Value-mask. The length bitmask is described by attributes.
+ self.lenfield_name = elt.get('value-mask-name')
+ self.lenfield_type = elt.get('value-mask-type')
+ self.lenwire = True
+ self.bitfield = True
+
+ elif elt.tag == 'op':
+ # Op field. Need to recurse.
+ self.op = elt.get('op')
+ self.lhs = Expression(list(elt)[0], parent)
+ self.rhs = Expression(list(elt)[1], parent)
+
+ # Hopefully we don't have two separate length fields...
+ self.lenfield_name = self.lhs.lenfield_name
+ 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, 0)
+
+ else:
+ # Notreached
+ raise Exception('XXX')
+
+
+ def fixed_size(self):
+ return self.nmemb != None
diff --git a/libxcb/xcb-proto/xcbgen/xtypes.py b/libxcb/xcb-proto/xcbgen/xtypes.py index 01d765e59..dae5102b3 100644 --- a/libxcb/xcb-proto/xcbgen/xtypes.py +++ b/libxcb/xcb-proto/xcbgen/xtypes.py @@ -1,471 +1,471 @@ -''' -This module contains the classes which represent XCB data types. -''' -from expr import Field, Expression -import __main__ - -class Type(object): - ''' - Abstract base class for all XCB data types. - Contains default fields, and some abstract methods. - ''' - def __init__(self, name): - ''' - Default structure initializer. Sets up default fields. - - Public fields: - name is a tuple of strings specifying the full type name. - size is the size of the datatype in bytes, or None if variable-sized. - nmemb is 1 for non-list types, None for variable-sized lists, otherwise number of elts. - booleans for identifying subclasses, because I can't figure out isinstance(). - ''' - self.name = name - self.size = None - self.nmemb = None - self.resolved = False - - # Screw isinstance(). - self.is_simple = False - self.is_list = False - self.is_expr = False - self.is_container = False - self.is_reply = False - self.is_union = False - self.is_pad = False - - def resolve(self, module): - ''' - Abstract method for resolving a type. - This should make sure any referenced types are already declared. - ''' - raise Exception('abstract resolve method not overridden!') - - def out(self, name): - ''' - Abstract method for outputting code. - These are declared in the language-specific modules, and - there must be a dictionary containing them declared when this module is imported! - ''' - raise Exception('abstract out method not overridden!') - - def fixed_size(self): - ''' - Abstract method for determining if the data type is fixed-size. - ''' - raise Exception('abstract fixed_size method not overridden!') - - def make_member_of(self, module, complex_type, field_type, field_name, visible, wire, auto): - ''' - Default method for making a data type a member of a structure. - Extend this if the data type needs to add an additional length field or something. - - 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 fields are added. - for (idx, field) in enumerate(complex_type.fields): - if field == _placeholder_byte: - complex_type.fields[idx] = new_field - return - - complex_type.fields.append(new_field) - -class SimpleType(Type): - ''' - Derived class which represents a cardinal type like CARD32 or char. - Any type which is typedef'ed to cardinal will be one of these. - - Public fields added: - none - ''' - def __init__(self, name, size): - Type.__init__(self, name) - self.is_simple = True - self.size = size - self.nmemb = 1 - - def resolve(self, module): - self.resolved = True - - def fixed_size(self): - return True - - out = __main__.output['simple'] - - -# Cardinal datatype globals. See module __init__ method. -tcard8 = SimpleType(('uint8_t',), 1) -tcard16 = SimpleType(('uint16_t',), 2) -tcard32 = SimpleType(('uint32_t',), 4) -tint8 = SimpleType(('int8_t',), 1) -tint16 = SimpleType(('int16_t',), 2) -tint32 = SimpleType(('int32_t',), 4) -tchar = SimpleType(('char',), 1) -tfloat = SimpleType(('float',), 4) -tdouble = SimpleType(('double',), 8) - - -class Enum(SimpleType): - ''' - Derived class which represents an enum. Fixed-size. - - Public fields added: - values contains a list of (name, value) tuples. value is empty, or a number. - bits contains a list of (name, bitnum) tuples. items only appear if specified as a bit. bitnum is a number. - ''' - def __init__(self, name, elt): - SimpleType.__init__(self, name, 4) - self.values = [] - self.bits = [] - for item in list(elt): - # First check if we're using a default value - if len(list(item)) == 0: - self.values.append((item.get('name'), '')) - continue - - # An explicit value or bit was specified. - value = list(item)[0] - 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.bits.append((item.get('name'), value.text)) - - def resolve(self, module): - self.resolved = True - - def fixed_size(self): - return True - - out = __main__.output['enum'] - - -class ListType(Type): - ''' - Derived class which represents a list of some other datatype. Fixed- or variable-sized. - - Public fields added: - member is the datatype of the list elements. - 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): - Type.__init__(self, member.name) - self.is_list = True - self.member = member - self.parent = parent - - if elt.tag == 'list': - elts = list(elt) - self.expr = Expression(elts[0] if len(elts) else elt, self) - elif elt.tag == 'valueparam': - self.expr = Expression(elt, self) - - self.size = member.size if member.fixed_size() else None - self.nmemb = self.expr.nmemb if self.expr.fixed_size() else None - - 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 field in self.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) - - def resolve(self, module): - if self.resolved: - return - self.member.resolve(module) - - # 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 - - self.resolved = True - - def fixed_size(self): - return self.member.fixed_size() and self.expr.fixed_size() - -class ExprType(Type): - ''' - Derived class which represents an exprfield. Fixed size. - - Public fields added: - expr is an Expression object containing the value of the field. - ''' - def __init__(self, elt, member, parent): - Type.__init__(self, member.name) - self.is_expr = True - self.member = member - self.parent = parent - - self.expr = Expression(list(elt)[0], self) - - self.size = member.size - self.nmemb = 1 - - def resolve(self, module): - if self.resolved: - return - self.member.resolve(module) - self.resolved = True - - def fixed_size(self): - return True - -class PadType(Type): - ''' - Derived class which represents a padding field. - ''' - def __init__(self, elt): - Type.__init__(self, tcard8.name) - self.is_pad = True - self.size = 1 - self.nmemb = 1 if (elt == None) else int(elt.get('bytes')) - - def resolve(self, module): - self.resolved = True - - def fixed_size(self): - return True - - -class ComplexType(Type): - ''' - Derived class which represents a structure. Base type for all structure types. - - Public fields added: - fields is an array of Field objects describing the structure fields. - ''' - def __init__(self, name, elt): - Type.__init__(self, name) - self.is_container = True - self.elt = elt - self.fields = [] - self.nmemb = 1 - self.size = 0 - - def resolve(self, module): - if self.resolved: - return - pads = 0 - - # Resolve all of our field datatypes. - for child in list(self.elt): - if child.tag == 'pad': - field_name = 'pad' + str(pads) - fkey = 'CARD8' - type = PadType(child) - pads = pads + 1 - visible = False - elif child.tag == 'field': - field_name = child.get('name') - fkey = child.get('type') - type = module.get_type(fkey) - visible = True - elif child.tag == 'exprfield': - field_name = child.get('name') - fkey = child.get('type') - type = ExprType(child, module.get_type(fkey), self) - visible = False - elif child.tag == 'list': - field_name = child.get('name') - fkey = child.get('type') - type = ListType(child, module.get_type(fkey), self) - visible = True - elif child.tag == 'valueparam': - field_name = child.get('value-list-name') - fkey = 'CARD32' - type = ListType(child, module.get_type(fkey), self) - visible = True - else: - # Hit this on Reply - continue - - # Get the full type name for the field - field_type = module.get_type_name(fkey) - # 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) - - self.calc_size() # Figure out how big we are - self.resolved = True - - def calc_size(self): - self.size = 0 - for m in self.fields: - if not m.wire: - continue - if m.type.fixed_size(): - self.size = self.size + (m.type.size * m.type.nmemb) - else: - self.size = None - break - - def fixed_size(self): - for m in self.fields: - if not m.type.fixed_size(): - return False - return True - - -class Struct(ComplexType): - ''' - Derived class representing a struct data type. - ''' - out = __main__.output['struct'] - - -class Union(ComplexType): - ''' - Derived class representing a union data type. - ''' - def __init__(self, name, elt): - ComplexType.__init__(self, name, elt) - self.is_union = True - - out = __main__.output['union'] - - -class Reply(ComplexType): - ''' - Derived class representing a reply. Only found as a field of Request. - ''' - def __init__(self, name, elt): - ComplexType.__init__(self, name, elt) - self.is_reply = True - - def resolve(self, module): - if self.resolved: - return - # Add the automatic protocol fields - self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True)) - self.fields.append(_placeholder_byte) - self.fields.append(Field(tcard16, tcard16.name, 'sequence', False, True, True)) - self.fields.append(Field(tcard32, tcard32.name, 'length', False, True, True)) - ComplexType.resolve(self, module) - - -class Request(ComplexType): - ''' - Derived class representing a request. - - Public fields added: - reply contains the reply datatype or None for void requests. - opcode contains the request number. - ''' - def __init__(self, name, elt): - ComplexType.__init__(self, name, elt) - self.reply = None - self.opcode = elt.get('opcode') - - for child in list(elt): - if child.tag == 'reply': - self.reply = Reply(name, child) - - def resolve(self, module): - if self.resolved: - return - # Add the automatic protocol fields - if module.namespace.is_ext: - self.fields.append(Field(tcard8, tcard8.name, 'major_opcode', False, True, True)) - self.fields.append(Field(tcard8, tcard8.name, 'minor_opcode', False, True, True)) - self.fields.append(Field(tcard16, tcard16.name, 'length', False, True, True)) - ComplexType.resolve(self, module) - else: - self.fields.append(Field(tcard8, tcard8.name, 'major_opcode', False, True, True)) - self.fields.append(_placeholder_byte) - self.fields.append(Field(tcard16, tcard16.name, 'length', False, True, True)) - ComplexType.resolve(self, module) - - if self.reply: - self.reply.resolve(module) - - out = __main__.output['request'] - - -class Event(ComplexType): - ''' - Derived class representing an event data type. - - Public fields added: - opcodes is a dictionary of name -> opcode number, for eventcopies. - ''' - def __init__(self, name, elt): - ComplexType.__init__(self, name, elt) - self.opcodes = {} - - tmp = elt.get('no-sequence-number') - self.has_seq = (tmp == None or tmp.lower() == 'false' or tmp == '0') - - def add_opcode(self, opcode, name, main): - self.opcodes[name] = opcode - if main: - self.name = name - - def resolve(self, module): - if self.resolved: - return - - # Add the automatic protocol fields - self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True)) - if self.has_seq: - self.fields.append(_placeholder_byte) - self.fields.append(Field(tcard16, tcard16.name, 'sequence', False, True, True)) - ComplexType.resolve(self, module) - - out = __main__.output['event'] - - -class Error(ComplexType): - ''' - Derived class representing an error data type. - - Public fields added: - opcodes is a dictionary of name -> opcode number, for errorcopies. - ''' - def __init__(self, name, elt): - ComplexType.__init__(self, name, elt) - self.opcodes = {} - - def add_opcode(self, opcode, name, main): - self.opcodes[name] = opcode - if main: - self.name = name - - def resolve(self, module): - if self.resolved: - return - - # Add the automatic protocol fields - self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True)) - self.fields.append(Field(tcard8, tcard8.name, 'error_code', False, True, True)) - self.fields.append(Field(tcard16, tcard16.name, 'sequence', False, True, True)) - ComplexType.resolve(self, module) - - out = __main__.output['error'] - -_placeholder_byte = Field(PadType(None), tcard8.name, 'pad0', False, True, False) +'''
+This module contains the classes which represent XCB data types.
+'''
+from expr import Field, Expression
+import __main__
+
+class Type(object):
+ '''
+ Abstract base class for all XCB data types.
+ Contains default fields, and some abstract methods.
+ '''
+ def __init__(self, name):
+ '''
+ Default structure initializer. Sets up default fields.
+
+ Public fields:
+ name is a tuple of strings specifying the full type name.
+ size is the size of the datatype in bytes, or None if variable-sized.
+ nmemb is 1 for non-list types, None for variable-sized lists, otherwise number of elts.
+ booleans for identifying subclasses, because I can't figure out isinstance().
+ '''
+ self.name = name
+ self.size = None
+ self.nmemb = None
+ self.resolved = False
+
+ # Screw isinstance().
+ self.is_simple = False
+ self.is_list = False
+ self.is_expr = False
+ self.is_container = False
+ self.is_reply = False
+ self.is_union = False
+ self.is_pad = False
+
+ def resolve(self, module):
+ '''
+ Abstract method for resolving a type.
+ This should make sure any referenced types are already declared.
+ '''
+ raise Exception('abstract resolve method not overridden!')
+
+ def out(self, name):
+ '''
+ Abstract method for outputting code.
+ These are declared in the language-specific modules, and
+ there must be a dictionary containing them declared when this module is imported!
+ '''
+ raise Exception('abstract out method not overridden!')
+
+ def fixed_size(self):
+ '''
+ Abstract method for determining if the data type is fixed-size.
+ '''
+ raise Exception('abstract fixed_size method not overridden!')
+
+ def make_member_of(self, module, complex_type, field_type, field_name, visible, wire, auto):
+ '''
+ Default method for making a data type a member of a structure.
+ Extend this if the data type needs to add an additional length field or something.
+
+ 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 fields are added.
+ for (idx, field) in enumerate(complex_type.fields):
+ if field == _placeholder_byte:
+ complex_type.fields[idx] = new_field
+ return
+
+ complex_type.fields.append(new_field)
+
+class SimpleType(Type):
+ '''
+ Derived class which represents a cardinal type like CARD32 or char.
+ Any type which is typedef'ed to cardinal will be one of these.
+
+ Public fields added:
+ none
+ '''
+ def __init__(self, name, size):
+ Type.__init__(self, name)
+ self.is_simple = True
+ self.size = size
+ self.nmemb = 1
+
+ def resolve(self, module):
+ self.resolved = True
+
+ def fixed_size(self):
+ return True
+
+ out = __main__.output['simple']
+
+
+# Cardinal datatype globals. See module __init__ method.
+tcard8 = SimpleType(('uint8_t',), 1)
+tcard16 = SimpleType(('uint16_t',), 2)
+tcard32 = SimpleType(('uint32_t',), 4)
+tint8 = SimpleType(('int8_t',), 1)
+tint16 = SimpleType(('int16_t',), 2)
+tint32 = SimpleType(('int32_t',), 4)
+tchar = SimpleType(('char',), 1)
+tfloat = SimpleType(('float',), 4)
+tdouble = SimpleType(('double',), 8)
+
+
+class Enum(SimpleType):
+ '''
+ Derived class which represents an enum. Fixed-size.
+
+ Public fields added:
+ values contains a list of (name, value) tuples. value is empty, or a number.
+ bits contains a list of (name, bitnum) tuples. items only appear if specified as a bit. bitnum is a number.
+ '''
+ def __init__(self, name, elt):
+ SimpleType.__init__(self, name, 4)
+ self.values = []
+ self.bits = []
+ for item in list(elt):
+ # First check if we're using a default value
+ if len(list(item)) == 0:
+ self.values.append((item.get('name'), ''))
+ continue
+
+ # An explicit value or bit was specified.
+ value = list(item)[0]
+ 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, 0))))
+ self.bits.append((item.get('name'), value.text))
+
+ def resolve(self, module):
+ self.resolved = True
+
+ def fixed_size(self):
+ return True
+
+ out = __main__.output['enum']
+
+
+class ListType(Type):
+ '''
+ Derived class which represents a list of some other datatype. Fixed- or variable-sized.
+
+ Public fields added:
+ member is the datatype of the list elements.
+ 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):
+ Type.__init__(self, member.name)
+ self.is_list = True
+ self.member = member
+ self.parent = parent
+
+ if elt.tag == 'list':
+ elts = list(elt)
+ self.expr = Expression(elts[0] if len(elts) else elt, self)
+ elif elt.tag == 'valueparam':
+ self.expr = Expression(elt, self)
+
+ self.size = member.size if member.fixed_size() else None
+ self.nmemb = self.expr.nmemb if self.expr.fixed_size() else None
+
+ 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 field in self.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)
+
+ def resolve(self, module):
+ if self.resolved:
+ return
+ self.member.resolve(module)
+
+ # 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
+
+ self.resolved = True
+
+ def fixed_size(self):
+ return self.member.fixed_size() and self.expr.fixed_size()
+
+class ExprType(Type):
+ '''
+ Derived class which represents an exprfield. Fixed size.
+
+ Public fields added:
+ expr is an Expression object containing the value of the field.
+ '''
+ def __init__(self, elt, member, parent):
+ Type.__init__(self, member.name)
+ self.is_expr = True
+ self.member = member
+ self.parent = parent
+
+ self.expr = Expression(list(elt)[0], self)
+
+ self.size = member.size
+ self.nmemb = 1
+
+ def resolve(self, module):
+ if self.resolved:
+ return
+ self.member.resolve(module)
+ self.resolved = True
+
+ def fixed_size(self):
+ return True
+
+class PadType(Type):
+ '''
+ Derived class which represents a padding field.
+ '''
+ def __init__(self, elt):
+ Type.__init__(self, tcard8.name)
+ self.is_pad = True
+ self.size = 1
+ self.nmemb = 1 if (elt == None) else int(elt.get('bytes'), 0)
+
+ def resolve(self, module):
+ self.resolved = True
+
+ def fixed_size(self):
+ return True
+
+
+class ComplexType(Type):
+ '''
+ Derived class which represents a structure. Base type for all structure types.
+
+ Public fields added:
+ fields is an array of Field objects describing the structure fields.
+ '''
+ def __init__(self, name, elt):
+ Type.__init__(self, name)
+ self.is_container = True
+ self.elt = elt
+ self.fields = []
+ self.nmemb = 1
+ self.size = 0
+
+ def resolve(self, module):
+ if self.resolved:
+ return
+ pads = 0
+
+ # Resolve all of our field datatypes.
+ for child in list(self.elt):
+ if child.tag == 'pad':
+ field_name = 'pad' + str(pads)
+ fkey = 'CARD8'
+ type = PadType(child)
+ pads = pads + 1
+ visible = False
+ elif child.tag == 'field':
+ field_name = child.get('name')
+ fkey = child.get('type')
+ type = module.get_type(fkey)
+ visible = True
+ elif child.tag == 'exprfield':
+ field_name = child.get('name')
+ fkey = child.get('type')
+ type = ExprType(child, module.get_type(fkey), self)
+ visible = False
+ elif child.tag == 'list':
+ field_name = child.get('name')
+ fkey = child.get('type')
+ type = ListType(child, module.get_type(fkey), self)
+ visible = True
+ elif child.tag == 'valueparam':
+ field_name = child.get('value-list-name')
+ fkey = 'CARD32'
+ type = ListType(child, module.get_type(fkey), self)
+ visible = True
+ else:
+ # Hit this on Reply
+ continue
+
+ # Get the full type name for the field
+ field_type = module.get_type_name(fkey)
+ # 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)
+
+ self.calc_size() # Figure out how big we are
+ self.resolved = True
+
+ def calc_size(self):
+ self.size = 0
+ for m in self.fields:
+ if not m.wire:
+ continue
+ if m.type.fixed_size():
+ self.size = self.size + (m.type.size * m.type.nmemb)
+ else:
+ self.size = None
+ break
+
+ def fixed_size(self):
+ for m in self.fields:
+ if not m.type.fixed_size():
+ return False
+ return True
+
+
+class Struct(ComplexType):
+ '''
+ Derived class representing a struct data type.
+ '''
+ out = __main__.output['struct']
+
+
+class Union(ComplexType):
+ '''
+ Derived class representing a union data type.
+ '''
+ def __init__(self, name, elt):
+ ComplexType.__init__(self, name, elt)
+ self.is_union = True
+
+ out = __main__.output['union']
+
+
+class Reply(ComplexType):
+ '''
+ Derived class representing a reply. Only found as a field of Request.
+ '''
+ def __init__(self, name, elt):
+ ComplexType.__init__(self, name, elt)
+ self.is_reply = True
+
+ def resolve(self, module):
+ if self.resolved:
+ return
+ # Add the automatic protocol fields
+ self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True))
+ self.fields.append(_placeholder_byte)
+ self.fields.append(Field(tcard16, tcard16.name, 'sequence', False, True, True))
+ self.fields.append(Field(tcard32, tcard32.name, 'length', False, True, True))
+ ComplexType.resolve(self, module)
+
+
+class Request(ComplexType):
+ '''
+ Derived class representing a request.
+
+ Public fields added:
+ reply contains the reply datatype or None for void requests.
+ opcode contains the request number.
+ '''
+ def __init__(self, name, elt):
+ ComplexType.__init__(self, name, elt)
+ self.reply = None
+ self.opcode = elt.get('opcode')
+
+ for child in list(elt):
+ if child.tag == 'reply':
+ self.reply = Reply(name, child)
+
+ def resolve(self, module):
+ if self.resolved:
+ return
+ # Add the automatic protocol fields
+ if module.namespace.is_ext:
+ self.fields.append(Field(tcard8, tcard8.name, 'major_opcode', False, True, True))
+ self.fields.append(Field(tcard8, tcard8.name, 'minor_opcode', False, True, True))
+ self.fields.append(Field(tcard16, tcard16.name, 'length', False, True, True))
+ ComplexType.resolve(self, module)
+ else:
+ self.fields.append(Field(tcard8, tcard8.name, 'major_opcode', False, True, True))
+ self.fields.append(_placeholder_byte)
+ self.fields.append(Field(tcard16, tcard16.name, 'length', False, True, True))
+ ComplexType.resolve(self, module)
+
+ if self.reply:
+ self.reply.resolve(module)
+
+ out = __main__.output['request']
+
+
+class Event(ComplexType):
+ '''
+ Derived class representing an event data type.
+
+ Public fields added:
+ opcodes is a dictionary of name -> opcode number, for eventcopies.
+ '''
+ def __init__(self, name, elt):
+ ComplexType.__init__(self, name, elt)
+ self.opcodes = {}
+
+ tmp = elt.get('no-sequence-number')
+ self.has_seq = (tmp == None or tmp.lower() == 'false' or tmp == '0')
+
+ def add_opcode(self, opcode, name, main):
+ self.opcodes[name] = opcode
+ if main:
+ self.name = name
+
+ def resolve(self, module):
+ if self.resolved:
+ return
+
+ # Add the automatic protocol fields
+ self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True))
+ if self.has_seq:
+ self.fields.append(_placeholder_byte)
+ self.fields.append(Field(tcard16, tcard16.name, 'sequence', False, True, True))
+ ComplexType.resolve(self, module)
+
+ out = __main__.output['event']
+
+
+class Error(ComplexType):
+ '''
+ Derived class representing an error data type.
+
+ Public fields added:
+ opcodes is a dictionary of name -> opcode number, for errorcopies.
+ '''
+ def __init__(self, name, elt):
+ ComplexType.__init__(self, name, elt)
+ self.opcodes = {}
+
+ def add_opcode(self, opcode, name, main):
+ self.opcodes[name] = opcode
+ if main:
+ self.name = name
+
+ def resolve(self, module):
+ if self.resolved:
+ return
+
+ # Add the automatic protocol fields
+ self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True))
+ self.fields.append(Field(tcard8, tcard8.name, 'error_code', False, True, True))
+ self.fields.append(Field(tcard16, tcard16.name, 'sequence', False, True, True))
+ ComplexType.resolve(self, module)
+
+ out = __main__.output['error']
+
+_placeholder_byte = Field(PadType(None), tcard8.name, 'pad0', False, True, False)
|