+Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org>
+
+ * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+ added a GData member instead.
+
+ * glist.[hc]: added g_list_remove_all().
+
+ * gslist.[hc]: added g_slist_remove_all().
+
Sat Mar 17 19:54:51 2001 Owen Taylor <otaylor@redhat.com>
* timeloop.c: Reorder headers to make FreeBSD happy.
+Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org>
+
+ * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+ added a GData member instead.
+
+ * glist.[hc]: added g_list_remove_all().
+
+ * gslist.[hc]: added g_slist_remove_all().
+
Sat Mar 17 19:54:51 2001 Owen Taylor <otaylor@redhat.com>
* timeloop.c: Reorder headers to make FreeBSD happy.
+Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org>
+
+ * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+ added a GData member instead.
+
+ * glist.[hc]: added g_list_remove_all().
+
+ * gslist.[hc]: added g_slist_remove_all().
+
Sat Mar 17 19:54:51 2001 Owen Taylor <otaylor@redhat.com>
* timeloop.c: Reorder headers to make FreeBSD happy.
+Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org>
+
+ * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+ added a GData member instead.
+
+ * glist.[hc]: added g_list_remove_all().
+
+ * gslist.[hc]: added g_slist_remove_all().
+
Sat Mar 17 19:54:51 2001 Owen Taylor <otaylor@redhat.com>
* timeloop.c: Reorder headers to make FreeBSD happy.
+Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org>
+
+ * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+ added a GData member instead.
+
+ * glist.[hc]: added g_list_remove_all().
+
+ * gslist.[hc]: added g_slist_remove_all().
+
Sat Mar 17 19:54:51 2001 Owen Taylor <otaylor@redhat.com>
* timeloop.c: Reorder headers to make FreeBSD happy.
+Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org>
+
+ * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+ added a GData member instead.
+
+ * glist.[hc]: added g_list_remove_all().
+
+ * gslist.[hc]: added g_slist_remove_all().
+
Sat Mar 17 19:54:51 2001 Owen Taylor <otaylor@redhat.com>
* timeloop.c: Reorder headers to make FreeBSD happy.
+Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org>
+
+ * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+ added a GData member instead.
+
+ * glist.[hc]: added g_list_remove_all().
+
+ * gslist.[hc]: added g_slist_remove_all().
+
Sat Mar 17 19:54:51 2001 Owen Taylor <otaylor@redhat.com>
* timeloop.c: Reorder headers to make FreeBSD happy.
+Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org>
+
+ * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+ added a GData member instead.
+
+ * glist.[hc]: added g_list_remove_all().
+
+ * gslist.[hc]: added g_slist_remove_all().
+
Sat Mar 17 19:54:51 2001 Owen Taylor <otaylor@redhat.com>
* timeloop.c: Reorder headers to make FreeBSD happy.
Portable way to copy <type>va_list</type> variables.
</para>
+<!-- # Unused Parameters # -->
@ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
@ap2: a <type>va_list</type>.
@max_parse_errors:
@parse_errors:
@input_name:
-@derived_data:
+@qdata:
@config:
@token:
@value:
@closure:
-<!-- ##### FUNCTION g_closure_add_fnotify ##### -->
-<para>
-
-</para>
-
-@closure:
-@notify_data:
-@notify_func:
-
-
-<!-- ##### FUNCTION g_closure_remove_fnotify ##### -->
-<para>
-
-</para>
-
-@closure:
-@notify_data:
-@notify_func:
-
-
-<!-- ##### FUNCTION g_closure_add_inotify ##### -->
-<para>
-
-</para>
-
-@closure:
-@notify_data:
-@notify_func:
-
-
-<!-- ##### FUNCTION g_closure_remove_inotify ##### -->
-<para>
-
-</para>
-
-@closure:
-@notify_data:
-@notify_func:
-
-
<!-- ##### FUNCTION g_closure_new_simple ##### -->
<para>
+<!-- ##### FUNCTION g_closure_add_fnotify ##### -->
+<para>
+
+</para>
+
+@closure:
+@notify_data:
+@notify_func:
+
+<!-- ##### FUNCTION g_closure_add_inotify ##### -->
+<para>
+
+</para>
+
+@closure:
+@notify_data:
+@notify_func:
+
+<!-- ##### FUNCTION g_closure_remove_fnotify ##### -->
+<para>
+
+</para>
+
+@closure:
+@notify_data:
+@notify_func:
+
+<!-- ##### FUNCTION g_closure_remove_inotify ##### -->
+<para>
+
+</para>
+
+@closure:
+@notify_data:
+@notify_func:
+
<!-- ##### FUNCTION g_param_spec_string_c ##### -->
<para>
@G_TYPE_CLOSURE:
@G_TYPE_VALUE:
@G_TYPE_VALUE_ARRAY:
+@G_TYPE_GSTRING:
@G_TYPE_PARAM_CHAR: Identifier for the "#GParamSpecChar" type.
@G_TYPE_PARAM_UCHAR: Identifier for the "#GParamSpecUChar" type.
@G_TYPE_PARAM_BOOLEAN: Identifier for the "#GParamSpecBoolean" type.
/* --- structures --- */
+GBSearchArray*
+g_bsearch_array_new (guint16 sizeof_node,
+ GBSearchCompareFunc node_cmp_func,
+ GBSearchArrayFlags flags)
+{
+ GBSearchArray *barray;
+
+ g_return_val_if_fail (sizeof_node > 0, NULL);
+ g_return_val_if_fail (node_cmp_func != NULL, NULL);
+
+ barray = g_new0 (GBSearchArray, 1);
+ barray->sizeof_node = sizeof_node;
+ barray->cmp_nodes = node_cmp_func;
+ barray->flags = flags;
+
+ return barray;
+}
+
+void
+g_bsearch_array_destroy (GBSearchArray *barray)
+{
+ g_return_if_fail (barray != NULL);
+
+#if 0
+ if (barray->destroy_node)
+ while (barray->n_nodes)
+ {
+ barray->destroy_node (((guint8*) barray->nodes) + (barray->n_nodes - 1) * barray->sizeof_node);
+ barray->n_nodes--;
+ }
+#endif
+ g_free (barray->nodes);
+ g_free (barray);
+}
+
static inline guint
upper_power2 (guint number)
{
{
guint new_size = barray->sizeof_node;
- if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+ if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
new_size = upper_power2 (new_size);
barray->nodes = g_realloc (barray->nodes, new_size);
barray->n_nodes = 1;
check = barray->nodes;
- replace = TRUE;
}
else
{
- GBSearchCompareFunc cmp_func = barray->cmp_func;
+ GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
guint n_nodes = barray->n_nodes;
guint8 *nodes = barray->nodes;
gint cmp;
{
i = (n_nodes + 1) >> 1;
check = nodes + i * sizeof_node;
- cmp = cmp_func (key_node, check);
+ cmp = cmp_nodes (key_node, check);
if (cmp > 0)
{
n_nodes -= i;
else if (cmp < 0)
n_nodes = i - 1;
else /* if (cmp == 0) */
- goto SKIP_GROW;
+ {
+ if (replace)
+ {
+#if 0
+ if (barray->destroy_node)
+ barray->destroy_node (check);
+#endif
+ memcpy (check, key_node, sizeof_node);
+ }
+ return check;
+ }
}
while (n_nodes);
/* grow */
check += sizeof_node;
i = (check - ((guint8*) barray->nodes)) / sizeof_node;
n_nodes = barray->n_nodes++;
- if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+ if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
{
guint new_size = upper_power2 (barray->n_nodes * sizeof_node);
guint old_size = upper_power2 (n_nodes * sizeof_node);
barray->nodes = g_realloc (barray->nodes, barray->n_nodes * sizeof_node);
check = ((guint8*) barray->nodes) + i * sizeof_node;
g_memmove (check + sizeof_node, check, (n_nodes - i) * sizeof_node);
- replace = TRUE;
- SKIP_GROW:
- ;
}
- if (replace)
- memcpy (check, key_node, sizeof_node);
+ memcpy (check, key_node, sizeof_node);
return check;
}
bound = nodes + old_size;
g_return_if_fail (node_in_array >= nodes && node_in_array < bound);
-
+
+#if 0
+ if (barray->destroy_node)
+ barray->destroy_node (node_in_array);
+#endif
bound -= barray->sizeof_node;
barray->n_nodes -= 1;
g_memmove (node_in_array, node_in_array + barray->sizeof_node, (bound - node_in_array) / barray->sizeof_node);
- if ((barray->flags & G_BSEARCH_DEFER_SHRINK) == 0)
+ if ((barray->flags & G_BSEARCH_ARRAY_DEFER_SHRINK) == 0)
{
guint new_size = bound - nodes; /* old_size - barray->sizeof_node */
- if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+ if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
{
new_size = upper_power2 (new_size);
old_size = upper_power2 (old_size);
gconstpointer bsearch_node2);
typedef enum
{
- G_BSEARCH_ALIGN_POWER2 = 1 << 0,
- G_BSEARCH_DEFER_SHRINK = 1 << 1
-} GBSearchFlags;
+ G_BSEARCH_ARRAY_ALIGN_POWER2 = 1 << 0,
+ G_BSEARCH_ARRAY_DEFER_SHRINK = 1 << 1
+} GBSearchArrayFlags;
/* --- structures --- */
struct _GBSearchArray
{
- GBSearchCompareFunc cmp_func;
- guint16 sizeof_node;
+ GBSearchCompareFunc cmp_nodes;
guint16 flags;
+ guint16 sizeof_node;
guint n_nodes;
gpointer nodes;
};
/* --- prototypes --- */
+GBSearchArray* g_bsearch_array_new (guint16 sizeof_node,
+ GBSearchCompareFunc node_cmp_func,
+ GBSearchArrayFlags flags);
+void g_bsearch_array_destroy (GBSearchArray *barray);
gpointer g_bsearch_array_insert (GBSearchArray *barray,
gconstpointer key_node,
gboolean replace_existing);
gpointer node_in_array);
+/* initialization of static arrays */
+#define G_STATIC_BSEARCH_ARRAY_INIT(sizeof_node, cmp_nodes, flags) \
+ { (cmp_nodes), (flags), (sizeof_node), 0, NULL }
+
+
/* --- implementation details --- */
#if defined (G_CAN_INLINE) || defined (__G_BSEARCHARRAY_C__)
G_INLINE_FUNC gpointer
{
if (barray->n_nodes > 0)
{
- GBSearchCompareFunc cmp_func = barray->cmp_func;
+ GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
gint sizeof_node = barray->sizeof_node;
guint n_nodes = barray->n_nodes;
guint8 *nodes = (guint8 *) barray->nodes;
i = (n_nodes + 1) >> 1;
check = nodes + i * sizeof_node;
- cmp = cmp_func (key_node, check);
+ cmp = cmp_nodes (key_node, check);
if (cmp == 0)
return check;
else if (cmp > 0)
return list;
}
+GList*
+g_list_remove_all (GList *list,
+ gconstpointer data)
+{
+ GList *tmp = list;
+
+ while (tmp)
+ {
+ if (tmp->data != data)
+ tmp = tmp->next;
+ else
+ {
+ GList *next = tmp->next;
+
+ if (tmp->prev)
+ tmp->prev->next = next;
+ else
+ list = next;
+ if (next)
+ next->prev = tmp->prev;
+
+ _g_list_free_1 (tmp);
+ tmp = next;
+ }
+ }
+ return list;
+}
+
static inline GList*
_g_list_remove_link (GList *list,
GList *link)
GList *list2);
GList* g_list_remove (GList *list,
gconstpointer data);
+GList* g_list_remove_all (GList *list,
+ gconstpointer data);
GList* g_list_remove_link (GList *list,
GList *llink);
GList* g_list_delete_link (GList *list,
scanner->max_parse_errors = 0;
scanner->parse_errors = 0;
scanner->input_name = NULL;
- scanner->derived_data = NULL;
+ g_datalist_init (&scanner->qdata);
scanner->config = g_new0 (GScannerConfig, 1);
{
g_return_if_fail (scanner != NULL);
+ g_datalist_clear (&scanner->qdata);
g_hash_table_foreach (scanner->symbol_table,
g_scanner_destroy_symbol_table_entry, NULL);
g_hash_table_destroy (scanner->symbol_table);
/* name of input stream, featured by the default message handler */
const gchar *input_name;
- /* data pointer for derived structures */
- gpointer derived_data;
+ /* quarked data */
+ GData *qdata;
/* link into the scanner configuration */
GScannerConfig *config;
g_slist_remove (GSList *list,
gconstpointer data)
{
- GSList *tmp;
- GSList *prev;
+ GSList *tmp, *prev = NULL;
- prev = NULL;
tmp = list;
-
while (tmp)
{
if (tmp->data == data)
{
if (prev)
prev->next = tmp->next;
- if (list == tmp)
- list = list->next;
-
- tmp->next = NULL;
- g_slist_free (tmp);
+ else
+ list = tmp->next;
+ g_slist_free_1 (tmp);
break;
}
-
prev = tmp;
- tmp = tmp->next;
+ tmp = prev->next;
+ }
+
+ return list;
+}
+
+GSList*
+g_slist_remove_all (GSList *list,
+ gconstpointer data)
+{
+ GSList *tmp, *prev = NULL;
+
+ tmp = list;
+ while (tmp)
+ {
+ if (tmp->data == data)
+ {
+ GSList *next = tmp->next;
+
+ if (prev)
+ prev->next = next;
+ else
+ list = next;
+
+ g_slist_free_1 (tmp);
+ tmp = next;
+ }
+ else
+ {
+ prev = tmp;
+ tmp = prev->next;
+ }
}
return list;
GSList *list2);
GSList* g_slist_remove (GSList *list,
gconstpointer data);
+GSList* g_slist_remove_all (GSList *list,
+ gconstpointer data);
GSList* g_slist_remove_link (GSList *list,
GSList *link);
GSList* g_slist_delete_link (GSList *list,
typedef long glong;
typedef int gint;
typedef gint gboolean;
-typedef gchar* gstring;
typedef unsigned char guchar;
typedef unsigned short gushort;
return list;
}
+GList*
+g_list_remove_all (GList *list,
+ gconstpointer data)
+{
+ GList *tmp = list;
+
+ while (tmp)
+ {
+ if (tmp->data != data)
+ tmp = tmp->next;
+ else
+ {
+ GList *next = tmp->next;
+
+ if (tmp->prev)
+ tmp->prev->next = next;
+ else
+ list = next;
+ if (next)
+ next->prev = tmp->prev;
+
+ _g_list_free_1 (tmp);
+ tmp = next;
+ }
+ }
+ return list;
+}
+
static inline GList*
_g_list_remove_link (GList *list,
GList *link)
GList *list2);
GList* g_list_remove (GList *list,
gconstpointer data);
+GList* g_list_remove_all (GList *list,
+ gconstpointer data);
GList* g_list_remove_link (GList *list,
GList *llink);
GList* g_list_delete_link (GList *list,
+Sat Mar 17 23:18:36 2001 Tim Janik <timj@gtk.org>
+
+ * gobject.c (g_object_get_property): minor bug-fix.
+
+ * gbsearcharray.[hc]: provide a macro for static initialization and
+ functions g_bsearch_array_new() and g_bsearch_array_destroy() for
+ dynamic allocations.
+
+ * gboxed.c: introduce G_TYPE_GSTRING, boxed type for GString.
+
+ * gclosure.[hc]: naming corrections.
+
Fri Mar 9 16:42:08 2001 Tim Janik <timj@gtk.org>
* gvaluetypes.[hc]: moved g_strdup_value_contents() into this file as
/* --- variables --- */
-static GBSearchArray boxed_bsa = { boxed_nodes_cmp, sizeof (BoxedNode), 0, 0, NULL };
+static GBSearchArray boxed_bsa = G_STATIC_BSEARCH_ARRAY_INIT (sizeof (BoxedNode), boxed_nodes_cmp, 0);
/* --- functions --- */
return g_value_array_new (0);
}
+static gpointer
+gstring_init (void)
+{
+ return g_string_new ("");
+}
+
+static gpointer
+gstring_copy (gpointer boxed)
+{
+ const GString *src_gstring = boxed;
+
+ return g_string_new_len (src_gstring->str, src_gstring->len);
+}
+
+static void
+gstring_free (gpointer boxed)
+{
+ GString *gstring = boxed;
+
+ g_string_free (gstring, TRUE);
+}
+
void
g_boxed_type_init (void) /* sync with gtype.c */
{
(GBoxedFreeFunc) g_value_array_free,
FALSE);
g_assert (type == G_TYPE_VALUE_ARRAY);
+
+ /* boxed: G_TYPE_GSTRING
+ * yes, the naming is a bit odd, but GString is obviously not G_TYPE_STRING
+ */
+ type = g_boxed_type_register_static ("GString",
+ gstring_init, /* don't allow NULL values */
+ gstring_copy,
+ gstring_free,
+ FALSE);
+ g_assert (type == G_TYPE_GSTRING);
}
static void
/* --- structures --- */
+GBSearchArray*
+g_bsearch_array_new (guint16 sizeof_node,
+ GBSearchCompareFunc node_cmp_func,
+ GBSearchArrayFlags flags)
+{
+ GBSearchArray *barray;
+
+ g_return_val_if_fail (sizeof_node > 0, NULL);
+ g_return_val_if_fail (node_cmp_func != NULL, NULL);
+
+ barray = g_new0 (GBSearchArray, 1);
+ barray->sizeof_node = sizeof_node;
+ barray->cmp_nodes = node_cmp_func;
+ barray->flags = flags;
+
+ return barray;
+}
+
+void
+g_bsearch_array_destroy (GBSearchArray *barray)
+{
+ g_return_if_fail (barray != NULL);
+
+#if 0
+ if (barray->destroy_node)
+ while (barray->n_nodes)
+ {
+ barray->destroy_node (((guint8*) barray->nodes) + (barray->n_nodes - 1) * barray->sizeof_node);
+ barray->n_nodes--;
+ }
+#endif
+ g_free (barray->nodes);
+ g_free (barray);
+}
+
static inline guint
upper_power2 (guint number)
{
{
guint new_size = barray->sizeof_node;
- if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+ if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
new_size = upper_power2 (new_size);
barray->nodes = g_realloc (barray->nodes, new_size);
barray->n_nodes = 1;
check = barray->nodes;
- replace = TRUE;
}
else
{
- GBSearchCompareFunc cmp_func = barray->cmp_func;
+ GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
guint n_nodes = barray->n_nodes;
guint8 *nodes = barray->nodes;
gint cmp;
{
i = (n_nodes + 1) >> 1;
check = nodes + i * sizeof_node;
- cmp = cmp_func (key_node, check);
+ cmp = cmp_nodes (key_node, check);
if (cmp > 0)
{
n_nodes -= i;
else if (cmp < 0)
n_nodes = i - 1;
else /* if (cmp == 0) */
- goto SKIP_GROW;
+ {
+ if (replace)
+ {
+#if 0
+ if (barray->destroy_node)
+ barray->destroy_node (check);
+#endif
+ memcpy (check, key_node, sizeof_node);
+ }
+ return check;
+ }
}
while (n_nodes);
/* grow */
check += sizeof_node;
i = (check - ((guint8*) barray->nodes)) / sizeof_node;
n_nodes = barray->n_nodes++;
- if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+ if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
{
guint new_size = upper_power2 (barray->n_nodes * sizeof_node);
guint old_size = upper_power2 (n_nodes * sizeof_node);
barray->nodes = g_realloc (barray->nodes, barray->n_nodes * sizeof_node);
check = ((guint8*) barray->nodes) + i * sizeof_node;
g_memmove (check + sizeof_node, check, (n_nodes - i) * sizeof_node);
- replace = TRUE;
- SKIP_GROW:
- ;
}
- if (replace)
- memcpy (check, key_node, sizeof_node);
+ memcpy (check, key_node, sizeof_node);
return check;
}
bound = nodes + old_size;
g_return_if_fail (node_in_array >= nodes && node_in_array < bound);
-
+
+#if 0
+ if (barray->destroy_node)
+ barray->destroy_node (node_in_array);
+#endif
bound -= barray->sizeof_node;
barray->n_nodes -= 1;
g_memmove (node_in_array, node_in_array + barray->sizeof_node, (bound - node_in_array) / barray->sizeof_node);
- if ((barray->flags & G_BSEARCH_DEFER_SHRINK) == 0)
+ if ((barray->flags & G_BSEARCH_ARRAY_DEFER_SHRINK) == 0)
{
guint new_size = bound - nodes; /* old_size - barray->sizeof_node */
- if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+ if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
{
new_size = upper_power2 (new_size);
old_size = upper_power2 (old_size);
gconstpointer bsearch_node2);
typedef enum
{
- G_BSEARCH_ALIGN_POWER2 = 1 << 0,
- G_BSEARCH_DEFER_SHRINK = 1 << 1
-} GBSearchFlags;
+ G_BSEARCH_ARRAY_ALIGN_POWER2 = 1 << 0,
+ G_BSEARCH_ARRAY_DEFER_SHRINK = 1 << 1
+} GBSearchArrayFlags;
/* --- structures --- */
struct _GBSearchArray
{
- GBSearchCompareFunc cmp_func;
- guint16 sizeof_node;
+ GBSearchCompareFunc cmp_nodes;
guint16 flags;
+ guint16 sizeof_node;
guint n_nodes;
gpointer nodes;
};
/* --- prototypes --- */
+GBSearchArray* g_bsearch_array_new (guint16 sizeof_node,
+ GBSearchCompareFunc node_cmp_func,
+ GBSearchArrayFlags flags);
+void g_bsearch_array_destroy (GBSearchArray *barray);
gpointer g_bsearch_array_insert (GBSearchArray *barray,
gconstpointer key_node,
gboolean replace_existing);
gpointer node_in_array);
+/* initialization of static arrays */
+#define G_STATIC_BSEARCH_ARRAY_INIT(sizeof_node, cmp_nodes, flags) \
+ { (cmp_nodes), (flags), (sizeof_node), 0, NULL }
+
+
/* --- implementation details --- */
#if defined (G_CAN_INLINE) || defined (__G_BSEARCHARRAY_C__)
G_INLINE_FUNC gpointer
{
if (barray->n_nodes > 0)
{
- GBSearchCompareFunc cmp_func = barray->cmp_func;
+ GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
gint sizeof_node = barray->sizeof_node;
guint n_nodes = barray->n_nodes;
guint8 *nodes = (guint8 *) barray->nodes;
i = (n_nodes + 1) >> 1;
check = nodes + i * sizeof_node;
- cmp = cmp_func (key_node, check);
+ cmp = cmp_nodes (key_node, check);
if (cmp == 0)
return check;
else if (cmp > 0)
}
void
-g_closure_add_fnotify (GClosure *closure,
- gpointer notify_data,
- GClosureNotify notify_func)
+g_closure_add_finalize_notifier (GClosure *closure,
+ gpointer notify_data,
+ GClosureNotify notify_func)
{
guint i;
}
void
-g_closure_add_inotify (GClosure *closure,
- gpointer notify_data,
- GClosureNotify notify_func)
+g_closure_add_invalidate_notifier (GClosure *closure,
+ gpointer notify_data,
+ GClosureNotify notify_func)
{
guint i;
}
void
-g_closure_remove_inotify (GClosure *closure,
- gpointer notify_data,
- GClosureNotify notify_func)
+g_closure_remove_invalidate_notifier (GClosure *closure,
+ gpointer notify_data,
+ GClosureNotify notify_func)
{
g_return_if_fail (closure != NULL);
g_return_if_fail (notify_func != NULL);
}
void
-g_closure_remove_fnotify (GClosure *closure,
- gpointer notify_data,
- GClosureNotify notify_func)
+g_closure_remove_finalize_notifier (GClosure *closure,
+ gpointer notify_data,
+ GClosureNotify notify_func)
{
g_return_if_fail (closure != NULL);
g_return_if_fail (notify_func != NULL);
closure = g_closure_new_simple (sizeof (GCClosure), user_data);
if (destroy_data)
- g_closure_add_fnotify (closure, user_data, destroy_data);
+ g_closure_add_finalize_notifier (closure, user_data, destroy_data);
((GCClosure*) closure)->callback = callback_func;
return closure;
closure = g_closure_new_simple (sizeof (GCClosure), user_data);
if (destroy_data)
- g_closure_add_fnotify (closure, user_data, destroy_data);
+ g_closure_add_finalize_notifier (closure, user_data, destroy_data);
((GCClosure*) closure)->callback = callback_func;
closure->derivative_flag = TRUE;
/* --- prototypes --- */
-GClosure* g_cclosure_new (GCallback callback_func,
+GClosure* g_cclosure_new (GCallback callback_func,
gpointer user_data,
GClosureNotify destroy_data);
-GClosure* g_cclosure_new_swap (GCallback callback_func,
+GClosure* g_cclosure_new_swap (GCallback callback_func,
gpointer user_data,
GClosureNotify destroy_data);
-GClosure* g_signal_type_cclosure_new (GType itype,
+GClosure* g_signal_type_cclosure_new (GType itype,
guint struct_offset);
/* --- prototypes --- */
-GClosure* g_closure_ref (GClosure *closure);
-void g_closure_sink (GClosure *closure);
-void g_closure_unref (GClosure *closure);
+GClosure* g_closure_ref (GClosure *closure);
+void g_closure_sink (GClosure *closure);
+void g_closure_unref (GClosure *closure);
/* intimidating */
-GClosure* g_closure_new_simple (guint sizeof_closure,
+GClosure* g_closure_new_simple (guint sizeof_closure,
gpointer data);
-void g_closure_add_fnotify (GClosure *closure,
+void g_closure_add_finalize_notifier (GClosure *closure,
gpointer notify_data,
GClosureNotify notify_func);
-void g_closure_remove_fnotify (GClosure *closure,
+void g_closure_remove_finalize_notifier (GClosure *closure,
gpointer notify_data,
GClosureNotify notify_func);
-void g_closure_add_inotify (GClosure *closure,
+void g_closure_add_invalidate_notifier (GClosure *closure,
gpointer notify_data,
GClosureNotify notify_func);
-void g_closure_remove_inotify (GClosure *closure,
+void g_closure_remove_invalidate_notifier (GClosure *closure,
gpointer notify_data,
GClosureNotify notify_func);
-void g_closure_add_marshal_guards (GClosure *closure,
+void g_closure_add_marshal_guards (GClosure *closure,
gpointer pre_marshal_data,
GClosureNotify pre_marshal_notify,
gpointer post_marshal_data,
GClosureNotify post_marshal_notify);
-void g_closure_set_marshal (GClosure *closure,
+void g_closure_set_marshal (GClosure *closure,
GClosureMarshal marshal);
-void g_closure_set_meta_marshal (GClosure *closure,
+void g_closure_set_meta_marshal (GClosure *closure,
gpointer marshal_data,
GClosureMarshal meta_marshal);
-void g_closure_invalidate (GClosure *closure);
-void g_closure_invoke (GClosure *closure,
+void g_closure_invalidate (GClosure *closure);
+void g_closure_invoke (GClosure *closure,
GValue /*out*/ *return_value,
guint n_param_values,
const GValue *param_values,
{
gchar *contents = g_strdup_value_contents (value);
- g_warning ("value <%s> of type `%s' is invalid for property `%s' of type `%s'",
+ g_warning ("value \"%s\" of type `%s' is invalid for property `%s' of type `%s'",
contents,
G_VALUE_TYPE_NAME (value),
pspec->name,
{
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
-
- /* we purposely leak the value here, it might not be
- * in a sane state if an error condition occoured
- */
+ g_value_unset (&value);
break;
}
G_OBJECT_TYPE (object),
TRUE);
if (!pspec)
- g_warning ("object class `%s' has no property named `%s'",
+ g_warning ("%s: object class `%s' has no property named `%s'",
+ G_STRLOC,
G_OBJECT_TYPE_NAME (object),
property_name);
else
G_OBJECT_TYPE (object),
TRUE);
if (!pspec)
- g_warning ("object class `%s' has no property named `%s'",
+ g_warning ("%s: object class `%s' has no property named `%s'",
+ G_STRLOC,
G_OBJECT_TYPE_NAME (object),
property_name);
else
pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
G_VALUE_TYPE_NAME (value));
+ g_object_unref (object);
return;
}
else
/* removing object_remove_closure() upfront is probably faster than
* letting it fiddle with quark_closure_array which is empty anyways
*/
- g_closure_remove_inotify (closure, object, object_remove_closure);
+ g_closure_remove_invalidate_notifier (closure, object, object_remove_closure);
g_closure_invalidate (closure);
}
g_free (carray);
g_return_if_fail (closure->in_marshal == FALSE);
g_return_if_fail (object->ref_count > 0); /* this doesn't work on finalizing objects */
- g_closure_add_inotify (closure, object, object_remove_closure);
+ g_closure_add_invalidate_notifier (closure, object, object_remove_closure);
g_closure_add_marshal_guards (closure,
object, (GClosureNotify) g_object_ref,
object, (GClosureNotify) g_object_unref);
g_return_val_if_fail (G_TYPE_IS_PARAM (param_type) && param_type != G_TYPE_PARAM, NULL);
g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail ((name[0] >= 'A' && name[0] <= 'Z') || (name[0] >= 'a' && name[0] <= 'z'), NULL);
pspec = (gpointer) g_type_create_instance (param_type);
pspec->name = g_strdup (name);
if (!pspec)
{
- /* sigh, try canonicalization */
+ /* try canonicalized form */
key.name = g_strdup (param_name);
key.owner_type = owner_type;
/* pre allocation configurations
*/
#define MAX_STACK_VALUES (16)
-#define BSA_PRE_ALLOC (20)
#define HANDLER_PRE_ALLOC (48)
#define EMISSION_PRE_ALLOC (16)
guint signal_id,
GQuark detail,
gpointer instance);
+static gint signal_key_cmp (gconstpointer node1,
+ gconstpointer node2);
static gboolean signal_emit_R (SignalNode *node,
GQuark detail,
gpointer instance,
/* --- variables --- */
-static GBSearchArray g_signal_key_bsa = { NULL, 0, 0, 0, NULL };
+static GBSearchArray g_signal_key_bsa = G_STATIC_BSEARCH_ARRAY_INIT (sizeof (SignalKey),
+ signal_key_cmp,
+ G_BSEARCH_ARRAY_ALIGN_POWER2);
static GHashTable *g_handler_list_bsa_ht = NULL;
static Emission *g_recursive_emissions = NULL;
static Emission *g_restart_emissions = NULL;
-static GTrashStack *g_bsa_ts = NULL;
static GTrashStack *g_handler_ts = NULL;
static GTrashStack *g_emission_ts = NULL;
G_LOCK_DEFINE_STATIC (g_signal_mutex);
if (!hlbsa)
{
- hlbsa = g_generic_node_alloc (&g_bsa_ts,
- sizeof (GBSearchArray),
- BSA_PRE_ALLOC);
- hlbsa->cmp_func = handler_lists_cmp;
- hlbsa->sizeof_node = sizeof (HandlerList);
- hlbsa->flags = G_BSEARCH_DEFER_SHRINK;
- hlbsa->n_nodes = 0;
- hlbsa->nodes = NULL;
+ hlbsa = g_bsearch_array_new (sizeof (HandlerList), handler_lists_cmp, G_BSEARCH_ARRAY_DEFER_SHRINK);
g_hash_table_insert (g_handler_list_bsa_ht, instance, hlbsa);
}
key.signal_id = signal_id;
/* handler_id_node_prepend() requires this */
g_assert (sizeof (GList) == sizeof (HandlerMatch));
- /* setup signal key array */
- g_signal_key_bsa.cmp_func = signal_key_cmp;
- g_signal_key_bsa.sizeof_node = sizeof (SignalKey);
- g_signal_key_bsa.flags = G_BSEARCH_ALIGN_POWER2; /* alloc-only */
-
/* 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_UNLOCK (g_signal_mutex);
- return (guint *) g_array_free (result, FALSE);
+ return (guint*) g_array_free (result, FALSE);
}
guint
}
}
}
- g_free (hlbsa->nodes);
- g_generic_node_free (&g_bsa_ts, hlbsa);
+ g_bsearch_array_destroy (hlbsa);
}
G_UNLOCK (g_signal_mutex);
}
G_TYPE_CLOSURE = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 1),
G_TYPE_VALUE = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 2),
G_TYPE_VALUE_ARRAY = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 3),
+ G_TYPE_GSTRING = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 4),
G_TYPE_PARAM_CHAR = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 1),
G_TYPE_PARAM_UCHAR = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 2),
G_TYPE_PARAM_BOOLEAN = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 3),
/* --- variables --- */
-static GBSearchArray transform_array = {
- transform_entries_cmp,
- sizeof (TransformEntry),
- 0, /* no flags */
- 0, NULL,
-};
+static GBSearchArray transform_array = G_STATIC_BSEARCH_ARRAY_INIT (sizeof (TransformEntry),
+ transform_entries_cmp,
+ 0);
/* --- functions --- */
*/
#define G_VALUE_LCOPY(value, var_args, flags, __error) \
G_STMT_START { \
- GValue *_value = (value); \
+ const GValue *_value = (value); \
guint _flags = (flags); \
GType _value_type = G_VALUE_TYPE (_value); \
GTypeValueTable *_vtable = g_type_value_table_peek (_value_type); \
value_lcopy_string, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_STRING, "gstring", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_STRING, "gchararray", &info, &finfo, 0);
g_assert (type == G_TYPE_STRING);
}
else if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING))
{
GValue tmp_value = { 0, };
-
+ gchar *s;
+
g_value_init (&tmp_value, G_TYPE_STRING);
g_value_transform (value, &tmp_value);
+ s = g_strescape (g_value_get_string (&tmp_value), NULL);
+ g_value_unset (&tmp_value);
if (G_VALUE_HOLDS_ENUM (value) || G_VALUE_HOLDS_FLAGS (value))
contents = g_strdup_printf ("((%s) %s)",
g_type_name (G_VALUE_TYPE (value)),
- g_value_get_string (&tmp_value));
+ s);
else
- {
- src = g_value_get_string (&tmp_value);
- contents = g_strdup (src ? src : "NULL");
- }
- g_value_unset (&tmp_value);
+ contents = g_strdup (s ? s : "NULL");
+ g_free (s);
}
else if (g_value_fits_pointer (value))
{
gchar *v_string);
+/* humpf, need a C representable type name for G_TYPE_STRING */
+typedef gchar* gchararray;
+
G_END_DECLS
scanner->max_parse_errors = 0;
scanner->parse_errors = 0;
scanner->input_name = NULL;
- scanner->derived_data = NULL;
+ g_datalist_init (&scanner->qdata);
scanner->config = g_new0 (GScannerConfig, 1);
{
g_return_if_fail (scanner != NULL);
+ g_datalist_clear (&scanner->qdata);
g_hash_table_foreach (scanner->symbol_table,
g_scanner_destroy_symbol_table_entry, NULL);
g_hash_table_destroy (scanner->symbol_table);
/* name of input stream, featured by the default message handler */
const gchar *input_name;
- /* data pointer for derived structures */
- gpointer derived_data;
+ /* quarked data */
+ GData *qdata;
/* link into the scanner configuration */
GScannerConfig *config;
g_slist_remove (GSList *list,
gconstpointer data)
{
- GSList *tmp;
- GSList *prev;
+ GSList *tmp, *prev = NULL;
- prev = NULL;
tmp = list;
-
while (tmp)
{
if (tmp->data == data)
{
if (prev)
prev->next = tmp->next;
- if (list == tmp)
- list = list->next;
-
- tmp->next = NULL;
- g_slist_free (tmp);
+ else
+ list = tmp->next;
+ g_slist_free_1 (tmp);
break;
}
-
prev = tmp;
- tmp = tmp->next;
+ tmp = prev->next;
+ }
+
+ return list;
+}
+
+GSList*
+g_slist_remove_all (GSList *list,
+ gconstpointer data)
+{
+ GSList *tmp, *prev = NULL;
+
+ tmp = list;
+ while (tmp)
+ {
+ if (tmp->data == data)
+ {
+ GSList *next = tmp->next;
+
+ if (prev)
+ prev->next = next;
+ else
+ list = next;
+
+ g_slist_free_1 (tmp);
+ tmp = next;
+ }
+ else
+ {
+ prev = tmp;
+ tmp = prev->next;
+ }
}
return list;
GSList *list2);
GSList* g_slist_remove (GSList *list,
gconstpointer data);
+GSList* g_slist_remove_all (GSList *list,
+ gconstpointer data);
GSList* g_slist_remove_link (GSList *list,
GSList *link);
GSList* g_slist_delete_link (GSList *list,
typedef long glong;
typedef int gint;
typedef gint gboolean;
-typedef gchar* gstring;
typedef unsigned char guchar;
typedef unsigned short gushort;