summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <jdahlin@async.com.br>2009-01-20 20:41:52 +0000
committerJohan Dahlin <johan@src.gnome.org>2009-01-20 20:41:52 +0000
commite6b0f3b11a2d00dc17d7f928ef94b4c3f610d499 (patch)
tree85eaaae8df6e3fb841adf348b11c6f3b2b9be64a
parentb8079c4098c2dbfc6f8aa607eefb4f53e59b04e6 (diff)
downloadgobject-introspection-e6b0f3b11a2d00dc17d7f928ef94b4c3f610d499.tar.gz
Bug 562615 – Struct methods missing
2009-01-20 Johan Dahlin <jdahlin@async.com.br> 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
-rw-r--r--ChangeLog12
-rw-r--r--giscanner/annotationparser.py6
-rw-r--r--giscanner/ast.py3
-rw-r--r--giscanner/girwriter.py23
-rw-r--r--giscanner/glibast.py4
-rw-r--r--giscanner/glibtransformer.py14
-rw-r--r--tests/scanner/foo-1.0-expected.gir64
-rw-r--r--tests/scanner/foo-1.0-expected.tgir61
8 files changed, 99 insertions, 88 deletions
diff --git a/ChangeLog b/ChangeLog
index 45f86f38..1b5b8ab8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-01-20 Johan Dahlin <jdahlin@async.com.br>
+
+ 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 <danw@gnome.org>
* gir/GL-1.0.gir: add back GLvoid, which got lost during the
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 240b96e8..e5ecc64c 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 b3c1fff5..8343009b 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 39d7c22e..89af8fb9 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 60f214b7..11a5ed0b 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 5eefe914..1829215c 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 d284246c..11a3b4e0 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. -->
<field name="height" writable="1">
<type name="int" c:type="gint"/>
</field>
+ <constructor name="new" c:identifier="foo_rectangle_new">
+ <return-value transfer-ownership="full">
+ <type name="Rectangle" c:type="FooRectangle*"/>
+ </return-value>
+ <parameters>
+ <parameter name="x" transfer-ownership="none">
+ <type name="int" c:type="int"/>
+ </parameter>
+ <parameter name="y" transfer-ownership="none">
+ <type name="int" c:type="int"/>
+ </parameter>
+ <parameter name="width" transfer-ownership="none">
+ <type name="int" c:type="int"/>
+ </parameter>
+ <parameter name="height" transfer-ownership="none">
+ <type name="int" c:type="int"/>
+ </parameter>
+ </parameters>
+ </constructor>
+ <method name="add" c:identifier="foo_rectangle_add">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="r2" transfer-ownership="none">
+ <type name="Rectangle" c:type="FooRectangle*"/>
+ </parameter>
+ </parameters>
+ </method>
</record>
<function name="method_external_references"
c:identifier="foo_method_external_references">
@@ -399,41 +428,6 @@ and/or use gtk-doc annotations. -->
</parameter>
</parameters>
</function>
- <function name="rectangle_add" c:identifier="foo_rectangle_add">
- <return-value transfer-ownership="none">
- <type name="none" c:type="void"/>
- </return-value>
- <parameters>
- <parameter name="r1"
- direction="inout"
- transfer-ownership="full"
- doc="add to this rect">
- <type name="Rectangle" c:type="FooRectangle*"/>
- </parameter>
- <parameter name="r2" transfer-ownership="none">
- <type name="Rectangle" c:type="FooRectangle*"/>
- </parameter>
- </parameters>
- </function>
- <function name="rectangle_new" c:identifier="foo_rectangle_new">
- <return-value transfer-ownership="full">
- <type name="Rectangle" c:type="FooRectangle*"/>
- </return-value>
- <parameters>
- <parameter name="x" transfer-ownership="none">
- <type name="int" c:type="int"/>
- </parameter>
- <parameter name="y" transfer-ownership="none">
- <type name="int" c:type="int"/>
- </parameter>
- <parameter name="width" transfer-ownership="none">
- <type name="int" c:type="int"/>
- </parameter>
- <parameter name="height" transfer-ownership="none">
- <type name="int" c:type="int"/>
- </parameter>
- </parameters>
- </function>
<record name="EventAny" c:type="FooEventAny">
<field name="send_event" writable="1">
<type name="int8" c:type="gint8"/>
diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir
index 2cb29d39..59549192 100644
--- a/tests/scanner/foo-1.0-expected.tgir
+++ b/tests/scanner/foo-1.0-expected.tgir
@@ -260,6 +260,35 @@
<field name="height" writable="1">
<type name="int"/>
</field>
+ <constructor name="new" c:identifier="foo_rectangle_new">
+ <return-value transfer-ownership="full">
+ <type name="Rectangle"/>
+ </return-value>
+ <parameters>
+ <parameter name="x" transfer-ownership="none">
+ <type name="int"/>
+ </parameter>
+ <parameter name="y" transfer-ownership="none">
+ <type name="int"/>
+ </parameter>
+ <parameter name="width" transfer-ownership="none">
+ <type name="int"/>
+ </parameter>
+ <parameter name="height" transfer-ownership="none">
+ <type name="int"/>
+ </parameter>
+ </parameters>
+ </constructor>
+ <method name="add" c:identifier="foo_rectangle_add">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="r2" transfer-ownership="none">
+ <type name="Rectangle"/>
+ </parameter>
+ </parameters>
+ </method>
</record>
<function name="method_external_references" c:identifier="foo_method_external_references">
<return-value transfer-ownership="none">
@@ -280,38 +309,6 @@
</parameter>
</parameters>
</function>
- <function name="rectangle_add" c:identifier="foo_rectangle_add">
- <return-value transfer-ownership="none">
- <type name="none"/>
- </return-value>
- <parameters>
- <parameter name="r1" transfer-ownership="full" direction="inout">
- <type name="Rectangle"/>
- </parameter>
- <parameter name="r2" transfer-ownership="none">
- <type name="Rectangle"/>
- </parameter>
- </parameters>
- </function>
- <function name="rectangle_new" c:identifier="foo_rectangle_new">
- <return-value transfer-ownership="full">
- <type name="Rectangle"/>
- </return-value>
- <parameters>
- <parameter name="x" transfer-ownership="none">
- <type name="int"/>
- </parameter>
- <parameter name="y" transfer-ownership="none">
- <type name="int"/>
- </parameter>
- <parameter name="width" transfer-ownership="none">
- <type name="int"/>
- </parameter>
- <parameter name="height" transfer-ownership="none">
- <type name="int"/>
- </parameter>
- </parameters>
- </function>
<record name="EventAny">
<field name="send_event" writable="1">
<type name="int8"/>