test creation of new fundamental types.

Sat Oct 12 22:02:32 2002  Tim Janik  <timj@gtk.org>

        * 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.
This commit is contained in:
Tim Janik 2002-10-12 20:04:58 +00:00 committed by Tim Janik
parent f650a78e8b
commit cab46e354d
3 changed files with 26 additions and 3 deletions

View File

@ -1,3 +1,14 @@
Sat Oct 12 22:02:32 2002 Tim Janik <timj@gtk.org>
* 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 <cinamod@hotmail.com>
* gtype.h: Fix problems with excessive C++ warnings: "ISO C++ forbids nested groups within expressions"

View File

@ -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;
}

View File

@ -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);