gobject-introspection r1019 - in trunk: . giscanner tests/scanner
- From: johan svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r1019 - in trunk: . giscanner tests/scanner
- Date: Mon, 12 Jan 2009 20:54:11 +0000 (UTC)
Author: johan
Date: Mon Jan 12 20:54:11 2009
New Revision: 1019
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=1019&view=rev
Log:
2009-01-12 Johan Dahlin <jdahlin async com br>
Bug 566419 â Element type of arrays not properly handled in all cases
* giscanner/annotationparser.py:
* tests/scanner/annotation-1.0-expected.gir:
* tests/scanner/annotation-1.0-expected.tgir:
* tests/scanner/annotation.c (annotation_object_set_data),
(annotation_object_set_data2), (annotation_object_set_data3):
* tests/scanner/annotation.h:
Based on patch by Andreas Rottmann
Modified:
trunk/ChangeLog
trunk/giscanner/annotationparser.py
trunk/tests/scanner/annotation-1.0-expected.gir
trunk/tests/scanner/annotation-1.0-expected.tgir
trunk/tests/scanner/annotation.c
trunk/tests/scanner/annotation.h
Modified: trunk/giscanner/annotationparser.py
==============================================================================
--- trunk/giscanner/annotationparser.py (original)
+++ trunk/giscanner/annotationparser.py Mon Jan 12 20:54:11 2009
@@ -329,7 +329,7 @@
parent, node, options)
if container_type is not None:
node.type = container_type
- if not node.direction:
+ if node.direction is None:
node.direction = self._guess_direction(node)
node.transfer = self._extract_transfer(parent, node, options)
if 'allow-none' in options:
@@ -383,18 +383,34 @@
def _parse_array(self, parent, node, options):
array_opt = options.get('array')
if array_opt:
- values = array_opt.all()
+ array_values = array_opt.all()
else:
- values = {}
- container_type = Array(node.type.ctype, node.type.name)
- if 'zero-terminated' in values:
- container_type.zeroterminated = values.get(
+ array_values = {}
+
+ element_type = options.get('element-type')
+ if element_type is not None:
+ element_type_name = element_type.one()
+ else:
+ element_type_name = node.type.name
+
+ container_type = Array(node.type.ctype,
+ element_type_name)
+ if 'zero-terminated' in array_values:
+ container_type.zeroterminated = array_values.get(
'zero-terminated') == '1'
- length = values.get('length')
+ length = array_values.get('length')
if length is not None:
param_index = parent.get_parameter_index(length)
container_type.length_param_index = param_index
- container_type.size = values.get('fized-size')
+ # For in parameters we're incorrectly deferring
+ # char/unsigned char to utf8 when a length annotation
+ # is specified.
+ if (isinstance(node, Parameter) and
+ node.type.name == 'utf8' and
+ self._guess_direction(node) == PARAM_DIRECTION_IN):
+ # FIXME: unsigned char/guchar should be uint8
+ container_type.element_type = 'int8'
+ container_type.size = array_values.get('fized-size')
return container_type
def _parse_element_type(self, parent, node, options):
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 Mon Jan 12 20:54:11 2009
@@ -261,6 +261,51 @@
</parameter>
</parameters>
</method>
+ <method name="set_data" c:identifier="annotation_object_set_data">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="data" transfer-ownership="none">
+ <array length="2" c:type="guchar*">
+ <type name="uint8"/>
+ </array>
+ </parameter>
+ <parameter name="length" transfer-ownership="none">
+ <type name="size_t" c:type="gsize"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="set_data2" c:identifier="annotation_object_set_data2">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="data" transfer-ownership="none">
+ <array length="2" c:type="gchar*">
+ <type name="int8"/>
+ </array>
+ </parameter>
+ <parameter name="length" transfer-ownership="none">
+ <type name="size_t" c:type="gsize"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="set_data3" c:identifier="annotation_object_set_data3">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="data" transfer-ownership="none">
+ <array length="2" c:type="gpointer">
+ <type name="uint8"/>
+ </array>
+ </parameter>
+ <parameter name="length" transfer-ownership="none">
+ <type name="size_t" c:type="gsize"/>
+ </parameter>
+ </parameters>
+ </method>
<method name="do_not_use"
c:identifier="annotation_object_do_not_use"
deprecated="Use annotation_object_create_object() instead."
Modified: trunk/tests/scanner/annotation-1.0-expected.tgir
==============================================================================
--- trunk/tests/scanner/annotation-1.0-expected.tgir (original)
+++ trunk/tests/scanner/annotation-1.0-expected.tgir Mon Jan 12 20:54:11 2009
@@ -247,6 +247,51 @@
</parameter>
</parameters>
</method>
+ <method name="set_data" c:identifier="annotation_object_set_data">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="data" transfer-ownership="none">
+ <array length="2" zero-terminated="1">
+ <type name="uint8"/>
+ </array>
+ </parameter>
+ <parameter name="length" transfer-ownership="none">
+ <type name="size"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="set_data2" c:identifier="annotation_object_set_data2">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="data" transfer-ownership="none">
+ <array length="2" zero-terminated="1">
+ <type name="int8"/>
+ </array>
+ </parameter>
+ <parameter name="length" transfer-ownership="none">
+ <type name="size"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="set_data3" c:identifier="annotation_object_set_data3">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="data" transfer-ownership="none">
+ <array length="2" zero-terminated="1">
+ <type name="uint8"/>
+ </array>
+ </parameter>
+ <parameter name="length" transfer-ownership="none">
+ <type name="size"/>
+ </parameter>
+ </parameters>
+ </method>
<method name="do_not_use" c:identifier="annotation_object_do_not_use" deprecated="1">
<return-value transfer-ownership="full">
<type name="GObject.Object"/>
Modified: trunk/tests/scanner/annotation.c
==============================================================================
--- trunk/tests/scanner/annotation.c (original)
+++ trunk/tests/scanner/annotation.c Mon Jan 12 20:54:11 2009
@@ -324,6 +324,55 @@
}
/**
+ * annotation_object_set_data:
+ * @object: a #AnnotationObject
+ * @data: (array length=length): The data
+ * @length: Length of the data
+ *
+ * Test taking a guchar * with a length.
+ **/
+void
+annotation_object_set_data (AnnotationObject *object,
+ const guchar *data,
+ gsize length)
+{
+
+}
+
+/**
+ * annotation_object_set_data2:
+ * @object: a #AnnotationObject
+ * @data: (array length=length): The data
+ * @length: Length of the data
+ *
+ * Test taking a gchar * with a length.
+ **/
+void
+annotation_object_set_data2 (AnnotationObject *object,
+ const gchar *data,
+ gsize length)
+{
+
+}
+
+/**
+ * annotation_object_set_data3:
+ * @object: a #AnnotationObject
+ * @data: (array length=length) (element-type uint8): The data
+ * @length: Length of the data
+ *
+ * Test taking a gchar * with a length, overriding the array element
+ * type.
+ **/
+void
+annotation_object_set_data3 (AnnotationObject *object,
+ gpointer data,
+ gsize length)
+{
+
+}
+
+/**
* annotation_object_allow_none:
* @object: a #GObject
* @somearg: (allow-none):
Modified: trunk/tests/scanner/annotation.h
==============================================================================
--- trunk/tests/scanner/annotation.h (original)
+++ trunk/tests/scanner/annotation.h Mon Jan 12 20:54:11 2009
@@ -83,6 +83,16 @@
AnnotationForeachFunc func,
gpointer user_data);
+void annotation_object_set_data (AnnotationObject *object,
+ const guchar *data,
+ gsize length);
+void annotation_object_set_data2 (AnnotationObject *object,
+ const gchar *data,
+ gsize length);
+void annotation_object_set_data3 (AnnotationObject *object,
+ gpointer data,
+ gsize length);
+
GObject* annotation_object_do_not_use (AnnotationObject *object);
void annotation_init (int *argc,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]