[Xcb-commit] 2 commits - xcbgen

Bart Massey bart at kemper.freedesktop.org
Wed Sep 3 11:59:48 PDT 2008


 xcbgen/xtypes.py |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit f9c1bc3c6f24b5533f8ec8a441c9856a57824576
Author: Carsten Meier <cm at trexity.de>
Date:   Wed Sep 3 12:55:04 2008 +0200

    Make bit-numbers available to code-generators
    
    The Enum-class now exports the bit numbers in the 'bits'-list
    if they have been specified in the protocol description.
    
    Signed-off-by: Bart Massey <bart at cs.pdx.edu>

diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 1ba02eb..30617b8 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -114,10 +114,12 @@ class Enum(SimpleType):
 
     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:
@@ -130,6 +132,7 @@ class Enum(SimpleType):
                 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
commit 929646d767c1eff07c6d0a551cce01922b2c887d
Author: Carsten Meier <cm at trexity.de>
Date:   Wed Sep 3 12:50:26 2008 +0200

    Generate values instead of shift-expressions for enum-bits
    
    Now more language independent as some languages don't have
    C-like shift-operators.
    
    Signed-off-by: Bart Massey <bart at cs.pdx.edu>

diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index b234003..1ba02eb 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -129,8 +129,7 @@ class Enum(SimpleType):
             if value.tag == 'value':
                 self.values.append((item.get('name'), value.text))
             elif value.tag == 'bit':
-                # XXX replace this with a simple number, please.
-                self.values.append((item.get('name'), '(1 << %s)' % value.text))
+                self.values.append((item.get('name'), '%u' % (1 << int(value.text))))
 
     def resolve(self, module):
         self.resolved = True


More information about the xcb-commit mailing list