From: Johan Dahlin Date: Tue, 20 Jan 2009 20:41:52 +0000 (+0000) Subject: Bug 562615 – Struct methods missing X-Git-Tag: GOBJECT_INTROSPECTION_0_6_2~5 X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=e6b0f3b11a2d00dc17d7f928ef94b4c3f610d499;p=gnome.gobject-introspection Bug 562615 – Struct methods missing 2009-01-20 Johan Dahlin Bug 562615 – Struct methods missing * giscanner/annotationparser.py: * giscanner/ast.py: * giscanner/girwriter.py: * giscanner/glibast.py: * giscanner/glibtransformer.py: * tests/scanner/foo-1.0-expected.gir: * tests/scanner/foo-1.0-expected.tgir: svn path=/trunk/; revision=1054 --- diff --git a/ChangeLog b/ChangeLog index 45f86f3..1b5b8ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-01-20 Johan Dahlin + + Bug 562615 – Struct methods missing + + * giscanner/annotationparser.py: + * giscanner/ast.py: + * giscanner/girwriter.py: + * giscanner/glibast.py: + * giscanner/glibtransformer.py: + * tests/scanner/foo-1.0-expected.gir: + * tests/scanner/foo-1.0-expected.tgir: + 2009-01-16 Dan Winship * gir/GL-1.0.gir: add back GLvoid, which got lost during the diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 240b96e..e5ecc64 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -295,9 +295,8 @@ class AnnotationApplier(object): block = self._blocks.get(record.symbol) self._parse_version(record, block) self._parse_constructors(record.constructors) + self._parse_methods(record.methods) self._parse_fields(record, record.fields) - if isinstance(record, GLibBoxed): - self._parse_methods(record.methods) if block: record.doc = block.comment @@ -313,8 +312,7 @@ class AnnotationApplier(object): block = self._blocks.get(union.name) self._parse_fields(union, union.fields) self._parse_constructors(union.constructors) - if isinstance(union, GLibBoxed): - self._parse_methods(union.methods) + self._parse_methods(union.methods) if block: union.doc = block.comment diff --git a/giscanner/ast.py b/giscanner/ast.py index b3c1fff..8343009 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -363,6 +363,8 @@ class Record(Node): self.symbol = symbol self.disguised = disguised self.doc = None + self.constructors = [] + self.methods = [] # BW compat, remove Struct = Record @@ -488,6 +490,7 @@ class Union(Node): Node.__init__(self, name) self.fields = [] self.constructors = [] + self.methods = [] self.symbol = symbol self.doc = None diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 39d7c22..89af8fb 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -323,7 +323,10 @@ and/or use gtk-doc annotations. ''') attrs.append(('doc', boxed.doc)) attrs.extend(self._boxed_attrs(boxed)) with self.tagcontext('glib:boxed', attrs): - self._write_boxed_ctors_methods(boxed) + for method in boxed.constructors: + self._write_constructor(method) + for method in boxed.methods: + self._write_method(method) def _write_property(self, prop): attrs = [('name', prop.name)] @@ -359,12 +362,6 @@ and/or use gtk-doc annotations. ''') return [('glib:type-name', boxed.type_name), ('glib:get-type', boxed.get_type)] - def _write_boxed_ctors_methods(self, boxed): - for method in boxed.constructors: - self._write_constructor(method) - for method in boxed.methods: - self._write_method(method) - def _write_record(self, record): attrs = [('name', record.name), ('c:type', record.symbol)] @@ -380,8 +377,10 @@ and/or use gtk-doc annotations. ''') if record.fields: for field in record.fields: self._write_field(field) - if isinstance(record, GLibBoxed): - self._write_boxed_ctors_methods(record) + for method in record.constructors: + self._write_constructor(method) + for method in record.methods: + self._write_method(method) def _write_union(self, union): attrs = [('name', union.name), @@ -396,8 +395,10 @@ and/or use gtk-doc annotations. ''') if union.fields: for field in union.fields: self._write_field(field) - if isinstance(union, GLibBoxed): - self._write_boxed_ctors_methods(union) + for method in union.constructors: + self._write_constructor(method) + for method in union.methods: + self._write_method(method) def _write_field(self, field): if isinstance(field, Function): diff --git a/giscanner/glibast.py b/giscanner/glibast.py index 60f214b..11a5ed0 100644 --- a/giscanner/glibast.py +++ b/giscanner/glibast.py @@ -110,8 +110,6 @@ class GLibObject(Class): class GLibBoxed: def __init__(self, type_name, get_type): - self.constructors = [] - self.methods = [] self.type_name = type_name self.get_type = get_type @@ -135,6 +133,8 @@ class GLibBoxedOther(Node, GLibBoxed): def __init__(self, name, type_name, get_type): Node.__init__(self, name) GLibBoxed.__init__(self, type_name, get_type) + self.constructors = [] + self.methods = [] self.ctype = type_name self.doc = None diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py index 5eefe91..1829215 100644 --- a/giscanner/glibtransformer.py +++ b/giscanner/glibtransformer.py @@ -418,9 +418,13 @@ class GLibTransformer(object): # The _uscore_type_names member holds the plain GLibBoxed # object; we want to actually use the struct/record associated - if isinstance(klass, (Record, GLibBoxed)): - name = self._transformer.remove_prefix(klass.type_name) - klass = self._get_attribute(name) + if isinstance(klass, (Record, Union)): + remove_prefix = klass.symbol + else: + remove_prefix = klass.type_name + + name = self._transformer.remove_prefix(remove_prefix) + klass = self._get_attribute(name) if not is_method: # Interfaces can't have constructors, punt to global scope @@ -432,7 +436,7 @@ class GLibTransformer(object): # class from the prefix # But for now, ensure that constructor returns are always # the most concrete class - name = self._transformer.remove_prefix(klass.type_name) + name = self._transformer.remove_prefix(remove_prefix) func.retval.type = Type(name, func.retval.type.ctype) self._remove_attribute(func.name) @@ -461,6 +465,7 @@ class GLibTransformer(object): node = self._names.names.get(record.name) if node is None: self._add_attribute(record, replace=True) + self._register_internal_type(record.symbol, record) return (ns, node) = node node.fields = record.fields[:] @@ -469,6 +474,7 @@ class GLibTransformer(object): node = self._names.names.get(union.name) if node is None: self._add_attribute(union, replace=True) + self._register_internal_type(union.symbol, union) return (ns, node) = node node.fields = union.fields[:] diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir index d284246..11a3b4e 100644 --- a/tests/scanner/foo-1.0-expected.gir +++ b/tests/scanner/foo-1.0-expected.gir @@ -378,6 +378,35 @@ and/or use gtk-doc annotations. --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -399,41 +428,6 @@ and/or use gtk-doc annotations. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir index 2cb29d3..5954919 100644 --- a/tests/scanner/foo-1.0-expected.tgir +++ b/tests/scanner/foo-1.0-expected.tgir @@ -260,6 +260,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -280,38 +309,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -