[tepl] Amtk: generate enum types
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] Amtk: generate enum types
- Date: Mon, 17 Jul 2017 17:06:36 +0000 (UTC)
commit 77e7687be31039c06688cffd355ca2a238265f42
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Jul 17 17:43:54 2017 +0200
Amtk: generate enum types
amtk/Makefile.am | 33 +++++++++++++++++++++++++-
amtk/amtk-enum-types.c.template | 41 ++++++++++++++++++++++++++++++++++
amtk/amtk-enum-types.h.template | 30 ++++++++++++++++++++++++
amtk/amtk.h | 1 +
docs/reference/tepl-3.0-sections.txt | 2 +
5 files changed, 105 insertions(+), 2 deletions(-)
---
diff --git a/amtk/Makefile.am b/amtk/Makefile.am
index 78a0574..65e99c6 100644
--- a/amtk/Makefile.am
+++ b/amtk/Makefile.am
@@ -35,6 +35,12 @@ amtk_public_c_files = \
amtk-menu-shell.c \
amtk-utils.c
+amtk_built_public_headers = \
+ amtk-enum-types.h
+
+amtk_built_public_c_files = \
+ amtk-enum-types.c
+
# Helper Libtool library, so that the private functions can be used in unit
# tests.
noinst_LTLIBRARIES = libamtk-core.la
@@ -43,6 +49,14 @@ libamtk_core_la_SOURCES = \
$(amtk_public_c_files) \
$(amtk_public_headers)
+nodist_libamtk_core_la_SOURCES = \
+ $(amtk_built_public_c_files) \
+ $(amtk_built_public_headers)
+
+BUILT_SOURCES = \
+ $(amtk_built_public_c_files) \
+ $(amtk_built_public_headers)
+
libamtk_core_la_CFLAGS = \
$(CODE_COVERAGE_CFLAGS)
@@ -70,8 +84,21 @@ libamtk_@TEPL_API_VERSION@_la_LDFLAGS = \
libamtk_includedir = $(includedir)/amtk-@TEPL_API_VERSION@/amtk
libamtk_include_HEADERS = $(amtk_public_headers)
+nodist_libamtk_include_HEADERS = $(amtk_built_public_headers)
+
+ENUM_TYPES = $(amtk_public_headers)
+
+amtk-enum-types.h: amtk-enum-types.h.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template amtk-enum-types.h.template $(ENUM_TYPES)) > $@
+
+amtk-enum-types.c: amtk-enum-types.c.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template amtk-enum-types.c.template $(ENUM_TYPES)) > $@
+
+EXTRA_DIST = \
+ amtk-enum-types.c.template \
+ amtk-enum-types.h.template
-CLEANFILES =
+CLEANFILES = $(BUILT_SOURCES)
if HAVE_INTROSPECTION
-include $(INTROSPECTION_MAKEFILE)
@@ -94,7 +121,9 @@ Amtk_@TEPL_API_VERSION@_gir_SCANNERFLAGS = $(WARN_SCANNERFLAGS)
Amtk_@TEPL_API_VERSION@_gir_LIBS = libamtk-@TEPL_API_VERSION@.la
Amtk_@TEPL_API_VERSION@_gir_FILES = \
$(amtk_public_headers) \
- $(amtk_public_c_files)
+ $(amtk_public_c_files) \
+ $(amtk_built_public_headers) \
+ $(amtk_built_public_c_files)
Amtk_@TEPL_API_VERSION@_gir_INCLUDES = Gtk-3.0
Amtk_@TEPL_API_VERSION@_gir_PACKAGES = gtk+-3.0
diff --git a/amtk/amtk-enum-types.c.template b/amtk/amtk-enum-types.c.template
new file mode 100644
index 0000000..e6d30a7
--- /dev/null
+++ b/amtk/amtk-enum-types.c.template
@@ -0,0 +1,41 @@
+/*** BEGIN file-header ***/
+#include "amtk-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/amtk/amtk-enum-types.h.template b/amtk/amtk-enum-types.h.template
new file mode 100644
index 0000000..dbc1c49
--- /dev/null
+++ b/amtk/amtk-enum-types.h.template
@@ -0,0 +1,30 @@
+/*** BEGIN file-header ***/
+#ifndef AMTK_ENUM_TYPES_H
+#define AMTK_ENUM_TYPES_H
+
+#if !defined (AMTK_H_INSIDE) && !defined (AMTK_COMPILATION)
+#error "Only <amtk/amtk.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 AMTK_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+GType @enum_name@_get_type (void);
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* AMTK_ENUM_TYPES_H */
+/*** END file-tail ***/
diff --git a/amtk/amtk.h b/amtk/amtk.h
index f6c793f..b8c94fb 100644
--- a/amtk/amtk.h
+++ b/amtk/amtk.h
@@ -23,6 +23,7 @@
#define AMTK_H_INSIDE
#include <amtk/amtk-types.h>
+#include <amtk/amtk-enum-types.h>
#include <amtk/amtk-action-info.h>
#include <amtk/amtk-action-info-store.h>
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index ae3ab2a..c91078e 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -105,6 +105,8 @@ AMTK_TYPE_FACTORY
AmtkFactoryClass
AmtkFactoryPrivate
amtk_factory_get_type
+AMTK_TYPE_FACTORY_FLAGS
+amtk_factory_flags_get_type
</SECTION>
<SECTION>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]