[gobject-introspection/wip/transformer: 8/17] tests/scanner: Update annotations and tests



commit 226826b16a0e00586fefce3e3aebefdf12d418b7
Author: Colin Walters <walters verbum org>
Date:   Thu Aug 19 09:31:47 2010 -0400

    tests/scanner: Update annotations and tests
    
    First of all, add missing (transfer) annotations that will be
    required by the new scanner.
    
    Other changes:
    Don't use the (type bitfield) hack; the new scanner will not accept it.
    Use shifts in the flag constants instead.
    
    Use typedefs consistently for structures.
    
    Drop scanning of anonymous structure/union members.

 tests/scanner/Annotation-1.0-expected.gir  |    6 ++-
 tests/scanner/Foo-1.0-expected.gir         |   14 ++++--
 tests/scanner/Regress-1.0-expected.gir     |    4 +-
 tests/scanner/TestInherit-1.0-expected.gir |    2 +-
 tests/scanner/Utility-1.0-expected.gir     |    6 +-
 tests/scanner/annotation.c                 |   26 +++++++----
 tests/scanner/drawable.c                   |   12 +++++
 tests/scanner/drawable.h                   |    2 +
 tests/scanner/foo.c                        |   63 +++++++++++++++++++++++++++-
 tests/scanner/foo.h                        |   12 ++++--
 tests/scanner/regress.c                    |    7 +--
 tests/scanner/regress.h                    |    5 ++
 tests/scanner/utility.c                    |   13 ++++--
 tests/scanner/utility.h                    |   11 +++--
 14 files changed, 141 insertions(+), 42 deletions(-)
---
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index 39c9b1d..1d73c25 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -82,7 +82,8 @@ and/or use gtk-doc annotations.  -->
       <attribute name="org.example.Test" value="cows"/>
       <doc xml:whitespace="preserve">This is an object used to test annotations.</doc>
       <method name="allow_none" c:identifier="annotation_object_allow_none">
-        <return-value transfer-ownership="full">
+        <return-value transfer-ownership="none">
+          <doc xml:whitespace="preserve">%NULL always</doc>
           <type name="GObject.Object" c:type="GObject*"/>
         </return-value>
         <parameters>
@@ -194,7 +195,8 @@ and/or use gtk-doc annotations.  -->
               c:identifier="annotation_object_do_not_use"
               deprecated="Use annotation_object_create_object() instead."
               deprecated-version="0.12">
-        <return-value transfer-ownership="full">
+        <return-value transfer-ownership="none">
+          <doc xml:whitespace="preserve">%NULL always</doc>
           <type name="GObject.Object" c:type="GObject*"/>
         </return-value>
       </method>
diff --git a/tests/scanner/Foo-1.0-expected.gir b/tests/scanner/Foo-1.0-expected.gir
index c2dd730..003485b 100644
--- a/tests/scanner/Foo-1.0-expected.gir
+++ b/tests/scanner/Foo-1.0-expected.gir
@@ -312,7 +312,7 @@ and/or use gtk-doc annotations.  -->
       <function name="get_default" c:identifier="foo_object_get_default">
         <doc xml:whitespace="preserve">This function is intended to match clutter_stage_get_default which
 uses a C sugar return type.</doc>
-        <return-value transfer-ownership="full">
+        <return-value transfer-ownership="none">
           <doc xml:whitespace="preserve">The global #FooSubobject</doc>
           <type name="Subobject" c:type="FooObject*"/>
         </return-value>
@@ -354,7 +354,8 @@ uses a C sugar return type.</doc>
         </return-value>
       </method>
       <method name="external_type" c:identifier="foo_object_external_type">
-        <return-value transfer-ownership="full">
+        <return-value transfer-ownership="none">
+          <doc xml:whitespace="preserve">%NULL always</doc>
           <type name="Utility.Object" c:type="UtilityObject*"/>
         </return-value>
       </method>
@@ -383,7 +384,10 @@ uses a C sugar return type.</doc>
           </parameter>
         </parameters>
       </method>
-      <method name="new_cookie" c:identifier="foo_object_new_cookie">
+      <method name="new_cookie"
+              c:identifier="foo_object_new_cookie"
+              introspectable="0">
+        <doc xml:whitespace="preserve">Not sure why this test is here...</doc>
         <return-value transfer-ownership="full">
           <type name="ObjectCookie" c:type="FooObjectCookie"/>
         </return-value>
