[devhelp: 6/7] Generate enum types for the application
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp: 6/7] Generate enum types for the application
- Date: Wed, 3 May 2017 15:32:56 +0000 (UTC)
commit 1caedc3df706616a3eb578ad53bd74875d3a4859
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed May 3 17:05:25 2017 +0200
Generate enum types for the application
dh-enum-types.[ch] are for the library.
Generate dh-enum-types-app.[ch] for the enums that are part of only the
application. Currently the only source file of the app is dh-main.c, so
there are no enums, but some files will be moved from the lib to the
app, so it'll be useful (for DhWindow).
docs/reference/Makefile.am | 1 +
src/Makefile.am | 45 ++++++++++++++++++++++++++++++++-----
src/dh-enum-types-app.c.template | 39 ++++++++++++++++++++++++++++++++
src/dh-enum-types-app.h.template | 27 ++++++++++++++++++++++
4 files changed, 106 insertions(+), 6 deletions(-)
---
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 262bd50..17a5550 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -48,6 +48,7 @@ IGNORE_HFILES = \
dh-app.h \
dh-assistant.h \
dh-enum-types.h \
+ dh-enum-types-app.h \
dh-error.h \
dh-parser.h \
dh-preferences.h \
diff --git a/src/Makefile.am b/src/Makefile.am
index 12f8c88..61b4e3d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,17 +63,38 @@ libdevhelp_built_public_c_files = \
dh-enum-types.c \
$(NULL)
-app_c_files = \
- dh-main.c \
- $(NULL)
-
-BUILT_SOURCES = \
+libdevhelp_built_sources = \
$(libdevhelp_built_public_headers) \
$(libdevhelp_built_public_c_files) \
dh-resources.c \
dh-resources.h \
$(NULL)
+app_headers = \
+ $(NULL)
+
+app_c_files = \
+ dh-main.c \
+ $(NULL)
+
+app_built_headers = \
+ dh-enum-types-app.h \
+ $(NULL)
+
+app_built_c_files = \
+ dh-enum-types-app.c \
+ $(NULL)
+
+app_built_sources = \
+ $(app_built_headers) \
+ $(app_built_c_files) \
+ $(NULL)
+
+BUILT_SOURCES = \
+ $(libdevhelp_built_sources) \
+ $(app_built_sources) \
+ $(NULL)
+
# The library
lib_LTLIBRARIES = libdevhelp-3.la
@@ -89,7 +110,7 @@ libdevhelp_3_la_SOURCES = \
# Do not distribute generated files.
nodist_libdevhelp_3_la_SOURCES = \
- $(BUILT_SOURCES)
+ $(libdevhelp_built_sources)
libdevhelp_3_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
@@ -114,9 +135,13 @@ libdevhelp_3_la_LDFLAGS = \
bin_PROGRAMS = devhelp
devhelp_SOURCES = \
+ $(app_headers) \
$(app_c_files) \
$(NULL)
+nodist_devhelp_SOURCES = \
+ $(app_built_sources)
+
devhelp_CPPFLAGS = \
$(AM_CPPFLAGS)
@@ -142,9 +167,17 @@ dh-enum-types.h: dh-enum-types.h.template $(libdevhelp_public_headers) $(GLIB_MK
dh-enum-types.c: dh-enum-types.c.template $(libdevhelp_public_headers) $(GLIB_MKENUMS)
$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template dh-enum-types.c.template
$(libdevhelp_public_headers)) > $@
+dh-enum-types-app.h: dh-enum-types-app.h.template $(app_headers) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template dh-enum-types-app.h.template $(app_headers))
$@
+
+dh-enum-types-app.c: dh-enum-types-app.c.template $(app_headers) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template dh-enum-types-app.c.template $(app_headers))
$@
+
EXTRA_DIST = \
dh-enum-types.c.template \
dh-enum-types.h.template \
+ dh-enum-types-app.c.template \
+ dh-enum-types-app.h.template \
dh.gresource.xml \
$(resource_files) \
$(NULL)
diff --git a/src/dh-enum-types-app.c.template b/src/dh-enum-types-app.c.template
new file mode 100644
index 0000000..c7262e0
--- /dev/null
+++ b/src/dh-enum-types-app.c.template
@@ -0,0 +1,39 @@
+/*** BEGIN file-header ***/
+#include "dh-enum-types-app.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/src/dh-enum-types-app.h.template b/src/dh-enum-types-app.h.template
new file mode 100644
index 0000000..28f6861
--- /dev/null
+++ b/src/dh-enum-types-app.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef DH_ENUM_TYPES_APP_H
+#define DH_ENUM_TYPES_APP_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* Enumerations from "@filename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+#define DH_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* DH_ENUM_TYPES_APP_H */
+/*** END file-tail ***/
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]