[evolution] Use template files to generate GEnumClass types.



commit f22e38ffad3d6360920e278ac35c3a00102738ff
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jul 17 10:52:43 2012 -0400

    Use template files to generate GEnumClass types.

 e-util/Makefile.am                          |   23 +++++++++++---
 e-util/e-util-enumtypes.c.template          |   38 +++++++++++++++++++++++
 e-util/e-util-enumtypes.h.template          |   27 +++++++++++++++++
 glib-gen.mak                                |   43 ---------------------------
 libemail-engine/Makefile.am                 |   17 +++++++---
 libemail-engine/e-mail-enumtypes.c.template |   38 +++++++++++++++++++++++
 libemail-engine/e-mail-enumtypes.h.template |   27 +++++++++++++++++
 libgnomecanvas/Makefile.am                  |   10 ------
 libgnomecanvas/gnome-canvas-marshal.list    |    2 -
 libgnomecanvas/gnome-canvas.c               |    8 +----
 shell/Makefile.am                           |   14 +++++---
 shell/e-shell-enumtypes.c.template          |   38 +++++++++++++++++++++++
 shell/e-shell-enumtypes.h.template          |   27 +++++++++++++++++
 13 files changed, 236 insertions(+), 76 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 7f6ef95..4464f93 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -2,11 +2,22 @@ eutilincludedir = $(privincludedir)/e-util
 ecpsdir = $(privdatadir)/ecps
 ruledir = $(privdatadir)
 
-include $(top_srcdir)/glib-gen.mak
-glib_enum_headers=e-util-enums.h
-glib_enum_output=e-util-enumtypes
-glib_enum_define=E_UTIL
-glib_enum_prefix=e
+ENUM_TYPES = e-util-enums.h
+
+e-util-enumtypes.h: e-util-enumtypes.h.template $(ENUM_TYPES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-util-enumtypes.h.template $(ENUM_TYPES)) > $@
+
+e-util-enumtypes.c: e-util-enumtypes.c.template $(ENUM_TYPES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-util-enumtypes.c.template $(ENUM_TYPES)) > $@
+
+e-marshal.h: e-marshal.list
+	$(AM_V_GEN) $(GLIB_GENMARSHAL) --header --prefix=e_marshal $^ > e-marshal.h.tmp && \
+	mv e-marshal.h.tmp e-marshal.h
+
+e-marshal.c: e-marshal.list
+	$(AM_V_GEN) echo "#include \"e-marshal.h\"" >> e-marshal.c.tmp && \
+	$(GLIB_GENMARSHAL) --body --prefix=e_marshal $^ >> e-marshal.c.tmp && \
+	mv e-marshal.c.tmp e-marshal.c
 
 ENUM_GENERATED = e-util-enumtypes.h e-util-enumtypes.c
 MARSHAL_GENERATED = e-marshal.c e-marshal.h
@@ -131,6 +142,8 @@ errordir = $(privdatadir)/errors
 @EVO_PLUGIN_RULE@
 
 EXTRA_DIST =				\
+	e-util-enumtypes.h.template	\
+	e-util-enumtypes.c.template	\
 	e-system.error.xml		\
 	e-marshal.list
 
diff --git a/e-util/e-util-enumtypes.c.template b/e-util/e-util-enumtypes.c.template
new file mode 100644
index 0000000..cb26347
--- /dev/null
+++ b/e-util/e-util-enumtypes.c.template
@@ -0,0 +1,38 @@
+/*** BEGIN file-header ***/
+#include "e-util-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/e-util/e-util-enumtypes.h.template b/e-util/e-util-enumtypes.h.template
new file mode 100644
index 0000000..c5bfa9c
--- /dev/null
+++ b/e-util/e-util-enumtypes.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef E_UTIL_ENUMTYPES_H
+#define E_UTIL_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_UTIL_ENUMTYPES_H */
+/*** END file-tail ***/
+
diff --git a/libemail-engine/Makefile.am b/libemail-engine/Makefile.am
index 103a9d5..5589fe4 100644
--- a/libemail-engine/Makefile.am
+++ b/libemail-engine/Makefile.am
@@ -2,11 +2,13 @@ NULL =
 
 privsolib_LTLIBRARIES = libemail-engine.la
 
-include $(top_srcdir)/glib-gen.mak
-glib_enum_headers=e-mail-enums.h
-glib_enum_output=e-mail-enumtypes
-glib_enum_define=E_MAIL
-glib_enum_prefix=e_mail
+ENUM_TYPES = e-mail-enums.h
+
+e-mail-enumtypes.h: e-mail-enumtypes.h.template $(ENUM_TYPES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-mail-enumtypes.h.template $(ENUM_TYPES)) > $@
+
+e-mail-enumtypes.c: e-mail-enumtypes.c.template $(ENUM_TYPES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-mail-enumtypes.c.template $(ENUM_TYPES)) > $@
 
 ENUM_GENERATED = e-mail-enumtypes.h e-mail-enumtypes.c
 
@@ -74,6 +76,11 @@ BUILT_SOURCES = $(ENUM_GENERATED)
 CLEANFILES = $(BUILT_SOURCES)
 DISTCLEANFILES = $(pkgconfig_DATA)
 
+EXTRA_DIST = \
+	e-mail-enumtypes.h.template \
+	e-mail-enumtypes.c.template \
+	$(NULL)
+
 dist-hook:
 	cd $(distdir); rm -f $(BUILT_SOURCES)
 
