mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-12 13:49:22 +01:00
applied patch from owen to implement GParamSpecUnichar.
Sat Mar 31 23:55:58 2001 Tim Janik <timj@gtk.org> * gtype.h: * gparamspecs.[hc]: applied patch from owen to implement GParamSpecUnichar. Fri Mar 30 07:34:02 2001 Tim Janik <timj@gtk.org> * gtype.c (type_iface_retrive_holder_info_Wm): * gtypeplugin.c (g_type_plugin_complete_interface_info): * gtypemodule.c (g_type_module_complete_interface_info): change order of instance_type and interface_type so they match the g_type_add_interface_*() API. * gsignal.c (g_signal_emit_valist): always assign C return value location, people depending on unaltered return values after emissions that had no handlers to run need to use g_signal_emitv(). * gtype.[hc] (g_type_query): new function to allow querying of class and object size (semantics like g_signal_query()). currently the implementation is better held conservative so as to only support types that are classed and static.
This commit is contained in:
parent
a2b269bae3
commit
743f49cec9
@ -211,6 +211,7 @@ The predefined identifiers of the reserved fundamental types.
|
||||
@G_TYPE_PARAM_UINT: Identifier for the "#GParamSpecUInt" type.
|
||||
@G_TYPE_PARAM_LONG: Identifier for the "#GParamSpecLong" type.
|
||||
@G_TYPE_PARAM_ULONG: Identifier for the "#GParamSpecULong" type.
|
||||
@G_TYPE_PARAM_UNICHAR:
|
||||
@G_TYPE_PARAM_ENUM: Identifier for the "#GParamSpecEnum" type.
|
||||
@G_TYPE_PARAM_FLAGS: Identifier for the "#GParamSpecFlags" type.
|
||||
@G_TYPE_PARAM_FLOAT: Identifier for the "#GParamSpecFloat" type.
|
||||
|
@ -1,3 +1,26 @@
|
||||
Sat Mar 31 23:55:58 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtype.h:
|
||||
* gparamspecs.[hc]: applied patch from owen to implement
|
||||
GParamSpecUnichar.
|
||||
|
||||
Fri Mar 30 07:34:02 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtype.c (type_iface_retrive_holder_info_Wm):
|
||||
* gtypeplugin.c (g_type_plugin_complete_interface_info):
|
||||
* gtypemodule.c (g_type_module_complete_interface_info):
|
||||
change order of instance_type and interface_type so they match
|
||||
the g_type_add_interface_*() API.
|
||||
|
||||
* gsignal.c (g_signal_emit_valist): always assign C return value
|
||||
location, people depending on unaltered return values after emissions
|
||||
that had no handlers to run need to use g_signal_emitv().
|
||||
|
||||
* gtype.[hc] (g_type_query): new function to allow querying of
|
||||
class and object size (semantics like g_signal_query()).
|
||||
currently the implementation is better held conservative so as to
|
||||
only support types that are classed and static.
|
||||
|
||||
2001-03-29 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* gobject.def: Updates.
|
||||
|
@ -278,6 +278,48 @@ param_ulong_values_cmp (GParamSpec *pspec,
|
||||
return value1->data[0].v_ulong > value2->data[0].v_ulong;
|
||||
}
|
||||
|
||||
static void
|
||||
param_unichar_init (GParamSpec *pspec)
|
||||
{
|
||||
GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec);
|
||||
|
||||
uspec->default_value = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
param_unichar_set_default (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
value->data[0].v_uint = G_PARAM_SPEC_UNICHAR (pspec)->default_value;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
param_unichar_validate (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
gunichar oval = value->data[0].v_uint;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
if (!g_unichar_validate (oval))
|
||||
{
|
||||
value->data[0].v_uint = 0;
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static gint
|
||||
param_unichar_values_cmp (GParamSpec *pspec,
|
||||
const GValue *value1,
|
||||
const GValue *value2)
|
||||
{
|
||||
if (value1->data[0].v_uint < value2->data[0].v_uint)
|
||||
return -1;
|
||||
else
|
||||
return value1->data[0].v_uint > value2->data[0].v_uint;
|
||||
}
|
||||
|
||||
static void
|
||||
param_enum_init (GParamSpec *pspec)
|
||||
{
|
||||
@ -999,8 +1041,25 @@ g_param_spec_types_init (void) /* sync with gtype.c */
|
||||
type = g_param_type_register_static ("GParamULong", &pspec_info);
|
||||
g_assert (type == G_TYPE_PARAM_ULONG);
|
||||
}
|
||||
|
||||
/* G_TYPE_PARAM_ENUM
|
||||
|
||||
/* G_TYPE_PARAM_UNICHAR
|
||||
*/
|
||||
{
|
||||
static const GParamSpecTypeInfo pspec_info = {
|
||||
sizeof (GParamSpecUnichar), /* instance_size */
|
||||
16, /* n_preallocs */
|
||||
param_unichar_init, /* instance_init */
|
||||
G_TYPE_UINT, /* value_type */
|
||||
NULL, /* finalize */
|
||||
param_unichar_set_default, /* value_set_default */
|
||||
param_unichar_validate, /* value_validate */
|
||||
param_unichar_values_cmp, /* values_cmp */
|
||||
};
|
||||
type = g_param_type_register_static ("GParamUnichar", &pspec_info);
|
||||
g_assert (type == G_TYPE_PARAM_UNICHAR);
|
||||
}
|
||||
|
||||
/* G_TYPE_PARAM_ENUM
|
||||
*/
|
||||
{
|
||||
static const GParamSpecTypeInfo pspec_info = {
|
||||
@ -1368,6 +1427,26 @@ g_param_spec_ulong (const gchar *name,
|
||||
return G_PARAM_SPEC (uspec);
|
||||
}
|
||||
|
||||
GParamSpec*
|
||||
g_param_spec_unichar (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
gunichar default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecUnichar *uspec;
|
||||
|
||||
uspec = g_param_spec_internal (G_TYPE_PARAM_UNICHAR,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
flags);
|
||||
|
||||
uspec->default_value = default_value;
|
||||
|
||||
return G_PARAM_SPEC (uspec);
|
||||
}
|
||||
|
||||
GParamSpec*
|
||||
g_param_spec_enum (const gchar *name,
|
||||
const gchar *nick,
|
||||
|
@ -43,6 +43,8 @@ G_BEGIN_DECLS
|
||||
#define G_IS_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG))
|
||||
#define G_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong))
|
||||
#define G_IS_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG))
|
||||
#define G_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UNICHAR, GParamSpecUnichar))
|
||||
#define G_IS_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UNICHAR))
|
||||
#define G_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong))
|
||||
#define G_IS_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM))
|
||||
#define G_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum))
|
||||
@ -76,6 +78,7 @@ typedef struct _GParamSpecInt GParamSpecInt;
|
||||
typedef struct _GParamSpecUInt GParamSpecUInt;
|
||||
typedef struct _GParamSpecLong GParamSpecLong;
|
||||
typedef struct _GParamSpecULong GParamSpecULong;
|
||||
typedef struct _GParamSpecUnichar GParamSpecUnichar;
|
||||
typedef struct _GParamSpecEnum GParamSpecEnum;
|
||||
typedef struct _GParamSpecFlags GParamSpecFlags;
|
||||
typedef struct _GParamSpecFloat GParamSpecFloat;
|
||||
@ -141,6 +144,12 @@ struct _GParamSpecULong
|
||||
gulong maximum;
|
||||
gulong default_value;
|
||||
};
|
||||
struct _GParamSpecUnichar
|
||||
{
|
||||
GParamSpec parent_instance;
|
||||
|
||||
gunichar default_value;
|
||||
};
|
||||
struct _GParamSpecEnum
|
||||
{
|
||||
GParamSpec parent_instance;
|
||||
@ -260,6 +269,11 @@ GParamSpec* g_param_spec_ulong (const gchar *name,
|
||||
gulong maximum,
|
||||
gulong default_value,
|
||||
GParamFlags flags);
|
||||
GParamSpec* g_param_spec_unichar (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
gunichar default_value,
|
||||
GParamFlags flags);
|
||||
GParamSpec* g_param_spec_enum (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
|
@ -1783,11 +1783,11 @@ g_signal_emit_valist (gpointer instance,
|
||||
gchar *error = NULL;
|
||||
|
||||
g_value_init (&return_value, node->return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE);
|
||||
if (signal_emit_R (node, detail, instance, &return_value, instance_and_params))
|
||||
G_VALUE_LCOPY (&return_value,
|
||||
var_args,
|
||||
node->return_type & G_SIGNAL_TYPE_STATIC_SCOPE ? G_VALUE_NOCOPY_CONTENTS : 0,
|
||||
&error);
|
||||
signal_emit_R (node, detail, instance, &return_value, instance_and_params);
|
||||
G_VALUE_LCOPY (&return_value,
|
||||
var_args,
|
||||
node->return_type & G_SIGNAL_TYPE_STATIC_SCOPE ? G_VALUE_NOCOPY_CONTENTS : 0,
|
||||
&error);
|
||||
if (!error)
|
||||
g_value_unset (&return_value);
|
||||
else
|
||||
|
@ -162,7 +162,7 @@ struct _TypeNode
|
||||
#define MAX_N_PREREQUISITES (MAX_N_IFACES)
|
||||
#define NODE_TYPE(node) (node->supers[0])
|
||||
#define NODE_PARENT_TYPE(node) (node->supers[1])
|
||||
#define NODE_NAME(node) ((gchar*)g_quark_to_string (node->qname))
|
||||
#define NODE_NAME(node) (g_quark_to_string (node->qname))
|
||||
#define NODE_IS_IFACE(node) (G_TYPE_IS_INTERFACE (NODE_TYPE (node)))
|
||||
#define CLASSED_NODE_N_IFACES(node) ((node)->_prot_n_ifaces_prerequisites)
|
||||
#define CLASSED_NODE_IFACES_ENTRIES(node) ((node)->_prot.iface_entries)
|
||||
@ -1225,7 +1225,7 @@ type_iface_retrive_holder_info_Wm (TypeNode *iface,
|
||||
|
||||
G_WRITE_UNLOCK (&type_rw_lock);
|
||||
g_type_plugin_use (iholder->plugin);
|
||||
g_type_plugin_complete_interface_info (iholder->plugin, NODE_TYPE (iface), instance_type, &tmp_info);
|
||||
g_type_plugin_complete_interface_info (iholder->plugin, instance_type, NODE_TYPE (iface), &tmp_info);
|
||||
G_WRITE_LOCK (&type_rw_lock);
|
||||
if (iholder->info)
|
||||
INVALID_RECURSION ("g_type_plugin_*", iholder->plugin, NODE_NAME (iface));
|
||||
@ -2354,6 +2354,33 @@ type_add_flags_W (TypeNode *node,
|
||||
type_set_qdata_W (node, static_quark_type_flags, GUINT_TO_POINTER (dflags));
|
||||
}
|
||||
|
||||
void
|
||||
g_type_query (GType type,
|
||||
GTypeQuery *query)
|
||||
{
|
||||
TypeNode *node;
|
||||
|
||||
g_return_if_fail (query != NULL);
|
||||
|
||||
G_READ_LOCK (&type_rw_lock);
|
||||
node = lookup_type_node_L (type);
|
||||
if (node && node->is_classed && !node->plugin && node->data)
|
||||
{
|
||||
/* type is classed and static, probably even instantiatable */
|
||||
|
||||
query->type = NODE_TYPE (node);
|
||||
query->type_name = NODE_NAME (node);
|
||||
query->class_size = node->data->class.class_size;
|
||||
query->instance_size = node->is_instantiatable ? node->data->instance.instance_size : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* node is not static and classed, won't allow query */
|
||||
query->type = 0;
|
||||
}
|
||||
G_READ_UNLOCK (&type_rw_lock);
|
||||
}
|
||||
|
||||
|
||||
/* --- implementation details --- */
|
||||
gboolean
|
||||
|
@ -79,17 +79,18 @@ typedef enum /*< skip >*/
|
||||
G_TYPE_PARAM_UINT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 5),
|
||||
G_TYPE_PARAM_LONG = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 6),
|
||||
G_TYPE_PARAM_ULONG = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 7),
|
||||
G_TYPE_PARAM_ENUM = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 8),
|
||||
G_TYPE_PARAM_FLAGS = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 9),
|
||||
G_TYPE_PARAM_FLOAT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 10),
|
||||
G_TYPE_PARAM_DOUBLE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 11),
|
||||
G_TYPE_PARAM_STRING = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 12),
|
||||
G_TYPE_PARAM_PARAM = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 13),
|
||||
G_TYPE_PARAM_BOXED = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 14),
|
||||
G_TYPE_PARAM_POINTER = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 15),
|
||||
G_TYPE_PARAM_VALUE_ARRAY = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 16),
|
||||
G_TYPE_PARAM_CLOSURE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17),
|
||||
G_TYPE_PARAM_OBJECT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18)
|
||||
G_TYPE_PARAM_UNICHAR = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 8),
|
||||
G_TYPE_PARAM_ENUM = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 9),
|
||||
G_TYPE_PARAM_FLAGS = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 10),
|
||||
G_TYPE_PARAM_FLOAT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 11),
|
||||
G_TYPE_PARAM_DOUBLE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 12),
|
||||
G_TYPE_PARAM_STRING = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 13),
|
||||
G_TYPE_PARAM_PARAM = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 14),
|
||||
G_TYPE_PARAM_BOXED = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 15),
|
||||
G_TYPE_PARAM_POINTER = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 16),
|
||||
G_TYPE_PARAM_VALUE_ARRAY = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17),
|
||||
G_TYPE_PARAM_CLOSURE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18),
|
||||
G_TYPE_PARAM_OBJECT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 19)
|
||||
} GTypeFundamentals;
|
||||
|
||||
|
||||
@ -122,6 +123,7 @@ typedef struct _GTypeInfo GTypeInfo;
|
||||
typedef struct _GTypeFundamentalInfo GTypeFundamentalInfo;
|
||||
typedef struct _GInterfaceInfo GInterfaceInfo;
|
||||
typedef struct _GTypeValueTable GTypeValueTable;
|
||||
typedef struct _GTypeQuery GTypeQuery;
|
||||
|
||||
|
||||
/* Basic Type Structures
|
||||
@ -142,6 +144,13 @@ struct _GTypeInterface
|
||||
GType g_type; /* iface type */
|
||||
GType g_instance_type;
|
||||
};
|
||||
struct _GTypeQuery
|
||||
{
|
||||
GType type;
|
||||
const gchar *type_name;
|
||||
guint class_size;
|
||||
guint instance_size;
|
||||
};
|
||||
|
||||
|
||||
/* Casts, checks and accessors for structured types
|
||||
@ -202,6 +211,8 @@ void g_type_set_qdata (GType type,
|
||||
gpointer data);
|
||||
gpointer g_type_get_qdata (GType type,
|
||||
GQuark quark);
|
||||
void g_type_query (GType type,
|
||||
GTypeQuery *query);
|
||||
|
||||
|
||||
/* --- type registration --- */
|
||||
|
@ -47,8 +47,8 @@ static void g_type_module_complete_type_info (GTypePlugin *plugin,
|
||||
GTypeInfo *info,
|
||||
GTypeValueTable *value_table);
|
||||
static void g_type_module_complete_interface_info (GTypePlugin *plugin,
|
||||
GType instance_type,
|
||||
GType interface_type,
|
||||
GType instance_info,
|
||||
GInterfaceInfo *info);
|
||||
|
||||
static GObjectClass *parent_class;
|
||||
@ -293,8 +293,8 @@ g_type_module_complete_type_info (GTypePlugin *plugin,
|
||||
|
||||
static void
|
||||
g_type_module_complete_interface_info (GTypePlugin *plugin,
|
||||
GType interface_type,
|
||||
GType instance_type,
|
||||
GType interface_type,
|
||||
GInterfaceInfo *info)
|
||||
{
|
||||
GTypeModule *module = G_TYPE_MODULE (plugin);
|
||||
|
@ -83,8 +83,8 @@ g_type_plugin_complete_type_info (GTypePlugin *plugin,
|
||||
|
||||
void
|
||||
g_type_plugin_complete_interface_info (GTypePlugin *plugin,
|
||||
GType interface_type,
|
||||
GType instance_type,
|
||||
GType interface_type,
|
||||
GInterfaceInfo *info)
|
||||
{
|
||||
GTypePluginClass *iface;
|
||||
@ -94,7 +94,7 @@ g_type_plugin_complete_interface_info (GTypePlugin *plugin,
|
||||
|
||||
iface = G_TYPE_PLUGIN_GET_CLASS (plugin);
|
||||
iface->complete_interface_info (plugin,
|
||||
interface_type,
|
||||
instance_type,
|
||||
interface_type,
|
||||
info);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user