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



commit 496adf5b93d0c131e999dbe9f2b68c99f1ba4db9
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          |   46 +++++++++++++++++++++++++++++--------
 geocode-glib/geocode-glib.h       |    1 +
 geocode-glib/geocode-glib.symbols |    1 +
 4 files changed, 41 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..dcfb726 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,34 @@ 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)
+       $(AM_V_GEN) ($(GLIB_MKENUMS) \
+               --fhead "#ifndef __GEOCODE_ENUM_TYPES_H__\n#define __GEOCODE_ENUM_TYPES_H__\n\n#include 
<glib-object.h>\n\nG_BEGIN_DECLS\n" \
+               --fprod "/* enumerations from \"@filename \" */\n" \
+               --vhead "GType @enum_name _get_type (void) G_GNUC_CONST;\n#define GEOCODE_TYPE_ ENUMSHORT@ 
(@enum_name _get_type())\n" \
+               --ftail "G_END_DECLS\n\n#endif /* __GEOCODE_ENUM_TYPES_H__ */" $^ > xgen-$(@F) \
+               && mv -f xgen-$(@F) $@)
+
+geocode-enum-types.c: $(GCGLIB_HEADER_FILES) geocode-enum-types.h
+       $(AM_V_GEN) ($(GLIB_MKENUMS) \
+               --fhead "#include \"geocode-glib.h\"\n#include \"geocode-enum-types.h\"" \
+               --fprod "\n/* enumerations from \"@filename \" */" \
+               --vhead "GType\n enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) 
{\n    static const G Type@Value values[] = {" \
+               --vprod "      { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+               --vtail "      { 0, NULL, NULL }\n    };\n    etype = g_ type@_register_static (\"@EnumName 
\", values);\n  }\n  return etype;\n}\n" $^ > xgen-$(@F) \
+               && mv -f xgen-$(@F) $@)
+
 -include $(INTROSPECTION_MAKEFILE)
 INTROSPECTION_GIRS =
 INTROSPECTION_SCANNER_ARGS = --warn-all --add-include-path=$(top_srcdir)
@@ -46,7 +72,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-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]