[gnome-bluetooth] build: Use template files for enums generation



commit 54476e06f868b37298a261a01c07414fd272e8a5
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Tue Nov 14 16:05:15 2017 +0100

    build: Use template files for enums generation
    
    The data contents for the enum related files were stored in the
    build files.
    
    This patch moves this information to template files to be used
    along glib-mkenums.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790332

 lib/gnome-bluetooth-enum-types.c.template |   40 +++++++++++++++++++++++++++++
 lib/gnome-bluetooth-enum-types.h.template |   28 ++++++++++++++++++++
 lib/meson.build                           |   20 +++-----------
 3 files changed, 72 insertions(+), 16 deletions(-)
---
diff --git a/lib/gnome-bluetooth-enum-types.c.template b/lib/gnome-bluetooth-enum-types.c.template
new file mode 100644
index 0000000..75db1e2
--- /dev/null
+++ b/lib/gnome-bluetooth-enum-types.c.template
@@ -0,0 +1,40 @@
+/*** BEGIN file-header ***/
+#include "gnome-bluetooth-enum-types.h"
+#include <glib-object.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/lib/gnome-bluetooth-enum-types.h.template b/lib/gnome-bluetooth-enum-types.h.template
new file mode 100644
index 0000000..54678e0
--- /dev/null
+++ b/lib/gnome-bluetooth-enum-types.h.template
@@ -0,0 +1,28 @@
+/*** BEGIN file-header ***/
+#ifndef __GNOME_BLUETOOTH_ENUM_TYPES_H__
+#define __GNOME_BLUETOOTH_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 BLUETOOTH_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 /* __GNOME_BLUETOOTH_ENUM_TYPES_H__ */
+/*** END file-tail ***/
+
diff --git a/lib/meson.build b/lib/meson.build
index 5588c7d..17fcbf2 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -53,22 +53,10 @@ built_sources += gnome.compile_resources(
 enum_types = 'gnome-bluetooth-enum-types'
 
 built_sources += gnome.mkenums(
-  enum_types + '.c',
-  sources: enum_headers,
-  fhead: '#include <bluetooth-enums.h>\n#include "gnome-bluetooth-enum-types.h"\n#include <glib-object.h>',
-  fprod: '\n/* enumerations from "@filename@" */',
-  vhead: 'GType\n@enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) {\n    static 
const G@Type@Value values[] = {',
-  vprod: '      { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-  vtail: '      { 0, NULL, NULL }\n    };\n    etype = g_@type@_register_static ("@EnumName@", values);\n  
}\n  return etype;\n}\n'
-)
-
-built_sources += gnome.mkenums(
-  enum_types + '.h',
-  sources: enum_headers,
-  fhead: '#ifndef __GNOME_BLUETOOTH_ENUM_TYPES_H__\n#define __GNOME_BLUETOOTH_ENUM_TYPES_H__\n\n#include 
<glib-object.h>\n\nG_BEGIN_DECLS\n',
-  fprod: '/* enumerations from "@filename@" */\n',
-  vhead: 'GType @enum_name@_get_type (void);\n#define BLUETOOTH_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n',
-  ftail: 'G_END_DECLS\n\n#endif /* __GNOME_BLUETOOTH_ENUM_TYPES_H__ */'
+  enum_types,
+  sources: headers,
+  c_template: enum_types + '.c.template',
+  h_template: enum_types + '.h.template'
 )
 
 client = 'bluetooth-client'


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