aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-07-17 22:52:43 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-07-18 01:49:09 +0800
commitf22e38ffad3d6360920e278ac35c3a00102738ff (patch)
tree6e66ce1159f3d2b41ee46dc273d85d0639f5edfa /e-util
parentcc29868877436d404610039b719c5d781925d97e (diff)
downloadgsoc2013-evolution-f22e38ffad3d6360920e278ac35c3a00102738ff.tar.gz
gsoc2013-evolution-f22e38ffad3d6360920e278ac35c3a00102738ff.tar.zst
gsoc2013-evolution-f22e38ffad3d6360920e278ac35c3a00102738ff.zip
Use template files to generate GEnumClass types.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/Makefile.am23
-rw-r--r--e-util/e-util-enumtypes.c.template38
-rw-r--r--e-util/e-util-enumtypes.h.template27
3 files changed, 83 insertions, 5 deletions
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 7f6ef95782..4464f93045 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 0000000000..cb2634790c
--- /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 0000000000..c5bfa9c2c1
--- /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 ***/
+