[libgit2-glib] Generate enum types
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Generate enum types
- Date: Thu, 19 Jul 2012 11:17:09 +0000 (UTC)
commit 3b4d1250294a090e8de989a45f0d71278b14d0b9
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Thu Jul 19 13:17:02 2012 +0200
Generate enum types
configure.ac | 3 ++
libgit2-glib/Makefile.am | 24 ++++++++++++++++--
libgit2-glib/ggit-enum-types.c.template | 39 +++++++++++++++++++++++++++++++
libgit2-glib/ggit-enum-types.h.template | 27 +++++++++++++++++++++
libgit2-glib/ggit.h | 1 +
5 files changed, 91 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 14a53de..f3d5768 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,9 @@ AM_INIT_AUTOMAKE
AC_PROG_LIBTOOL
AC_PROG_CC
+# GLib enums
+AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
+
# Documentation
GTK_DOC_CHECK([1.11], [--flavour=no-tmpl])
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index aec8ce1..9b9e3e3 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -87,13 +87,27 @@ C_FILES = \
ggit-types.c \
ggit-utils.c
+ENUM_TYPES = \
+ $(INST_H_FILES)
+
+ggit-enum-types.h: ggit-enum-types.h.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template ggit-enum-types.h.template $(ENUM_TYPES)) > $@
+
+ggit-enum-types.c: ggit-enum-types.c.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template ggit-enum-types.c.template $(ENUM_TYPES)) > $@
+
+BUILT_SOURCES = \
+ ggit-enum-types.c \
+ ggit-enum-types.h
+
libgit2_glib_1_0_la_SOURCES = \
$(INST_H_FILES) \
$(NOINST_H_FILES) \
+ $(BUILT_SOURCES) \
$(C_FILES)
headerdir = $(prefix)/include/libgit2-glib-1.0/libgit2-glib
-header_DATA = $(INST_H_FILES)
+header_DATA = $(INST_H_FILES) ggit-enum-types.h
if ENABLE_PYTHON
overridesdir = $(pyoverridesdir)
@@ -101,8 +115,12 @@ overrides_PYTHON = \
Ggit.py
endif
-EXTRA_DIST = Ggit.py
-CLEANFILES =
+EXTRA_DIST = \
+ Ggit.py \
+ ggit-enum-types.h.template \
+ ggit-enum-types.c.template
+
+CLEANFILES = $(BUILT_SOURCES)
if HAVE_INTROSPECTION
-include $(INTROSPECTION_MAKEFILE)
diff --git a/libgit2-glib/ggit-enum-types.c.template b/libgit2-glib/ggit-enum-types.c.template
new file mode 100644
index 0000000..2c5f15b
--- /dev/null
+++ b/libgit2-glib/ggit-enum-types.c.template
@@ -0,0 +1,39 @@
+/*** BEGIN file-header ***/
+#include "ggit-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/libgit2-glib/ggit-enum-types.h.template b/libgit2-glib/ggit-enum-types.h.template
new file mode 100644
index 0000000..7d7c564
--- /dev/null
+++ b/libgit2-glib/ggit-enum-types.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef __GGIT_ENUM_TYPES_H__
+#define __GGIT_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* Enumerations from "@filename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+#define GGIT_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 /* __GGIT_ENUM_TYPES_H__ */
+/*** END file-tail ***/
+
diff --git a/libgit2-glib/ggit.h b/libgit2-glib/ggit.h
index 171d003..8ac4504 100644
--- a/libgit2-glib/ggit.h
+++ b/libgit2-glib/ggit.h
@@ -29,6 +29,7 @@
#include <libgit2-glib/ggit-diff-file.h>
#include <libgit2-glib/ggit-diff-options.h>
#include <libgit2-glib/ggit-diff-range.h>
+#include <libgit2-glib/ggit-enum-types.h>
#include <libgit2-glib/ggit-error.h>
#include <libgit2-glib/ggit-index.h>
#include <libgit2-glib/ggit-index-entry.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]