mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 14:36:16 +01:00
adapt to new gbsearcharray.h code. (g_value_register_transform_func): turn
Tue Aug 19 04:08:14 2003 Tim Janik <timj@gtk.org> * gvalue.c: adapt to new gbsearcharray.h code. (g_value_register_transform_func): turn transform function replacement into a valid operation. * gsignal.c: adapt to new gbsearcharray.h code. * gboxed.c: adapt to new gbsearcharray.h code.
This commit is contained in:
parent
779c44cdfb
commit
6d6e68f3e4
@ -1,3 +1,13 @@
|
|||||||
|
Tue Aug 19 04:08:14 2003 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gvalue.c: adapt to new gbsearcharray.h code.
|
||||||
|
(g_value_register_transform_func): turn transform function
|
||||||
|
replacement into a valid operation.
|
||||||
|
|
||||||
|
* gsignal.c: adapt to new gbsearcharray.h code.
|
||||||
|
|
||||||
|
* gboxed.c: adapt to new gbsearcharray.h code.
|
||||||
|
|
||||||
Tue Aug 19 01:31:28 2003 Tim Janik <timj@gtk.org>
|
Tue Aug 19 01:31:28 2003 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gsignal.c: added optimizations to skip NOP signal emissions.
|
* gsignal.c: added optimizations to skip NOP signal emissions.
|
||||||
|
@ -42,7 +42,11 @@ static gint boxed_nodes_cmp (gconstpointer p1,
|
|||||||
|
|
||||||
/* --- variables --- */
|
/* --- variables --- */
|
||||||
static GBSearchArray *boxed_bsa = NULL;
|
static GBSearchArray *boxed_bsa = NULL;
|
||||||
static GBSearchConfig boxed_bconfig = G_STATIC_BCONFIG (sizeof (BoxedNode), boxed_nodes_cmp, 0);
|
static const GBSearchConfig boxed_bconfig = {
|
||||||
|
sizeof (BoxedNode),
|
||||||
|
boxed_nodes_cmp,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* --- functions --- */
|
/* --- functions --- */
|
||||||
@ -121,7 +125,7 @@ g_boxed_type_init (void) /* sync with gtype.c */
|
|||||||
const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
|
const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
|
||||||
GType type;
|
GType type;
|
||||||
|
|
||||||
boxed_bsa = g_bsearch_array_new (&boxed_bconfig);
|
boxed_bsa = g_bsearch_array_create (&boxed_bconfig);
|
||||||
|
|
||||||
/* G_TYPE_BOXED
|
/* G_TYPE_BOXED
|
||||||
*/
|
*/
|
||||||
@ -317,7 +321,7 @@ g_boxed_type_register_static (const gchar *name,
|
|||||||
key.type = type;
|
key.type = type;
|
||||||
key.copy = boxed_copy;
|
key.copy = boxed_copy;
|
||||||
key.free = boxed_free;
|
key.free = boxed_free;
|
||||||
boxed_bsa = g_bsearch_array_insert (boxed_bsa, &boxed_bconfig, &key, TRUE);
|
boxed_bsa = g_bsearch_array_insert (boxed_bsa, &boxed_bconfig, &key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
|
@ -241,15 +241,21 @@ typedef struct
|
|||||||
|
|
||||||
/* --- variables --- */
|
/* --- variables --- */
|
||||||
static GBSearchArray *g_signal_key_bsa = NULL;
|
static GBSearchArray *g_signal_key_bsa = NULL;
|
||||||
static GBSearchConfig g_signal_key_bconfig = G_STATIC_BCONFIG (sizeof (SignalKey),
|
static const GBSearchConfig g_signal_key_bconfig = {
|
||||||
signal_key_cmp,
|
sizeof (SignalKey),
|
||||||
G_BSEARCH_ARRAY_ALIGN_POWER2);
|
signal_key_cmp,
|
||||||
static GBSearchConfig g_signal_hlbsa_bconfig = G_STATIC_BCONFIG (sizeof (HandlerList),
|
G_BSEARCH_ARRAY_ALIGN_POWER2,
|
||||||
handler_lists_cmp,
|
};
|
||||||
G_BSEARCH_ARRAY_DEFER_SHRINK);
|
static GBSearchConfig g_signal_hlbsa_bconfig = {
|
||||||
static GBSearchConfig g_class_closure_bconfig = G_STATIC_BCONFIG (sizeof (ClassClosure),
|
sizeof (HandlerList),
|
||||||
class_closures_cmp,
|
handler_lists_cmp,
|
||||||
0);
|
0,
|
||||||
|
};
|
||||||
|
static GBSearchConfig g_class_closure_bconfig = {
|
||||||
|
sizeof (ClassClosure),
|
||||||
|
class_closures_cmp,
|
||||||
|
0,
|
||||||
|
};
|
||||||
static GHashTable *g_handler_list_bsa_ht = NULL;
|
static GHashTable *g_handler_list_bsa_ht = NULL;
|
||||||
static Emission *g_recursive_emissions = NULL;
|
static Emission *g_recursive_emissions = NULL;
|
||||||
static Emission *g_restart_emissions = NULL;
|
static Emission *g_restart_emissions = NULL;
|
||||||
@ -351,15 +357,15 @@ handler_list_ensure (guint signal_id,
|
|||||||
key.handlers = NULL;
|
key.handlers = NULL;
|
||||||
if (!hlbsa)
|
if (!hlbsa)
|
||||||
{
|
{
|
||||||
hlbsa = g_bsearch_array_new (&g_signal_hlbsa_bconfig);
|
hlbsa = g_bsearch_array_create (&g_signal_hlbsa_bconfig);
|
||||||
hlbsa = g_bsearch_array_insert (hlbsa, &g_signal_hlbsa_bconfig, &key, FALSE);
|
hlbsa = g_bsearch_array_insert (hlbsa, &g_signal_hlbsa_bconfig, &key);
|
||||||
g_hash_table_insert (g_handler_list_bsa_ht, instance, hlbsa);
|
g_hash_table_insert (g_handler_list_bsa_ht, instance, hlbsa);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GBSearchArray *o = hlbsa;
|
GBSearchArray *o = hlbsa;
|
||||||
|
|
||||||
hlbsa = g_bsearch_array_insert (o, &g_signal_hlbsa_bconfig, &key, FALSE);
|
hlbsa = g_bsearch_array_insert (o, &g_signal_hlbsa_bconfig, &key);
|
||||||
if (hlbsa != o)
|
if (hlbsa != o)
|
||||||
g_hash_table_insert (g_handler_list_bsa_ht, instance, hlbsa);
|
g_hash_table_insert (g_handler_list_bsa_ht, instance, hlbsa);
|
||||||
}
|
}
|
||||||
@ -713,7 +719,7 @@ g_signal_init (void) /* sync with gtype.c */
|
|||||||
|
|
||||||
/* setup handler list binary searchable array hash table (in german, that'd be one word ;) */
|
/* setup handler list binary searchable array hash table (in german, that'd be one word ;) */
|
||||||
g_handler_list_bsa_ht = g_hash_table_new (g_direct_hash, NULL);
|
g_handler_list_bsa_ht = g_hash_table_new (g_direct_hash, NULL);
|
||||||
g_signal_key_bsa = g_bsearch_array_new (&g_signal_key_bconfig);
|
g_signal_key_bsa = g_bsearch_array_create (&g_signal_key_bconfig);
|
||||||
|
|
||||||
/* invalid (0) signal_id */
|
/* invalid (0) signal_id */
|
||||||
g_n_signal_nodes = 1;
|
g_n_signal_nodes = 1;
|
||||||
@ -1029,8 +1035,8 @@ g_signal_list_ids (GType itype,
|
|||||||
g_return_val_if_fail (n_ids != NULL, NULL);
|
g_return_val_if_fail (n_ids != NULL, NULL);
|
||||||
|
|
||||||
SIGNAL_LOCK ();
|
SIGNAL_LOCK ();
|
||||||
keys = G_BSEARCH_ARRAY_NODES (g_signal_key_bsa);
|
keys = g_bsearch_array_get_nth (g_signal_key_bsa, &g_signal_key_bconfig, 0);
|
||||||
n_nodes = g_signal_key_bsa->n_nodes;
|
n_nodes = g_bsearch_array_get_n_nodes (g_signal_key_bsa);
|
||||||
result = g_array_new (FALSE, FALSE, sizeof (guint));
|
result = g_array_new (FALSE, FALSE, sizeof (guint));
|
||||||
|
|
||||||
for (i = 0; i < n_nodes; i++)
|
for (i = 0; i < n_nodes; i++)
|
||||||
@ -1175,8 +1181,8 @@ signal_lookup_closure (SignalNode *node,
|
|||||||
{
|
{
|
||||||
ClassClosure *cc;
|
ClassClosure *cc;
|
||||||
|
|
||||||
if (node->class_closure_bsa && node->class_closure_bsa->n_nodes == 1)
|
if (node->class_closure_bsa && g_bsearch_array_get_n_nodes (node->class_closure_bsa) == 1)
|
||||||
cc = G_BSEARCH_ARRAY_NODES (node->class_closure_bsa);
|
cc = g_bsearch_array_get_nth (node->class_closure_bsa, &g_class_closure_bconfig, 0);
|
||||||
else
|
else
|
||||||
cc = signal_find_class_closure (node, G_TYPE_FROM_INSTANCE (instance));
|
cc = signal_find_class_closure (node, G_TYPE_FROM_INSTANCE (instance));
|
||||||
return cc ? cc->closure : NULL;
|
return cc ? cc->closure : NULL;
|
||||||
@ -1193,13 +1199,12 @@ signal_add_class_closure (SignalNode *node,
|
|||||||
node->test_class_offset = 0;
|
node->test_class_offset = 0;
|
||||||
|
|
||||||
if (!node->class_closure_bsa)
|
if (!node->class_closure_bsa)
|
||||||
node->class_closure_bsa = g_bsearch_array_new (&g_class_closure_bconfig);
|
node->class_closure_bsa = g_bsearch_array_create (&g_class_closure_bconfig);
|
||||||
key.instance_type = itype;
|
key.instance_type = itype;
|
||||||
key.closure = g_closure_ref (closure);
|
key.closure = g_closure_ref (closure);
|
||||||
node->class_closure_bsa = g_bsearch_array_insert (node->class_closure_bsa,
|
node->class_closure_bsa = g_bsearch_array_insert (node->class_closure_bsa,
|
||||||
&g_class_closure_bconfig,
|
&g_class_closure_bconfig,
|
||||||
&key,
|
&key);
|
||||||
FALSE);
|
|
||||||
g_closure_sink (closure);
|
g_closure_sink (closure);
|
||||||
if (node->c_marshaller && closure && G_CLOSURE_NEEDS_MARSHAL (closure))
|
if (node->c_marshaller && closure && G_CLOSURE_NEEDS_MARSHAL (closure))
|
||||||
g_closure_set_marshal (closure, node->c_marshaller);
|
g_closure_set_marshal (closure, node->c_marshaller);
|
||||||
@ -1300,10 +1305,10 @@ g_signal_newv (const gchar *signal_name,
|
|||||||
key.itype = itype;
|
key.itype = itype;
|
||||||
key.quark = g_quark_from_string (node->name);
|
key.quark = g_quark_from_string (node->name);
|
||||||
key.signal_id = signal_id;
|
key.signal_id = signal_id;
|
||||||
g_signal_key_bsa = g_bsearch_array_insert (g_signal_key_bsa, &g_signal_key_bconfig, &key, FALSE);
|
g_signal_key_bsa = g_bsearch_array_insert (g_signal_key_bsa, &g_signal_key_bconfig, &key);
|
||||||
g_strdelimit (node->name, "_", '-');
|
g_strdelimit (node->name, "_", '-');
|
||||||
key.quark = g_quark_from_static_string (node->name);
|
key.quark = g_quark_from_static_string (node->name);
|
||||||
g_signal_key_bsa = g_bsearch_array_insert (g_signal_key_bsa, &g_signal_key_bconfig, &key, FALSE);
|
g_signal_key_bsa = g_bsearch_array_insert (g_signal_key_bsa, &g_signal_key_bconfig, &key);
|
||||||
}
|
}
|
||||||
node->destroyed = FALSE;
|
node->destroyed = FALSE;
|
||||||
node->test_class_offset = 0;
|
node->test_class_offset = 0;
|
||||||
@ -1414,7 +1419,7 @@ signal_destroy_R (SignalNode *signal_node)
|
|||||||
|
|
||||||
g_closure_unref (cc->closure);
|
g_closure_unref (cc->closure);
|
||||||
}
|
}
|
||||||
g_bsearch_array_destroy (node.class_closure_bsa, &g_class_closure_bconfig);
|
g_bsearch_array_free (node.class_closure_bsa, &g_class_closure_bconfig);
|
||||||
}
|
}
|
||||||
g_free (node.accumulator);
|
g_free (node.accumulator);
|
||||||
if (node.emission_hooks)
|
if (node.emission_hooks)
|
||||||
@ -1789,7 +1794,7 @@ g_signal_handlers_destroy (gpointer instance)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_bsearch_array_destroy (hlbsa, &g_signal_hlbsa_bconfig);
|
g_bsearch_array_free (hlbsa, &g_signal_hlbsa_bconfig);
|
||||||
}
|
}
|
||||||
SIGNAL_UNLOCK ();
|
SIGNAL_UNLOCK ();
|
||||||
}
|
}
|
||||||
|
@ -43,16 +43,18 @@ static gint transform_entries_cmp (gconstpointer bsearch_node1,
|
|||||||
|
|
||||||
/* --- variables --- */
|
/* --- variables --- */
|
||||||
static GBSearchArray *transform_array = NULL;
|
static GBSearchArray *transform_array = NULL;
|
||||||
static GBSearchConfig transform_bconfig = G_STATIC_BCONFIG (sizeof (TransformEntry),
|
static GBSearchConfig transform_bconfig = {
|
||||||
transform_entries_cmp,
|
sizeof (TransformEntry),
|
||||||
0);
|
transform_entries_cmp,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* --- functions --- */
|
/* --- functions --- */
|
||||||
void
|
void
|
||||||
g_value_c_init (void) /* sync with gtype.c */
|
g_value_c_init (void) /* sync with gtype.c */
|
||||||
{
|
{
|
||||||
transform_array = g_bsearch_array_new (&transform_bconfig);
|
transform_array = g_bsearch_array_create (&transform_bconfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void /* keep this function in sync with gvaluecollector.h and gboxed.c */
|
static inline void /* keep this function in sync with gvaluecollector.h and gboxed.c */
|
||||||
@ -285,16 +287,17 @@ g_value_register_transform_func (GType src_type,
|
|||||||
|
|
||||||
entry.src_type = src_type;
|
entry.src_type = src_type;
|
||||||
entry.dest_type = dest_type;
|
entry.dest_type = dest_type;
|
||||||
|
|
||||||
|
#if 0 /* let transform function replacement be a valid operation */
|
||||||
if (g_bsearch_array_lookup (transform_array, &transform_bconfig, &entry))
|
if (g_bsearch_array_lookup (transform_array, &transform_bconfig, &entry))
|
||||||
g_warning ("reregistering value transformation function (%p) for `%s' to `%s'",
|
g_warning ("reregistering value transformation function (%p) for `%s' to `%s'",
|
||||||
transform_func,
|
transform_func,
|
||||||
g_type_name (src_type),
|
g_type_name (src_type),
|
||||||
g_type_name (dest_type));
|
g_type_name (dest_type));
|
||||||
|
#endif
|
||||||
|
|
||||||
entry.func = transform_func;
|
entry.func = transform_func;
|
||||||
|
transform_array = g_bsearch_array_replace (transform_array, &transform_bconfig, &entry);
|
||||||
transform_array = g_bsearch_array_insert (transform_array, &transform_bconfig, &entry, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user