gobject-introspection r787 - in trunk: giscanner tests/scanner



Author: walters
Date: Thu Oct 23 12:37:10 2008
New Revision: 787
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=787&view=rev

Log:
Always write out transfer-ownership attribute


Modified:
   trunk/giscanner/ast.py
   trunk/giscanner/glibtransformer.py
   trunk/giscanner/transformer.py
   trunk/tests/scanner/GtkFrob-1.0-expected.gir
   trunk/tests/scanner/annotation-1.0-expected.gir
   trunk/tests/scanner/drawable-1.0-expected.gir
   trunk/tests/scanner/drawable-injected-1.0-expected.gir
   trunk/tests/scanner/foo-1.0-expected.gir
   trunk/tests/scanner/foo.c

Modified: trunk/giscanner/ast.py
==============================================================================
--- trunk/giscanner/ast.py	(original)
+++ trunk/giscanner/ast.py	Thu Oct 23 12:37:10 2008
@@ -264,24 +264,32 @@
         return 'Alias(%r, %r)' % (self.name, self.target)
 
 
-class Parameter(Node):
+class TypeContainer(Node):
 
-    def __init__(self, name, typenode, direction=PARAM_DIRECTION_IN,
-                 transfer=None, allow_none=False):
+    def __init__(self, name, typenode, transfer):
         Node.__init__(self, name)
         self.type = typenode
-        if direction in [PARAM_DIRECTION_IN, PARAM_DIRECTION_OUT,
-                         PARAM_DIRECTION_INOUT]:
-            self.direction = direction
-        else:
-            self.direction = PARAM_DIRECTION_IN
-
         if transfer in [PARAM_TRANSFER_NONE, PARAM_TRANSFER_CONTAINER,
                         PARAM_TRANSFER_FULL]:
             self.transfer = transfer
         else:
             self.transfer = None
 
+        # transformer.py overrides this as needed
+        self.transfer_inferred = False
+
+
+class Parameter(TypeContainer):
+
+    def __init__(self, name, typenode, direction=PARAM_DIRECTION_IN,
+                 transfer=None, allow_none=False):
+        TypeContainer.__init__(self, name, typenode, transfer)
+        if direction in [PARAM_DIRECTION_IN, PARAM_DIRECTION_OUT,
+                         PARAM_DIRECTION_INOUT]:
+            self.direction = direction
+        else:
+            self.direction = PARAM_DIRECTION_IN
+
         self.allow_none = not not allow_none
 
     def __repr__(self):
@@ -336,15 +344,10 @@
             return 'Field(%r, %r)' % (self.name, self.type)
 
 
-class Return(Node):
+class Return(TypeContainer):
 
     def __init__(self, rtype, transfer=None):
-        Node.__init__(self)
-        self.type = rtype
-        if transfer is None and rtype.name in ['utf8', 'filename']:
-            self.transfer = 'full'
-        else:
-            self.transfer = transfer
+        TypeContainer.__init__(self, None, rtype, transfer)
 
     def __repr__(self):
         return 'Return(%r)' % (self.type, )

Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py	(original)
+++ trunk/giscanner/glibtransformer.py	Thu Oct 23 12:37:10 2008
@@ -784,7 +784,7 @@
         else:
             is_out = True
         if (is_out and
-            param.transfer is None and
+            (param.transfer is None or param.transfer_inferred) and
             (param.type.name == 'GObject.Object' or
              (self._namespace_name == 'GObject'
               and param.type.name == 'Object'))):

Modified: trunk/giscanner/transformer.py
==============================================================================
--- trunk/giscanner/transformer.py	(original)
+++ trunk/giscanner/transformer.py	Thu Oct 23 12:37:10 2008
@@ -26,7 +26,7 @@
                            Type, Alias, Interface, Class, Node, Union,
                            List, Map, Varargs, Constant, type_name_from_ctype,
                            type_names, default_array_types, default_out_types,
-                           TYPE_STRING)
+                           TYPE_STRING, BASIC_GIR_TYPES, TYPE_NONE)
 from giscanner.config import DATADIR
 from .glibast import GLibBoxed
 from giscanner.sourcescanner import (
@@ -311,7 +311,7 @@
             symbol.base_type.base_type.type == CTYPE_FUNCTION):
             node = self._create_callback(symbol)
         else:
-            ftype = self._create_type(symbol.base_type, {})
+            ftype = self._create_type(symbol.base_type, {}, True)
             # Fields are assumed to be read-write
             # (except for Objects, see also glibtransformer.py)
             node = Field(symbol.ident, ftype, symbol.ident,
@@ -361,7 +361,7 @@
         # this ensures we turn e.g. plain "guint" => "int"
         return type_name_from_ctype(derefed)
 
-    def _create_type(self, source_type, options):
+    def _create_type(self, source_type, options, is_param):
         ctype = self._create_source_type(source_type)
         if ctype == 'va_list':
             raise SkipError()
@@ -377,9 +377,10 @@
                 contained_type = self._parse_ctype(param[0])
             else:
                 contained_type = None
-            return List(ctype.replace('*', ''),
-                        ctype,
-                        contained_type)
+            derefed_name = self._parse_ctype(ctype)
+            rettype = List(derefed_name,
+                           ctype,
+                           contained_type)
         elif ctype in self._map_ctypes:
             param = options.get('element-type')
             if param:
@@ -388,31 +389,26 @@
             else:
                 key_type = None
                 value_type = None
-            return Map(ctype.replace('*', ''),
-                       ctype,
-                       key_type, value_type)
+            derefed_name = self._parse_ctype(ctype)
+            rettype = Map(derefed_name,
+                          ctype,
+                          key_type, value_type)
         elif (ctype in default_array_types) or ('array' in options):
-            derefed = ctype[:-1] # strip the *
-            result = Array(ctype,
-                         self._parse_ctype(derefed))
+            derefed_name = ctype[:-1] # strip the *
+            rettype = Array(ctype,
+                            self._parse_ctype(derefed_name))
             array_opts = options.get('array')
             if array_opts:
                 (_, len_name) = array_opts[0].split('=')
-                result.length_param_name = len_name
-            return result
-
-        # string memory management - we just look at 'const'
-        if (type_name_from_ctype(ctype) == TYPE_STRING
-            and 'transfer' not in options):
-            if source_type.base_type.type_qualifier & TYPE_QUALIFIER_CONST:
-                options['transfer'] = ['none']
-            else:
-                options['transfer'] = ['full']
-
-        derefed_name = self._parse_ctype(ctype)
+                rettype.length_param_name = len_name
+        else:
+            derefed_name = self._parse_ctype(ctype)
+            rettype = Type(derefed_name, ctype)
 
-        # deduce direction for some types passed by reference
-        if (not ('out' in options or
+        # Deduce direction for some types passed by reference that
+        # aren't arrays; modifies the options array.
+        if ('array' not in options and
+            not ('out' in options or
                  'in' in options or
                  'inout' in options or
                  'in-out' in options) and
@@ -420,7 +416,57 @@
             derefed_name in default_out_types):
             options['out'] = []
 
-        return Type(derefed_name, ctype)
+        if 'transfer' in options:
+            # Transfer is specified, we don't question it.
+            return rettype
+
+        canontype = type_name_from_ctype(ctype)
+
+        # Since no transfer is specified, we drop into a bunch of
+        # heuristics to guess it.  This mutates the options array to
+        # set the 'transfer' option.
+        # Note that we inferred the transfer
+        options['transfer-inferred'] = []
+        stype = source_type
+        if canontype == TYPE_STRING:
+            # It's a string - we just look at 'const'
+            if source_type.base_type.type_qualifier & TYPE_QUALIFIER_CONST:
+                options['transfer'] = ['none']
+            else:
+                options['transfer'] = ['full']
+        elif 'array' in options or stype.type == CTYPE_ARRAY:
+            # It's rare to mutate arrays in public GObject APIs
+            options['transfer'] = ['none']
+        elif (canontype in BASIC_GIR_TYPES or
+              canontype == TYPE_NONE or
+              stype.type == CTYPE_ENUM):
+            # Basic types default to 'none'
+            options['transfer'] = ['none']
+        elif (stype.type == CTYPE_POINTER and
+              stype.base_type.type_qualifier & TYPE_QUALIFIER_CONST):
+            # Anything with 'const' gets none
+            options['transfer'] = ['none']
+        elif is_param and stype.type == CTYPE_POINTER:
+            # For generic pointer types, let's look at the argument
+            # direction.  An out/inout argument gets full, everything
+            # else none.
+            if ('out' in options or
+                'inout' in options or
+                'in-out' in options):
+                options['transfer'] = ['full']
+            else:
+                options['transfer'] = ['none']
+        else:
+            # For anything else we default to none for parameters;
+            # this covers enums and possibly some other corner cases.
+            # Return values of structures and the like will end up
+            # full.
+            if is_param:
+                options['transfer'] = ['none']
+            else:
+                options['transfer'] = ['full']
+
+        return rettype
 
     def _handle_generic_param_options(self, param, options):
         for option, data in options.iteritems():
@@ -432,13 +478,17 @@
                 else:
                     depth = 'full'
                 param.transfer = depth
+            elif option == 'transfer-inferred':
+                # This is a purely internal flag; we don't expect
+                # people to write it
+                param.transfer_inferred = True
 
     def _create_parameter(self, symbol, options):
         options = self._parse_options(options)
         if symbol.type == CSYMBOL_TYPE_ELLIPSIS:
             ptype = Varargs()
         else:
-            ptype = self._create_type(symbol.base_type, options)
+            ptype = self._create_type(symbol.base_type, options, True)
         param = Parameter(symbol.ident, ptype)
         for option, data in options.iteritems():
             if option in ['in-out', 'inout']:
@@ -451,7 +501,7 @@
                 param.allow_none = True
             elif option.startswith(('element-type', 'array')):
                 pass
-            elif option == 'transfer':
+            elif option in ('transfer', 'transfer-inferred'):
                 pass
             else:
                 print 'Unhandled parameter annotation option: %r' % (
@@ -464,12 +514,13 @@
             options_map = {}
         else:
             options_map = self._parse_options(options)
-        rtype = self._create_type(source_type, options_map)
+        rtype = self._create_type(source_type, options_map, False)
         rtype = self.resolve_param_type(rtype)
         return_ = Return(rtype)
         self._handle_generic_param_options(return_, options_map)
         for option, data in options_map.iteritems():
-            if option in ('transfer', 'element-type', 'out'):
+            if option in ('transfer', 'transfer-inferred',
+                          'element-type', 'out'):
                 pass
             else:
                 print 'Unhandled return type annotation option: %r' % (

Modified: trunk/tests/scanner/GtkFrob-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/GtkFrob-1.0-expected.gir	(original)
+++ trunk/tests/scanner/GtkFrob-1.0-expected.gir	Thu Oct 23 12:37:10 2008
@@ -8,7 +8,7 @@
   <namespace name="GtkFrob" version="1.0" shared-library="gtkfrob">
     <function name="language_manager_get_default"
               c:identifier="gtk_frob_language_manager_get_default">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="none" c:type="void"/>
       </return-value>
     </function>

Modified: trunk/tests/scanner/annotation-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/annotation-1.0-expected.gir	(original)
+++ trunk/tests/scanner/annotation-1.0-expected.gir	Thu Oct 23 12:37:10 2008
@@ -37,16 +37,16 @@
            glib:type-name="AnnotationObject"
            glib:get-type="annotation_object_get_type">
       <method name="method" c:identifier="annotation_object_method">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
         </return-value>
       </method>
       <method name="out" c:identifier="annotation_object_out">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
         </return-value>
         <parameters>
-          <parameter name="outarg" direction="out">
+          <parameter name="outarg" direction="out" transfer-ownership="full">
             <type name="int" c:type="int*"/>
           </parameter>
         </parameters>
@@ -73,47 +73,54 @@
         </return-value>
       </method>
       <method name="inout" c:identifier="annotation_object_inout">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
         </return-value>
         <parameters>
-          <parameter name="inoutarg" direction="inout">
+          <parameter name="inoutarg"
+                     direction="inout"
+                     transfer-ownership="full">
             <type name="int" c:type="int*"/>
           </parameter>
         </parameters>
       </method>
       <method name="inout2" c:identifier="annotation_object_inout2">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
         </return-value>
         <parameters>
-          <parameter name="inoutarg" direction="inout">
+          <parameter name="inoutarg"
+                     direction="inout"
+                     transfer-ownership="full">
             <type name="int" c:type="int*"/>
           </parameter>
         </parameters>
       </method>
       <method name="inout3" c:identifier="annotation_object_inout3">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
         </return-value>
         <parameters>
-          <parameter name="inoutarg" direction="inout" allow-none="1">
+          <parameter name="inoutarg"
+                     direction="inout"
+                     transfer-ownership="full"
+                     allow-none="1">
             <type name="int" c:type="int*"/>
           </parameter>
         </parameters>
       </method>
       <method name="in" c:identifier="annotation_object_in">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
         </return-value>
         <parameters>
-          <parameter name="inarg">
+          <parameter name="inarg" transfer-ownership="none">
             <type name="int" c:type="int*"/>
           </parameter>
         </parameters>
       </method>
       <method name="calleeowns" c:identifier="annotation_object_calleeowns">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
         </return-value>
         <parameters>
@@ -123,7 +130,7 @@
         </parameters>
       </method>
       <method name="calleesowns" c:identifier="annotation_object_calleesowns">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
         </return-value>
         <parameters>
@@ -150,11 +157,11 @@
         </return-value>
       </method>
       <method name="use_buffer" c:identifier="annotation_object_use_buffer">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="bytes">
+          <parameter name="bytes" transfer-ownership="none">
             <array c:type="guchar*">
               <type name="uint8"/>
             </array>
@@ -162,11 +169,11 @@
         </parameters>
       </method>
       <method name="compute_sum" c:identifier="annotation_object_compute_sum">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="nums">
+          <parameter name="nums" transfer-ownership="none">
             <array c:type="int*">
               <type name="int"/>
             </array>
@@ -175,16 +182,16 @@
       </method>
       <method name="compute_sum_n"
               c:identifier="annotation_object_compute_sum_n">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="nums">
+          <parameter name="nums" transfer-ownership="none">
             <array length="2" c:type="int*">
               <type name="int"/>
             </array>
           </parameter>
-          <parameter name="n_nums">
+          <parameter name="n_nums" transfer-ownership="none">
             <type name="int" c:type="int"/>
           </parameter>
         </parameters>

Modified: trunk/tests/scanner/drawable-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/drawable-1.0-expected.gir	(original)
+++ trunk/tests/scanner/drawable-1.0-expected.gir	Thu Oct 23 12:37:10 2008
@@ -14,37 +14,37 @@
            glib:type-name="TestDrawable"
            glib:get-type="test_drawable_get_type">
       <method name="do_foo" c:identifier="test_drawable_do_foo">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="x">
+          <parameter name="x" transfer-ownership="none">
             <type name="int" c:type="int"/>
           </parameter>
         </parameters>
       </method>
       <method name="get_origin" c:identifier="test_drawable_get_origin">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="x" direction="out">
+          <parameter name="x" direction="out" transfer-ownership="full">
             <type name="int" c:type="int*"/>
           </parameter>
-          <parameter name="y" direction="out">
+          <parameter name="y" direction="out" transfer-ownership="full">
             <type name="int" c:type="int*"/>
           </parameter>
         </parameters>
       </method>
       <method name="get_size" c:identifier="test_drawable_get_size">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="width" direction="out">
+          <parameter name="width" direction="out" transfer-ownership="full">
             <type name="uint" c:type="guint*"/>
           </parameter>
-          <parameter name="height" direction="out">
+          <parameter name="height" direction="out" transfer-ownership="full">
             <type name="uint" c:type="guint*"/>
           </parameter>
         </parameters>
@@ -52,11 +52,11 @@
       <method name="do_foo_maybe_throw"
               c:identifier="test_drawable_do_foo_maybe_throw"
               throws="1">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="x">
+          <parameter name="x" transfer-ownership="none">
             <type name="int" c:type="int"/>
           </parameter>
         </parameters>

Modified: trunk/tests/scanner/drawable-injected-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/drawable-injected-1.0-expected.gir	(original)
+++ trunk/tests/scanner/drawable-injected-1.0-expected.gir	Thu Oct 23 12:37:10 2008
@@ -14,37 +14,37 @@
            glib:type-name="TestDrawable"
            glib:get-type="test_drawable_get_type">
       <method name="do_foo" c:identifier="test_drawable_do_foo">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="x">
+          <parameter name="x" transfer-ownership="none">
             <type name="int" c:type="int"/>
           </parameter>
         </parameters>
       </method>
       <method name="get_origin" c:identifier="test_drawable_get_origin">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="x" direction="out">
+          <parameter name="x" direction="out" transfer-ownership="full">
             <type name="int" c:type="int*"/>
           </parameter>
-          <parameter name="y" direction="out">
+          <parameter name="y" direction="out" transfer-ownership="full">
             <type name="int" c:type="int*"/>
           </parameter>
         </parameters>
       </method>
       <method name="get_size" c:identifier="test_drawable_get_size">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="width" direction="out">
+          <parameter name="width" direction="out" transfer-ownership="full">
             <type name="uint" c:type="guint*"/>
           </parameter>
-          <parameter name="height" direction="out">
+          <parameter name="height" direction="out" transfer-ownership="full">
             <type name="uint" c:type="guint*"/>
           </parameter>
         </parameters>
@@ -52,11 +52,11 @@
       <method name="do_foo_maybe_throw"
               c:identifier="test_drawable_do_foo_maybe_throw"
               throws="1">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="x">
+          <parameter name="x" transfer-ownership="none">
             <type name="int" c:type="int"/>
           </parameter>
         </parameters>

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	Thu Oct 23 12:37:10 2008
@@ -15,11 +15,11 @@
                glib:type-name="FooInterface"
                glib:get-type="foo_interface_get_type">
       <callback name="do_foo" c:type="do_foo">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="self">
+          <parameter name="self" transfer-ownership="none">
             <type name="Interface" c:type="FooInterface*"/>
           </parameter>
         </parameters>
@@ -30,11 +30,11 @@
         <type name="GObject.TypeInterface" c:type="GTypeInterface"/>
       </field>
       <callback name="do_foo" c:type="do_foo">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="self">
+          <parameter name="self" transfer-ownership="none">
             <type name="Interface" c:type="FooInterface*"/>
           </parameter>
         </parameters>
@@ -47,34 +47,34 @@
            glib:get-type="foo_object_get_type">
       <implements name="Interface"/>
       <constructor name="new" c:identifier="foo_object_new">
-        <return-value>
+        <return-value transfer-ownership="full">
           <type name="Object" c:type="FooObject*"/>
         </return-value>
       </constructor>
       <method name="external_type" c:identifier="foo_object_external_type">
-        <return-value>
+        <return-value transfer-ownership="full">
           <type name="utility.Object" c:type="UtilityObject*"/>
         </return-value>
       </method>
       <method name="various" c:identifier="foo_object_various">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="data">
+          <parameter name="data" transfer-ownership="none">
             <type name="any" c:type="void*"/>
           </parameter>
-          <parameter name="some_type">
+          <parameter name="some_type" transfer-ownership="none">
             <type name="GType" c:type="GType"/>
           </parameter>
         </parameters>
       </method>
       <method name="take_all" c:identifier="foo_object_take_all">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="x">
+          <parameter name="x" transfer-ownership="none">
             <type name="int" c:type="int"/>
           </parameter>
           <parameter>
@@ -84,17 +84,17 @@
         </parameters>
       </method>
       <method name="with_tdef" c:identifier="foo_object_with_tdef">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="blah">
+          <parameter name="blah" transfer-ownership="none">
             <type name="List" c:type="FooList*"/>
           </parameter>
         </parameters>
       </method>
       <method name="new_cookie" c:identifier="foo_object_new_cookie">
-        <return-value>
+        <return-value transfer-ownership="full">
           <type name="ObjectCookie" c:type="FooObjectCookie"/>
         </return-value>
         <parameters>
@@ -104,11 +104,11 @@
         </parameters>
       </method>
       <method name="is_it_time_yet" c:identifier="foo_object_is_it_time_yet">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="time">
+          <parameter name="time" transfer-ownership="none">
             <type name="time_t" c:type="time_t"/>
           </parameter>
         </parameters>
@@ -124,11 +124,11 @@
         </return-value>
       </method>
       <method name="handle_glyph" c:identifier="foo_object_handle_glyph">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="glyph">
+          <parameter name="glyph" transfer-ownership="none">
             <type name="utility.Glyph" c:type="UtilityGlyph"/>
           </parameter>
         </parameters>
@@ -140,20 +140,20 @@
         <type name="GObject.Object" c:type="GObject"/>
       </field>
       <callback name="virtual_method" c:type="virtual_method">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="boolean" c:type="gboolean"/>
         </return-value>
         <parameters>
-          <parameter name="object">
+          <parameter name="object" transfer-ownership="none">
             <type name="Object" c:type="FooObject*"/>
           </parameter>
-          <parameter name="first_param">
+          <parameter name="first_param" transfer-ownership="none">
             <type name="int" c:type="int"/>
           </parameter>
         </parameters>
       </callback>
       <glib:signal name="signal">
-        <return-value transfer-ownership="full">
+        <return-value>
           <type name="utf8" c:type="gchararray"/>
         </return-value>
         <parameters>
@@ -171,14 +171,14 @@
         <type name="GObject.ObjectClass" c:type="GObjectClass"/>
       </field>
       <callback name="virtual_method" c:type="virtual_method">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="boolean" c:type="gboolean"/>
         </return-value>
         <parameters>
-          <parameter name="object">
+          <parameter name="object" transfer-ownership="none">
             <type name="Object" c:type="FooObject*"/>
           </parameter>
-          <parameter name="first_param">
+          <parameter name="first_param" transfer-ownership="none">
             <type name="int" c:type="int"/>
           </parameter>
         </parameters>
@@ -192,7 +192,7 @@
            glib:get-type="foo_subobject_get_type">
       <implements name="Interface"/>
       <constructor name="new" c:identifier="foo_subobject_new">
-        <return-value>
+        <return-value transfer-ownership="full">
           <type name="Subobject" c:type="FooSubobject*"/>
         </return-value>
       </constructor>
@@ -206,7 +206,7 @@
       </field>
     </record>
     <function name="init" c:identifier="foo_init">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="int" c:type="gint"/>
       </return-value>
     </function>
@@ -228,21 +228,21 @@
               glib:nick="delta"/>
     </enumeration>
     <function name="enum_type_method" c:identifier="foo_enum_type_method">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="int" c:type="int"/>
       </return-value>
       <parameters>
-        <parameter name="foo_enum">
+        <parameter name="foo_enum" transfer-ownership="none">
           <type name="EnumType" c:type="FooEnumType"/>
         </parameter>
       </parameters>
     </function>
     <function name="enum_type_returnv" c:identifier="foo_enum_type_returnv">
-      <return-value>
+      <return-value transfer-ownership="full">
         <type name="EnumType" c:type="FooEnumType"/>
       </return-value>
       <parameters>
-        <parameter name="x">
+        <parameter name="x" transfer-ownership="none">
           <type name="int" c:type="int"/>
         </parameter>
       </parameters>
@@ -280,12 +280,12 @@
             glib:type-name="FooBoxed"
             glib:get-type="foo_boxed_get_type">
       <constructor name="new" c:identifier="foo_boxed_new">
-        <return-value>
+        <return-value transfer-ownership="full">
           <type name="Boxed" c:type="FooBoxed*"/>
         </return-value>
       </constructor>
       <method name="method" c:identifier="foo_boxed_method">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
       </method>
@@ -295,23 +295,23 @@
             glib:type-name="FooDBusData"
             glib:get-type="foo_dbus_data_get_type">
       <method name="method" c:identifier="foo_dbus_data_method">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
       </method>
     </record>
     <callback name="Callback" c:type="FooCallback">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="boolean" c:type="gboolean"/>
       </return-value>
       <parameters>
-        <parameter name="foo">
+        <parameter name="foo" transfer-ownership="none">
           <type name="Object" c:type="FooObject*"/>
         </parameter>
-        <parameter name="b">
+        <parameter name="b" transfer-ownership="none">
           <type name="boolean" c:type="gboolean"/>
         </parameter>
-        <parameter name="data">
+        <parameter name="data" transfer-ownership="none">
           <type name="any" c:type="gpointer"/>
         </parameter>
       </parameters>
@@ -342,52 +342,52 @@
     </record>
     <function name="method_external_references"
               c:identifier="foo_method_external_references">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="none" c:type="void"/>
       </return-value>
       <parameters>
-        <parameter name="object">
+        <parameter name="object" transfer-ownership="none">
           <type name="utility.Object" c:type="UtilityObject*"/>
         </parameter>
-        <parameter name="e">
+        <parameter name="e" transfer-ownership="none">
           <type name="utility.EnumType" c:type="UtilityEnumType"/>
         </parameter>
-        <parameter name="f">
+        <parameter name="f" transfer-ownership="none">
           <type name="utility.FlagType" c:type="UtilityFlagType"/>
         </parameter>
-        <parameter name="s">
+        <parameter name="s" transfer-ownership="none">
           <type name="utility.Struct" c:type="UtilityStruct"/>
         </parameter>
       </parameters>
     </function>
     <function name="rectangle_add" c:identifier="foo_rectangle_add">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="none" c:type="void"/>
       </return-value>
       <parameters>
-        <parameter name="r1">
+        <parameter name="r1" direction="inout" transfer-ownership="full">
           <type name="Rectangle" c:type="FooRectangle*"/>
         </parameter>
-        <parameter name="r2">
+        <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>
+      <return-value transfer-ownership="full">
         <type name="Rectangle" c:type="FooRectangle*"/>
       </return-value>
       <parameters>
-        <parameter name="x">
+        <parameter name="x" transfer-ownership="none">
           <type name="int" c:type="int"/>
         </parameter>
-        <parameter name="y">
+        <parameter name="y" transfer-ownership="none">
           <type name="int" c:type="int"/>
         </parameter>
-        <parameter name="width">
+        <parameter name="width" transfer-ownership="none">
           <type name="int" c:type="int"/>
         </parameter>
-        <parameter name="height">
+        <parameter name="height" transfer-ownership="none">
           <type name="int" c:type="int"/>
         </parameter>
       </parameters>
@@ -427,24 +427,24 @@
         <type name="double" c:type="double"/>
       </field>
       <constructor name="new" c:identifier="foo_brect_new">
-        <return-value>
+        <return-value transfer-ownership="full">
           <type name="BRect" c:type="FooBRect*"/>
         </return-value>
         <parameters>
-          <parameter name="x">
+          <parameter name="x" transfer-ownership="none">
             <type name="double" c:type="double"/>
           </parameter>
-          <parameter name="y">
+          <parameter name="y" transfer-ownership="none">
             <type name="double" c:type="double"/>
           </parameter>
         </parameters>
       </constructor>
       <method name="add" c:identifier="foo_brect_add">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter name="b2">
+          <parameter name="b2" transfer-ownership="none">
             <type name="BRect" c:type="FooBRect*"/>
           </parameter>
         </parameters>
@@ -464,13 +464,13 @@
         <type name="BRect" c:type="FooBRect*"/>
       </field>
       <constructor name="new" c:identifier="foo_bunion_new">
-        <return-value>
+        <return-value transfer-ownership="full">
           <type name="BUnion" c:type="FooBUnion*"/>
         </return-value>
       </constructor>
       <method name="get_contained_type"
               c:identifier="foo_bunion_get_contained_type">
-        <return-value>
+        <return-value transfer-ownership="none">
           <type name="int" c:type="int"/>
         </return-value>
       </method>
@@ -482,31 +482,31 @@
     </union>
     <function name="test_unsigned_qualifier"
               c:identifier="foo_test_unsigned_qualifier">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="none" c:type="void"/>
       </return-value>
       <parameters>
-        <parameter name="unsigned_param">
+        <parameter name="unsigned_param" transfer-ownership="none">
           <type name="uint" c:type="unsigned int"/>
         </parameter>
       </parameters>
     </function>
     <function name="test_unsigned_type" c:identifier="foo_test_unsigned_type">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="none" c:type="void"/>
       </return-value>
       <parameters>
-        <parameter name="unsigned_param">
+        <parameter name="unsigned_param" transfer-ownership="none">
           <type name="uint" c:type="unsigned"/>
         </parameter>
       </parameters>
     </function>
     <function name="test_string_array" c:identifier="foo_test_string_array">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="none" c:type="void"/>
       </return-value>
       <parameters>
-        <parameter name="array">
+        <parameter name="array" transfer-ownership="none">
           <array c:type="char**">
             <type name="utf8"/>
           </array>
@@ -515,11 +515,11 @@
     </function>
     <function name="test_string_array_with_g"
               c:identifier="foo_test_string_array_with_g">
-      <return-value>
+      <return-value transfer-ownership="none">
         <type name="none" c:type="void"/>
       </return-value>
       <parameters>
-        <parameter name="array">
+        <parameter name="array" transfer-ownership="none">
           <array c:type="gchar**">
             <type name="utf8"/>
           </array>

Modified: trunk/tests/scanner/foo.c
==============================================================================
--- trunk/tests/scanner/foo.c	(original)
+++ trunk/tests/scanner/foo.c	Thu Oct 23 12:37:10 2008
@@ -385,3 +385,14 @@
 foo_test_string_array (char **array)
 {
 }
+
+/**
+ * foo_rectangle_add:
+ * @r1: (inout): add to this rect
+ * @r2: source rectangle
+ */
+void
+foo_rectangle_add(FooRectangle *r1, const FooRectangle *r2)
+{
+
+}



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