@@ -687,7 +691,7 @@ exposed to language bindings.</doc>
         <type name="ObjectClass" c:type="FooObjectClass"/>
       </field>
     </record>
-    <record name="ThingWithArray" c:type="_FooThingWithArray">
+    <record name="ThingWithArray" c:type="FooThingWithArray">
       <field name="x" writable="1">
         <type name="gint" c:type="int"/>
       </field>
@@ -703,7 +707,7 @@ exposed to language bindings.</doc>
         <type name="gpointer" c:type="guchar*"/>
       </field>
     </record>
-    <union name="Union" c:type="_FooUnion">
+    <union name="Union" c:type="FooUnion">
       <field name="foo" writable="1">
         <type name="gint" c:type="int"/>
       </field>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index aeae8a6..e909a2f 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -1986,7 +1986,6 @@ call and can be released on return.</doc>
       </return-value>
     </function>
     <function name="test_strv_out" c:identifier="regress_test_strv_out">
-      <doc xml:whitespace="preserve">No annotations here.  We want the default to Do The Right Thing.</doc>
       <return-value transfer-ownership="full">
         <array c:type="char**">
           <type name="utf8"/>
@@ -1994,8 +1993,7 @@ call and can be released on return.</doc>
       </return-value>
     </function>
     <function name="test_strv_out_c" c:identifier="regress_test_strv_out_c">
-      <doc xml:whitespace="preserve">No annotations here.  We want the default to Do The Right Thing.</doc>
-      <return-value transfer-ownership="full">
+      <return-value transfer-ownership="none">
         <array c:type="char**">
           <type name="utf8"/>
         </array>
diff --git a/tests/scanner/TestInherit-1.0-expected.gir b/tests/scanner/TestInherit-1.0-expected.gir
index 1d8a262..4ed155e 100644
--- a/tests/scanner/TestInherit-1.0-expected.gir
+++ b/tests/scanner/TestInherit-1.0-expected.gir
@@ -93,7 +93,7 @@ and/or use gtk-doc annotations.  -->
         <type name="GObject.ObjectClass" c:type="GObjectClass"/>
       </field>
     </record>
-    <record name="PixmapObjectClass" c:type="_TestInheritPixmapObjectClass">
+    <record name="PixmapObjectClass" c:type="TestInheritPixmapObjectClass">
       <field name="parent_class" writable="1">
         <type name="DrawableClass" c:type="TestInheritDrawableClass"/>
       </field>
diff --git a/tests/scanner/Utility-1.0-expected.gir b/tests/scanner/Utility-1.0-expected.gir
index 7fbbed4..f4c6909 100644
--- a/tests/scanner/Utility-1.0-expected.gir
+++ b/tests/scanner/Utility-1.0-expected.gir
@@ -18,7 +18,7 @@ and/or use gtk-doc annotations.  -->
     </alias>
     <record name="Buffer" c:type="UtilityBuffer">
       <field name="data" writable="1">
-        <type name="GLib.pointer" c:type="char*"/>
+        <type name="gpointer" c:type="char*"/>
       </field>
       <field name="length" writable="1">
         <type name="gulong" c:type="gsize"/>
@@ -28,7 +28,7 @@ and/or use gtk-doc annotations.  -->
       <field name="value" writable="1">
         <type name="guint8" c:type="guint8"/>
       </field>
-      <record>
+      <record name="parts" c:type="parts">
         <field name="first_nibble" writable="1" bits="4">
           <type name="guint8" c:type="guint8"/>
         </field>
@@ -120,7 +120,7 @@ and/or use gtk-doc annotations.  -->
       <field name="tag" writable="1">
         <type name="gint" c:type="int"/>
       </field>
-      <union>
+      <union name="value" c:type="value">
         <field name="v_pointer" writable="1">
           <type name="gpointer" c:type="gpointer"/>
         </field>
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index 015fd83..40df086 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -89,7 +89,7 @@ annotation_object_class_init (AnnotationObjectClass *klass)
   /**
    * AnnotationObject::list-signal:
    * @annotation: the annotation object
-   * @list: (type GLib.List): (element-type utf8): (transfer container): a list of strings
+   * @list: (type GLib.List) (element-type utf8): (transfer container): a list of strings
    *
    * This is a signal which takes a list of strings, but it's not
    * known by GObject as it's only marked as G_TYPE_POINTER
@@ -310,7 +310,7 @@ annotation_object_calleesowns (AnnotationObject *object,
  * This is a test for returning a list of strings, where
  * each string needs to be freed.
  *
- * Return value: (element-type utf8) (transfer): list of strings
+ * Return value: (element-type utf8) (transfer full): list of strings
  */
 GList*
 annotation_object_get_strings (AnnotationObject *object)
