aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-10-15 09:24:00 +0200
committerGuido Günther <agx@sigxcpu.org>2015-05-07 09:47:12 +0200
commit6dc49293225cf01f1663b6c7387c283057b3c30a (patch)
tree9c7963ef0e613eae01be783be977db22a34d18c6
parentea66ff6027b8f6a14da274a840f57fcd3bfb6556 (diff)
Create types for enums and flags
-rw-r--r--.gitignore2
-rw-r--r--libplanfahr/Makefile.am36
-rw-r--r--libplanfahr/libplanfahr.sym5
-rw-r--r--libplanfahr/lpf-enumtypes.c.template38
-rw-r--r--libplanfahr/lpf-enumtypes.h.template24
-rw-r--r--libplanfahr/lpf-provider.h6
-rw-r--r--libplanfahr/lpf-trip.c1
7 files changed, 104 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 3a0bc8f..836c942 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,6 +46,8 @@ docs/reference/libplanfahr-*-sections.txt
docs/reference/tmpl
docs/reference/xml
m4/
+libplanfahr/lpf-enumtypes.c
+libplanfahr/lpf-enumtypes.h
libplanfahr/tests/lpf-loc
libplanfahr/tests/lpf-trip
libplanfahr/tests/lpf-manager
diff --git a/libplanfahr/Makefile.am b/libplanfahr/Makefile.am
index f96cd13..82e8f43 100644
--- a/libplanfahr/Makefile.am
+++ b/libplanfahr/Makefile.am
@@ -2,7 +2,15 @@ include $(top_srcdir)/flymake.mk
SUBDIRS = providers tests
-EXTRA_DIST = libplanfahr.sym
+EXTRA_DIST = libplanfahr.sym \
+ lpf-enumtypes.c \
+ lpf-enumtypes.h \
+ $(NULL)
+
+BUILT_SOURCES = \
+ lpf-enumtypes.c \
+ lpf-enumtypes.h \
+ $(NULL)
lib_LTLIBRARIES = libplanfahr-0.0.la
@@ -17,7 +25,13 @@ PLANFAHR_HEADER_FILES = \
lpf-trip-part.h \
$(NULL)
+PLANFAHR_INCLUDE_HEADER_FILES = \
+ $(PLANFAHR_HEADER_FILES) \
+ lpf-enumtypes.h \
+ $(NULL)
+
PLANFAHR_SOURCE_FILES = \
+ lpf-enumtypes.c \
lpf-manager.c \
lpf-provider.c \
lpf-loc.c \
@@ -26,9 +40,17 @@ PLANFAHR_SOURCE_FILES = \
lpf-trip-part.c \
$(NULL)
+lpf-enumtypes.h: $(PLANFAHR_HEADER_FILES) lpf-enumtypes.h.template
+ $(AM_V_GEN) $(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
+ lpf-enumtypes.h.tmp && mv lpf-enumtypes.h.tmp lpf-enumtypes.h
+
+lpf-enumtypes.c: $(PLANFAHR_HEADER_FILES) lpf-enumtypes.c.template
+ $(AM_V_GEN) $(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
+ lpf-enumtypes.c.tmp && mv lpf-enumtypes.c.tmp lpf-enumtypes.c
+
libplanfahr_0_0_ladir = $(includedir)/libplanfahr-0.0/libplanfahr
libplanfahr_0_0_la_HEADERS = \
- $(PLANFAHR_HEADER_FILES) \
+ $(PLANFAHR_INCLUDE_HEADER_FILES) \
$(NULL)
libplanfahr_0_0_la_SOURCES = \
@@ -82,16 +104,20 @@ Lpf_0_0_gir_SCANNERFLAGS = \
$(NULL)
Lpf_0_0_gir_FILES = \
$(PLANFAHR_SOURCE_FILES:%=$(srcdir)/%) \
- $(PLANFAHR_HEADER_FILES:%=$(srcdir)/%) \
+ $(PLANFAHR_INCLUDE_HEADER_FILES:%=$(srcdir)/%) \
$(NULL)
girdir = $(datadir)/gir-1.0
nodist_gir_DATA = $(INTROSPECTION_GIRS)
-
typelibdir = $(libdir)/girepository-1.0
nodist_typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
-CLEANFILES = $(nodist_gir_DATA) $(nodist_typelib_DATA)
+CLEANFILES = \
+ $(nodist_gir_DATA) \
+ $(nodist_typelib_DATA) \
+ lpf-enumtypes.c \
+ lpf-enumtypes.h \
+ $(NULL)
endif # HAVE_INTROSPECTION
diff --git a/libplanfahr/libplanfahr.sym b/libplanfahr/libplanfahr.sym
index 0e7b5bf..1f16b11 100644
--- a/libplanfahr/libplanfahr.sym
+++ b/libplanfahr/libplanfahr.sym
@@ -32,6 +32,11 @@ LIBPLANFAHR_0.0.0 {
lpf_trip_part_get_end;
lpf_trip_part_get_start;
lpf_trip_part_get_stops;
+ /* Generated by glib-mkenums */
+ lpf_manager_error_get_type;
+ lpf_provider_error_get_type;
+ lpf_provider_get_locs_flags_get_type;
+ lpf_provider_get_trips_flags_get_type;
local:
*;
};
diff --git a/libplanfahr/lpf-enumtypes.c.template b/libplanfahr/lpf-enumtypes.c.template
new file mode 100644
index 0000000..8d24265
--- /dev/null
+++ b/libplanfahr/lpf-enumtypes.c.template
@@ -0,0 +1,38 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+#include "libplanfahr.h"
+#include "lpf-enumtypes.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/libplanfahr/lpf-enumtypes.h.template b/libplanfahr/lpf-enumtypes.h.template
new file mode 100644
index 0000000..c6cb02a
--- /dev/null
+++ b/libplanfahr/lpf-enumtypes.h.template
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __LPF_ENUM_TYPES_H__
+#define __LPF_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GLIB_AVAILABLE_IN_ALL 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 /* __LPF_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libplanfahr/lpf-provider.h b/libplanfahr/lpf-provider.h
index fb05a70..0bb98de 100644
--- a/libplanfahr/lpf-provider.h
+++ b/libplanfahr/lpf-provider.h
@@ -60,7 +60,7 @@ typedef enum {
*/
typedef enum
{
- LPF_PROVIDER_GET_LOCS_NONE = 0,
+ LPF_PROVIDER_GET_LOCS_NONE = 0, /*< nick=none >*/
} LpfProviderGetLocsFlags;
@@ -74,8 +74,8 @@ typedef enum
*/
typedef enum
{
- LPF_PROVIDER_GET_TRIPS_NONE = 0,
- LPF_PROVIDER_GET_TRIPS_ARRIVAL = 1 << 1,
+ LPF_PROVIDER_GET_TRIPS_NONE = 0, /*< nick=none >*/
+ LPF_PROVIDER_GET_TRIPS_ARRIVAL = 1 << 1, /*< nick=arrival >*/
} LpfProviderGetTripsFlags;
diff --git a/libplanfahr/lpf-trip.c b/libplanfahr/lpf-trip.c
index a6146a9..7e4bb3a 100644
--- a/libplanfahr/lpf-trip.c
+++ b/libplanfahr/lpf-trip.c
@@ -28,6 +28,7 @@
#include <glib/gprintf.h>
#include <gmodule.h>
+#include "lpf-enumtypes.h"
#include "lpf-trip.h"
#include "lpf-loc.h"
#include "lpf-priv.h"