/soc/2013/ankitkv/gobjectification: 4c0ae73d3745: Added autogene...

Ankit Vani a at nevitus.org
Fri Jun 21 04:50:50 EDT 2013


Changeset: 4c0ae73d3745a48dd9c9c94c906808916158a048
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-21 14:20 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/4c0ae73d3745

Description:

Added autogeneration of GEnums using glib-mkenums to enums.c and enums.h
using template files enums.c.template and enums.h.template

diffstat:

 configure.ac               |   3 ++
 libpurple/Makefile.am      |  24 ++++++++++++++++-
 libpurple/cipher.c         |  17 ------------
 libpurple/cipher.h         |   3 --
 libpurple/enums.c.template |  64 ++++++++++++++++++++++++++++++++++++++++++++++
 libpurple/enums.h.template |  45 ++++++++++++++++++++++++++++++++
 6 files changed, 135 insertions(+), 21 deletions(-)

diffs (227 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -353,6 +353,9 @@ AC_SUBST(GLIB_LIBS)
 GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
 AC_SUBST(GLIB_GENMARSHAL)
 
+GLIB_MKENUMS=`pkg-config --variable=glib_mkenums glib-2.0`
+AC_SUBST(GLIB_MKENUMS)
+
 AC_ARG_WITH([extraversion],
 			AS_HELP_STRING([--with-extraversion=STRING],
 						   [extra version number to be displayed in Help->About and --help (for packagers)]),
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -105,6 +105,7 @@ purple_coresources = \
 	whiteboard.c
 
 purple_builtsources = \
+	enums.c \
 	marshallers.c
 
 purple_coreheaders = \
@@ -176,7 +177,22 @@ purple_mediaheaders = \
 	codec.h \
 	enum-types.h
 
-purple_builtheaders = purple.h version.h marshallers.h
+purple_builtheaders = purple.h version.h enums.h marshallers.h
+
+purple_enumheaders = \
+	account.h \
+	accounts.h \
+	cipher.h \
+	circularbuffer.h \
+	conversation.h \
+	conversations.h \
+	hash.h \
+	smiley.h \
+	sound-theme.h \
+	sound-theme-loader.h \
+	theme.h \
+	theme-loader.h \
+	theme-manager.h
 
 marshallers.h: marshallers.list
 	$(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --header > marshallers.h
@@ -185,6 +201,12 @@ marshallers.c: marshallers.list marshall
 	$(AM_V_GEN)echo "#include \"marshallers.h\"" > marshallers.c
 	$(AM_V_at)$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --body >> marshallers.c
 
+enums.h: enums.h.template $(purple_enumheaders)
+	$(AM_V_GEN)$(GLIB_MKENUMS) --template enums.h.template $(purple_enumheaders) > $@
+
+enums.c: enums.c.template $(purple_enumheaders)
+	$(AM_V_GEN)$(GLIB_MKENUMS) --template enums.c.template $(purple_enumheaders) > $@
+
 if ENABLE_DBUS
 
 CLEANFILES = \
diff --git a/libpurple/cipher.c b/libpurple/cipher.c
--- a/libpurple/cipher.c
+++ b/libpurple/cipher.c
@@ -86,23 +86,6 @@ purple_cipher_get_type(void) {
 	return type;
 }
 
-GType
-purple_cipher_batch_mode_get_type(void) {
-	static GType type = 0;
-
-	if(type == 0) {
-		static const GEnumValue values[] = {
-			{ PURPLE_CIPHER_BATCH_MODE_ECB, "ECB", "ECB" },
-			{ PURPLE_CIPHER_BATCH_MODE_CBC, "CBC", "CBC" },
-			{ 0, NULL, NULL },
-		};
-
-		type = g_enum_register_static("PurpleCipherBatchMode", values);
-	}
-
-	return type;
-}
-
 /**
  * purple_cipher_reset:
  * @cipher: The cipher to reset
diff --git a/libpurple/cipher.h b/libpurple/cipher.h
--- a/libpurple/cipher.h
+++ b/libpurple/cipher.h
@@ -43,8 +43,6 @@
 typedef struct _PurpleCipher       PurpleCipher;
 typedef struct _PurpleCipherClass  PurpleCipherClass;
 
-#define PURPLE_TYPE_CIPHER_BATCH_MODE	(purple_cipher_batch_mode_get_type())
-
 /**
  * PurpleCipherBatchMode:
  * @PURPLE_CIPHER_BATCH_MODE_ECB: Electronic Codebook Mode
@@ -135,7 +133,6 @@ struct _PurpleCipherClass {
 G_BEGIN_DECLS
 
 GType purple_cipher_get_type(void);
-GType purple_cipher_batch_mode_get_type(void);
 
 const gchar *purple_cipher_get_name(PurpleCipher *cipher);
 
diff --git a/libpurple/enums.c.template b/libpurple/enums.c.template
new file mode 100644
--- /dev/null
+++ b/libpurple/enums.c.template
@@ -0,0 +1,64 @@
+/*** BEGIN file-header ***/
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "enums.h"
+
+/*** END file-header ***/
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+#include "@filename@"
+
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+ at enum_name@_get_type(void) {
+    static volatile gsize g_define_type_id__volatile = 0;
+
+    if(g_once_init_enter(&g_define_type_id__volatile)) {
+        static const G at Type@Value values [] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+            { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+            { 0, NULL, NULL }
+        };
+
+        GType g_define_type_id =
+            g_ at type@_register_static(g_intern_static_string("@EnumName@"), values);
+        g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
+    }
+
+    return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+/*** END file-tail ***/
diff --git a/libpurple/enums.h.template b/libpurple/enums.h.template
new file mode 100644
--- /dev/null
+++ b/libpurple/enums.h.template
@@ -0,0 +1,45 @@
+/*** BEGIN file-header ***/
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+#ifndef PURPLE_ENUM_H
+#define PURPLE_ENUM_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+/*** BEGIN value-header ***/
+GType @enum_name at _get_type(void) G_GNUC_CONST;
+#define @ENUMPREFIX at _TYPE_@ENUMSHORT@ (@enum_name at _get_type())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* PURPLE_ENUM_H */
+
+/*** END file-tail ***/
+



More information about the Commits mailing list