[tracker/gsettings-rebased: 3/8] libtracker-common: Add type generation for libtracker-common enums.



commit 0f3f1cf55cbb82045b81494f6d34ab9feeccaa94
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Feb 17 14:18:42 2011 +0100

    libtracker-common: Add type generation for libtracker-common enums.

 configure.ac                                       |    3 +
 src/libtracker-common/Makefile.am                  |   27 +++++++++---
 .../tracker-enum-types.c.template                  |   44 ++++++++++++++++++++
 .../tracker-enum-types.h.template                  |   26 ++++++++++++
 4 files changed, 94 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e587ab7..dfc9f71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -662,6 +662,9 @@ fi
 GLIB_GENMARSHAL=`$PKG_CONFIG glib-2.0 --variable=glib_genmarshal`
 AC_SUBST(GLIB_GENMARSHAL)
 
+GLIB_MKENUMS=`$PKG_CONFIG glib-2.0 --variable=glib_mkenums`
+AC_SUBST(GLIB_MKENUMS)
+
 ####################################################################
 # Should we build GLib based unit tests
 ####################################################################
diff --git a/src/libtracker-common/Makefile.am b/src/libtracker-common/Makefile.am
index a5d2a2d..f0d4f78 100644
--- a/src/libtracker-common/Makefile.am
+++ b/src/libtracker-common/Makefile.am
@@ -16,7 +16,7 @@ os_sources = tracker-os-dependant-unix.c
 endif
 
 libtracker_common_la_SOURCES = \
-	$(marshal_sources) \
+	$(BUILD_SOURCES) \
 	$(os_sources) \
 	tracker-config-file.c \
 	tracker-date-time.c \
@@ -86,11 +86,26 @@ tracker-marshal.c: tracker-marshal.list
 	$(AM_V_GEN)echo "#include \"tracker-marshal.h\"" > $@ && \
 		   $(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --body >> $@
 
-BUILT_SOURCES =	$(marshal_sources)
+tracker-enum-types.h: tracker-enum-types.h.template $(NOINST_H_FILES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template tracker-enum-types.h.template $(noinst_HEADERS)) > $@
 
-CLEANFILES = $(marshal_sources)
+tracker-enum-types.c: tracker-enum-types.c.template $(NOINST_H_FILES)
+	$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template tracker-enum-types.c.template $(noinst_HEADERS)) > $@
 
-EXTRA_DIST = \
-	tracker-marshal.list \
-	libtracker-common.vapi
+
+BUILT_SOURCES =	                                       \
+	$(marshal_sources)                             \
+	tracker-enum-types.c                           \
+	tracker-enum-types.h
+
+CLEANFILES =                                           \
+	$(marshal_sources)                             \
+	tracker-enum-types.c                           \
+	tracker-enum-types.h
+
+EXTRA_DIST =                                           \
+	tracker-marshal.list                           \
+	libtracker-common.vapi                         \
+	tracker-enum-types.c.template                  \
+	tracker-enum-types.h.template
 
diff --git a/src/libtracker-common/tracker-enum-types.c.template b/src/libtracker-common/tracker-enum-types.c.template
new file mode 100644
index 0000000..f71ace8
--- /dev/null
+++ b/src/libtracker-common/tracker-enum-types.c.template
@@ -0,0 +1,44 @@
+/*** BEGIN file-header ***/
+#include <config.h>
+
+#include "tracker-enum-types.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 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 ***/
+
+/*** BEGIN file-tail ***/
+
+/*** END file-tail ***/
diff --git a/src/libtracker-common/tracker-enum-types.h.template b/src/libtracker-common/tracker-enum-types.h.template
new file mode 100644
index 0000000..a2ba63b
--- /dev/null
+++ b/src/libtracker-common/tracker-enum-types.h.template
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+
+#ifndef __TRACKER_ENUMS_TYPES_H__
+#define __TRACKER_ENUMS_TYPES_H__
+
+#include <glib-object.h>
+#include "tracker-enums.h"
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name _get_type (void) G_GNUC_CONST;
+#define TRACKER_TYPE_ ENUMSHORT@ (@enum_name _get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __TRACKER_ENUMS_TYPES_H__ */
+/*** END file-tail ***/



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