[json-glib] Update the enum types templates
- From: Emmanuele Bassi <ebassi src gnome org>
- To: svn-commits-list gnome org
- Subject: [json-glib] Update the enum types templates
- Date: Sun, 17 May 2009 10:17:29 -0400 (EDT)
commit 5778210462b8b7a1a5d98466508276f712ea8c47
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Sat May 16 13:53:58 2009 +0100
Update the enum types templates
The autogenerated enumeration types registration code should
be using the same pattern used by the G_DEFINE_TYPE() macros,
with GOnce to enable atomic (and thread-safe) type registration.
---
json-glib/json-enum-types.c.in | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/json-glib/json-enum-types.c.in b/json-glib/json-enum-types.c.in
index 3578c6e..eba4222 100644
--- a/json-glib/json-enum-types.c.in
+++ b/json-glib/json-enum-types.c.in
@@ -3,15 +3,18 @@
/*** END file-header ***/
/*** BEGIN file-production ***/
+
/* enumerations from "@filename@" */
#include "@filename@"
+
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name _get_type(void) {
- static GType etype = 0;
- if (G_UNLIKELY (!etype))
+ static volatile gsize g_enum_type_id__volatile = 0;
+
+ if (g_once_init_enter (&g_enum_type_id__volatile))
{
const G Type@Value values[] = {
/*** END value-header ***/
@@ -23,9 +26,14 @@ GType
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
- etype = g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+ GType g_enum_type_id;
+
+ g_enum_type_id =
+ g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+
+ g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id);
}
- return etype;
-}
+ return g_enum_type_id__volatile;
+}
/*** END value-tail ***/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]