gobject-introspection r1054 - in trunk: . giscanner tests/scanner



Author: johan
Date: Tue Jan 20 20:41:52 2009
New Revision: 1054
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=1054&view=rev

Log:
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:



Modified:
   trunk/ChangeLog
   trunk/giscanner/annotationparser.py
   trunk/giscanner/ast.py
   trunk/giscanner/girwriter.py
   trunk/giscanner/glibast.py
   trunk/giscanner/glibtransformer.py
   trunk/tests/scanner/foo-1.0-expected.gir
   trunk/tests/scanner/foo-1.0-expected.tgir

Modified: trunk/giscanner/annotationparser.py
==============================================================================
--- trunk/giscanner/annotationparser.py	(original)
+++ trunk/giscanner/annotationparser.py	Tue Jan 20 20:41:52 2009
@@ -295,9 +295,8 @@
         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 @@
         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
 

Modified: trunk/giscanner/ast.py
==============================================================================
--- trunk/giscanner/ast.py	(original)
+++ trunk/giscanner/ast.py	Tue Jan 20 20:41:52 2009
@@ -363,6 +363,8 @@
         self.symbol = symbol
         self.disguised = disguised
         self.doc = None
+        self.constructors = []
+        self.methods = []
 
 # BW compat, remove
 Struct = Record
@@ -488,6 +490,7 @@
         Node.__init__(self, name)
         self.fields = []
         self.constructors = []
+        self.methods = []
         self.symbol = symbol
         self.doc = None
 

Modified: trunk/giscanner/girwriter.py
==============================================================================
--- trunk/giscanner/girwriter.py	(original)
+++ trunk/giscanner/girwriter.py	Tue Jan 20 20:41:52 2009
@@ -323,7 +323,10 @@
             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 @@
         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 @@
             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 @@
             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):

Modified: trunk/giscanner/glibast.py
==============================================================================
--- trunk/giscanner/glibast.py	(original)
+++ trunk/giscanner/glibast.py	Tue Jan 20 20:41:52 2009
@@ -110,8 +110,6 @@
 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 @@
     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
 

Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py	(original)
+++ trunk/giscanner/glibtransformer.py	Tue Jan 20 20:41:52 2009
@@ -418,9 +418,13 @@
 
         # 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 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 @@
         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 @@
         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[:]

Modified: trunk/tests/scanner/foo-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/foo-1.0-expected.gir	(original)
+++ trunk/tests/scanner/foo-1.0-expected.gir	Tue Jan 20 20:41:52 2009
@@ -378,6 +378,35 @@
       <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 @@
         </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"/>

Modified: trunk/tests/scanner/foo-1.0-expected.tgir
==============================================================================
--- trunk/tests/scanner/foo-1.0-expected.tgir	(original)
+++ trunk/tests/scanner/foo-1.0-expected.tgir	Tue Jan 20 20:41:52 2009
@@ -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"/>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]