summaryrefslogtreecommitdiff
path: root/gobject
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>2000-07-25 22:47:41 +0000
committerTim Janik <timj@src.gnome.org>2000-07-25 22:47:41 +0000
commit18ac8965f8c3f59d98da8c67cb37d8f655fbd3f1 (patch)
tree58d0a1694e7e2b2a331b6580002c5fd3dbe5d6ba /gobject
parent524cb26d54ae07120a4bbea2a29f9d85ac648fbf (diff)
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.
Diffstat (limited to 'gobject')
-rw-r--r--gobject/ChangeLog6
-rw-r--r--gobject/gtype.c34
-rw-r--r--gobject/gtype.h15
3 files changed, 28 insertions, 27 deletions
diff --git a/gobject/ChangeLog b/gobject/ChangeLog
index 2c69fbfc0..cb04c82f8 100644
--- a/gobject/ChangeLog
+++ b/gobject/ChangeLog
@@ -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>
* gparam.h
diff --git a/gobject/gtype.c b/gobject/gtype.c
index 615e738b7..e6ade67ed 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -162,8 +162,8 @@ static ClassCacheFunc *class_cache_funcs = NULL;
/* --- externs --- */
-const char *g_log_domain_gobject = "GLib-Object";
-GOBJECT_VAR GType _g_type_fundamental_last = 0;
+const char *g_log_domain_gobject = "GLib-Object";
+static GType last_fundamental_id = 0;
/* --- type nodes --- */
@@ -177,7 +177,7 @@ LOOKUP_TYPE_NODE (register GType utype)
register GType ftype = G_TYPE_FUNDAMENTAL (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];
else
return NULL;
@@ -286,18 +286,18 @@ type_node_fundamental_new (GType ftype,
{
GTypeFundamentalInfo *finfo;
TypeNode *node;
- guint i, flast = G_TYPE_FUNDAMENTAL_LAST;
+ guint i, flast = last_fundamental_id;
g_assert (ftype == G_TYPE_FUNDAMENTAL (ftype));
type_flags &= G_TYPE_FLAG_MASK;
- _g_type_fundamental_last = MAX (_g_type_fundamental_last, ftype + 1);
- if (G_TYPE_FUNDAMENTAL_LAST > flast)
+ last_fundamental_id = MAX (last_fundamental_id, ftype + 1);
+ if (last_fundamental_id > flast)
{
- g_type_nodes = g_renew (TypeNode**, g_type_nodes, G_TYPE_FUNDAMENTAL_LAST);
- g_branch_seqnos = g_renew (GType, g_branch_seqnos, G_TYPE_FUNDAMENTAL_LAST);
- for (i = flast; i < G_TYPE_FUNDAMENTAL_LAST; i++)
+ g_type_nodes = g_renew (TypeNode**, g_type_nodes, last_fundamental_id);
+ g_branch_seqnos = g_renew (GType, g_branch_seqnos, last_fundamental_id);
+ for (i = flast; i < last_fundamental_id; i++)
{
g_type_nodes[i] = NULL;
g_branch_seqnos[i] = 0;
@@ -1688,7 +1688,7 @@ g_type_fundamental_branch_last (GType 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 */
@@ -1863,6 +1863,12 @@ g_type_get_plugin (GType type)
return node ? node->plugin : NULL;
}
+GType
+g_type_fundamental_last (void)
+{
+ return last_fundamental_id;
+}
+
gboolean
g_type_instance_conforms_to (GTypeInstance *type_instance,
GType iface_type)
@@ -1958,7 +1964,7 @@ g_type_init (void)
TypeNode *node;
GType type;
- if (G_TYPE_FUNDAMENTAL_LAST)
+ if (last_fundamental_id)
return;
/* type qname hash table */
@@ -1966,10 +1972,10 @@ g_type_init (void)
/* invalid type G_TYPE_INVALID (0)
*/
- _g_type_fundamental_last = 1;
- g_type_nodes = g_renew (TypeNode**, g_type_nodes, G_TYPE_FUNDAMENTAL_LAST);
+ last_fundamental_id = 1;
+ g_type_nodes = g_renew (TypeNode**, g_type_nodes, last_fundamental_id);
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;
/* void type G_TYPE_NONE
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 4b18540fe..60086e8b1 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -34,7 +34,7 @@ extern "C" {
#define G_TYPE_FUNDAMENTAL_MAX (0xff)
#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_FUNDAMENTAL_LAST ((GType) _g_type_fundamental_last)
+#define G_TYPE_FUNDAMENTAL_LAST ((GType) g_type_fundamental_last ())
/* predefined fundamental and derived types
@@ -317,6 +317,7 @@ void g_type_remove_class_cache_func (gpointer cache_data,
GTypeClassCacheFunc cache_func);
void g_type_class_unref_uncached (gpointer g_class);
GTypePlugin* g_type_get_plugin (GType type);
+GType g_type_fundamental_last (void);
#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_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
}
#endif /* __cplusplus */