+2008-10-15 Johan Bilien <jobi@via.ecp.fr>
+
+ Bug 556433 – assume direction = out for int * parameters
+
+ * giscanner/ast.py: define a list of types for which, if passed as
+ reference, we assume a default direction of 'out'
+ * giscanner/transformer.py: if a type has type pointer to one of the
+ previously defined types, and no direction is set, assume out.
+ * tests/scanner/drawable.[ch]: added tests for guessed direction=out
+
2008-10-15 Johan Bilien <jobi@via.ecp.fr>
* tests/scanner/annotation.c: fixed a few copy-paste errors
default_array_types['uint8*'] = TYPE_UINT8
default_array_types['char**'] = TYPE_STRING
+# These types, when seen by reference, are interpreted as out parameters
+default_out_types = (TYPE_INT, TYPE_UINT, TYPE_LONG, TYPE_ULONG,
+ TYPE_FLOAT, TYPE_DOUBLE)
+
def type_name_from_ctype(ctype):
return type_names.get(ctype, ctype)
Parameter, Return, Array, Struct, Field,
Type, Alias, Interface, Class, Node, Union,
List, Map, Varargs, Constant, type_name_from_ctype,
- type_names, default_array_types, TYPE_STRING)
+ type_names, default_array_types, default_out_types,
+ TYPE_STRING)
from giscanner.config import DATADIR
from .glibast import GLibBoxed
from giscanner.sourcescanner import (
else:
options['transfer'] = ['full']
+ # deduce direction for some types passed by reference
+ if (not ('out' in options or
+ 'in' in options or
+ 'inout' in options or
+ 'in-out' in options) and
+ source_type.type == CTYPE_POINTER and
+ type_name_from_ctype(resolved_type_name) in default_out_types):
+ options['out'] = []
+
return Type(resolved_type_name, ctype)
def _handle_generic_param_options(self, param, options):
</parameter>
</parameters>
</method>
+ <method name="get_origin" c:identifier="test_drawable_get_origin">
+ <return-value>
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="x" direction="out">
+ <type name="int" c:type="int*"/>
+ </parameter>
+ <parameter name="y" direction="out">
+ <type name="int" c:type="int*"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="get_size" c:identifier="test_drawable_get_size">
+ <return-value>
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="width" direction="out">
+ <type name="uint" c:type="guint*"/>
+ </parameter>
+ <parameter name="height" direction="out">
+ <type name="uint" c:type="guint*"/>
+ </parameter>
+ </parameters>
+ </method>
<field name="parent_instance">
<type name="GObject.Object" c:type="GObject"/>
</field>
{
}
+
+void
+test_drawable_get_origin (TestDrawable *drawable, int *x, int *y)
+{
+ *x = 0;
+ *y = 0;
+}
+
+void
+test_drawable_get_size (TestDrawable *drawable, guint *width, guint *height)
+{
+ *width = 42;
+ *height = 42;
+}
GType test_drawable_get_type (void) G_GNUC_CONST;
void test_drawable_do_foo (TestDrawable *drawable, int x);
+void test_drawable_get_origin (TestDrawable *drawable, int *x, int *y);
+void test_drawable_get_size (TestDrawable *drawable, guint *width, guint *height);
struct _TestPixmapObjectClass
{