@@ -328,7 +328,7 @@ annotation_object_get_strings (AnnotationObject *object)
  * This is a test for returning a hash table mapping strings to
  * objects.
  *
- * Return value: (element-type utf8 GObject): hash table
+ * Return value: (element-type utf8 GObject) (transfer full): hash table
  */
 GHashTable*
 annotation_object_get_hash (AnnotationObject *object)
@@ -374,7 +374,7 @@ annotation_object_get_objects (AnnotationObject *object)
  *
  * Test returning a caller-owned object
  *
- * Return value: (transfer): The object
+ * Return value: (transfer full): The object
  **/
 GObject*
 annotation_object_create_object (AnnotationObject *object)
@@ -382,6 +382,11 @@ annotation_object_create_object (AnnotationObject *object)
 	return g_object_ref (object);
 }
 
+/**
+ * annotation_object_use_buffer:
+ * @object: a #GObject
+ *
+ **/
 void
 annotation_object_use_buffer   (AnnotationObject *object,
 				guchar           *bytes)
@@ -504,7 +509,7 @@ annotation_object_set_data (AnnotationObject *object,
 /**
  * annotation_object_set_data2:
  * @object: a #AnnotationObject
- * @data: (array length=length): The data
+ * @data: (array length=length) (element-type gint8): The data
  * @length: Length of the data
  *
  * Test taking a gchar * with a length.
@@ -538,6 +543,8 @@ annotation_object_set_data3 (AnnotationObject *object,
  * annotation_object_allow_none:
  * @object: a #GObject
  * @somearg: (allow-none):
+ *
+ * Returns: (transfer none): %NULL always
  **/
 GObject*
 annotation_object_allow_none (AnnotationObject *object, const gchar *somearg)
@@ -562,6 +569,7 @@ annotation_object_notrans (AnnotationObject *object)
  * annotation_object_do_not_use:
  * @object: a #GObject
  *
+ * Returns: (transfer none): %NULL always
  * Deprecated: 0.12: Use annotation_object_create_object() instead.
  **/
 GObject*
@@ -571,7 +579,7 @@ annotation_object_do_not_use (AnnotationObject *object)
 }
 
 /**
- * annotation_object_watch:
+ * annotation_object_watch: (skip)
  * @object: A #AnnotationObject
  * @func: The callback
  * @user_data: The callback data
@@ -620,7 +628,7 @@ annotation_init (int *argc, char ***argv)
  * annotation_return_array:
  * @length: (out): Number of return values
  *
- * Return value: (array length=length): The return value
+ * Return value: (transfer full) (array length=length): The return value
  **/
 char **
 annotation_return_array (int *length)
@@ -631,7 +639,7 @@ annotation_return_array (int *length)
 /**
  * annotation_string_zero_terminated:
  *
- * Return value: (array zero-terminated=1): The return value
+ * Return value: (transfer full) (array zero-terminated=1): The return value
  **/
 char **
 annotation_string_zero_terminated (void)
@@ -696,7 +704,7 @@ annotation_custom_destroy (AnnotationCallback callback,
 /**
  * annotation_get_source_file:
  *
- * Return value: (type filename): Source file
+ * Return value: (type filename) (transfer full): Source file
  */
 char *
 annotation_get_source_file (void)
diff --git a/tests/scanner/drawable.c b/tests/scanner/drawable.c
index 0250fc0..0345b03 100644
--- a/tests/scanner/drawable.c
+++ b/tests/scanner/drawable.c
@@ -20,6 +20,12 @@ test_inherit_drawable_do_foo (TestInheritDrawable *drawable, int x)
   
 }
 
+/**
+ * test_inherit_drawable_get_origin:
+ * @drawable:
+ * @x: (out):
+ * @y: (out):
+ */
 void
 test_inherit_drawable_get_origin (TestInheritDrawable *drawable, int *x, int *y)
 {
@@ -27,6 +33,12 @@ test_inherit_drawable_get_origin (TestInheritDrawable *drawable, int *x, int *y)
   *y = 0;
 }
 
