mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
Revert "gtype: disallow adding interfaces after the fact"
This reverts commit d6a075b0d8
.
This commit is contained in:
parent
f0f6c8d231
commit
d1ab41c940
@ -1002,12 +1002,6 @@ check_add_interface_L (GType instance_type,
|
|||||||
NODE_NAME (node));
|
NODE_NAME (node));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (node->data && node->data->class.class)
|
|
||||||
{
|
|
||||||
g_warning ("attempting to add an interface (%s) to class (%s) after class_init",
|
|
||||||
NODE_NAME (iface), NODE_NAME (node));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
tnode = lookup_type_node_I (NODE_PARENT_TYPE (iface));
|
tnode = lookup_type_node_I (NODE_PARENT_TYPE (iface));
|
||||||
if (NODE_PARENT_TYPE (tnode) && !type_lookup_iface_entry_L (node, tnode))
|
if (NODE_PARENT_TYPE (tnode) && !type_lookup_iface_entry_L (node, tnode))
|
||||||
{
|
{
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
static volatile int mtsafe_call_counter = 0; /* multi thread safe call counter */
|
static volatile int mtsafe_call_counter = 0; /* multi thread safe call counter */
|
||||||
static int unsafe_call_counter = 0; /* single-threaded call counter */
|
static int unsafe_call_counter = 0; /* single-threaded call counter */
|
||||||
static GCond sync_cond;
|
|
||||||
static GMutex sync_mutex;
|
|
||||||
|
|
||||||
#define NUM_COUNTER_INCREMENTS 100000
|
#define NUM_COUNTER_INCREMENTS 100000
|
||||||
|
|
||||||
@ -54,6 +52,10 @@ typedef GTypeInterface MyFace1Interface;
|
|||||||
static GType my_face1_get_type (void);
|
static GType my_face1_get_type (void);
|
||||||
G_DEFINE_INTERFACE (MyFace1, my_face1, G_TYPE_OBJECT);
|
G_DEFINE_INTERFACE (MyFace1, my_face1, G_TYPE_OBJECT);
|
||||||
static void my_face1_default_init (MyFace1Interface *iface) { call_counter_init (iface); }
|
static void my_face1_default_init (MyFace1Interface *iface) { call_counter_init (iface); }
|
||||||
|
typedef GTypeInterface MyFace2Interface;
|
||||||
|
static GType my_face2_get_type (void);
|
||||||
|
G_DEFINE_INTERFACE (MyFace2, my_face2, G_TYPE_OBJECT);
|
||||||
|
static void my_face2_default_init (MyFace2Interface *iface) { call_counter_init (iface); }
|
||||||
|
|
||||||
/* define 3 test objects, adding interfaces 0 & 1, and adding interface 2 after class initialization */
|
/* define 3 test objects, adding interfaces 0 & 1, and adding interface 2 after class initialization */
|
||||||
typedef GObject MyTester0;
|
typedef GObject MyTester0;
|
||||||
@ -67,14 +69,6 @@ static void my_tester0_init (MyTester0*t) {}
|
|||||||
static void my_tester0_class_init (MyTester0Class*c) { call_counter_init (c); }
|
static void my_tester0_class_init (MyTester0Class*c) { call_counter_init (c); }
|
||||||
typedef GObject MyTester1;
|
typedef GObject MyTester1;
|
||||||
typedef GObjectClass MyTester1Class;
|
typedef GObjectClass MyTester1Class;
|
||||||
|
|
||||||
/* Disabled for now (see https://bugzilla.gnome.org/show_bug.cgi?id=687659) */
|
|
||||||
#if 0
|
|
||||||
typedef GTypeInterface MyFace2Interface;
|
|
||||||
static GType my_face2_get_type (void);
|
|
||||||
G_DEFINE_INTERFACE (MyFace2, my_face2, G_TYPE_OBJECT);
|
|
||||||
static void my_face2_default_init (MyFace2Interface *iface) { call_counter_init (iface); }
|
|
||||||
|
|
||||||
static GType my_tester1_get_type (void);
|
static GType my_tester1_get_type (void);
|
||||||
G_DEFINE_TYPE_WITH_CODE (MyTester1, my_tester1, G_TYPE_OBJECT,
|
G_DEFINE_TYPE_WITH_CODE (MyTester1, my_tester1, G_TYPE_OBJECT,
|
||||||
G_IMPLEMENT_INTERFACE (my_face0_get_type(), interface_per_class_init);
|
G_IMPLEMENT_INTERFACE (my_face0_get_type(), interface_per_class_init);
|
||||||
@ -92,6 +86,9 @@ G_DEFINE_TYPE_WITH_CODE (MyTester2, my_tester2, G_TYPE_OBJECT,
|
|||||||
static void my_tester2_init (MyTester2*t) {}
|
static void my_tester2_init (MyTester2*t) {}
|
||||||
static void my_tester2_class_init (MyTester2Class*c) { call_counter_init (c); }
|
static void my_tester2_class_init (MyTester2Class*c) { call_counter_init (c); }
|
||||||
|
|
||||||
|
static GCond sync_cond;
|
||||||
|
static GMutex sync_mutex;
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
tester_init_thread (gpointer data)
|
tester_init_thread (gpointer data)
|
||||||
{
|
{
|
||||||
@ -143,7 +140,6 @@ test_threaded_class_init (void)
|
|||||||
/* ensure non-corrupted counter updates */
|
/* ensure non-corrupted counter updates */
|
||||||
g_assert_cmpint (g_atomic_int_get (&mtsafe_call_counter), ==, unsafe_call_counter);
|
g_assert_cmpint (g_atomic_int_get (&mtsafe_call_counter), ==, unsafe_call_counter);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
@ -341,7 +337,7 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
/* g_test_add_func ("/GObject/threaded-class-init", test_threaded_class_init); */
|
g_test_add_func ("/GObject/threaded-class-init", test_threaded_class_init);
|
||||||
g_test_add_func ("/GObject/threaded-object-init", test_threaded_object_init);
|
g_test_add_func ("/GObject/threaded-object-init", test_threaded_object_init);
|
||||||
g_test_add_func ("/GObject/threaded-weak-ref", test_threaded_weak_ref);
|
g_test_add_func ("/GObject/threaded-weak-ref", test_threaded_weak_ref);
|
||||||
|
|
||||||
|
@ -59,6 +59,9 @@ test_programs = \
|
|||||||
accumulator \
|
accumulator \
|
||||||
defaultiface \
|
defaultiface \
|
||||||
dynamictype \
|
dynamictype \
|
||||||
|
ifacecheck \
|
||||||
|
ifaceinit \
|
||||||
|
ifaceinherit \
|
||||||
override \
|
override \
|
||||||
performance \
|
performance \
|
||||||
performance-threaded \
|
performance-threaded \
|
||||||
|
Loading…
Reference in New Issue
Block a user