Commit 09f8e937 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

define gstring in terms of gchar*. this typedef reflects the type name of

Fri Jun 23 17:20:26 2000  Tim Janik  <timj@gtk.org>

        * glib.h: define gstring in terms of gchar*. this typedef reflects
        the type name of the primitive G_TYPE_STRING in the gobject module.

Sat Jun 24 23:03:04 2000  Tim Janik  <timj@gtk.org>

        * gtype.[hc]: provide G_TYPE_CHAR, G_TYPE_UCHAR, G_TYPE_BOOLEAN,
        G_TYPE_INT, G_TYPE_UINT, G_TYPE_LONG, G_TYPE_ULONG, G_TYPE_FLOAT,
        G_TYPE_DOUBLE and G_TYPE_STRING fundamental types.
        added a GTypeValueTable* pointer to GTypeInfo structure for types
        to implement GValue handling functions.
        GTypeValueTable contains the following members:
          value_init(): initialize a GValue structure.
          value_free(): free GValue structure contents (optional).
          value_copy(): copy one GValue contents to another GValue structure of
          collect_type: varargs collection type for the first variable argument
          to be collected by collect_value().
          collect_value(): variable arguments collection function (optional).
          lcopy_type: varargs collection type for the first variable argument
          to be location copyied by lcopy_value().
          lcopy_value(): variable arguments location copy function (optional).
        g_type_value_table_peek(): new function to retrive the GTypeValueTable*
        for a type node. ValueTables get inherited from parent types, unless
        overridden through the GTypeInfo structure. internally, GTypeValueTable
        support means an added overhead of one pointer per static or used
        dynamic type node.
        g_type_add_class_cache_func(): provide a cache_func/data pair to be
        called  prior to a type nodes last_unref() function, this can be used
        to prevent premature class destruction. multiple installed cache_func()
        will be chained upon last_unref() untill one of them returns TRUE.
        the cache_func()s have to check the type id passed in to figure whether
        they actually wants to cache the class of this type (since any types are
        routed through the cache_func() chain).
        g_type_remove_class_cache_func(): remove a previously installed
        cache_func/data pair. the cache maintained by this function has to be
        clear when calling g_type_remove_class_cache_func() to avoid leaks.
        g_type_class_unref_uncached(): class unref function for cache_func()
        implementations, unreferences a class omitting the cache chain (and
        therefore unref->cache->unref->... loops).

        * gvaluetypes.[hc]: provide the value setters/getters for the primitive
        fundamental types boolean, char, uchar, int, uint, long, ulong, float,
        double and string.

        * gvalue.[hc]: provide G_TYPE_IS_VALUE() in terms of whether a
        GTypeValueTable is provided for this type.
        removed g_value_init_default(), g_value_validate(), g_value_defaults(),
        g_value_set_default() and g_values_cmp() as these are supplied by the
        GParamSpec API now.
        moved g_values_exchange() into the "implementation details" section,
        since it just provides the underlying functionality for
        g_value_convert().

        * gvaluecollector.h: renamed the varargs value container from
        GParamCValue to GTypeCValue as the value collection methods are
        supplied by the type system now.
        G_PARAM_COLLECT_VALUE() and G_PARAM_LCOPY_VALUE() got renamed to
        G_VALUE_COLLECT() and G_VALUE_LCOPY() and operate without a
        GParamSpec structure now.

        * genums.h: macros cleanups/fixes.

        * genum.c: provide G_TYPE_ENUM and G_TYPE_FLAGS type
        and assorted g_value_{s|g}et_{enum|flags}() implementations.

        * gobject.[hc]:
        provide G_IS_VALUE_OBJECT(), G_TYPE_OBJECT ValueTable methods
        and g_value_{s|g}et_object().

        * gparam.[hc]: reduced class to value_set_default(),
        value_validate() and values_cmp(). also parameters now need to fill
        in a GType value_type; field to indicate the GValue type they
        are handling. provide g_param_value_set_default(),
        g_param_value_defaults(), g_param_value_validate() and
        g_param_values_cmp().

        * gparamspecs.[hc]: got rid of the g_value_* functions and
        the G_IS_VALUE_* macros. adapted param spec implementations
        according to the GParamSpecClass changes.
