/soc/2013/ankitkv/gobjectification: 5f61d5e5cf47: Allow register...

Ankit Vani a at nevitus.org
Fri Sep 20 12:41:34 EDT 2013


Changeset: 5f61d5e5cf473f52d674dc04631118388b6d48d2
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-20 22:09 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/5f61d5e5cf47

Description:

Allow register_type() to be executed multiple times

diffstat:

 libpurple/plugins.h |  38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)

diffs (52 lines):

diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -290,30 +290,28 @@ struct _PurplePluginAction {
 /** A more general version of PURPLE_DEFINE_DYNAMIC_TYPE(). */
 #define PURPLE_DEFINE_DYNAMIC_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \
 static GType type_name##_type_id = 0; \
-GType type_name##_get_type(void) { \
+G_MODULE_EXPORT GType type_name##_get_type(void) { \
 	return type_name##_type_id; \
 } \
 void type_name##_register_type(PurplePlugin *); \
 void type_name##_register_type(PurplePlugin *plugin) { \
-	if (type_name##_type_id == 0) { \
-		GType type_id; \
-		const GTypeInfo type_info = { \
-			sizeof (TypeName##Class), \
-			(GBaseInitFunc) NULL, \
-			(GBaseFinalizeFunc) NULL, \
-			(GClassInitFunc) type_name##_class_init, \
-			(GClassFinalizeFunc) NULL, \
-			NULL, \
-			sizeof (TypeName), \
-			0, \
-			(GInstanceInitFunc) type_name##_init, \
-			NULL \
-		}; \
-		type_id = purple_plugin_register_type(plugin, TYPE_PARENT, #TypeName, \
-		                                      &type_info, (GTypeFlags) flags); \
-		type_name##_type_id = type_id; \
-		{ CODE ; } \
-	} \
+	GType type_id; \
+	const GTypeInfo type_info = { \
+		sizeof (TypeName##Class), \
+		(GBaseInitFunc) NULL, \
+		(GBaseFinalizeFunc) NULL, \
+		(GClassInitFunc) type_name##_class_init, \
+		(GClassFinalizeFunc) NULL, \
+		NULL, \
+		sizeof (TypeName), \
+		0, \
+		(GInstanceInitFunc) type_name##_init, \
+		NULL \
+	}; \
+	type_id = purple_plugin_register_type(plugin, TYPE_PARENT, #TypeName, \
+	                                      &type_info, (GTypeFlags) flags); \
+	type_name##_type_id = type_id; \
+	{ CODE ; } \
 }
 
 /** A convenience macro to ease dynamic interface addition. */



More information about the Commits mailing list