diff options
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/ast.py | 8 | ||||
-rw-r--r-- | giscanner/girwriter.py | 2 | ||||
-rw-r--r-- | giscanner/scannerparser.y | 7 | ||||
-rw-r--r-- | giscanner/transformer.py | 4 |
4 files changed, 18 insertions, 3 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index 0c82623a..31f5f798 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -266,13 +266,17 @@ class Struct(Node): class Field(Node): - def __init__(self, name, typenode, symbol): + def __init__(self, name, typenode, symbol, bits=None): Node.__init__(self, name) self.type = typenode self.symbol = symbol + self.bits = bits def __repr__(self): - return 'Field(%r, %r)' % (self.name, self.type) + if self.bits: + return 'Field(%r, %r, %r)' % (self.name, self.type, self.bits) + else: + return 'Field(%r, %r)' % (self.name, self.type) class Return(Node): diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 43678581..e8faa5de 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -316,6 +316,8 @@ class GIRWriter(XMLWriter): return attrs = [('name', field.name)] + if field.bits: + attrs.append(('bits', str(field.bits))) with self.tagcontext('field', attrs): self._write_type(field.type) diff --git a/giscanner/scannerparser.y b/giscanner/scannerparser.y index 43a5ae0d..43635bd7 100644 --- a/giscanner/scannerparser.y +++ b/giscanner/scannerparser.y @@ -792,6 +792,13 @@ struct_declarator $$ = gi_source_symbol_new (CSYMBOL_TYPE_INVALID); } | declarator ':' constant_expression + { + $$ = $1; + if ($3->const_int_set) { + $$->const_int_set = TRUE; + $$->const_int = $3->const_int; + } + } ; enum_specifier diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 4c1cf17b..6b411e31 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -301,7 +301,7 @@ class Transformer(object): node = self._create_callback(symbol) else: ftype = self._create_type(symbol.base_type) - node = Field(symbol.ident, ftype, symbol.ident) + node = Field(symbol.ident, ftype, symbol.ident, symbol.const_int) return node def _create_typedef(self, symbol): @@ -417,6 +417,7 @@ class Transformer(object): name = self.strip_namespace_object(symbol.ident) struct = Struct(name, symbol.ident) self._typedefs_ns[symbol.ident] = struct + self._create_struct(symbol) return struct def _create_typedef_union(self, symbol): @@ -424,6 +425,7 @@ class Transformer(object): name = self.strip_namespace_object(name) union = Union(name, symbol.ident) self._typedefs_ns[symbol.ident] = union + self._create_union(symbol) return union def _create_struct(self, symbol): |