[gspell] Generate enum types



commit a75ed0177dbbc49e634230e103a3dcdbd8383d1e
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Jun 20 13:39:55 2016 +0200

    Generate enum types

 configure.ac                           |    2 +
 docs/reference/Makefile.am             |    5 ++++
 docs/reference/gspell-1.0-sections.txt |    2 +
 gspell/Makefile.am                     |   30 ++++++++++++++++++++---
 gspell/gspell-enum-types.c.template    |   41 ++++++++++++++++++++++++++++++++
 gspell/gspell-enum-types.h.template    |   30 +++++++++++++++++++++++
 gspell/gspell.h                        |    2 +
 7 files changed, 108 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 43869e0..078be03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,6 +72,8 @@ AX_REQUIRE_DEFINED([PKG_INSTALLDIR])
 PKG_PROG_PKG_CONFIG
 PKG_INSTALLDIR
 
+AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
+
 # Needed on Mac OS X
 AC_PROG_OBJC
 
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 97efc7a..3bf6622 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -21,6 +21,11 @@ DOC_SOURCE_DIR = $(top_srcdir)/gspell
 HFILE_GLOB = $(top_srcdir)/gspell/*.h
 CFILE_GLOB = $(top_srcdir)/gspell/*.c
 
+# Extra header to include when scanning, which are not under DOC_SOURCE_DIR
+# e.g. EXTRA_HFILES = $(top_srcdir)/contrib/extra.h
+EXTRA_HFILES =                                         \
+       $(top_builddir)/gspell/gspell-enum-types.h
+
 # Header files or dirs to ignore when scanning. Use base file/dir names
 # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
 IGNORE_HFILES =                                        \
diff --git a/docs/reference/gspell-1.0-sections.txt b/docs/reference/gspell-1.0-sections.txt
index 7e9feba..431ea46 100644
--- a/docs/reference/gspell-1.0-sections.txt
+++ b/docs/reference/gspell-1.0-sections.txt
@@ -19,6 +19,8 @@ gspell_checker_set_correction
 GspellCheckerClass
 GSPELL_TYPE_CHECKER
 gspell_checker_error_quark
+GSPELL_TYPE_CHECKER_ERROR
+gspell_checker_error_get_type
 </SECTION>
 
 <SECTION>
diff --git a/gspell/Makefile.am b/gspell/Makefile.am
index 8791f2a..98b3d11 100644
--- a/gspell/Makefile.am
+++ b/gspell/Makefile.am
@@ -13,9 +13,6 @@ AM_CPPFLAGS =                         \
        $(DEP_CFLAGS)                   \
        $(GTK_MAC_CFLAGS)
 
-BUILT_SOURCES =                        \
-       gspell-resources.c
-
 gspell_public_headers =                                \
        gspell.h                                \
        gspell-checker.h                        \
@@ -56,6 +53,17 @@ gspell_private_c_files =                     \
        gspell-text-iter.c                      \
        gspell-utils.c
 
+gspell_built_public_headers =          \
+       gspell-enum-types.h
+
+gspell_built_public_c_files =          \
+       gspell-enum-types.c
+
+BUILT_SOURCES =                                \
+       gspell-resources.c              \
+       $(gspell_built_public_c_files)  \
+       $(gspell_built_public_headers)
+
 # Helper Libtool library, so that the private functions can be used in unit
 # tests.
 noinst_LTLIBRARIES = libgspell-core.la
@@ -100,11 +108,24 @@ libgspell_ GSPELL_API_VERSION@_la_LDFLAGS =       \
 
 libgspell_includedir = $(includedir)/gspell- GSPELL_API_VERSION@/gspell
 libgspell_include_HEADERS = $(gspell_public_headers)
+nodist_libgspell_include_HEADERS = $(gspell_built_public_headers)
 
 xml_res = $(srcdir)/resources/gspell.gresource.xml
 gspell-resources.c: $(xml_res) $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/resources 
--generate-dependencies $(xml_res))
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/resources --generate-source 
$(xml_res)
 
+ENUM_TYPES = $(gspell_public_headers)
+
+gspell-enum-types.h: gspell-enum-types.h.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+       $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gspell-enum-types.h.template $(ENUM_TYPES)) > 
$@
+
+gspell-enum-types.c: gspell-enum-types.c.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+       $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gspell-enum-types.c.template $(ENUM_TYPES)) > 
$@
+
+EXTRA_DIST =                           \
+       gspell-enum-types.c.template    \
+       gspell-enum-types.h.template
+
 CLEANFILES = $(BUILT_SOURCES)
 
 if OS_OSX
@@ -142,7 +163,8 @@ Gspell_ GSPELL_API_VERSION@_gir_LIBS = libgspell- GSPELL_API_VERSION@.la
 Gspell_ GSPELL_API_VERSION@_gir_FILES =        \
        $(gspell_public_headers)        \
        $(gspell_public_c_files)        \
-       $(BUILT_SOURCES)
+       $(gspell_built_public_headers)  \
+       $(gspell_built_public_c_files)
 
 Gspell_ GSPELL_API_VERSION@_gir_INCLUDES = Gtk-3.0
 Gspell_ GSPELL_API_VERSION@_gir_PACKAGES = gtk+-3.0
diff --git a/gspell/gspell-enum-types.c.template b/gspell/gspell-enum-types.c.template
new file mode 100644
index 0000000..f3909db
--- /dev/null
+++ b/gspell/gspell-enum-types.c.template
@@ -0,0 +1,41 @@
+/*** BEGIN file-header ***/
+#include "gspell-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 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/gspell/gspell-enum-types.h.template b/gspell/gspell-enum-types.h.template
new file mode 100644
index 0000000..7e83963
--- /dev/null
+++ b/gspell/gspell-enum-types.h.template
@@ -0,0 +1,30 @@
+/*** BEGIN file-header ***/
+#ifndef GSPELL_ENUM_TYPES_H
+#define GSPELL_ENUM_TYPES_H
+
+#if !defined (GSPELL_H_INSIDE) && !defined (GSPELL_COMPILATION)
+#error "Only <gspell/gspell.h> can be included directly."
+#endif
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* Enumerations from "@filename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+#define GSPELL_TYPE_ ENUMSHORT@ (@enum_name _get_type())
+GType @enum_name _get_type (void);
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* GSPELL_ENUM_TYPES_H */
+/*** END file-tail ***/
diff --git a/gspell/gspell.h b/gspell/gspell.h
index ac1c39d..98702c5 100644
--- a/gspell/gspell.h
+++ b/gspell/gspell.h
@@ -33,6 +33,8 @@
 #include <gspell/gspell-text-buffer.h>
 #include <gspell/gspell-text-view.h>
 
+#include <gspell/gspell-enum-types.h>
+
 #undef GSPELL_H_INSIDE
 
 #endif /* GSPELL_H */


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