diff --git a/libemail-engine/e-mail-enumtypes.c.template b/libemail-engine/e-mail-enumtypes.c.template
new file mode 100644
index 0000000..db4f2a4
--- /dev/null
+++ b/libemail-engine/e-mail-enumtypes.c.template
@@ -0,0 +1,38 @@
+/*** BEGIN file-header ***/
+#include "e-mail-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/libemail-engine/e-mail-enumtypes.h.template b/libemail-engine/e-mail-enumtypes.h.template
new file mode 100644
index 0000000..d983a72
--- /dev/null
+++ b/libemail-engine/e-mail-enumtypes.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef E_MAIL_ENUMTYPES_H
+#define E_MAIL_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_MAIL_ENUMTYPES_H */
+/*** END file-tail ***/
+
diff --git a/libgnomecanvas/Makefile.am b/libgnomecanvas/Makefile.am
index 02fa1e0..a1eb3f1 100644
--- a/libgnomecanvas/Makefile.am
+++ b/libgnomecanvas/Makefile.am
@@ -49,13 +49,6 @@ libgnomecanvas_la_SOURCES =			\
 	gnome-canvas-widget.c			\
 	gnome-canvas.c
 
-include $(top_srcdir)/glib-gen.mak
-glib_enum_prefix=gnome_canvas
-
-MARSHAL_GENERATED =				\
-	gnome-canvas-marshal.c			\
-	gnome-canvas-marshal.h
-
 libgnomecanvas_la_LIBADD = \
 	$(GNOME_PLATFORM_LIBS) \
 	$(MATH_LIB)
@@ -66,7 +59,4 @@ BUILT_SOURCES = $(MARSHAL_GENERATED)
 
 CLEANFILES = $(BUILT_SOURCES)
 
-EXTRA_DIST = \
-	gnome-canvas-marshal.list
-
 -include $(top_srcdir)/git.mk
diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c
index 8911e61..62cc772 100644
--- a/libgnomecanvas/gnome-canvas.c
+++ b/libgnomecanvas/gnome-canvas.c
@@ -91,8 +91,6 @@
 #include "gnome-canvas.h"
 #include "gnome-canvas-i18n.h"
 #include "gnome-canvas-util.h"
-#include "gnome-canvas-marshal.h"
-#include "gnome-canvas-marshal.c"
 
 /* We must run our idle update handler *before* GDK wants to redraw. */
 #define CANVAS_IDLE_PRIORITY (GDK_PRIORITY_REDRAW - 5)
@@ -1839,8 +1837,7 @@ gnome_canvas_class_init (GnomeCanvasClass *class)
 			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (GnomeCanvasClass, draw_background),
-			      NULL, NULL,
-			      gnome_canvas_marshal_VOID__BOXED_INT_INT_INT_INT,
+			      NULL, NULL, NULL,
 			      G_TYPE_NONE, 5, CAIRO_GOBJECT_TYPE_CONTEXT,
 			      G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
 
@@ -3320,8 +3317,7 @@ gnome_canvas_item_class_init (GnomeCanvasItemClass *class)
 			      G_TYPE_FROM_CLASS (class),
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (GnomeCanvasItemClass, event),
-			      boolean_handled_accumulator, NULL,
-			      gnome_canvas_marshal_BOOLEAN__BOXED,
+			      boolean_handled_accumulator, NULL, NULL,
 			      G_TYPE_BOOLEAN, 1,
 			      GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
 
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 0398379..b460d08 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -10,11 +10,13 @@ privsolib_LTLIBRARIES = libeshell.la
 
 eshellincludedir = $(privincludedir)/shell
 
-include $(top_srcdir)/glib-gen.mak
-glib_enum_headers=e-shell.h
-glib_enum_output=e-shell-enumtypes
-glib_enum_define=E_SHELL
-glib_enum_prefix=e_shell
+ENUM_TYPES = e-shell.h
+
+e-shell-enumtypes.h: e-shell-enumtypes.h.template $(ENUM_TYPES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-shell-enumtypes.h.template $(ENUM_TYPES)) > $@
+
+e-shell-enumtypes.c: e-shell-enumtypes.c.template $(ENUM_TYPES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template e-shell-enumtypes.c.template $(ENUM_TYPES)) > $@
 
 ENUM_GENERATED = e-shell-enumtypes.h e-shell-enumtypes.c
 
@@ -190,6 +192,8 @@ errordir = $(privdatadir)/errors
 
 EXTRA_DIST = 					\
 	evo-version.h.in			\
+	e-shell-enumtypes.h.template		\
+	e-shell-enumtypes.c.template		\
 	shell.error.xml				\
 	evolution-icon.rc			\
 	evolution.ico				\
diff --git a/shell/e-shell-enumtypes.c.template b/shell/e-shell-enumtypes.c.template
new file mode 100644
index 0000000..4d30900
--- /dev/null
+++ b/shell/e-shell-enumtypes.c.template
@@ -0,0 +1,38 @@
+/*** BEGIN file-header ***/
+#include "e-shell-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/shell/e-shell-enumtypes.h.template b/shell/e-shell-enumtypes.h.template
new file mode 100644
index 0000000..76ff677
--- /dev/null
+++ b/shell/e-shell-enumtypes.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef E_SHELL_ENUMTYPES_H
+#define E_SHELL_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_SHELL_ENUMTYPES_H */
+/*** END file-tail ***/
+



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