[gupnp: 18/18] Use glib-mkenums for enums



commit 3004ee68cc132a29aeb5a835d1a98ab3796d6784
Author: Jens Georg <mail jensge org>
Date:   Sat Oct 15 21:28:35 2016 +0200

    Use glib-mkenums for enums
    
    Signed-off-by: Jens Georg <mail jensge org>

 configure.ac               |    7 +++++++
 libgupnp/Makefile.am       |   41 +++++++++++++++++++++++++++++++++++++++++
 libgupnp/gupnp-error.h     |    3 ++-
 vala/GUPnP-1.2.metadata    |   10 ----------
 vala/gupnp-1.2-custom.vala |   43 -------------------------------------------
 5 files changed, 50 insertions(+), 54 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 53bec2d..f73b3c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -150,6 +150,13 @@ AM_CONDITIONAL([HAVE_VAPIGEN], [test "x$VAPIGEN" != "x"])
 # Gtk-doc
 GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
 
+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])])
+
 AC_CONFIG_FILES([
 Makefile
 libgupnp/Makefile
diff --git a/libgupnp/Makefile.am b/libgupnp/Makefile.am
index b8f7bff..2b5a5dd 100644
--- a/libgupnp/Makefile.am
+++ b/libgupnp/Makefile.am
@@ -127,6 +127,47 @@ EXTRA_DIST = gupnp-marshal.list       \
             gupnp-windows-context-manager.c \
             gupnp-windows-context-manager.h
 
+enumheaders = \
+       $(srcdir)/gupnp-error.h \
+       $(srcdir)/gupnp-service-introspection.h
+
+BUILT_SOURCES = \
+       gupnp-enums.c \
+       gupnp-enums.h
+
+gupnp-enums.c: $(enumheaders) Makefile
+       $(AM_V_GEN)$(GLIB_MKENUMS) \
+               --identifier-prefix GUPnP \
+               --symbol-prefix gupnp \
+               --fhead "#include \"gupnp-enums.h\"\n\n" \
+               --fprod "/* enumerations from \"@filename@\" */\n" \
+               --fprod "#include \"@filename@\"\n" \
+               --vhead "GType\n@enum_name@_get_type (void)\n{\n" \
+               --vhead "    static GType type = 0;\n\n" \
+               --vhead "    if (!type)\n    {\n" \
+               --vhead "        static const G@Type@Value _@enum_name@_values[] = {" \
+               --vprod "            { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
+               --vtail "            { 0, NULL, NULL }\n        };\n\n" \
+               --vtail "        type = g_@type@_register_static (\"@EnumName@\", _@enum_name@_values);\n    
}\n\n" \
+               --vtail "  return type;\n}\n\n" \
+               $(enumheaders) > $@
+
+gupnp-enums.h: $(enumheaders) Makefile
+       $(AM_V_GEN)$(GLIB_MKENUMS) \
+               --identifier-prefix GUPnP \
+               --symbol-prefix gupnp \
+               --fhead "#ifndef GUPNP_ENUMS_H\n" \
+               --fhead "#define GUPNP_ENUMS_H\n\n" \
+               --fhead "#include <glib-object.h>\n\n" \
+               --fhead "G_BEGIN_DECLS\n\n" \
+               --fprod "/* enumerations from @filename@ */\n" \
+               --vhead "GType @enum_name@_get_type (void);\n" \
+               --vhead "#define GUPNP_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
+               --ftail "G_END_DECLS\n\n" \
+               --ftail "#endif /* GUPNP_ENUMS_H */" \
+               $(enumheaders) > $@
+
+
 -include $(INTROSPECTION_MAKEFILE)
 INTROSPECTION_GIRS =
 INTROSPECTION_SCANNER_ARGS = \
diff --git a/libgupnp/gupnp-error.h b/libgupnp/gupnp-error.h
index 890fd1b..ba0bfb0 100644
--- a/libgupnp/gupnp-error.h
+++ b/libgupnp/gupnp-error.h
@@ -134,7 +134,8 @@ gupnp_rootdevice_error_quark (void) G_GNUC_CONST;
 typedef enum {
         GUPNP_ROOT_DEVICE_ERROR_NO_CONTEXT,
         GUPNP_ROOT_DEVICE_ERROR_NO_DESCRIPTION_PATH,
-        GUPNP_ROOT_DEVICE_ERROR_NO_DESCRIPTION_FOLDER
+        GUPNP_ROOT_DEVICE_ERROR_NO_DESCRIPTION_FOLDER,
+        GUPNP_ROOT_DEVICE_ERROR_FAIL
 } GUPnPRootdeviceError;
 
 G_END_DECLS
diff --git a/vala/GUPnP-1.2.metadata b/vala/GUPnP-1.2.metadata
index 1108c78..e3e6af2 100644
--- a/vala/GUPnP-1.2.metadata
+++ b/vala/GUPnP-1.2.metadata
@@ -30,13 +30,3 @@ ServiceProxy
     .send_action_list skip
 WhiteList
     .entries skip
-ControlError skip
-control_error_quark skip
-EventingError skip
-eventing_error_quark skip
-RootdeviceError skip
-rootdevice_error_quark skip
-ServerError skip
-server_error_quark skip
-XMLError skip
-xml_error_quark skip
diff --git a/vala/gupnp-1.2-custom.vala b/vala/gupnp-1.2-custom.vala
index ab584c2..425d878 100644
--- a/vala/gupnp-1.2-custom.vala
+++ b/vala/gupnp-1.2-custom.vala
@@ -34,46 +34,3 @@ public interface GUPnP.Acl : GLib.Object {
                public abstract async bool is_allowed_async (GUPnP.Device? device, GUPnP.Service? service, 
string path, string address, string? agent, GLib.Cancellable? cancellable) throws GLib.Error;
 }
 
-namespace GUPnP {
-       [CCode (cheader_filename = "libgupnp/gupnp.h", cprefix = "GUPNP_ROOT_DEVICEL_ERROR_")]
-       public errordomain RootdeviceError {
-               NO_CONTEXT,
-               NO_DESCRIPTION_PATH,
-               NO_DESCRIPTION_FOLDER;
-               public static GLib.Quark quark ();
-       }
-       [CCode (cheader_filename = "libgupnp/gupnp.h", cprefix = "GUPNP_CONTROL_ERROR_")]
-       public errordomain ControlError {
-               INVALID_ACTION,
-               INVALID_ARGS,
-               OUT_OF_SYNC,
-               ACTION_FAILED;
-               public static GLib.Quark quark ();
-       }
-       [CCode (cheader_filename = "libgupnp/gupnp.h", cprefix = "GUPNP_EVENTING_ERROR_")]
-       public errordomain EventingError {
-               SUBSCRIPTION_FAILED,
-               SUBSCRIPTION_LOST,
-               NOTIFY_FAILED;
-               public static GLib.Quark quark ();
-       }
-       [CCode (cheader_filename = "libgupnp/gupnp.h", cprefix = "GUPNP_SERVER_ERROR_")]
-       public errordomain ServerError {
-               INTERNAL_SERVER_ERROR,
-               NOT_FOUND,
-               NOT_IMPLEMENTED,
-               INVALID_RESPONSE,
-               INVALID_URL,
-               OTHER;
-               public static GLib.Quark quark ();
-       }
-       [CCode (cheader_filename = "libgupnp/gupnp.h", cprefix = "GUPNP_XML_ERROR_")]
-       public errordomain XMLError {
-               PARSE,
-               NO_NODE,
-               EMPTY_NODE,
-               INVALID_ATTRIBUTE,
-               OTHER;
-               public static GLib.Quark quark ();
-       }
-}


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