summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2008-10-11 21:16:57 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-10-11 21:16:57 +0000
commit7b1e139cd77b60b37d2b1dadfe45855e7bf122e1 (patch)
treed9b67de55369591a343b5d4f6f8e5cf4a093dc1f /giscanner
parent59011ffa9f2d12cb0c087f451b5918be98d6022e (diff)
downloadgobject-introspection-7b1e139cd77b60b37d2b1dadfe45855e7bf122e1.tar.gz
Bug 555712: Struct and union issues
2008-10-09 Andreas Rottmann <a.rottmann@gmx.at> Bug 555712: Struct and union issues * giscanner/scannerparser.y (struct_declarator): Use information provided about the bit width of a field. * giscanner/transformer.py (Transformer._create_member): Pass the symbol's const_int member to the created field (it represents the bit width). * giscanner/girwriter.py (GIRWriter._write_field): Output 'bits' field attribute, if present. * giscanner/ast.py (Field): Add 'bits' member, specifying the width in bits of the field (only relevant for bitfields). * tests/*: Updated. * giscanner/transformer.py (Transformer._create_typedef_struct) (Transformer._create_typedef_union): Add calls to _create_struct() and _create_union(), respectively. This causes the scanner to generate output for fields of struct and union typedefs. * tests/*: Updated. svn path=/trunk/; revision=667
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/ast.py8
-rw-r--r--giscanner/girwriter.py2
-rw-r--r--giscanner/scannerparser.y7
-rw-r--r--giscanner/transformer.py4
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):