Commit 3b346e35 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

remove left-over usages of an anonymous GBoxed typedef.

Mon Jun 11 17:07:06 2001  Tim Janik  <timj@gtk.org>

        * gboxed.[hc]: remove left-over usages of an anonymous GBoxed typedef.

        * gobjectnotifyqueue.c: moved property notify queue implementation
        bits into this function.

        * gparam.[hc]: added g_param_spec_pool_belongings(), completed
        g_param_spec_pool_list(). added GParameter for _setv() functions.

        * gobject.[hc]: use gobjectnotifyqueue.h implementation now.
        got rid of properties_changed signal.
        new functions g_object_newv(), g_object_class_list_properties().
        removed "properties_changed" signal.

        * gtype.[hc]: added g_type_depth() to figure number of parent
        types + 1 for a type.

        * gsignal.h: add g_signal_connect() (as per owen's request) and
        g_signal_connect_swapped().
parent efc2ec72
......@@ -71,6 +71,7 @@ arrays or arrays on the stack.
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>.
......
......@@ -14,12 +14,6 @@ gboxed
</para>
<!-- ##### STRUCT GBoxed ##### -->
<para>
</para>
<!-- ##### USER_FUNCTION GBoxedCopyFunc ##### -->
<para>
......
<!-- ##### STRUCT GBoxed ##### -->
<para>
</para>
<!-- ##### FUNCTION g_closure_add_fnotify ##### -->
<para>
......
......@@ -25,6 +25,7 @@ Parameter Specifications
@blurb:
@flags:
@value_type:
@owner_type:
<!-- ##### STRUCT GParamSpecClass ##### -->
<para>
......
......@@ -26,7 +26,7 @@
G_BEGIN_DECLS
/* helper macro to avoid signed overflow for value comparisions */
#define G_BSEARCH_ARRAY_CMP(v1,v2) ((v1) < (v2) ? -1 : (v1) > (v2) ? 1 : 0)
#define G_BSEARCH_ARRAY_CMP(v1,v2) ((v1) < (v2) ? -1 : (v1) > (v2))
/* --- typedefs --- */
......
Mon Jun 11 17:07:06 2001 Tim Janik <timj@gtk.org>
* gboxed.[hc]: remove left-over usages of an anonymous GBoxed typedef.
* gobjectnotifyqueue.c: moved property notify queue implementation
bits into this function.
* gparam.[hc]: added g_param_spec_pool_belongings(), completed
g_param_spec_pool_list(). added GParameter for _setv() functions.
* gobject.[hc]: use gobjectnotifyqueue.h implementation now.
got rid of properties_changed signal.
new functions g_object_newv(), g_object_class_list_properties().
removed "properties_changed" signal.
* gtype.[hc]: added g_type_depth() to figure number of parent
types + 1 for a type.
* gsignal.h: add g_signal_connect() (as per owen's request) and
g_signal_connect_swapped().
2001-06-13 Havoc Pennington <hp@redhat.com>
* Makefile.am (progs_LDADD): link to ./libgobject-1.3.la
......
......@@ -52,9 +52,11 @@ gruntime_public_h_sources = @STRIP_BEGIN@ \
gvaluearray.h \
gvaluecollector.h \
gvaluetypes.h \
gobjectnotifyqueue.c \
@STRIP_END@
# GRuntime header files that don't get installed
gruntime_private_h_sources =
gruntime_private_h_sources = @STRIP_BEGIN@ \
@STRIP_END@
# GRuntime C sources to build the library from
gruntime_c_sources = @STRIP_BEGIN@ \
gboxed.c \
......
......@@ -333,7 +333,7 @@ g_boxed_type_register_static (const gchar *name,
return type;
}
GBoxed*
gpointer
g_boxed_copy (GType boxed_type,
gconstpointer src_boxed)
{
......
......@@ -29,14 +29,13 @@ G_BEGIN_DECLS
/* --- typedefs --- */
typedef struct _GBoxed GBoxed;
typedef gpointer (*GBoxedInitFunc) (void);
typedef gpointer (*GBoxedCopyFunc) (gpointer boxed);
typedef void (*GBoxedFreeFunc) (gpointer boxed);
/* --- prototypes --- */
GBoxed* g_boxed_copy (GType boxed_type,
gpointer g_boxed_copy (GType boxed_type,
gconstpointer src_boxed);
void g_boxed_free (GType boxed_type,
gpointer boxed);
......
......@@ -26,7 +26,7 @@
G_BEGIN_DECLS
/* helper macro to avoid signed overflow for value comparisions */
#define G_BSEARCH_ARRAY_CMP(v1,v2) ((v1) < (v2) ? -1 : (v1) > (v2) ? 1 : 0)
#define G_BSEARCH_ARRAY_CMP(v1,v2) ((v1) < (v2) ? -1 : (v1) > (v2))
/* --- typedefs --- */
......
This diff is collapsed.
......@@ -65,9 +65,7 @@ struct _GObjectClass
{
GTypeClass g_type_class;
/* private, these fields might vanish */
guint n_property_specs;
GParamSpec **property_specs;
/*< private >*/
GSList *construct_properties;
/* public overridable methods */
......@@ -85,15 +83,12 @@ struct _GObjectClass
void (*shutdown) (GObject *object);
void (*finalize) (GObject *object);
/*< private >*/
/* seldomly overidden */
void (*dispatch_properties_changed) (GObject *object,
guint n_pspecs,
GParamSpec **pspecs);
/* signals */
void (*properties_changed) (GObject *object,
guint n_pspecs,
GParamSpec **pspecs);
void (*notify) (GObject *object,
GParamSpec *pspec);
};
......@@ -110,9 +105,14 @@ void g_object_class_install_property (GObjectClass *oclass,
GParamSpec *pspec);
GParamSpec* g_object_class_find_property (GObjectClass *oclass,
const gchar *property_name);
GParamSpec**g_object_class_list_properties (GObjectClass *oclass,
guint *n_properties);
gpointer g_object_new (GType object_type,
const gchar *first_property_name,
...);
gpointer g_object_newv (GType object_type,
guint n_parameters,
GParameter *parameters);
gpointer g_object_new_valist (GType object_type,
const gchar *first_property_name,
va_list var_args);
......@@ -189,18 +189,21 @@ guint g_signal_connect_object (gpointer instance,
/* --- implementation macros --- */
#define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \
#define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \
G_STMT_START { \
GObject *_object = (GObject*) (object); \
GParamSpec *_pspec = (GParamSpec*) (pspec); \
guint _property_id = (property_id); \
g_warning ("%s: invalid property id %u for \"%s\" of type `%s' in `%s'", \
g_warning ("%s: invalid %s id %u for \"%s\" of type `%s' in `%s'", \
G_STRLOC, \
(pname), \
_property_id, \
_pspec->name, \
g_type_name (G_PARAM_SPEC_TYPE (_pspec)), \
G_OBJECT_TYPE_NAME (_object)); \
} G_STMT_END
#define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \
G_OBJECT_WARN_INVALID_PSPEC ((object), "property id", (property_id), (pspec))
G_END_DECLS
......
/* GObject - GLib Type, Object, Parameter and Signal Library
* Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __G_NOTIFY_H__
#define __G_NOTIFY_H__
#include <gobject/gobject.h>
G_BEGIN_DECLS
/* --- typedefs --- */
typedef struct _GObjectNotifyContext GObjectNotifyContext;
typedef struct _GObjectNotifyQueue GObjectNotifyQueue;
typedef void (*GObjectNotifyQueueDispatcher) (GObject *object,
guint n_pspecs,
GParamSpec **pspecs);
/* --- structures --- */
struct _GObjectNotifyContext
{
GQuark quark_notify_queue;
GObjectNotifyQueueDispatcher dispatcher;
GTrashStack *nqueue_trash;
};
struct _GObjectNotifyQueue
{
GObjectNotifyContext *context;
GSList *pspecs;
guint n_pspecs;
guint freeze_count;
};
/* --- functions --- */
static void
g_object_notify_queue_free (gpointer data)
{
GObjectNotifyQueue *nqueue = data;
g_slist_free (nqueue->pspecs);
g_trash_stack_push (&nqueue->context->nqueue_trash, nqueue);
}
static inline GObjectNotifyQueue*
g_object_notify_queue_freeze (GObject *object,
GObjectNotifyContext *context)
{
GObjectNotifyQueue *nqueue;
nqueue = g_datalist_id_get_data (&object->qdata, context->quark_notify_queue);
if (!nqueue)
{
nqueue = g_trash_stack_pop (&context->nqueue_trash);
if (!nqueue)
{
guint i;
nqueue = g_new (GObjectNotifyQueue, 16);
for (i = 0; i < 15; i++)
g_trash_stack_push (&context->nqueue_trash, nqueue++);
}
memset (nqueue, 0, sizeof (*nqueue));
nqueue->context = context;
g_datalist_id_set_data_full (&object->qdata, context->quark_notify_queue,
nqueue, g_object_notify_queue_free);
}
nqueue->freeze_count++;
return nqueue;
}
static inline void
g_object_notify_queue_thaw (GObject *object,
GObjectNotifyQueue *nqueue)
{
GObjectNotifyContext *context = nqueue->context;
GParamSpec *pspecs_mem[16], **pspecs, **free_me = NULL;
GSList *slist;
guint n_pspecs = 0;
g_return_if_fail (nqueue->freeze_count > 0);
nqueue->freeze_count--;
if (nqueue->freeze_count)
return;
g_return_if_fail (object->ref_count > 0);
pspecs = nqueue->n_pspecs > 16 ? free_me = g_new (GParamSpec*, nqueue->n_pspecs) : pspecs_mem;
for (slist = nqueue->pspecs; slist; slist = slist->next)
{
GParamSpec *pspec = slist->data;
gint i = 0;
/* dedup, make pspecs in the list unique */
redo_dedup_check:
if (pspecs[i] == pspec)
continue;
if (++i < n_pspecs)
goto redo_dedup_check;
pspecs[n_pspecs++] = pspec;
}
g_datalist_id_set_data (&object->qdata, context->quark_notify_queue, NULL);
if (n_pspecs)
context->dispatcher (object, n_pspecs, pspecs);
g_free (free_me);
}
static inline void
g_object_notify_queue_clear (GObject *object,
GObjectNotifyQueue *nqueue)
{
g_return_if_fail (nqueue->freeze_count > 0);
g_slist_free (nqueue->pspecs);
nqueue->pspecs = NULL;
nqueue->n_pspecs = 0;
}
static inline void
g_object_notify_queue_add (GObject *object,
GObjectNotifyQueue *nqueue,
GParamSpec *pspec)
{
if (pspec->flags & G_PARAM_READABLE)
{
/* we do the deduping in _thaw */
nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec);
nqueue->n_pspecs++;
}
}
static inline GObjectNotifyQueue*
g_object_notify_queue_from_object (GObject *object,
GObjectNotifyContext *context)
{
return g_datalist_id_get_data (&object->qdata, context->quark_notify_queue);
}
G_END_DECLS
#endif /* __G_OBJECT_H__ */
......@@ -144,6 +144,7 @@ g_param_spec_init (GParamSpec *pspec,
pspec->owner_type = 0;
pspec->qdata = NULL;
pspec->ref_count = 1;
pspec->param_id = 0;
g_datalist_id_set_data (&pspec->qdata, quark_floating, GUINT_TO_POINTER (TRUE));
}
......@@ -725,7 +726,7 @@ pool_list (gpointer key,
}
GList*
g_param_spec_pool_list (GParamSpecPool *pool,
g_param_spec_pool_belongings (GParamSpecPool *pool,
GType owner_type)
{
gpointer data[2];
......@@ -742,6 +743,99 @@ g_param_spec_pool_list (GParamSpecPool *pool,
return data[0];
}
static gint
pspec_compare_id (gconstpointer a,
gconstpointer b)
{
const GParamSpec *pspec1 = a, *pspec2 = b;
return pspec1->param_id < pspec2->param_id ? -1 : pspec1->param_id > pspec2->param_id;
}
static inline GSList*
pspec_list_remove_overridden (GSList *plist,
GHashTable *ht,
GType owner_type,
guint *n_p)
{
GSList *rlist = NULL;
while (plist)
{
GSList *tmp = plist->next;
GParamSpec *pspec = plist->data;
if (param_spec_ht_lookup (ht, pspec->name, owner_type, TRUE) != pspec)
g_slist_free_1 (plist);
else
{
plist->next = rlist;
rlist = plist;
*n_p += 1;
}
plist = tmp;
}
return rlist;
}
static void
pool_depth_list (gpointer key,
gpointer value,
gpointer user_data)
{
GParamSpec *pspec = value;
gpointer *data = user_data;
GSList **slists = data[0];
GType owner_type = GPOINTER_TO_UINT (data[1]);
if (g_type_is_a (owner_type, pspec->owner_type))
{
guint d = g_type_depth (pspec->owner_type);
slists[d - 1] = g_slist_prepend (slists[d - 1], pspec);
}
}
GParamSpec** /* free result */
g_param_spec_pool_list (GParamSpecPool *pool,
GType owner_type,
guint *n_pspecs_p)
{
GParamSpec **pspecs, **p;
GSList **slists, *node;
gpointer data[2];
guint d, i;
g_return_val_if_fail (pool != NULL, NULL);
g_return_val_if_fail (owner_type > 0, NULL);
g_return_val_if_fail (n_pspecs_p != NULL, NULL);
G_SLOCK (&pool->smutex);
*n_pspecs_p = 0;
d = g_type_depth (owner_type);
slists = g_new0 (GSList*, d);
data[0] = slists;
data[1] = GUINT_TO_POINTER (owner_type);
g_hash_table_foreach (pool->hash_table, pool_depth_list, &data);
for (i = 0; i < d - 1; i++)
slists[i] = pspec_list_remove_overridden (slists[i], pool->hash_table, owner_type, n_pspecs_p);
*n_pspecs_p += g_slist_length (slists[i]);
pspecs = g_new (GParamSpec*, *n_pspecs_p + 1);
p = pspecs;
for (i = 0; i < d; i++)
{
slists[i] = g_slist_sort (slists[i], pspec_compare_id);
for (node = slists[i]; node; node = node->next)
*p++ = node->data;
g_slist_free (slists[i]);
}
*p++ = NULL;
g_free (slists);
G_SUNLOCK (&pool->smutex);
return pspecs;
}
/* --- auxillary functions --- */
typedef struct
......
......@@ -56,6 +56,7 @@ typedef enum
/* --- typedefs & structures --- */
typedef struct _GParamSpec GParamSpec;
typedef struct _GParamSpecClass GParamSpecClass;
typedef struct _GParameter GParameter;
typedef struct _GParamSpecPool GParamSpecPool;
struct _GParamSpec
{
......@@ -66,11 +67,12 @@ struct _GParamSpec
gchar *blurb;
GParamFlags flags;
GType value_type;
GType owner_type; /* class using this property */
/*< private >*/
GType owner_type;
GData *qdata;
guint ref_count;
guint param_id; /* sort-criteria */
};
struct _GParamSpecClass
{
......@@ -89,6 +91,11 @@ struct _GParamSpecClass
const GValue *value1,
const GValue *value2);
};
struct _GParameter /* auxillary structure for _setv() variants */
{
const gchar *name;
GValue value;
};
/* --- prototypes --- */
......@@ -165,8 +172,11 @@ GParamSpec* g_param_spec_pool_lookup (GParamSpecPool *pool,
const gchar *param_name,
GType owner_type,
gboolean walk_ancestors);
GList* g_param_spec_pool_list (GParamSpecPool *pool,
GList* g_param_spec_pool_belongings (GParamSpecPool *pool,
GType owner_type);
GParamSpec** g_param_spec_pool_list (GParamSpecPool *pool,
GType owner_type,
guint *n_pspecs_p);
......
......@@ -222,6 +222,10 @@ guint g_signal_handlers_disconnect_matched (gpointer instance,
/* --- convenience --- */
#define g_signal_connectc(instance, detailed_signal, c_handler, data, swapped) \
g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (swapped), FALSE)
#define g_signal_connect(instance, detailed_signal, c_handler, data) \
g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, FALSE, FALSE)
#define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \
g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, TRUE, FALSE)
#define g_signal_disconnect_by_func(instance, func, data) \
g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, \
0, 0, NULL, (func), (data))
......
......@@ -2073,6 +2073,18 @@ g_type_parent (GType type)
return node ? NODE_PARENT_TYPE (node) : 0;
}
guint
g_type_depth (GType type)
{
TypeNode *node;
G_READ_LOCK (&type_rw_lock);
node = lookup_type_node_L (type);
G_READ_UNLOCK (&type_rw_lock);
return node ? node->n_supers + 1 : 0;
}
GType
g_type_next_base (GType type,
GType base_type)
......
......@@ -187,6 +187,7 @@ G_CONST_RETURN gchar* g_type_name (GType type);
GQuark g_type_qname (GType type);
GType g_type_from_name (const gchar *name);
GType g_type_parent (GType type);
guint g_type_depth (GType type);
GType g_type_next_base (GType leaf_type,
GType root_type);
gboolean g_type_is_a (GType type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment