[glib/script-enum] Define enum types for Unicode enums



commit 8f2e23e587fee2a495f18f4773ef49d9c95083eb
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Nov 19 15:10:09 2018 -0500

    Define enum types for Unicode enums
    
    We want to stop shipping PangoScript in pango, so
    we need a replacement for the type that used to
    be provided by pango.

 glib/glib-object.h                  |  1 +
 gobject/gobjectenumtypes.c.template | 38 ++++++++++++++++++++
 gobject/gobjectenumtypes.h.template | 24 +++++++++++++
 gobject/meson.build                 | 72 ++++++++++++++++++++++++-------------
 4 files changed, 110 insertions(+), 25 deletions(-)
---
diff --git a/glib/glib-object.h b/glib/glib-object.h
index 355623391..53b53d50f 100644
--- a/glib/glib-object.h
+++ b/glib/glib-object.h
@@ -34,6 +34,7 @@
 #include <gobject/gvalue.h>
 #include <gobject/gvaluearray.h>
 #include <gobject/gvaluetypes.h>
+#include <gobject/gobjectenumtypes.h>
 
 #include <gobject/gobject-autocleanups.h>
 
diff --git a/gobject/gobjectenumtypes.c.template b/gobject/gobjectenumtypes.c.template
new file mode 100644
index 000000000..f926a463a
--- /dev/null
+++ b/gobject/gobjectenumtypes.c.template
@@ -0,0 +1,38 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+#include "gobjectenumtypes.h"
+#include <glib-object.h>
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+  static volatile gsize g_define_type_id__volatile = 0;
+
+  if (g_once_init_enter (&g_define_type_id__volatile))
+    {
+      static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+        { 0, NULL, NULL }
+      };
+      GType g_define_type_id =
+        g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
+      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+    }
+
+  return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
diff --git a/gobject/gobjectenumtypes.h.template b/gobject/gobjectenumtypes.h.template
new file mode 100644
index 000000000..dd003526f
--- /dev/null
+++ b/gobject/gobjectenumtypes.h.template
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __GOBJECT_ENUM_TYPES_H__
+#define __GOBJECT_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GLIB_AVAILABLE_IN_ALL GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __GOBJECT_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/gobject/meson.build b/gobject/meson.build
index d426f12b4..95b5eed59 100644
--- a/gobject/meson.build
+++ b/gobject/meson.build
@@ -61,31 +61,6 @@ else
   gobject_dtrace_hdr = []
 endif
 
-libgobject = library('gobject-2.0',
-  gobject_dtrace_obj, gobject_dtrace_hdr,
-  sources : gobject_sources,
-  version : library_version,
-  soversion : soversion,
-  darwin_versions : darwin_versions,
-  install : true,
-  include_directories : [configinc],
-  dependencies : [libffi_dep, libglib_dep],
-  c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args,
-  link_args : glib_link_flags,
-)
-
-pkg.generate(libraries : libgobject,
-  requires : ['glib-2.0'],
-  version : glib_version,
-  install_dir : glib_pkgconfigreldir,
-  filebase : 'gobject-2.0',
-  name : 'GObject',
-  description : 'GLib Type, Object, Parameter and Signal Library',
-)
-
-libgobject_dep = declare_dependency(link_with : libgobject,
-  include_directories : gobjectinc)
-
 python_tools = [
   'glib-genmarshal',
   'glib-mkenums',
@@ -110,6 +85,53 @@ foreach tool: python_tools
   meson.override_find_program(tool, tool_bin)
 endforeach
 
+gobjectenumtypes_h = custom_target('gobjectenumtypes_h',
+  output : 'gobjectenumtypes.h',
+  capture : true,
+  input : '../glib/gunicode.h',
+  install : true,
+  install_dir : join_paths(get_option('includedir'), 'glib-2.0/gobject'),
+  command : [python, glib_mkenums,
+             '--template', files('gobjectenumtypes.h.template'),
+             '@INPUT@'])
+
+gobjectenumtypes_c = custom_target('gobjectenumtypes_c',
+  output : 'gobjectenumtypes.c',
+  capture : true,
+  input : '../glib/gunicode.h',
+  depends : [gobjectenumtypes_h],
+  command : [python, glib_mkenums,
+             '--template', files('gobjectenumtypes.c.template'),
+             '@INPUT@'])
+
+gobjectenumtypes_dep = declare_dependency(sources : [gobjectenumtypes_c])
+
+libgobject = library('gobject-2.0',
+  gobjectenumtypes_c,
+  gobject_dtrace_obj, gobject_dtrace_hdr,
+  gobject_sources,
+  version : library_version,
+  soversion : soversion,
+  darwin_versions : darwin_versions,
+  install : true,
+  include_directories : [configinc],
+  dependencies : [libffi_dep, libglib_dep],
+  c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args,
+  link_args : glib_link_flags,
+)
+
+pkg.generate(libraries : libgobject,
+  requires : ['glib-2.0'],
+  version : glib_version,
+  install_dir : glib_pkgconfigreldir,
+  filebase : 'gobject-2.0',
+  name : 'GObject',
+  description : 'GLib Type, Object, Parameter and Signal Library',
+)
+
+libgobject_dep = declare_dependency(link_with : libgobject,
+  include_directories : gobjectinc)
+
 executable('gobject-query', 'gobject-query.c',
   install : true,
   dependencies : [libglib_dep, libgobject_dep])


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