[evolution-kolab/gnome-3-5-4: 2/4] Use template files to generate GEnumClass types.



commit 2cebe0388d00cf5f9186f587ca27e507f6dca096
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jul 17 08:37:13 2012 -0400

    Use template files to generate GEnumClass types.

 configure.ac                             |    2 +
 src/libekolab/Makefile.am                |   28 ++++++++-------------
 src/libekolab/kolab-enumtypes.c.template |   38 ++++++++++++++++++++++++++++++
 src/libekolab/kolab-enumtypes.h.template |   27 +++++++++++++++++++++
 4 files changed, 78 insertions(+), 17 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d19d2c2..37f0214 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,8 @@ AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 
+AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
+
 dnl ************
 dnl i18n stuff
 dnl ************
diff --git a/src/libekolab/Makefile.am b/src/libekolab/Makefile.am
index a2cfb7e..f9fb6b6 100644
--- a/src/libekolab/Makefile.am
+++ b/src/libekolab/Makefile.am
@@ -19,22 +19,13 @@ AM_CPPFLAGS =			\
 
 ## --- libekolab ---------------------------------------------------------------
 
-kolab-enumtypes.h: kolab-types.h
-	$(AM_V_GEN) glib-mkenums \
-	--fhead "#ifndef KOLAB_ENUM_TYPES_H\n#define KOLAB_ENUM_TYPES_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
-	--fprod "/* enumerations from \"@filename \" */\n" \
-	--vhead "GType @enum_name _get_type (void);\n#define KOLAB_TYPE_ ENUMSHORT@ (@enum_name _get_type())\n" \
-	--ftail "G_END_DECLS\n\n#endif /* KOLAB_ENUM_TYPES_H */" \
-	$^ > $@
-
-kolab-enumtypes.c: kolab-types.h
-	$(AM_V_GEN) glib-mkenums \
-	--fhead "#include <$<>\n#include \"kolab-enumtypes.h\"" \
-	--fprod "\n/* enumerations from \"@filename \" */" \
-	--vhead "GType\n enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) {\n    static const G Type@Value values[] = {" \
-	--vprod "      { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
-	--vtail "      { 0, NULL, NULL }\n    };\n    etype = g_ type@_register_static (\"@EnumName \", values);\n  }\n  return etype;\n}\n" \
-	$^ > $@
+ENUM_TYPES = kolab-types.h
+
+kolab-enumtypes.h: kolab-enumtypes.h.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template kolab-enumtypes.h.template $(ENUM_TYPES)) > $@
+
+kolab-enumtypes.c: kolab-enumtypes.c.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template kolab-enumtypes.c.template $(ENUM_TYPES)) > $@
 
 ENUM_GENERATED =			\
 	kolab-enumtypes.h		\
@@ -136,7 +127,10 @@ libekolabbackend_la_LIBADD =			\
 
 BUILT_SOURCES = $(ENUM_GENERATED)
 
-EXTRA_DIST = $(noinst_HEADERS)
+EXTRA_DIST =					\
+	$(noinst_HEADERS)			\
+	kolab-enumtypes.h.template		\
+	kolab-enumtypes.c.template
 
 CLEANFILES = $(BUILT_SOURCES)
 
diff --git a/src/libekolab/kolab-enumtypes.c.template b/src/libekolab/kolab-enumtypes.c.template
new file mode 100644
index 0000000..1ffc44d
--- /dev/null
+++ b/src/libekolab/kolab-enumtypes.c.template
@@ -0,0 +1,38 @@
+/*** BEGIN file-header ***/
+#include "kolab-enumtypes.h"
+
+/*** 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 the_type = 0;
+	
+	if (the_type == 0) {
+		static const G Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+			{ @VALUENAME@,
+			  "@VALUENAME@",
+			  "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+			{ 0, NULL, NULL }
+		};
+		the_type = g_ type@_register_static (
+			g_intern_static_string ("@EnumName@"),
+			values);
+	}
+	return the_type;
+}
+
+/*** END value-tail ***/
diff --git a/src/libekolab/kolab-enumtypes.h.template b/src/libekolab/kolab-enumtypes.h.template
new file mode 100644
index 0000000..40a589f
--- /dev/null
+++ b/src/libekolab/kolab-enumtypes.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef KOLAB_ENUM_TYPES_H
+#define KOLAB_ENUM_TYPES_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* Enumerations from "@filename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+#define KOLAB_TYPE_ ENUMSHORT@	(@enum_name _get_type())
+GType @enum_name _get_type	(void) G_GNUC_CONST;
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* KOLAB_ENUM_TYPES_H */
+/*** END file-tail ***/
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]