gobject-introspection r943 - in trunk: . tests/everything



Author: otaylor
Date: Tue Nov 18 12:29:01 2008
New Revision: 943
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=943&view=rev

Log:
Add enums to the Everything test module

* tests/everything/everything.[ch]: Add TestEnum and TestFlags to the Everything
test module and register them as GTypes.

https://bugzilla.gnome.org/show_bug.cgi?id=561296

Modified:
   trunk/ChangeLog
   trunk/tests/everything/everything.c
   trunk/tests/everything/everything.h

Modified: trunk/tests/everything/everything.c
==============================================================================
--- trunk/tests/everything/everything.c	(original)
+++ trunk/tests/everything/everything.c	Tue Nov 18 12:29:01 2008
@@ -390,6 +390,42 @@
 /* ghash? */
 /* error? */
 
+/* enums / flags */
+
+GType
+test_enum_get_type (void)
+{
+    static GType etype = 0;
+    if (G_UNLIKELY(etype == 0)) {
+        static const GEnumValue values[] = {
+            { TEST_VALUE1, "TEST_VALUE1", "value1" },
+            { TEST_VALUE2, "TEST_VALUE2", "value2" },
+            { TEST_VALUE3, "TEST_VALUE3", "value3" },
+            { 0, NULL, NULL }
+        };
+        etype = g_enum_register_static (g_intern_static_string ("TestEnum"), values);
+    }
+
+    return etype;
+}
+
+GType
+test_flags_get_type (void)
+{
+    static GType etype = 0;
+    if (G_UNLIKELY(etype == 0)) {
+        static const GFlagsValue values[] = {
+            { TEST_FLAG1, "TEST_FLAG1", "flag1" },
+            { TEST_FLAG2, "TEST_FLAG2", "flag2" },
+            { TEST_FLAG3, "TEST_FLAG3", "flag2" },
+            { 0, NULL, NULL }
+        };
+        etype = g_flags_register_static (g_intern_static_string ("TestFlags"), values);
+    }
+
+    return etype;
+}
+
 /* structures */
 
 /**

Modified: trunk/tests/everything/everything.h
==============================================================================
--- trunk/tests/everything/everything.h	(original)
+++ trunk/tests/everything/everything.h	Tue Nov 18 12:29:01 2008
@@ -65,6 +65,27 @@
 /* ghash? */
 /* error? */
 
+/* enums / flags */
+
+typedef enum
+{
+  TEST_VALUE1,
+  TEST_VALUE2,
+  TEST_VALUE3 = 42
+} TestEnum;
+
+typedef enum
+{
+  TEST_FLAG1 = 1 << 0,
+  TEST_FLAG2 = 1 << 1,
+  TEST_FLAG3 = 1 << 2,
+} TestFlags;
+
+GType test_enum_get_type (void) G_GNUC_CONST;
+#define TEST_TYPE_ENUM (test_enum_get_type ())
+GType test_flags_get_type (void) G_GNUC_CONST;
+#define TES_TYPE_FLAGS (test_flags_get_type ())
+
 /* structures */
 typedef struct _TestStructA TestStructA;
 typedef struct _TestStructB TestStructB;
@@ -74,6 +95,7 @@
   gint some_int;
   gint8 some_int8;
   gdouble some_double;
+  TestEnum some_enum;
 };
 
 void test_struct_a_clone (TestStructA *a,
@@ -97,6 +119,7 @@
   gint some_int;
   gint8 some_int8;
   gdouble some_double;
+  TestEnum some_enum;
 };
 
 GType             test_simple_boxed_a_get_type (void);



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