parent 0891c648
Fri Jun 23 17:20:26 2000 Tim Janik <timj@gtk.org>
* glib.h: define gstring in terms of gchar*. this typedef reflects
the type name of the primitive G_TYPE_STRING in the gobject module.
Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com> Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com>
* gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h * gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h
......
Fri Jun 23 17:20:26 2000 Tim Janik <timj@gtk.org>
* glib.h: define gstring in terms of gchar*. this typedef reflects
the type name of the primitive G_TYPE_STRING in the gobject module.
Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com> Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com>
* gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h * gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h
......
Fri Jun 23 17:20:26 2000 Tim Janik <timj@gtk.org>
* glib.h: define gstring in terms of gchar*. this typedef reflects
the type name of the primitive G_TYPE_STRING in the gobject module.
Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com> Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com>
* gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h * gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h
......
Fri Jun 23 17:20:26 2000 Tim Janik <timj@gtk.org>
* glib.h: define gstring in terms of gchar*. this typedef reflects
the type name of the primitive G_TYPE_STRING in the gobject module.
Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com> Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com>
* gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h * gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h
......
Fri Jun 23 17:20:26 2000 Tim Janik <timj@gtk.org>
* glib.h: define gstring in terms of gchar*. this typedef reflects
the type name of the primitive G_TYPE_STRING in the gobject module.
Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com> Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com>
* gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h * gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h
......
Fri Jun 23 17:20:26 2000 Tim Janik <timj@gtk.org>
* glib.h: define gstring in terms of gchar*. this typedef reflects
the type name of the primitive G_TYPE_STRING in the gobject module.
Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com> Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com>
* gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h * gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h
......
Fri Jun 23 17:20:26 2000 Tim Janik <timj@gtk.org>
* glib.h: define gstring in terms of gchar*. this typedef reflects
the type name of the primitive G_TYPE_STRING in the gobject module.
Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com> Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com>
* gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h * gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h
......
Fri Jun 23 17:20:26 2000 Tim Janik <timj@gtk.org>
* glib.h: define gstring in terms of gchar*. this typedef reflects
the type name of the primitive G_TYPE_STRING in the gobject module.
Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com> Wed Jun 21 12:09:03 2000 Owen Taylor <otaylor@redhat.com>
* gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h * gunicode.h gutf8.c guniprop.c gunidecomp.[ch] gunichartables.h
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <gobject/gtype.h> #include <gobject/gtype.h>
#include <gobject/genums.h> #include <gobject/genums.h>
#include <gobject/gvalue.h> #include <gobject/gvalue.h>
#include <gobject/gvaluetypes.h>
#include <gobject/gparam.h> #include <gobject/gparam.h>
#include <gobject/gparamspecs.h> #include <gobject/gparamspecs.h>
#include <gobject/gobject.h> #include <gobject/gobject.h>
......
...@@ -500,6 +500,7 @@ typedef short gshort; ...@@ -500,6 +500,7 @@ typedef short gshort;
typedef long glong; typedef long glong;
typedef int gint; typedef int gint;
typedef gint gboolean; typedef gint gboolean;
typedef gchar* gstring;
typedef unsigned char guchar; typedef unsigned char guchar;
typedef unsigned short gushort; typedef unsigned short gushort;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <gobject/gtype.h> #include <gobject/gtype.h>
#include <gobject/genums.h> #include <gobject/genums.h>
#include <gobject/gvalue.h> #include <gobject/gvalue.h>
#include <gobject/gvaluetypes.h>
#include <gobject/gparam.h> #include <gobject/gparam.h>
#include <gobject/gparamspecs.h> #include <gobject/gparamspecs.h>
#include <gobject/gobject.h> #include <gobject/gobject.h>
......
...@@ -500,6 +500,7 @@ typedef short gshort; ...@@ -500,6 +500,7 @@ typedef short gshort;
typedef long glong; typedef long glong;
typedef int gint; typedef int gint;
typedef gint gboolean; typedef gint gboolean;
typedef gchar* gstring;
typedef unsigned char guchar; typedef unsigned char guchar;
typedef unsigned short gushort; typedef unsigned short gushort;
......
Sat Jun 24 23:03:04 2000 Tim Janik <timj@gtk.org>
* gtype.[hc]: provide G_TYPE_CHAR, G_TYPE_UCHAR, G_TYPE_BOOLEAN,
G_TYPE_INT, G_TYPE_UINT, G_TYPE_LONG, G_TYPE_ULONG, G_TYPE_FLOAT,
G_TYPE_DOUBLE and G_TYPE_STRING fundamental types.
added a GTypeValueTable* pointer to GTypeInfo structure for types
to implement GValue handling functions.
GTypeValueTable contains the following members:
value_init(): initialize a GValue structure.
value_free(): free GValue structure contents (optional).
value_copy(): copy one GValue contents to another GValue structure of
collect_type: varargs collection type for the first variable argument
to be collected by collect_value().
collect_value(): variable arguments collection function (optional).
lcopy_type: varargs collection type for the first variable argument
to be location copyied by lcopy_value().
lcopy_value(): variable arguments location copy function (optional).
g_type_value_table_peek(): new function to retrive the GTypeValueTable*
for a type node. ValueTables get inherited from parent types, unless
overridden through the GTypeInfo structure. internally, GTypeValueTable
support means an added overhead of one pointer per static or used
dynamic type node.
g_type_add_class_cache_func(): provide a cache_func/data pair to be
called prior to a type nodes last_unref() function, this can be used
to prevent premature class destruction. multiple installed cache_func()
will be chained upon last_unref() untill one of them returns TRUE.
the cache_func()s have to check the type id passed in to figure whether
they actually wants to cache the class of this type (since any types are
routed through the cache_func() chain).
g_type_remove_class_cache_func(): remove a previously installed
cache_func/data pair. the cache maintained by this function has to be
clear when calling g_type_remove_class_cache_func() to avoid leaks.
g_type_class_unref_uncached(): class unref function for cache_func()
implementations, unreferences a class omitting the cache chain (and
therefore unref->cache->unref->... loops).
* gvaluetypes.[hc]: provide the value setters/getters for the primitive
fundamental types boolean, char, uchar, int, uint, long, ulong, float,
double and string.
* gvalue.[hc]: provide G_TYPE_IS_VALUE() in terms of whether a
GTypeValueTable is provided for this type.
removed g_value_init_default(), g_value_validate(), g_value_defaults(),
g_value_set_default() and g_values_cmp() as these are supplied by the
GParamSpec API now.
moved g_values_exchange() into the "implementation details" section,
since it just provides the underlying functionality for
g_value_convert().
* gvaluecollector.h: renamed the varargs value container from
GParamCValue to GTypeCValue as the value collection methods are
supplied by the type system now.
G_PARAM_COLLECT_VALUE() and G_PARAM_LCOPY_VALUE() got renamed to
G_VALUE_COLLECT() and G_VALUE_LCOPY() and operate without a
GParamSpec structure now.
* genums.h: macros cleanups/fixes.
* genum.c: provide G_TYPE_ENUM and G_TYPE_FLAGS type
and assorted g_value_{s|g}et_{enum|flags}() implementations.
* gobject.[hc]:
provide G_IS_VALUE_OBJECT(), G_TYPE_OBJECT ValueTable methods
and g_value_{s|g}et_object().
* gparam.[hc]: reduced class to value_set_default(),
value_validate() and values_cmp(). also parameters now need to fill
in a GType value_type; field to indicate the GValue type they
are handling. provide g_param_value_set_default(),
g_param_value_defaults(), g_param_value_validate() and
g_param_values_cmp().
* gparamspecs.[hc]: got rid of the g_value_* functions and
the G_IS_VALUE_* macros. adapted param spec implementations
according to the GParamSpecClass changes.
Sat Jun 10 08:38:27 2000 Tim Janik <timj@gtk.org> Sat Jun 10 08:38:27 2000 Tim Janik <timj@gtk.org>
* gtype.c (type_class_init): fetch the nth iface entry of the * gtype.c (type_class_init): fetch the nth iface entry of the
......
...@@ -28,6 +28,7 @@ libgobject_la_LIBADD = # $(libglib) ...@@ -28,6 +28,7 @@ libgobject_la_LIBADD = # $(libglib)
# GObject header files for public installation (non-generated) # GObject header files for public installation (non-generated)
gobject_public_h_sources = @STRIP_BEGIN@ \ gobject_public_h_sources = @STRIP_BEGIN@ \
gvalue.h \ gvalue.h \
gvaluetypes.h \
gparam.h \ gparam.h \
gparamspecs.h \ gparamspecs.h \
genums.h \ genums.h \
...@@ -42,6 +43,7 @@ gobject_private_h_sources = @STRIP_BEGIN@ \ ...@@ -42,6 +43,7 @@ gobject_private_h_sources = @STRIP_BEGIN@ \
# GObject C sources to build the library from # GObject C sources to build the library from
gobject_c_sources = @STRIP_BEGIN@ \ gobject_c_sources = @STRIP_BEGIN@ \
gvalue.c \ gvalue.c \
gvaluetypes.c \
gparam.c \ gparam.c \
gparamspecs.c \ gparamspecs.c \
genums.c \ genums.c \
......
...@@ -18,24 +18,35 @@ ...@@ -18,24 +18,35 @@
*/ */
#include "genums.h" #include "genums.h"
#include "gvalue.h"
#include "gvaluecollector.h"
/* --- prototypes --- */ /* --- prototypes --- */
extern void g_enum_types_init (void);
static void g_enum_class_init (GEnumClass *class, static void g_enum_class_init (GEnumClass *class,
gpointer class_data); gpointer class_data);
static void g_flags_class_init (GFlagsClass *class, static void g_flags_class_init (GFlagsClass *class,
gpointer class_data); gpointer class_data);
static void g_value_enum_init (GValue *value);
static void g_value_enum_copy_value (const GValue *src_value,
GValue *dest_value);
static gchar* g_value_enum_collect_value (GValue *value,
guint nth_value,
GType *collect_type,
GTypeCValue *collect_value);
static gchar* g_value_enum_lcopy_value (const GValue *value,
guint nth_value,
GType *collect_type,
GTypeCValue *collect_value);
/* --- functions --- */ /* --- functions --- */
void void
g_enum_types_init (void) /* sync with glib-gtype.c */ g_enum_types_init (void) /* sync with gtype.c */
{ {
static gboolean initialized = FALSE; static gboolean initialized = FALSE;
static const GTypeFundamentalInfo finfo = { static const GTypeFundamentalInfo finfo = {
G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_DERIVABLE, G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_DERIVABLE,
0 /* n_collect_bytes */,
NULL /* GTypeParamCollector */,
}; };
static GTypeInfo info = { static GTypeInfo info = {
0 /* class_size */, 0 /* class_size */,
...@@ -45,21 +56,32 @@ g_enum_types_init (void) /* sync with glib-gtype.c */ ...@@ -45,21 +56,32 @@ g_enum_types_init (void) /* sync with glib-gtype.c */
NULL /* class_finalize */, NULL /* class_finalize */,
NULL /* class_data */, NULL /* class_data */,
}; };
static const GTypeValueTable value_table = {
g_value_enum_init, /* value_init */
NULL, /* value_free */
g_value_enum_copy_value, /* value_copy */
G_VALUE_COLLECT_INT, /* collect_type */
g_value_enum_collect_value, /* collect_value */
G_VALUE_COLLECT_POINTER, /* lcopy_type */
g_value_enum_lcopy_value, /* lcopy_value */
};
GType type; GType type;
g_return_if_fail (initialized == FALSE); g_return_if_fail (initialized == FALSE);
initialized = TRUE; initialized = TRUE;
info.value_table = &value_table;
/* G_TYPE_ENUM /* G_TYPE_ENUM
*/ */
info.class_size = sizeof (GEnumClass); info.class_size = sizeof (GEnumClass);
type = g_type_register_fundamental (G_TYPE_ENUM, "GEnum", &finfo, &info); type = g_type_register_fundamental (G_TYPE_ENUM, "GEnum", &info, &finfo);
g_assert (type == G_TYPE_ENUM); g_assert (type == G_TYPE_ENUM);
/* G_TYPE_FLAGS /* G_TYPE_FLAGS
*/ */
info.class_size = sizeof (GFlagsClass); info.class_size = sizeof (GFlagsClass);
type = g_type_register_fundamental (G_TYPE_FLAGS, "GFlags", &finfo, &info); type = g_type_register_fundamental (G_TYPE_FLAGS, "GFlags", &info, &finfo);
g_assert (type == G_TYPE_FLAGS); g_assert (type == G_TYPE_FLAGS);
} }
...@@ -304,3 +326,79 @@ g_flags_get_first_value (GFlagsClass *flags_class, ...@@ -304,3 +326,79 @@ g_flags_get_first_value (GFlagsClass *flags_class,
return NULL; return NULL;
} }
void
g_value_set_enum (GValue *value,
gint v_enum)
{
g_return_if_fail (G_IS_VALUE_ENUM (value));
value->data[0].v_long = v_enum;
}
gint
g_value_get_enum (GValue *value)
{
g_return_val_if_fail (G_IS_VALUE_ENUM (value), 0);
return value->data[0].v_long;
}
void
g_value_set_flags (GValue *value,
guint v_flags)
{
g_return_if_fail (G_IS_VALUE_FLAGS (value));
value->data[0].v_ulong = v_flags;
}
guint
g_value_get_flags (GValue *value)
{
g_return_val_if_fail (G_IS_VALUE_FLAGS (value), 0);
return value->data[0].v_ulong;
}
static void
g_value_enum_init (GValue *value)
{
value->data[0].v_long = 0;
}
static void
g_value_enum_copy_value (const GValue *src_value,
GValue *dest_value)
{
dest_value->data[0].v_long = src_value->data[0].v_long;
}
static gchar*
g_value_enum_collect_value (GValue *value,
guint nth_value,
GType *collect_type,
GTypeCValue *collect_value)
{
value->data[0].v_long = collect_value->v_int;
*collect_type = 0;
return NULL;
}
static gchar*
g_value_enum_lcopy_value (const GValue *value,
guint nth_value,
GType *collect_type,
GTypeCValue *collect_value)
{
gint *int_p = collect_value->v_pointer;
if (!int_p)
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
*int_p = value->data[0].v_long;
*collect_type = 0;
return NULL;
}
...@@ -28,16 +28,18 @@ extern "C" { ...@@ -28,16 +28,18 @@ extern "C" {
/* --- type macros --- */ /* --- type macros --- */
#define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM) #define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM)
#define G_ENUM_TYPE(class) (G_TYPE_FROM_CLASS (class)) #define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass))
#define G_ENUM_NAME(class) (g_type_name (G_ENUM_TYPE (class))) #define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM))
#define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass)) #define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
#define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM)) #define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_TYPE (class)))
#define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS) #define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS)
#define G_FLAGS_TYPE(class) (G_TYPE_FROM_CLASS (class)) #define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass))
#define G_FLAGS_NAME(class) (g_type_name (G_FLAGS_TYPE (class))) #define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))
#define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass)) #define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
#define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS)) #define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_TYPE (class)))
#define G_IS_VALUE_ENUM(value) (G_TYPE_CHECK_CLASS_TYPE ((value), G_TYPE_ENUM))
#define G_IS_VALUE_FLAGS(value) (G_TYPE_CHECK_CLASS_TYPE ((value), G_TYPE_FLAGS))
/* --- enum/flag values & classes --- */ /* --- enum/flag values & classes --- */
...@@ -89,6 +91,13 @@ GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class, ...@@ -89,6 +91,13 @@ GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class,
const gchar *name); const gchar *name);
GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class, GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class,
const gchar *nick); const gchar *nick);
void g_value_set_enum (GValue *value,
gint v_enum);
gint g_value_get_enum (GValue *value);
void g_value_set_flags (GValue *value,
guint v_flags);
guint g_value_get_flags (GValue *value);
/* --- registration functions --- */ /* --- registration functions --- */
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "gobject.h" #include "gobject.h"
#include "gvalue.h"
#include "gvaluecollector.h" #include "gvaluecollector.h"
...@@ -31,18 +30,29 @@ ...@@ -31,18 +30,29 @@
/* --- prototypes --- */ /* --- prototypes --- */
extern void g_object_type_init (void);
static void g_object_base_class_init (GObjectClass *class); static void g_object_base_class_init (GObjectClass *class);
static void g_object_base_class_finalize (GObjectClass *class); static void g_object_base_class_finalize (GObjectClass *class);
static void g_object_do_class_init (GObjectClass *class); static void g_object_do_class_init (GObjectClass *class);
static void g_object_do_init (GObject *object); static void g_object_do_init (GObject *object);
static void g_object_do_queue_param_changed (GObject *object, static void g_object_do_queue_param_changed (GObject *object,
GParamSpec *pspec); GParamSpec *pspec);
static void g_object_do_dispatch_param_changed (GObject *object, static void g_object_do_dispatch_param_changed (GObject *object,
GParamSpec *pspec); GParamSpec *pspec);
static void g_object_last_unref (GObject *object); static void g_object_last_unref (GObject *object);
static void g_object_do_shutdown (GObject *object); static void g_object_do_shutdown (GObject *object);
static void g_object_do_finalize (GObject *object); static void g_object_do_finalize (GObject *object);
static void g_value_object_init (GValue *value);
static void g_value_object_free_value (GValue *value);
static void g_value_object_copy_value (const GValue *src_value,
GValue *dest_value);
static gchar* g_value_object_collect_value (GValue *value,
guint nth_value,
GType *collect_type,
GTypeCValue *collect_value);
static gchar* g_value_object_lcopy_value (const GValue *value,
guint nth_value,
GType *collect_type,
GTypeCValue *collect_value);
/* --- variables --- */ /* --- variables --- */
...@@ -61,7 +71,7 @@ debug_objects_foreach (gpointer key, ...@@ -61,7 +71,7 @@ debug_objects_foreach (gpointer key,
gpointer user_data) gpointer user_data)
{ {
GObject *object = value; GObject *object = value;
g_message ("[%p] stale %s\tref_count=%u", g_message ("[%p] stale %s\tref_count=%u",
object, object,
G_OBJECT_TYPE_NAME (object), G_OBJECT_TYPE_NAME (object),
...@@ -79,13 +89,11 @@ debug_objects_atexit (void) ...@@ -79,13 +89,11 @@ debug_objects_atexit (void)
#endif DEBUG_OBJECTS #endif DEBUG_OBJECTS
void void
g_object_type_init (void) /* sync with glib-gtype.c */ g_object_type_init (void) /* sync with gtype.c */
{ {
static gboolean initialized = FALSE; static gboolean initialized = FALSE;
static const GTypeFundamentalInfo finfo = { static const GTypeFundamentalInfo finfo = {
G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE, G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE,
0 /* n_collect_bytes */,
NULL /* GTypeParamCollector */,
}; };
static GTypeInfo info = { static GTypeInfo info = {
sizeof (GObjectClass), sizeof (GObjectClass),
...@@ -97,6 +105,16 @@ g_object_type_init (void) /* sync with glib-gtype.c */ ...@@ -97,6 +105,16 @@ g_object_type_init (void) /* sync with glib-gtype.c */
sizeof (GObject), sizeof (GObject),
0 /* n_preallocs */, 0 /* n_preallocs */,
(GInstanceInitFunc) g_object_do_init, (GInstanceInitFunc) g_object_do_init,
NULL, /* value_table */
};
static const GTypeValueTable value_table = {
g_value_object_init, /* value_init */
g_value_object_free_value, /* value_free */
g_value_object_copy_value, /* value_copy */
G_VALUE_COLLECT_POINTER, /* collect_type */
g_value_object_collect_value, /* collect_value */
G_VALUE_COLLECT_POINTER, /* lcopy_type */
g_value_object_lcopy_value, /* lcopy_value */
}; };
GType type; GType type;
...@@ -105,12 +123,13 @@ g_object_type_init (void) /* sync with glib-gtype.c */ ...@@ -105,12 +123,13 @@ g_object_type_init (void) /* sync with glib-gtype.c */
/* G_TYPE_OBJECT /* G_TYPE_OBJECT
*/ */
type = g_type_register_fundamental (G_TYPE_OBJECT, "GObject", &finfo, &info); info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_OBJECT, "GObject", &info, &finfo);
g_assert (type == G_TYPE_OBJECT); g_assert (type == G_TYPE_OBJECT);
#ifdef DEBUG_OBJECTS #ifdef DEBUG_OBJECTS
g_atexit (debug_objects_atexit); g_atexit (debug_objects_atexit);
#endif DEBUG_OBJECTS #endif DEBUG_OBJECTS
} }
static void static void
...@@ -127,7 +146,7 @@ static void ...@@ -127,7 +146,7 @@ static void
g_object_base_class_finalize (GObjectClass *class) g_object_base_class_finalize (GObjectClass *class)
{ {
guint i; guint i;
g_message ("finallizing base class of %s", G_OBJECT_CLASS_NAME (class)); g_message ("finallizing base class of %s", G_OBJECT_CLASS_NAME (class));
for (i = 0; i < class->n_param_specs; i++) for (i = 0; i < class->n_param_specs; i++)
...@@ -158,11 +177,11 @@ g_object_do_class_init (GObjectClass *class) ...@@ -158,11 +177,11 @@ g_object_do_class_init (GObjectClass *class)
void void
g_object_class_install_param (GObjectClass *class, g_object_class_install_param (GObjectClass *class,
guint param_id, guint param_id,
GParamSpec *pspec /* 1 ref_count taken over */) GParamSpec *pspec /* 1 ref_count taken over */)
{ {
guint i; guint i;
g_return_if_fail (G_IS_OBJECT_CLASS (class));