[geocode-glib/gnome-maps: 4/6] lib: Use glib-mkenums to register enums with glib



commit c1534583923d51bdc8ef589ebb53f10faa71f75b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sun Mar 24 02:48:42 2013 +0200

    lib: Use glib-mkenums to register enums with glib
    
    Based on a similar patch in libvirt-glib from Christophe Fergeau
    <cfergeau redhat com>.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=696527

 configure.ac                               |    3 ++
 geocode-glib/Makefile.am                   |   35 +++++++++++++++++++-------
 geocode-glib/geocode-enum-types.c.template |   36 ++++++++++++++++++++++++++++
 geocode-glib/geocode-enum-types.h.template |   24 ++++++++++++++++++
 geocode-glib/geocode-glib.h                |    1 +
 geocode-glib/geocode-glib.symbols          |    1 +
 6 files changed, 90 insertions(+), 10 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0d72010..48c8bfb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,9 @@ GNOME_COMPILE_WARNINGS([maximum])
 GNOME_CXX_WARNINGS
 GNOME_MAINTAINER_MODE_DEFINES
 
+GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+AC_SUBST(GLIB_MKENUMS)
+
 if test "$GCC" = "yes" ; then
        CFLAGS="\
        -Wall \
diff --git a/geocode-glib/Makefile.am b/geocode-glib/Makefile.am
index 6af610d..2d15bcf 100644
--- a/geocode-glib/Makefile.am
+++ b/geocode-glib/Makefile.am
@@ -2,22 +2,23 @@ include $(top_srcdir)/Makefile.decl
 
 SUBDIRS = geocode-ip-server
 
-EXTRA_DIST = geocode-glib.symbols
+EXTRA_DIST =
+       geocode-glib.symbols                            \
+       geocode-enum-types.h.template                   \
+       geocode-enum-types.c.template
+
 BUILT_GIRSOURCES =
 
 lib_LTLIBRARIES = libgeocode-glib.la
 
-public_files =                                         \
-       $(gcglib_HEADERS)                               \
+libgeocode_glib_la_SOURCES =                           \
        geocode-location.c                              \
        geocode-forward.c                               \
        geocode-reverse.c                               \
        geocode-glib.c                                  \
        geocode-error.c                                 \
-       geocode-ipclient.c
-
-libgeocode_glib_la_SOURCES =                           \
-       $(public_files)                                 \
+       geocode-ipclient.c                              \
+       geocode-enum-types.c
        geocode-glib-private.h
 
 libgeocode_glib_la_LIBADD = $(GEOCODE_LIBS)
@@ -28,8 +29,7 @@ libgeocode_glib_la_LDFLAGS =                          \
        $(AM_LDFLAGS)                                   \
        -export-symbols $(srcdir)/geocode-glib.symbols
 
-gcglibdir = $(pkgincludedir)
-gcglib_HEADERS = \
+GCGLIB_HEADER_FILES = \
        geocode-glib.h                                  \
        geocode-location.h                              \
        geocode-forward.h                               \
@@ -37,8 +37,23 @@ gcglib_HEADERS = \
        geocode-error.h                                 \
        geocode-ipclient.h
 
+gcglibdir = $(pkgincludedir)
+gcglib_HEADERS =                                       \
+       $(GCGLIB_HEADER_FILES)                          \
+       geocode-enum-types.h
+
 AM_CFLAGS = -I$(top_srcdir) $(GEOCODE_CFLAGS) $(COMMON_CFLAGS) $(WARN_CFLAGS) $(DISABLE_DEPRECATED) 
-DTEST_SRCDIR=\""$(srcdir)/data/"\"
 
+BUILT_SOURCES = \
+               geocode-enum-types.c \
+               geocode-enum-types.h
+
+geocode-enum-types.h: $(GCGLIB_HEADER_FILES) geocode-enum-types.h.template
+       $(GLIB_MKENUMS) --template geocode-enum-types.h.template $(GCGLIB_HEADER_FILES) >geocode-enum-types.h
+
+geocode-enum-types.c: $(GCGLIB_HEADER_FILES) geocode-enum-types.c.template
+       $(GLIB_MKENUMS) --template geocode-enum-types.c.template $(GCGLIB_HEADER_FILES) >geocode-enum-types.c
+
 -include $(INTROSPECTION_MAKEFILE)
 INTROSPECTION_GIRS =
 INTROSPECTION_SCANNER_ARGS = --warn-all --add-include-path=$(top_srcdir)
@@ -46,7 +61,7 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(top_srcdir)
 CLEANFILES =
 
 if HAVE_INTROSPECTION
-introspection_files = $(public_files)
+introspection_files = $(libgeocode_glib_la_SOURCES) $(gcglib_HEADERS)
 
 GeocodeGlib-1.0.gir: libgeocode-glib.la
 GeocodeGlib_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0 Json-1.0 SoupGNOME-2.4
diff --git a/geocode-glib/geocode-enum-types.c.template b/geocode-glib/geocode-enum-types.c.template
new file mode 100644
index 0000000..1e7790a
--- /dev/null
+++ b/geocode-glib/geocode-enum-types.c.template
@@ -0,0 +1,36 @@
+/*** BEGIN file-header ***/
+#include <geocode-glib/geocode-glib.h>
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@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/geocode-glib/geocode-enum-types.h.template b/geocode-glib/geocode-enum-types.h.template
new file mode 100644
index 0000000..d2e3c69
--- /dev/null
+++ b/geocode-glib/geocode-enum-types.h.template
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __GEOCODE_ENUM_TYPES_H__
+#define __GEOCODE_ENUM_TYPES_H__
+
+#include <geocode-glib/geocode-glib.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 @ENUMPREFIX _TYPE_@ENUMSHORT@ (@enum_name _get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __GEOCODE_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/geocode-glib/geocode-glib.h b/geocode-glib/geocode-glib.h
index 1253171..53a5fba 100644
--- a/geocode-glib/geocode-glib.h
+++ b/geocode-glib/geocode-glib.h
@@ -30,6 +30,7 @@
 #include <geocode-glib/geocode-reverse.h>
 #include <geocode-glib/geocode-ipclient.h>
 #include <geocode-glib/geocode-error.h>
+#include <geocode-glib/geocode-enum-types.h>
 
 G_BEGIN_DECLS
 
diff --git a/geocode-glib/geocode-glib.symbols b/geocode-glib/geocode-glib.symbols
index 5245bf9..9dfb37e 100644
--- a/geocode-glib/geocode-glib.symbols
+++ b/geocode-glib/geocode-glib.symbols
@@ -17,6 +17,7 @@ geocode_reverse_resolve_async
 geocode_reverse_resolve_finish
 geocode_reverse_resolve
 geocode_error_quark
+geocode_error_get_type
 _geocode_parse_search_json
 _geocode_parse_resolve_json
 geocode_ipclient_get_type


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