[gssdp/wip/meson: 3/17] meson: Generate enums



commit f135fe6679fb33919b73b6a037c17dc58af06408
Author: Jens Georg <mail jensge org>
Date:   Fri Oct 26 16:43:35 2018 +0200

    meson: Generate enums

 libgssdp/gssdp-enums.c.template | 33 +++++++++++++++++++++++++++++++++
 libgssdp/gssdp-enums.h.template | 26 ++++++++++++++++++++++++++
 libgssdp/gssdp.h                |  1 -
 libgssdp/meson.build            |  9 ++++++++-
 meson.build                     |  1 +
 5 files changed, 68 insertions(+), 2 deletions(-)
---
diff --git a/libgssdp/gssdp-enums.c.template b/libgssdp/gssdp-enums.c.template
new file mode 100644
index 0000000..600d426
--- /dev/null
+++ b/libgssdp/gssdp-enums.c.template
@@ -0,0 +1,33 @@
+/*** BEGIN file-header ***/
+#include "gssdp-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/libgssdp/gssdp-enums.h.template b/libgssdp/gssdp-enums.h.template
new file mode 100644
index 0000000..17561ca
--- /dev/null
+++ b/libgssdp/gssdp-enums.h.template
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+#ifndef GSSDP_ENUMS_H
+#define GSSDP_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 GSSDP_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* GSSDP_ENUMS_H */
+/*** END file-tail ***/
diff --git a/libgssdp/gssdp.h b/libgssdp/gssdp.h
index 2cd9087..4544e57 100644
--- a/libgssdp/gssdp.h
+++ b/libgssdp/gssdp.h
@@ -23,4 +23,3 @@
 #include <libgssdp/gssdp-error.h>
 #include <libgssdp/gssdp-resource-browser.h>
 #include <libgssdp/gssdp-resource-group.h>
-#include <libgssdp/gssdp-enums.h>
diff --git a/libgssdp/meson.build b/libgssdp/meson.build
index 0097022..627d9dd 100644
--- a/libgssdp/meson.build
+++ b/libgssdp/meson.build
@@ -1,3 +1,10 @@
+enums = gnome.mkenums('gssdp-enums', sources : 'gssdp-error.h',
+                      identifier_prefix : 'GSSDP',
+                      symbol_prefix : 'gssdp',
+                      c_template : 'gssdp-enums.c.template',
+                      h_template : 'gssdp-enums.h.template'
+                      )
+
 headers = [
     'gssdp-client.h',
     'gssdp-resource-browser.h',
@@ -17,7 +24,7 @@ sources = [
     'gssdp-socket-source.h',
     'gssdp-socket-functions.c',
     'gssdp-socket-functions.h'
-    ]
+    ] + enums
 
 if host_machine.system() == 'windows'
   sources += 'gssdp-net-win32.c'
diff --git a/meson.build b/meson.build
index e89d58a..0cba74a 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,5 @@
 project('GSSDP', 'c', version: '1.1.0')
+gnome = import('gnome')
 
 as_version = meson.project_version() # set in project() below
 ver_arr = as_version.split('.')


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