[evolution-ews] Use template files to generate GEnumClass types.



commit 4c82896772202abd15248dc6c051b121ec4e3243
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jul 17 21:15:08 2012 -0400

    Use template files to generate GEnumClass types.

 src/server/Makefile.am                |   25 ++++++++++++++++++++-
 src/server/e-ews-enumtypes.c.template |   38 +++++++++++++++++++++++++++++++++
 src/server/e-ews-enumtypes.h.template |   27 +++++++++++++++++++++++
 3 files changed, 89 insertions(+), 1 deletions(-)
---
diff --git a/src/server/Makefile.am b/src/server/Makefile.am
index fc84f82..6237002 100644
--- a/src/server/Makefile.am
+++ b/src/server/Makefile.am
@@ -16,6 +16,19 @@ ews-marshal.c: ews-marshal.h
 	&& mv ews-marshal.tmp ews-marshal.c ) \
 	|| ( rm -f ews-marshal.tmp && exit 1 )
 
+ENUM_TYPES = e-ews-enums.h
+
+e-ews-enumtypes.h: e-ews-enumtypes.h.template $(ENUM_TYPES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-ews-enumtypes.h.template $(ENUM_TYPES)) > $@
+
+e-ews-enumtypes.c: e-ews-enumtypes.c.template $(ENUM_TYPES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-ews-enumtypes.c.template $(ENUM_TYPES)) > $@
+
+ENUM_GENERATED = \
+	e-ews-enumtypes.h \
+	e-ews-enumtypes.c \
+	$(NULL)
+
 e-ews-connection.c: $(MARSHAL_GENERATED)
 
 if ENABLE_KRB5
@@ -91,7 +104,17 @@ libeewsinclude_HEADERS = \
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libeews-$(API_VERSION).pc
 
-EXTRA_DIST = $(pkgconfig_DATA:-$(API_VERSION).pc=.pc.in) ews-marshal.list
+BUILT_SOURCES = \
+	$(ENUM_GENERATED) \
+	$(MARSHAL_GENERATED) \
+	$(NULL)
+
+EXTRA_DIST = \
+	$(pkgconfig_DATA:-$(API_VERSION).pc=.pc.in) \
+	e-ews-enumtypes.h.template \
+	e-ews-enumtypes.c.template \
+	ews-marshal.list \
+	$(NULL)
 
 DISTCLEANFILES = $(pkgconfig_DATA)
 CLEANFILES = $(MARSHAL_GENERATED)
diff --git a/src/server/e-ews-enumtypes.c.template b/src/server/e-ews-enumtypes.c.template
new file mode 100644
index 0000000..90dd2e7
--- /dev/null
+++ b/src/server/e-ews-enumtypes.c.template
@@ -0,0 +1,38 @@
+/*** BEGIN file-header ***/
+#include "e-ews-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/server/e-ews-enumtypes.h.template b/src/server/e-ews-enumtypes.h.template
new file mode 100644
index 0000000..31b36d7
--- /dev/null
+++ b/src/server/e-ews-enumtypes.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef E_EWS_ENUMTYPES_H
+#define E_EWS_ENUMTYPES_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* Enumerations from "@filename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+#define E_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 /* E_EWS_ENUMTYPES_H */
+/*** END file-tail ***/
+



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