mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 18:26:19 +01:00
Add g_type_get_type_registration_serial()
This lets you cache type lookup information and then know when the cache information is out of date. In particular, we want this in order to be able to cache g_type_from_name() lookups in the Gtk+ theme machinery. https://bugzilla.gnome.org/show_bug.cgi?id=689847
This commit is contained in:
parent
d77948eadf
commit
e218b96a6b
@ -99,6 +99,7 @@ g_type_remove_interface_check
|
|||||||
GTypeInterfaceCheckFunc
|
GTypeInterfaceCheckFunc
|
||||||
g_type_value_table_peek
|
g_type_value_table_peek
|
||||||
g_type_ensure
|
g_type_ensure
|
||||||
|
g_type_get_type_registration_serial
|
||||||
|
|
||||||
G_DEFINE_TYPE
|
G_DEFINE_TYPE
|
||||||
G_DEFINE_TYPE_WITH_CODE
|
G_DEFINE_TYPE_WITH_CODE
|
||||||
|
@ -350,6 +350,7 @@ g_type_fundamental
|
|||||||
g_type_fundamental_next
|
g_type_fundamental_next
|
||||||
g_type_get_plugin
|
g_type_get_plugin
|
||||||
g_type_get_qdata
|
g_type_get_qdata
|
||||||
|
g_type_get_type_registration_serial
|
||||||
g_type_init
|
g_type_init
|
||||||
g_type_init_with_debug_flags
|
g_type_init_with_debug_flags
|
||||||
g_type_instance_get_private
|
g_type_instance_get_private
|
||||||
|
@ -377,6 +377,7 @@ static IFaceCheckFunc *static_iface_check_funcs = NULL;
|
|||||||
static GQuark static_quark_type_flags = 0;
|
static GQuark static_quark_type_flags = 0;
|
||||||
static GQuark static_quark_iface_holder = 0;
|
static GQuark static_quark_iface_holder = 0;
|
||||||
static GQuark static_quark_dependants_array = 0;
|
static GQuark static_quark_dependants_array = 0;
|
||||||
|
static guint type_registration_serial = 0;
|
||||||
GTypeDebugFlags _g_type_debug_flags = 0;
|
GTypeDebugFlags _g_type_debug_flags = 0;
|
||||||
|
|
||||||
/* --- type nodes --- */
|
/* --- type nodes --- */
|
||||||
@ -393,6 +394,25 @@ lookup_type_node_I (register GType utype)
|
|||||||
return static_fundamental_type_nodes[utype >> G_TYPE_FUNDAMENTAL_SHIFT];
|
return static_fundamental_type_nodes[utype >> G_TYPE_FUNDAMENTAL_SHIFT];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_type_get_type_registration_serial:
|
||||||
|
*
|
||||||
|
* Returns an opaque serial number that represents the state of the set of registered
|
||||||
|
* types. Any time a type is registred this serial changes, which means you can
|
||||||
|
* cache information based on type lookups (such as g_type_from_name) and know if
|
||||||
|
* the cache is still valid at a later time by comparing the current serial with
|
||||||
|
* the one at the type lookup.
|
||||||
|
*
|
||||||
|
* Since: 2.36
|
||||||
|
*
|
||||||
|
* Returns: An unsigned int, representing the state of type registrations.
|
||||||
|
*/
|
||||||
|
guint
|
||||||
|
g_type_get_type_registration_serial (void)
|
||||||
|
{
|
||||||
|
return (guint)g_atomic_int_get ((gint *)&type_registration_serial);
|
||||||
|
}
|
||||||
|
|
||||||
static TypeNode*
|
static TypeNode*
|
||||||
type_node_any_new_W (TypeNode *pnode,
|
type_node_any_new_W (TypeNode *pnode,
|
||||||
GType ftype,
|
GType ftype,
|
||||||
@ -490,6 +510,9 @@ type_node_any_new_W (TypeNode *pnode,
|
|||||||
g_hash_table_insert (static_type_nodes_ht,
|
g_hash_table_insert (static_type_nodes_ht,
|
||||||
(gpointer) g_quark_to_string (node->qname),
|
(gpointer) g_quark_to_string (node->qname),
|
||||||
(gpointer) type);
|
(gpointer) type);
|
||||||
|
|
||||||
|
g_atomic_int_inc ((gint *)&type_registration_serial);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1263,6 +1263,9 @@ gpointer g_type_class_get_private (GTypeClass *klass,
|
|||||||
|
|
||||||
GLIB_AVAILABLE_IN_2_34
|
GLIB_AVAILABLE_IN_2_34
|
||||||
void g_type_ensure (GType type);
|
void g_type_ensure (GType type);
|
||||||
|
GLIB_AVAILABLE_IN_2_36
|
||||||
|
guint g_type_get_type_registration_serial (void);
|
||||||
|
|
||||||
|
|
||||||
/* --- GType boilerplate --- */
|
/* --- GType boilerplate --- */
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user