diff options
-rw-r--r-- | giscanner/girparser.py | 1 | ||||
-rw-r--r-- | giscanner/girwriter.py | 2 | ||||
-rw-r--r-- | giscanner/maintransformer.py | 8 | ||||
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 7 | ||||
-rw-r--r-- | tests/scanner/regress.h | 16 |
5 files changed, 33 insertions, 1 deletions
diff --git a/giscanner/girparser.py b/giscanner/girparser.py index ab2b29d..582dcc0 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -179,6 +179,7 @@ class GIRParser(object): alias = ast.Alias(node.attrib['name'], typeval, node.attrib.get(_cns('type'))) + self._parse_generic_attribs(node, alias) self._namespace.append(alias) def _parse_generic_attribs(self, node, obj): diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index a450bb1..d3b023a 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -154,7 +154,9 @@ and/or use gtk-doc annotations. ''') attrs = [('name', alias.name)] if alias.ctype is not None: attrs.append(('c:type', alias.ctype)) + self._append_node_generic(alias, attrs) with self.tagcontext('alias', attrs): + self._write_generic(alias) self._write_type(alias.target) def _write_callable(self, callable, tag_name, extra_attrs): diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 74873a3..a7f2b61 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -176,7 +176,7 @@ usage is void (*_gtk_reserved1)(void);""" def _get_annotation_name(self, node): if isinstance(node, (ast.Class, ast.Interface, ast.Record, ast.Union, ast.Enum, ast.Bitfield, - ast.Callback)): + ast.Callback, ast.Alias)): if node.ctype is not None: return node.ctype elif isinstance(node, ast.Registered) and node.gtype_name is not None: @@ -190,6 +190,8 @@ usage is void (*_gtk_reserved1)(void);""" def _pass_read_annotations(self, node, chain): if not node.namespace: return False + if isinstance(node, ast.Alias): + self._apply_annotations_alias(node, chain) if isinstance(node, ast.Function): self._apply_annotations_function(node, chain) if isinstance(node, ast.Callback): @@ -500,6 +502,10 @@ usage is void (*_gtk_reserved1)(void);""" if OPT_FOREIGN in block.options: node.foreign = True + def _apply_annotations_alias(self, node, chain): + block = self._get_block(node) + self._apply_annotations_annotated(node, block) + def _apply_annotations_param(self, parent, param, tag): if tag: options = tag.options diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index 192a7ae..16b8015 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -15,12 +15,19 @@ and/or use gtk-doc annotations. --> shared-library="libregress.so" c:identifier-prefixes="Regress" c:symbol-prefixes="regress"> + <alias name="IntSet" c:type="RegressIntSet" introspectable="0"> + <doc xml:whitespace="preserve">Compatibility typedef, like telepathy-glib's TpIntSet</doc> + <type name="Intset" c:type="RegressIntset"/> + </alias> <constant name="DOUBLE_CONSTANT" value="44.220000"> <type name="gdouble" c:type="gdouble"/> </constant> <constant name="INT_CONSTANT" value="4422"> <type name="gint" c:type="gint"/> </constant> + <record name="Intset" c:type="RegressIntset" disguised="1"> + <doc xml:whitespace="preserve">Like telepathy-glib's TpIntset.</doc> + </record> <constant name="Mixed_Case_Constant" value="4423"> <type name="gint" c:type="gint"/> </constant> diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 5c39260..dde4e5b 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -539,4 +539,20 @@ void regress_random_function_with_skipped_structure (int x, RegressSkippedStructure *foo, double v); +/** + * RegressIntset: + * + * Like telepathy-glib's TpIntset. + * + */ +typedef struct _RegressIntset RegressIntset; + +/** + * RegressIntSet: (skip) + * + * Compatibility typedef, like telepathy-glib's TpIntSet + * + */ +typedef RegressIntset RegressIntSet; + #endif /* __GITESTTYPES_H__ */ |