mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 23:58:54 +02:00
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:
@@ -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>
|
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"
|
* gtype.h: Fix problems with excessive C++ warnings: "ISO C++ forbids nested groups within expressions"
|
||||||
|
@@ -383,8 +383,8 @@ type_node_fundamental_new_W (GType ftype,
|
|||||||
g_assert ((ftype & TYPE_ID_MASK) == 0);
|
g_assert ((ftype & TYPE_ID_MASK) == 0);
|
||||||
g_assert (ftype <= G_TYPE_FUNDAMENTAL_MAX);
|
g_assert (ftype <= G_TYPE_FUNDAMENTAL_MAX);
|
||||||
|
|
||||||
if (ftype == static_fundamental_next)
|
if (ftype >> G_TYPE_FUNDAMENTAL_SHIFT == static_fundamental_next)
|
||||||
static_fundamental_next += 1 << G_TYPE_FUNDAMENTAL_SHIFT;
|
static_fundamental_next++;
|
||||||
|
|
||||||
type_flags &= TYPE_FUNDAMENTAL_FLAG_MASK;
|
type_flags &= TYPE_FUNDAMENTAL_FLAG_MASK;
|
||||||
|
|
||||||
@@ -2581,7 +2581,7 @@ g_type_fundamental_next (void)
|
|||||||
G_READ_LOCK (&type_rw_lock);
|
G_READ_LOCK (&type_rw_lock);
|
||||||
type = static_fundamental_next;
|
type = static_fundamental_next;
|
||||||
G_READ_UNLOCK (&type_rw_lock);
|
G_READ_UNLOCK (&type_rw_lock);
|
||||||
|
type = G_TYPE_MAKE_FUNDAMENTAL (type);
|
||||||
return type <= G_TYPE_FUNDAMENTAL_MAX ? type : 0;
|
return type <= G_TYPE_FUNDAMENTAL_MAX ? type : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -310,6 +310,9 @@ int
|
|||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
|
GTypeInfo info = { 0, };
|
||||||
|
GTypeFundamentalInfo finfo = { 0, };
|
||||||
|
GType type;
|
||||||
TestObject *sigarg;
|
TestObject *sigarg;
|
||||||
DerivedObject *dobject;
|
DerivedObject *dobject;
|
||||||
gchar *string = NULL;
|
gchar *string = NULL;
|
||||||
@@ -319,6 +322,15 @@ main (int argc,
|
|||||||
G_LOG_LEVEL_CRITICAL);
|
G_LOG_LEVEL_CRITICAL);
|
||||||
g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS);
|
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 */
|
/* to test past class initialization interface setups, create the class here */
|
||||||
g_type_class_ref (TEST_TYPE_OBJECT);
|
g_type_class_ref (TEST_TYPE_OBJECT);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user