[gexiv2] Use glib-mkenums to create enum types



commit 79f164dcd9acb1383e4ba6d62c3fd2e3c9509dd6
Author: Jens Georg <mail jensge org>
Date:   Sun May 14 22:42:09 2017 +0200

    Use glib-mkenums to create enum types

 Makefile.am                      |   22 ++++++++++++++++++++--
 configure.ac                     |   10 ++++++++++
 gexiv2/gexiv2-enums.cpp.template |   33 +++++++++++++++++++++++++++++++++
 gexiv2/gexiv2-enums.h.template   |   26 ++++++++++++++++++++++++++
 gexiv2/gexiv2-metadata.h         |   23 ++++++++++-------------
 5 files changed, 99 insertions(+), 15 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 517b268..c4ab805 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,6 +31,22 @@ EXTRA_DIST = \
        test/python/gexiv2.py \
        test/python/test_metadata.py
 
+enumheaders = $(srcdir)/gexiv2/gexiv2-metadata.h \
+       $(srcdir)/gexiv2/gexiv2-log.h
+
+gexiv2-enums.cpp: $(enumheaders) Makefile
+       $(AM_V_GEN)$(GLIB_MKENUMS) \
+               --identifier-prefix GEXIV2 \
+               --symbol-prefix gexiv2 \
+               --template $(srcdir)/gexiv2/gexiv2-enums.cpp.template \
+               $(enumheaders) > $@
+
+gexiv2-enums.h: $(enumheaders) Makefile
+       $(AM_V_GEN)$(GLIB_MKENUMS) \
+               --identifier-prefix GEXIV2 \
+               --symbol-prefix gexiv2 \
+               --template $(srcdir)/gexiv2/gexiv2-enums.h.template \
+               $(enumheaders) > $@
 
 # Installed Files #
 pkgconfig_DATA  = @PACKAGE_NAME@.pc
@@ -73,7 +89,8 @@ GEXIV2_GIRHEADERS = \
        $(srcdir)/gexiv2/gexiv2-preview-image.h \
        $(srcdir)/gexiv2/gexiv2-log.h \
        $(srcdir)/gexiv2/gexiv2-startup.h \
-       gexiv2/gexiv2-version.h
+       gexiv2/gexiv2-version.h \
+       gexiv2-enums.h
 
 GEXIV2_public_HEADERS = \
        $(srcdir)/gexiv2/gexiv2-managed-stream.h \
@@ -95,7 +112,8 @@ GEXIV2_sources = \
        gexiv2/gexiv2-metadata-private.h \
        gexiv2/gexiv2-stream-io.h \
        gexiv2/gexiv2-preview-properties-private.h \
-       gexiv2/gexiv2-preview-image-private.h
+       gexiv2/gexiv2-preview-image-private.h \
+       gexiv2-enums.cpp
 
 # compilation setup. #
 
diff --git a/configure.ac b/configure.ac
index 92de44c..a5aa1a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -233,6 +233,16 @@ VAPIGEN_CHECK
 ###########
 GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
 
+################
+# glib-mkenums #
+################
+AC_MSG_CHECKING([for glib-mkenums script])
+GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+AS_IF([test "x$GLIB_MKENUMS" = "x"],
+    [AC_MSG_ERROR([glib-mkenums not listed in glib-2.0 pkg-config file])],
+    [AC_SUBST([GLIB_MKENUMS])
+     AC_MSG_RESULT([$GLIB_MKENUMS])])
+
 ##############
 # Generation #
 ##############
