[msitools] Generate GObject enum/flags types



commit e0b5fcb1c513c8360dd41e005c124600e6b62e4a
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Thu Jan 17 19:04:32 2013 +0100

    Generate GObject enum/flags types

 Makefile.am                      |   18 +++++++-----
 configure.ac                     |    1 +
 include/libmsi-enums.h.etemplate |   37 +++++++++++++++++++++++++
 include/libmsi-types.h           |    4 +-
 include/libmsi.h                 |    1 +
 libmsi/Makefile.am               |    9 +++++-
 libmsi/libmsi-enums.c.etemplate  |   56 ++++++++++++++++++++++++++++++++++++++
 tests/Makefile.am                |    2 +-
 8 files changed, 115 insertions(+), 13 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3fc1c55..beae662 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,15 +1,17 @@
 NULL =
 ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = data libmsi tests po .
+SUBDIRS = include data libmsi tests po .
 
 libmsiincludedir = $(includedir)/libmsi-1.0
-dist_libmsiinclude_HEADERS = \
-	include/libmsi.h \
-	include/libmsi-database.h \
-	include/libmsi-query.h \
-	include/libmsi-record.h \
-	include/libmsi-summary-info.h \
-	include/libmsi-types.h
+dist_libmsiinclude_HEADERS =			\
+	include/libmsi-database.h		\
+	include/libmsi-enums.h			\
+	include/libmsi-query.h			\
+	include/libmsi-record.h			\
+	include/libmsi-summary-info.h		\
+	include/libmsi-types.h			\
+	include/libmsi.h			\
+	$(NULL)
 
 AM_CPPFLAGS = -Iinclude -I$(srcdir)/include	\
 	$(GLIB_CFLAGS) $(GSF_CFLAGS) $(UUID_CFLAGS) \
