Add a function to test arrays as inout argument in Everything
authorSimon van der Linden <svdlinden@src.gnome.org>
Sun, 5 Jul 2009 16:12:45 +0000 (18:12 +0200)
committerColin Walters <walters@verbum.org>
Mon, 6 Jul 2009 16:13:46 +0000 (12:13 -0400)
Add test_array_int_inout in Everything.

gir/Everything-1.0-expected.gir
gir/everything.c
gir/everything.h

index 35aa770..4dbc0f2 100644 (file)
@@ -583,6 +583,27 @@ case.">
         </parameter>
       </parameters>
     </function>
+    <function name="test_array_int_inout" c:identifier="test_array_int_inout">
+      <return-value transfer-ownership="none">
+        <type name="none" c:type="void"/>
+      </return-value>
+      <parameters>
+        <parameter name="n_ints"
+                   direction="inout"
+                   transfer-ownership="full"
+                   doc="the length of @ints">
+          <type name="int" c:type="int*"/>
+        </parameter>
+        <parameter name="ints"
+                   direction="inout"
+                   transfer-ownership="full"
+                   doc="a list of integers whose items will be increased by 1, except the first that will be dropped">
+          <array length="0" c:type="int**">
+            <type name="int"/>
+          </array>
+        </parameter>
+      </parameters>
+    </function>
     <function name="test_array_int_none_out"
               c:identifier="test_array_int_none_out">
       <return-value transfer-ownership="none"
index 2eedeef..a1c92e4 100644 (file)
@@ -321,6 +321,26 @@ test_array_int_out (int *n_ints, int **ints)
     (*ints)[i] = (*ints)[i-1] + 1;
 }
 
+/**
+ * test_array_int_inout:
+ * @n_ints: (inout): the length of @ints
+ * @ints: (inout) (array length=n_ints) (transfer full): a list of integers whose items will be increased by 1, except the first that will be dropped
+ */
+void
+test_array_int_inout (int *n_ints, int **ints)
+{
+  int i;
+
+  for (i = 1; i < *n_ints; i++) {
+       (*ints)[i-1] = (*ints)[i] + 1;
+  }
+
+  if (0 < *n_ints) {
+    *n_ints -= 1;
+  }
+  *ints = g_realloc(*ints, sizeof(**ints) * *n_ints);
+}
+
 /**
  * test_array_gint8_in:
  * @n_ints:
index d566f5f..436c74c 100644 (file)
@@ -45,6 +45,7 @@ char *test_utf8_out_nonconst_return (char **out);
 gboolean test_strv_in (char **arr);
 int test_array_int_in (int n_ints, int *ints);
 void test_array_int_out (int *n_ints, int **ints);
+void test_array_int_inout (int *n_ints, int **ints);
 int test_array_gint8_in (int n_ints, gint8 *ints);
 int test_array_gint16_in (int n_ints, gint16 *ints);
 gint32 test_array_gint32_in (int n_ints, gint32 *ints);