[lasem] Use glib-mkenums to generate GTypes for enums.



commit b7ef60b8ed88b25478d567067195cd5317f340cc
Author: Jorn Baayen <jorn baayen gmail com>
Date:   Sun Oct 4 10:07:04 2009 +0200

    Use glib-mkenums to generate GTypes for enums.
    
    Signed-off-by: Emmanuel Pacaud <emmanuel pacaud lapp in2p3 fr>

 configure.ac                |    2 ++
 src/Makefile.am             |   12 ++++++++++++
 src/lsmenumtypes.c.template |   39 +++++++++++++++++++++++++++++++++++++++
 src/lsmenumtypes.h.template |   26 ++++++++++++++++++++++++++
 4 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a7ce0c2..5653346 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,8 @@ PKG_CHECK_MODULES(LASEM, [gobject-2.0 glib-2.0 gio-2.0 gdk-pixbuf-2.0 >= 2.16 gd
 AC_SUBST(LASEM_CFLAGS)
 AC_SUBST(LASEM_LIBS)
 
+AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
+
 AC_OUTPUT([
 Makefile
 itex2mml/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index c54a255..df540f7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,11 +12,14 @@ AM_CFLAGS =\
 
 lib_LTLIBRARIES = liblasem.la
 
+BUILT_SOURCES = lsmenumtypes.c lsmenumtypes.h
+
 liblasem_la_LIBADD = 				\
 	../itex2mml/libitex2mml.la		\
 	$(LASEM_LIBS)
 
 liblasem_la_SOURCES =				\
+	lsmenumtypes.c			\
 	lsmdebug.c				\
 	lsmstr.c				\
 	lsmtraits.c				\
@@ -100,6 +103,7 @@ liblasem_la_SOURCES =				\
 liblasem_ladir = $(includedir)/lasem
 liblasem_la_HEADERS = \
 	lsm.h					\
+	lsmenumtypes.h			\
 	lsmstr.h				\
 	lsmdebug.h				\
 	lsmtraits.h				\
@@ -184,6 +188,12 @@ liblasem_la_HEADERS = \
 	lsmsvgpatternelement.h			\
 	lsmsvgmaskelement.h
 
+lsmenumtypes.h: lsmenumtypes.h.template $(liblasem_la_HEADERS) $(GLIB_MKENUMS)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template lsmenumtypes.h.template $(liblasem_la_HEADERS)) > $@
+
+lsmenumtypes.c: lsmenumtypes.c.template $(liblasem_la_HEADERS) $(GLIB_MKENUMS)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template lsmenumtypes.c.template $(liblasem_la_HEADERS)) > $@
+
 bin_PROGRAMS = lasemtest lasemrender
 
 lasemrender_SOURCES = 				\
@@ -199,3 +209,5 @@ lasemtest_SOURCES = 				\
 lasemtest_LDFLAGS =
 
 lasemtest_LDADD = $(LASEM_LIBS) liblasem.la ../itex2mml/libitex2mml.la
+
+CLEAN_FILES = $(BUILT_SOURCES)
diff --git a/src/lsmenumtypes.c.template b/src/lsmenumtypes.c.template
new file mode 100644
index 0000000..a4cd708
--- /dev/null
+++ b/src/lsmenumtypes.c.template
@@ -0,0 +1,39 @@
+/*** BEGIN file-header ***/
+#include "lsmenumtypes.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/lsmenumtypes.h.template b/src/lsmenumtypes.h.template
new file mode 100644
index 0000000..528cd5d
--- /dev/null
+++ b/src/lsmenumtypes.h.template
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+#ifndef LSM_ENUM_TYPES_H
+#define LSM_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 LSM_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 /* LSM_ENUM_TYPES_H */
+/*** END file-tail ***/



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