From: Tim Janik Date: Sat, 12 Oct 2002 20:04:58 +0000 (+0000) Subject: test creation of new fundamental types. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=cab46e354d4f52852c083ddb3ed20b4b15fd30dc;p=dana%2Fcg-glib.git test creation of new fundamental types. Sat Oct 12 22:02:32 2002 Tim Janik * merged up from 2.0: * testgobject.c: test creation of new fundamental types. * gtype.c (g_type_fundamental_next), (type_node_fundamental_new_W): account for static_fundamental_next storing non-shifted fundamental IDs. this fixes g_type_fundamental_next() not returning a new usable fundamental ID. --- diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 38380b66..9c3e55d0 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,14 @@ +Sat Oct 12 22:02:32 2002 Tim Janik + + * merged up from 2.0: + + * testgobject.c: test creation of new fundamental types. + + * gtype.c (g_type_fundamental_next), (type_node_fundamental_new_W): + account for static_fundamental_next storing non-shifted fundamental + IDs. this fixes g_type_fundamental_next() not returning a new usable + fundamental ID. + Wed Sep 11 16:50:20 2002 Dom Lachowicz * gtype.h: Fix problems with excessive C++ warnings: "ISO C++ forbids nested groups within expressions" diff --git a/gobject/gtype.c b/gobject/gtype.c index 21e73854..f5d341e9 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -383,8 +383,8 @@ type_node_fundamental_new_W (GType ftype, g_assert ((ftype & TYPE_ID_MASK) == 0); g_assert (ftype <= G_TYPE_FUNDAMENTAL_MAX); - if (ftype == static_fundamental_next) - static_fundamental_next += 1 << G_TYPE_FUNDAMENTAL_SHIFT; + if (ftype >> G_TYPE_FUNDAMENTAL_SHIFT == static_fundamental_next) + static_fundamental_next++; type_flags &= TYPE_FUNDAMENTAL_FLAG_MASK; @@ -2581,7 +2581,7 @@ g_type_fundamental_next (void) G_READ_LOCK (&type_rw_lock); type = static_fundamental_next; G_READ_UNLOCK (&type_rw_lock); - + type = G_TYPE_MAKE_FUNDAMENTAL (type); return type <= G_TYPE_FUNDAMENTAL_MAX ? type : 0; } diff --git a/gobject/testgobject.c b/gobject/testgobject.c index fbf5c7c6..479959bf 100644 --- a/gobject/testgobject.c +++ b/gobject/testgobject.c @@ -310,6 +310,9 @@ int main (int argc, char *argv[]) { + GTypeInfo info = { 0, }; + GTypeFundamentalInfo finfo = { 0, }; + GType type; TestObject *sigarg; DerivedObject *dobject; gchar *string = NULL; @@ -319,6 +322,15 @@ main (int argc, G_LOG_LEVEL_CRITICAL); g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS); + /* test new fundamentals */ + g_assert (G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_USER_FIRST) == g_type_fundamental_next ()); + type = g_type_register_fundamental (g_type_fundamental_next (), "FooShadow1", &info, &finfo, 0); + g_assert (G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_USER_FIRST + 1) == g_type_fundamental_next ()); + type = g_type_register_fundamental (g_type_fundamental_next (), "FooShadow2", &info, &finfo, 0); + g_assert (G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_USER_FIRST + 2) == g_type_fundamental_next ()); + g_assert (g_type_from_name ("FooShadow1") == G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_USER_FIRST)); + g_assert (g_type_from_name ("FooShadow2") == G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_USER_FIRST + 1)); + /* to test past class initialization interface setups, create the class here */ g_type_class_ref (TEST_TYPE_OBJECT);