+/**
+ * test_inherit_drawable_get_size:
+ * @drawable:
+ * @width: (out):
+ * @height: (out):
+ */
 void
 test_inherit_drawable_get_size (TestInheritDrawable *drawable, guint *width, guint *height)
 {
diff --git a/tests/scanner/drawable.h b/tests/scanner/drawable.h
index ccc2a0e..d1752e4 100644
--- a/tests/scanner/drawable.h
+++ b/tests/scanner/drawable.h
@@ -23,6 +23,8 @@ void test_inherit_drawable_get_origin (TestInheritDrawable *drawable, int *x, in
 void test_inherit_drawable_get_size (TestInheritDrawable *drawable, guint *width, guint *height);
 void test_inherit_drawable_do_foo_maybe_throw (TestInheritDrawable *drawable, int x, GError **error);
 
+typedef struct _TestInheritPixmapObjectClass TestInheritPixmapObjectClass;
+
 struct _TestInheritPixmapObjectClass
 {
   TestInheritDrawableClass parent_class;
diff --git a/tests/scanner/foo.c b/tests/scanner/foo.c
index 6239bfa..d66817f 100644
--- a/tests/scanner/foo.c
+++ b/tests/scanner/foo.c
@@ -203,6 +203,12 @@ foo_object_init (FooObject *object)
 
 }
 
+/**
+ * foo_object_external_type:
+ * @object: a #FooObject
+ * 
+ * Returns: (transfer none): %NULL always
+ */
 UtilityObject*
 foo_object_external_type (FooObject *object)
 {
@@ -227,6 +233,19 @@ foo_object_is_it_time_yet (FooObject *object, time_t time)
 {
 }
 
+/**
+ * foo_object_new_cookie: (skip)
+ * @object:
+ * @target:
+ *
+ * Not sure why this test is here...
+ */
+FooObjectCookie
+foo_object_new_cookie (FooObject *object, const char *target)
+{
+  return NULL;
+}
+
 const char *
 foo_object_get_name (FooObject *object)
 {
@@ -286,7 +305,7 @@ foo_subobject_init (FooSubobject *object)
  * This function is intended to match clutter_stage_get_default which
  * uses a C sugar return type.
  *
- * Return value: (type FooSubobject): The global #FooSubobject
+ * Return value: (type FooSubobject) (transfer none): The global #FooSubobject
  */
 FooObject *
 foo_object_get_default ()
@@ -449,12 +468,25 @@ void foo_test_unsigned (unsigned int uint)
 {
 }
 
+/**
+ * foo_test_string_array:
+ * @array: (array zero-terminated=1):
+ */
 void
 foo_test_string_array (char **array)
 {
 }
 
 /**
+ * foo_test_string_array_with_g:
+ * @array: (array zero-terminated=1):
+ */
+void
+foo_test_string_array_with_g (gchar **array)
+{
+}
+
+/**
  * foo_test_array:
  * Returns: (element-type utf8) (transfer container):
  */
@@ -626,3 +658,32 @@ foo_skip_me (FooSkippable fs)
  * FooForeignStruct: (foreign)
  *
  */
+
+/**
+ * foo_test_varargs_callback: (skip)
+ *
+ */
+void
+foo_test_varargs_callback (gint i, FooVarargsCallback callback)
+{
+}
+
+/**
+ * foo_test_varargs_callback2: (skip)
+ *
+ */
+void
+foo_test_varargs_callback2 (FooVarargsCallback callback)
+{
+}
+
+/**
+ * foo_test_varargs_callback3: (skip)
+ *
+ */
+void
+foo_test_varargs_callback3 (FooVarargsCallback callback,
+			    FooVarargsCallback callback2)
+{
+}
+
diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h
index 7120d01..f31a79e 100644
--- a/tests/scanner/foo.h
+++ b/tests/scanner/foo.h
@@ -298,23 +298,27 @@ union _FooBUnion
   FooBRect *rect;
 };
 
-typedef union _FooUnion
+typedef union _FooUnion FooUnion;
+
+union _FooUnion
 {
   int foo;
-} FooUnion;
+};
 
 typedef struct _FooUtilityStruct FooUtilityStruct;
 struct _FooUtilityStruct
 {
   UtilityStruct bar;
 };
-typedef struct _FooThingWithArray
+
+typedef struct _FooThingWithArray FooThingWithArray;
+struct _FooThingWithArray
 {
   int x;
   int y;
   char lines[80];
   guchar *data;
-} FooThingWithArray;
+} ;
 
 FooBUnion *foo_bunion_new (void);
 
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index e4326fb..2f3b827 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -629,7 +629,8 @@ regress_test_strv_in_container (char **arr)
  * regress_test_array_gtype_in:
  * @n_types:
  * @types: (array length=n_types): List of types
- * Return value: string representation of provided types
+ *
+ * Return value: (transfer full): string representation of provided types
  * */
 char *
 regress_test_array_gtype_in (int n_types, GType *types)
@@ -650,8 +651,6 @@ regress_test_array_gtype_in (int n_types, GType *types)
 /**
  * regress_test_strv_out:
  *
- * No annotations here.  We want the default to Do The Right Thing.
- *
  * Returns: (transfer full):
  */
 char **
@@ -761,7 +760,7 @@ regress_test_array_int_in_take (int n_ints, int *ints)
 /**
  * regress_test_strv_out_c:
  *
- * No annotations here.  We want the default to Do The Right Thing.
+ * Returns: (transfer none):
  */
 const char * const*
 regress_test_strv_out_c (void)
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 5911712..6dafd9c 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -349,6 +349,11 @@ int         regress_test_sub_obj_instance_method (RegressTestSubObj *obj);
 
 typedef struct _RegressTestFundamentalObject RegressTestFundamentalObject;
 typedef struct _RegressTestFundamentalObjectClass RegressTestFundamentalObjectClass;
+/**
+ * RegressTestFundamentalObjectCopyFunction:
+ *
+ * Returns: (transfer full):
+ */
 typedef RegressTestFundamentalObject * (*RegressTestFundamentalObjectCopyFunction) (const RegressTestFundamentalObject *obj);
 typedef void (*RegressTestFundamentalObjectFinalizeFunction) (RegressTestFundamentalObject *obj);
 
diff --git a/tests/scanner/utility.c b/tests/scanner/utility.c
index 5ae5ed3..97afa43 100644
--- a/tests/scanner/utility.c
+++ b/tests/scanner/utility.c
@@ -3,13 +3,9 @@
 G_DEFINE_TYPE (UtilityObject, utility_object, G_TYPE_OBJECT);
 
 /**
- * UtilityFlagType: (type bitfield)
- **/
-
-/**
  * UtilityBuffer:
  *
- * @data: (type pointer): the data
+ * @data: (type gpointer): the data
  **/
 
 static void
@@ -34,6 +30,13 @@ utility_object_watch_dir (UtilityObject *object,
 
 }
 
+/**
+ * utility_dir_foreach:
+ * @path::
+ * @func: (scope call):
+ * @user_data::
+ *
+ */
 void
 utility_dir_foreach (const char *path, UtilityFileFunc func, gpointer user_data)
 {
diff --git a/tests/scanner/utility.h b/tests/scanner/utility.h
index a3eb3ef..8dc6d54 100644
--- a/tests/scanner/utility.h
+++ b/tests/scanner/utility.h
@@ -31,7 +31,7 @@ typedef struct
     gpointer v_pointer;
     double v_real;
     long v_integer;
-  };
+  } value;
 } UtilityTaggedValue;
 
 typedef union
@@ -41,7 +41,7 @@ typedef union
   {
     guint8 first_nibble : 4;
     guint8 second_nibble : 4;
-  };
+  } parts;
 } UtilityByte;
 
 /* This one is similiar to Soup.Buffer */
@@ -67,11 +67,12 @@ typedef enum
   UTILITY_ENUM_C
 } UtilityEnumType;
 
+/* The shift operators here should imply bitfield */ 
 typedef enum
 {
-  UTILITY_FLAG_A = 1,
-  UTILITY_FLAG_B = 2,
-  UTILITY_FLAG_C = 4
+  UTILITY_FLAG_A = 1 << 0,
+  UTILITY_FLAG_B = 1 << 1,
+  UTILITY_FLAG_C = 1 << 2
 } UtilityFlagType;
 
 typedef struct



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