diff --git a/gexiv2/gexiv2-enums.cpp.template b/gexiv2/gexiv2-enums.cpp.template
new file mode 100644
index 0000000..f0890f9
--- /dev/null
+++ b/gexiv2/gexiv2-enums.cpp.template
@@ -0,0 +1,33 @@
+/*** BEGIN file-header ***/
+#include "gexiv2-enums.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 type = 0;
+
+
+    if (!type)
+    {
+        static const G@Type@Value _@enum_name@_values[] = {
+/*** END value-header ***/
+/*** BEGIN value-production ***/
+            { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+/*** BEGIN value-tail ***/
+            { 0, NULL, NULL }
+        };
+
+        type = g_@type@_register_static ("@EnumName@", _@enum_name@_values);
+    }
+
+
+  return type;
+}
+/*** END value-tail ***/
diff --git a/gexiv2/gexiv2-enums.h.template b/gexiv2/gexiv2-enums.h.template
new file mode 100644
index 0000000..879ec01
--- /dev/null
+++ b/gexiv2/gexiv2-enums.h.template
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+#ifndef GEXIV2_ENUMS_H
+#define GEXIV2_ENUMS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from @filename@ */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void);
+#define GEXIV2_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* GEXIV2_ENUMS_H */
+/*** END file-tail ***/
diff --git a/gexiv2/gexiv2-metadata.h b/gexiv2/gexiv2-metadata.h
index 1225368..aafc3bb 100644
--- a/gexiv2/gexiv2-metadata.h
+++ b/gexiv2/gexiv2-metadata.h
@@ -102,9 +102,7 @@ G_BEGIN_DECLS
  * <ulink url="http://jpegclub.org/exif_orientation.html";></ulink>
  */
 typedef enum {
-    /*<private>*/
-       GEXIV2_ORIENTATION_MIN                  = 0,
-    /*<public>*/
+       GEXIV2_ORIENTATION_MIN                  = 0, /*< skip >*/
        GEXIV2_ORIENTATION_UNSPECIFIED  = 0,
        GEXIV2_ORIENTATION_NORMAL               = 1,
        GEXIV2_ORIENTATION_HFLIP                = 2,
@@ -114,8 +112,7 @@ typedef enum {
        GEXIV2_ORIENTATION_ROT_90               = 6,
        GEXIV2_ORIENTATION_ROT_90_VFLIP = 7,
        GEXIV2_ORIENTATION_ROT_270              = 8,
-    /*<private>*/
-       GEXIV2_ORIENTATION_MAX                  = 8
+       GEXIV2_ORIENTATION_MAX                  = 8 /*< skip >*/
 } GExiv2Orientation;
 
 /**
@@ -150,14 +147,14 @@ typedef enum {
  * Taken from: exiv2/src/xmp.hpp
  *
  */
-typedef enum {
-  GEXIV2_OMIT_PACKET_WRAPPER   = 0x0010UL,  //!< Omit the XML packet wrapper.
-  GEXIV2_READ_ONLY_PACKET      = 0x0020UL,  //!< Default is a writeable packet.
-  GEXIV2_USE_COMPACT_FORMAT    = 0x0040UL,  //!< Use a compact form of RDF.
-  GEXIV2_INCLUDE_THUMBNAIL_PAD = 0x0100UL,  //!< Include a padding allowance for a thumbnail image.
-  GEXIV2_EXACT_PACKET_LENGTH   = 0x0200UL,  //!< The padding parameter is the overall packet length.
-  GEXIV2_WRITE_ALIAS_COMMENTS  = 0x0400UL,  //!< Show aliases as XML comments.
-  GEXIV2_OMIT_ALL_FORMATTING   = 0x0800UL   //!< Omit all formatting whitespace.
+typedef enum { /*< flags >*/
+  GEXIV2_OMIT_PACKET_WRAPPER   = 0x0010UL,
+  GEXIV2_READ_ONLY_PACKET      = 0x0020UL,
+  GEXIV2_USE_COMPACT_FORMAT    = 0x0040UL,
+  GEXIV2_INCLUDE_THUMBNAIL_PAD = 0x0100UL,
+  GEXIV2_EXACT_PACKET_LENGTH   = 0x0200UL,
+  GEXIV2_WRITE_ALIAS_COMMENTS  = 0x0400UL,
+  GEXIV2_OMIT_ALL_FORMATTING   = 0x0800UL
 } GExiv2XmpFormatFlags;
 
 /**


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