diff --git a/configure.ac b/configure.ac
index 9f37678..0d32618 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,7 @@ AC_CONFIG_FILES([tests/package.m4.tmp:tests/package.m4.in],
 
 AC_CONFIG_FILES([
     Makefile
+    include/Makefile
     data/Makefile
     po/Makefile.in
     libmsi/Makefile
diff --git a/include/libmsi-enums.h.etemplate b/include/libmsi-enums.h.etemplate
new file mode 100644
index 0000000..442dc03
--- /dev/null
+++ b/include/libmsi-enums.h.etemplate
@@ -0,0 +1,37 @@
+/*** BEGIN file-header ***/
+/*
+ * Copyright (C) 2002,2003 Mike McCormack
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef LIBMSI_ENUMS_H
+#define LIBMSI_ENUMS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name _get_type (void) G_GNUC_CONST;
+#define LIBMSI_TYPE_ ENUMSHORT@ (@enum_name _get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif
+/*** END file-tail ***/
diff --git a/include/libmsi-types.h b/include/libmsi-types.h
index 857393d..73edcf4 100644
--- a/include/libmsi-types.h
+++ b/include/libmsi-types.h
@@ -36,7 +36,7 @@ typedef struct _LibmsiSummaryInfo LibmsiSummaryInfo;
 
 typedef enum LibmsiResultError
 {
-    LIBMSI_RESULT_SUCCESS, // FIXME: remove me
+    LIBMSI_RESULT_SUCCESS, /* FIXME: remove me */
     LIBMSI_RESULT_ACCESS_DENIED,
     LIBMSI_RESULT_INVALID_HANDLE,
     LIBMSI_RESULT_NOT_ENOUGH_MEMORY,
@@ -82,7 +82,7 @@ typedef enum LibmsiColInfo
 
 typedef enum LibmsiDBError
 {
-    LIBMSI_DB_ERROR_SUCCESS, // FIXME: remove me
+    LIBMSI_DB_ERROR_SUCCESS, /* FIXME: remove me */
     LIBMSI_DB_ERROR_INVALIDARG,
     LIBMSI_DB_ERROR_MOREDATA,
     LIBMSI_DB_ERROR_FUNCTIONERROR,
diff --git a/include/libmsi.h b/include/libmsi.h
index fc39237..44358b9 100644
--- a/include/libmsi.h
+++ b/include/libmsi.h
@@ -24,5 +24,6 @@
 #include <libmsi-query.h>
 #include <libmsi-record.h>
 #include <libmsi-summary-info.h>
+#include <libmsi-enums.h>
 
 #endif /* _LIBMSI_H */
diff --git a/libmsi/Makefile.am b/libmsi/Makefile.am
index 023ac73..e75ff77 100644
--- a/libmsi/Makefile.am
+++ b/libmsi/Makefile.am
@@ -20,6 +20,7 @@ libmsi_la_SOURCES =				\
 	drop.c					\
 	insert.c				\
 	libmsi-database.c			\
+	libmsi-enums.c				\
 	libmsi-istream.h			\
 	libmsi-istream.c			\
 	libmsi-query.c				\
@@ -44,6 +45,8 @@ libmsi_la_LDFLAGS = -no-undefined -rpath $(libdir) \
 
 libmsi_la_LIBADD = $(GLIB_LIBS) $(GSF_LIBS) $(GOBJECT_LIBS)
 
+EXTRA_DIST = libmsi-enums.c.etemplate
+
 INTROSPECTION_SCANNER_ARGS = --warn-all
 
 if GIR
@@ -57,16 +60,18 @@ Libmsi_1_0_gir_CFLAGS = $(AM_CPPFLAGS)
 Libmsi_1_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gio-2.0
 Libmsi_1_0_gir_LIBS = libmsi.la
 Libmsi_1_0_gir_FILES =					\
-	$(top_srcdir)/include/libmsi.h			\
-	$(top_srcdir)/include/libmsi-types.h		\
 	$(top_srcdir)/include/libmsi-database.h		\
 	$(top_srcdir)/include/libmsi-query.h		\
 	$(top_srcdir)/include/libmsi-record.h		\
 	$(top_srcdir)/include/libmsi-summary-info.h	\
+	$(top_srcdir)/include/libmsi-types.h		\
+	$(top_srcdir)/include/libmsi.h			\
 	$(top_srcdir)/libmsi/libmsi-database.c		\
 	$(top_srcdir)/libmsi/libmsi-query.c		\
 	$(top_srcdir)/libmsi/libmsi-record.c		\
 	$(top_srcdir)/libmsi/libmsi-summary-info.c	\
+	$(top_builddir)/include/libmsi-enums.h		\
+	libmsi-enums.c					\
 	$(NULL)
 Libmsi_1_0_gir_EXPORT_PACKAGES = libmsi-1.0
 Libmsi_1_0_gir_SCANNERFLAGS = --c-include="libmsi.h"
diff --git a/libmsi/libmsi-enums.c.etemplate b/libmsi/libmsi-enums.c.etemplate
new file mode 100644
index 0000000..04d7cf1
--- /dev/null
+++ b/libmsi/libmsi-enums.c.etemplate
@@ -0,0 +1,56 @@
+/*** BEGIN file-header ***/
+/*
+ * Copyright (C) 2002,2003 Mike McCormack
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "libmsi-enums.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+#include "@filename@"
+/*** END file-production ***/
+
+
+/*** BEGIN value-header ***/
+
+GType
+ enum_name@_get_type (void)
+{
+  static volatile gsize g_define_type_id__volatile = 0;
+
+  if (g_once_init_enter (&g_define_type_id__volatile))
+    {
+      static const G Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+        { 0, NULL, NULL }
+      };
+      GType g_define_type_id =
+        g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+    }
+
+  return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cced9d6..21c4620 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(srcdir) -I. \
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(srcdir) -I. \
 	      $(GLIB_CFLAGS) $(GOBJECT_CFLAGS)
 
 dist_noinst_HEADERS = test.h



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