diff options
author | Owen Taylor <otaylor@src.gnome.org> | 2008-11-18 12:29:01 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2008-11-18 12:29:01 +0000 |
commit | 6cea68fc58343509c7012ef7b5fec86a115e6fb4 (patch) | |
tree | ee92b375de98fc018c7f52b5f7e357fd768374d7 | |
parent | 5ab26345e9d6552c96dc4c5612bc441cbced2a17 (diff) | |
download | gobject-introspection-6cea68fc58343509c7012ef7b5fec86a115e6fb4.tar.gz |
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
svn path=/trunk/; revision=943
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | tests/everything/everything.c | 36 | ||||
-rw-r--r-- | tests/everything/everything.h | 23 |
3 files changed, 68 insertions, 0 deletions
@@ -1,3 +1,12 @@ +2008-11-18 Owen Taylor <otaylor@redhat.com> + + 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 + 2008-11-18 Johan Dahlin <jdahlin@async.com.br> * giscanner/cachestore.py: diff --git a/tests/everything/everything.c b/tests/everything/everything.c index 32e8e82d..6e90d7c9 100644 --- a/tests/everything/everything.c +++ b/tests/everything/everything.c @@ -390,6 +390,42 @@ void test_gslist_everything_in (GSList *in) /* 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 */ /** diff --git a/tests/everything/everything.h b/tests/everything/everything.h index e855dfb5..a09132c0 100644 --- a/tests/everything/everything.h +++ b/tests/everything/everything.h @@ -65,6 +65,27 @@ void test_gslist_free (GSList *in); /* 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 @@ struct _TestStructA gint some_int; gint8 some_int8; gdouble some_double; + TestEnum some_enum; }; void test_struct_a_clone (TestStructA *a, @@ -97,6 +119,7 @@ struct _TestSimpleBoxedA gint some_int; gint8 some_int8; gdouble some_double; + TestEnum some_enum; }; GType test_simple_boxed_a_get_type (void); |