diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2010-09-14 11:59:03 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2010-11-01 17:25:45 -0400 |
commit | 8916db0a3831cb5e6c3b714125f7596f43d6aa6a (patch) | |
tree | c4d523a925a666be85bfdaea804407ca782778f7 /tests/scanner/regress.c | |
parent | 29ec4294d9232dcfd7cfec4e20c0e302a5ff3e80 (diff) | |
download | gobject-introspection-8916db0a3831cb5e6c3b714125f7596f43d6aa6a.tar.gz |
Handle enumerations with the full range of signed and unsigned values
The C compiler will pick an enumeration type that accomodates the specified
values for the enumeration, so ignoring 64-bit enumerations, we can
have enumeration values from MININT32 to MAXUINT32. To handle this properly:
- Use gint64 for holding eumeration values when scanning
- Add a 'unsigned_value' bit to ValueBlob so we can distinguish the
int32 vs. uint32 cases in the typelib
- Change the return value of g_value_info_get_value() to gint64.
https://bugzilla.gnome.org/show_bug.cgi?id=629704
Diffstat (limited to 'tests/scanner/regress.c')
-rw-r--r-- | tests/scanner/regress.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index b83ed981..40562f55 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1238,6 +1238,22 @@ regress_test_enum_get_type (void) } GType +regress_test_enum_unsigned_get_type (void) +{ + static GType etype = 0; + if (G_UNLIKELY(etype == 0)) { + static const GEnumValue values[] = { + { REGRESS_TEST_UNSIGNED_VALUE1, "REGRESS_TEST_UNSIGNED_VALUE1", "value1" }, + { REGRESS_TEST_UNSIGNED_VALUE2, "REGRESS_TEST_UNSIGNED_VALUE2", "value2" }, + { 0, NULL, NULL } + }; + etype = g_enum_register_static (g_intern_static_string ("RegressTestEnumUnsigned"), values); + } + + return etype; +} + +GType regress_test_flags_get_type (void) { static GType etype = 0; @@ -1267,6 +1283,19 @@ regress_test_enum_param(RegressTestEnum e) return ev->value_nick; } +const gchar * +regress_test_unsigned_enum_param(RegressTestEnumUnsigned e) +{ + GEnumValue *ev; + GEnumClass *ec; + + ec = g_type_class_ref (regress_test_enum_unsigned_get_type ()); + ev = g_enum_get_value (ec, e); + g_type_class_unref (ec); + + return ev->value_nick; +} + /* structures */ /** |