mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
make g_type_fundamental_last() a function, avoiding all that extern
Sun Jul 23 17:23:35 2000 Tim Janik <timj@gtk.org> * gtype.[hc]: make g_type_fundamental_last() a function, avoiding all that extern variable clutter and avoiding further problems with thread safety.
This commit is contained in:
parent
524cb26d54
commit
18ac8965f8
@ -1,3 +1,9 @@
|
|||||||
|
Sun Jul 23 17:23:35 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gtype.[hc]: make g_type_fundamental_last() a function, avoiding all
|
||||||
|
that extern variable clutter and avoiding further problems with thread
|
||||||
|
safety.
|
||||||
|
|
||||||
2000-07-19 Tor Lillqvist <tml@iki.fi>
|
2000-07-19 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gparam.h
|
* gparam.h
|
||||||
|
@ -162,8 +162,8 @@ static ClassCacheFunc *class_cache_funcs = NULL;
|
|||||||
|
|
||||||
|
|
||||||
/* --- externs --- */
|
/* --- externs --- */
|
||||||
const char *g_log_domain_gobject = "GLib-Object";
|
const char *g_log_domain_gobject = "GLib-Object";
|
||||||
GOBJECT_VAR GType _g_type_fundamental_last = 0;
|
static GType last_fundamental_id = 0;
|
||||||
|
|
||||||
|
|
||||||
/* --- type nodes --- */
|
/* --- type nodes --- */
|
||||||
@ -177,7 +177,7 @@ LOOKUP_TYPE_NODE (register GType utype)
|
|||||||
register GType ftype = G_TYPE_FUNDAMENTAL (utype);
|
register GType ftype = G_TYPE_FUNDAMENTAL (utype);
|
||||||
register GType b_seqno = G_TYPE_BRANCH_SEQNO (utype);
|
register GType b_seqno = G_TYPE_BRANCH_SEQNO (utype);
|
||||||
|
|
||||||
if (ftype < G_TYPE_FUNDAMENTAL_LAST && b_seqno < g_branch_seqnos[ftype])
|
if (ftype < last_fundamental_id && b_seqno < g_branch_seqnos[ftype])
|
||||||
return g_type_nodes[ftype][b_seqno];
|
return g_type_nodes[ftype][b_seqno];
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -286,18 +286,18 @@ type_node_fundamental_new (GType ftype,
|
|||||||
{
|
{
|
||||||
GTypeFundamentalInfo *finfo;
|
GTypeFundamentalInfo *finfo;
|
||||||
TypeNode *node;
|
TypeNode *node;
|
||||||
guint i, flast = G_TYPE_FUNDAMENTAL_LAST;
|
guint i, flast = last_fundamental_id;
|
||||||
|
|
||||||
g_assert (ftype == G_TYPE_FUNDAMENTAL (ftype));
|
g_assert (ftype == G_TYPE_FUNDAMENTAL (ftype));
|
||||||
|
|
||||||
type_flags &= G_TYPE_FLAG_MASK;
|
type_flags &= G_TYPE_FLAG_MASK;
|
||||||
|
|
||||||
_g_type_fundamental_last = MAX (_g_type_fundamental_last, ftype + 1);
|
last_fundamental_id = MAX (last_fundamental_id, ftype + 1);
|
||||||
if (G_TYPE_FUNDAMENTAL_LAST > flast)
|
if (last_fundamental_id > flast)
|
||||||
{
|
{
|
||||||
g_type_nodes = g_renew (TypeNode**, g_type_nodes, G_TYPE_FUNDAMENTAL_LAST);
|
g_type_nodes = g_renew (TypeNode**, g_type_nodes, last_fundamental_id);
|
||||||
g_branch_seqnos = g_renew (GType, g_branch_seqnos, G_TYPE_FUNDAMENTAL_LAST);
|
g_branch_seqnos = g_renew (GType, g_branch_seqnos, last_fundamental_id);
|
||||||
for (i = flast; i < G_TYPE_FUNDAMENTAL_LAST; i++)
|
for (i = flast; i < last_fundamental_id; i++)
|
||||||
{
|
{
|
||||||
g_type_nodes[i] = NULL;
|
g_type_nodes[i] = NULL;
|
||||||
g_branch_seqnos[i] = 0;
|
g_branch_seqnos[i] = 0;
|
||||||
@ -1688,7 +1688,7 @@ g_type_fundamental_branch_last (GType type)
|
|||||||
{
|
{
|
||||||
GType ftype = G_TYPE_FUNDAMENTAL (type);
|
GType ftype = G_TYPE_FUNDAMENTAL (type);
|
||||||
|
|
||||||
return ftype < G_TYPE_FUNDAMENTAL_LAST ? g_branch_seqnos[ftype] : 0;
|
return ftype < last_fundamental_id ? g_branch_seqnos[ftype] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GType* /* free result */
|
GType* /* free result */
|
||||||
@ -1863,6 +1863,12 @@ g_type_get_plugin (GType type)
|
|||||||
return node ? node->plugin : NULL;
|
return node ? node->plugin : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GType
|
||||||
|
g_type_fundamental_last (void)
|
||||||
|
{
|
||||||
|
return last_fundamental_id;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_type_instance_conforms_to (GTypeInstance *type_instance,
|
g_type_instance_conforms_to (GTypeInstance *type_instance,
|
||||||
GType iface_type)
|
GType iface_type)
|
||||||
@ -1958,7 +1964,7 @@ g_type_init (void)
|
|||||||
TypeNode *node;
|
TypeNode *node;
|
||||||
GType type;
|
GType type;
|
||||||
|
|
||||||
if (G_TYPE_FUNDAMENTAL_LAST)
|
if (last_fundamental_id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* type qname hash table */
|
/* type qname hash table */
|
||||||
@ -1966,10 +1972,10 @@ g_type_init (void)
|
|||||||
|
|
||||||
/* invalid type G_TYPE_INVALID (0)
|
/* invalid type G_TYPE_INVALID (0)
|
||||||
*/
|
*/
|
||||||
_g_type_fundamental_last = 1;
|
last_fundamental_id = 1;
|
||||||
g_type_nodes = g_renew (TypeNode**, g_type_nodes, G_TYPE_FUNDAMENTAL_LAST);
|
g_type_nodes = g_renew (TypeNode**, g_type_nodes, last_fundamental_id);
|
||||||
g_type_nodes[0] = &type0_node;
|
g_type_nodes[0] = &type0_node;
|
||||||
g_branch_seqnos = g_renew (GType, g_branch_seqnos, G_TYPE_FUNDAMENTAL_LAST);
|
g_branch_seqnos = g_renew (GType, g_branch_seqnos, last_fundamental_id);
|
||||||
g_branch_seqnos[0] = 1;
|
g_branch_seqnos[0] = 1;
|
||||||
|
|
||||||
/* void type G_TYPE_NONE
|
/* void type G_TYPE_NONE
|
||||||
|
@ -34,7 +34,7 @@ extern "C" {
|
|||||||
#define G_TYPE_FUNDAMENTAL_MAX (0xff)
|
#define G_TYPE_FUNDAMENTAL_MAX (0xff)
|
||||||
#define G_TYPE_DERIVE_ID(ptype, branch_seqno) (G_TYPE_FUNDAMENTAL (ptype) | ((branch_seqno) << 8))
|
#define G_TYPE_DERIVE_ID(ptype, branch_seqno) (G_TYPE_FUNDAMENTAL (ptype) | ((branch_seqno) << 8))
|
||||||
#define G_TYPE_BRANCH_SEQNO(type) ((type) >> 8)
|
#define G_TYPE_BRANCH_SEQNO(type) ((type) >> 8)
|
||||||
#define G_TYPE_FUNDAMENTAL_LAST ((GType) _g_type_fundamental_last)
|
#define G_TYPE_FUNDAMENTAL_LAST ((GType) g_type_fundamental_last ())
|
||||||
|
|
||||||
|
|
||||||
/* predefined fundamental and derived types
|
/* predefined fundamental and derived types
|
||||||
@ -317,6 +317,7 @@ void g_type_remove_class_cache_func (gpointer cache_data,
|
|||||||
GTypeClassCacheFunc cache_func);
|
GTypeClassCacheFunc cache_func);
|
||||||
void g_type_class_unref_uncached (gpointer g_class);
|
void g_type_class_unref_uncached (gpointer g_class);
|
||||||
GTypePlugin* g_type_get_plugin (GType type);
|
GTypePlugin* g_type_get_plugin (GType type);
|
||||||
|
GType g_type_fundamental_last (void);
|
||||||
|
|
||||||
|
|
||||||
#ifndef G_DISABLE_CAST_CHECKS
|
#ifndef G_DISABLE_CAST_CHECKS
|
||||||
@ -332,18 +333,6 @@ GTypePlugin* g_type_get_plugin (GType type);
|
|||||||
#define _G_TYPE_CIT(ip, gt) (g_type_instance_conforms_to ((GTypeInstance*) ip, gt))
|
#define _G_TYPE_CIT(ip, gt) (g_type_instance_conforms_to ((GTypeInstance*) ip, gt))
|
||||||
#define _G_TYPE_CCT(cp, gt) (g_type_class_is_a ((GTypeClass*) cp, gt))
|
#define _G_TYPE_CCT(cp, gt) (g_type_class_is_a ((GTypeClass*) cp, gt))
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
|
||||||
# ifdef GOBJECT_COMPILATION
|
|
||||||
# define GOBJECT_VAR __declspec(dllexport)
|
|
||||||
# else /* !GOBJECT_COMPILATION */
|
|
||||||
# define GOBJECT_VAR extern __declspec(dllimport)
|
|
||||||
# endif /* !GOBJECT_COMPILATION */
|
|
||||||
#else /* !G_OS_WIN32 */
|
|
||||||
# define GOBJECT_VAR extern
|
|
||||||
#endif /* !G_OS_WIN32 */
|
|
||||||
|
|
||||||
GOBJECT_VAR GType _g_type_fundamental_last;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
Loading…
Reference in New Issue
Block a user