summaryrefslogtreecommitdiff
path: root/gir
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-06-02 19:36:59 +0200
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-06-02 19:36:59 +0200
commitb7804cc7114657f367f6371ddfe9805dad8c67ff (patch)
tree9e7169a9f339ba2fcf0f4530134bae8bbd705dc4 /gir
parent2cdd4e9a3eb7944eb8cfeed17eb50185fc7623d1 (diff)
downloadgobject-introspection-b7804cc7114657f367f6371ddfe9805dad8c67ff.tar.gz
Fix marshalling of GStrv.GOBJECT_INTROSPECTION_0_6_13
* gir/gimarshallingtests.[hc]: Add a test for GStrv in function args and as struct fields. * girepository/giroffsets.c: Correctly compute the size of structs with array fields * girepository/girparser.c: Set is_pointer to FALSE for arrays with fixed size that are inside structs. * giscanner/glibtransformer.py: Special case GStrv as arrays of utf8. * giscanner/annotationparser.py: Make full transfer the default for arrays of char* returned by functions. https://bugzilla.gnome.org/show_bug.cgi?id=620170
Diffstat (limited to 'gir')
-rw-r--r--gir/GIMarshallingTests-1.0-expected.gir56
-rw-r--r--gir/gimarshallingtests.c61
-rw-r--r--gir/gimarshallingtests.h8
3 files changed, 125 insertions, 0 deletions
diff --git a/gir/GIMarshallingTests-1.0-expected.gir b/gir/GIMarshallingTests-1.0-expected.gir
index 743b94df..0ed461ba 100644
--- a/gir/GIMarshallingTests-1.0-expected.gir
+++ b/gir/GIMarshallingTests-1.0-expected.gir
@@ -20,6 +20,11 @@ and/or use gtk-doc annotations. -->
<field name="long_" writable="1">
<type name="long" c:type="glong"/>
</field>
+ <field name="g_strv" writable="1">
+ <array c:type="GStrv">
+ <type name="utf8"/>
+ </array>
+ </field>
<constructor name="new"
c:identifier="g_i_marshalling_tests_boxed_struct_new">
<return-value transfer-ownership="full">
@@ -1830,6 +1835,57 @@ and/or use gtk-doc annotations. -->
</type>
</return-value>
</function>
+ <function name="gstrv_in" c:identifier="g_i_marshalling_tests_gstrv_in">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="g_strv" transfer-ownership="none">
+ <array c:type="GStrv">
+ <type name="utf8"/>
+ </array>
+ </parameter>
+ </parameters>
+ </function>
+ <function name="gstrv_inout"
+ c:identifier="g_i_marshalling_tests_gstrv_inout">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="g_strv"
+ direction="inout"
+ caller-allocates="0"
+ transfer-ownership="none">
+ <array c:type="GStrv*">
+ <type name="utf8"/>
+ </array>
+ </parameter>
+ </parameters>
+ </function>
+ <function name="gstrv_out" c:identifier="g_i_marshalling_tests_gstrv_out">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="g_strv"
+ direction="out"
+ caller-allocates="1"
+ transfer-ownership="none">
+ <array c:type="GStrv*">
+ <type name="utf8"/>
+ </array>
+ </parameter>
+ </parameters>
+ </function>
+ <function name="gstrv_return"
+ c:identifier="g_i_marshalling_tests_gstrv_return">
+ <return-value transfer-ownership="full">
+ <array c:type="GStrv">
+ <type name="utf8"/>
+ </array>
+ </return-value>
+ </function>
<function name="gtype_in" c:identifier="g_i_marshalling_tests_gtype_in">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
diff --git a/gir/gimarshallingtests.c b/gir/gimarshallingtests.c
index 0888197d..ee6d91f3 100644
--- a/gir/gimarshallingtests.c
+++ b/gir/gimarshallingtests.c
@@ -1581,6 +1581,62 @@ g_i_marshalling_tests_garray_utf8_full_inout (GArray **array_)
}
/**
+ * g_i_marshalling_tests_gstrv_return:
+ * Returns:
+ */
+GStrv
+g_i_marshalling_tests_gstrv_return (void)
+{
+ GStrv values = g_new0 (gchar*, 4);
+ values[0] = g_strdup ("0");
+ values[1] = g_strdup ("1");
+ values[2] = g_strdup ("2");
+ values[3] = NULL;
+ return values;
+}
+
+/**
+ * g_i_marshalling_tests_gstrv_in:
+ * @g_strv:
+ */
+void
+g_i_marshalling_tests_gstrv_in (GStrv g_strv)
+{
+ g_assert(g_strv_length(g_strv) == 3);
+ g_assert(strcmp(g_strv[0], "0") == 0);
+ g_assert(strcmp(g_strv[1], "1") == 0);
+ g_assert(strcmp(g_strv[2], "2") == 0);
+}
+
+/**
+ * g_i_marshalling_tests_gstrv_out:
+ * @g_strv: (out) (transfer none):
+ */
+void
+g_i_marshalling_tests_gstrv_out (GStrv *g_strv)
+{
+ static gchar *values[] = {"0", "1", "2", NULL};
+ *g_strv = values;
+}
+
+/**
+ * g_i_marshalling_tests_gstrv_inout:
+ * @g_strv: (inout) (transfer none):
+ */
+void
+g_i_marshalling_tests_gstrv_inout (GStrv *g_strv)
+{
+ static gchar *values[] = {"-1", "0", "1", "2", NULL};
+
+ g_assert(g_strv_length(*g_strv) == 3);
+ g_assert(strcmp((*g_strv)[0], "0") == 0);
+ g_assert(strcmp((*g_strv)[1], "1") == 0);
+ g_assert(strcmp((*g_strv)[2], "2") == 0);
+
+ *g_strv = values;
+}
+
+/**
* g_i_marshalling_tests_glist_int_none_return:
* Returns: (element-type gint) (transfer none):
*/
@@ -2735,6 +2791,11 @@ g_i_marshalling_tests__boxed_struct_return (void)
struct_ = g_new(GIMarshallingTestsBoxedStruct, 1);
struct_->long_ = 42;
+ struct_->g_strv = g_new0(gchar*, 4);
+ struct_->g_strv[0] = g_strdup("0");
+ struct_->g_strv[1] = g_strdup("1");
+ struct_->g_strv[2] = g_strdup("2");
+ struct_->g_strv[3] = NULL;
}
return struct_;
diff --git a/gir/gimarshallingtests.h b/gir/gimarshallingtests.h
index deb33e50..1ad5dd7e 100644
--- a/gir/gimarshallingtests.h
+++ b/gir/gimarshallingtests.h
@@ -316,6 +316,13 @@ void g_i_marshalling_tests_garray_utf8_none_inout (GArray **array_);
void g_i_marshalling_tests_garray_utf8_container_inout (GArray **array_);
void g_i_marshalling_tests_garray_utf8_full_inout (GArray **array_);
+/* GStrv */
+
+GStrv g_i_marshalling_tests_gstrv_return (void);
+void g_i_marshalling_tests_gstrv_in (GStrv g_strv);
+void g_i_marshalling_tests_gstrv_out (GStrv *g_strv);
+void g_i_marshalling_tests_gstrv_inout (GStrv *g_strv);
+
/* GList */
GList *g_i_marshalling_tests_glist_int_none_return (void);
@@ -505,6 +512,7 @@ void g_i_marshalling_tests__pointer_struct_inout (GIMarshallingTestsPointerStruc
typedef struct {
glong long_;
+ GStrv g_strv;
} GIMarshallingTestsBoxedStruct;
GType g_i_marshalling_tests_boxed_struct_get_type (void) G_GNUC_CONST;