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



commit f7f579b6c3bddf72ab9be0042014e77e9b831609
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.

 docs/reference/gobject/meson.build  |  3 +-
 glib/glib-object.h                  |  1 +
 gobject/gobjectenumtypes.c.template | 38 +++++++++++++++++++
 gobject/gobjectenumtypes.h.template | 24 ++++++++++++
 gobject/meson.build                 | 73 ++++++++++++++++++++++++-------------
 5 files changed, 113 insertions(+), 26 deletions(-)
---
diff --git a/docs/reference/gobject/meson.build b/docs/reference/gobject/meson.build
index 7a7f1b81d..6f07a79f3 100644
--- a/docs/reference/gobject/meson.build
+++ b/docs/reference/gobject/meson.build
@@ -6,7 +6,8 @@ if get_option('gtk_doc')
     'gatomicarray.h',
     'gobject_probes.h',
     'gobject_trace.h',
-    'gtype-private.h'
+    'gtype-private.h',
+    'gobjectenumtypes.h'
   ]
 
   ignore_decorators = [
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..2a4b0e4f3
--- /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_2_60 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 2ad903a40..2912613ed 100644
--- a/gobject/meson.build
+++ b/gobject/meson.build
@@ -61,6 +61,53 @@ else
   gobject_dtrace_hdr = []
 endif
 
+python_tools = [
+  'glib-genmarshal',
+  'glib-mkenums',
+]
+
+python_tools_conf = configuration_data()
+python_tools_conf.set('VERSION', glib_version)
+python_tools_conf.set('PYTHON', python_name)
+
+foreach tool: python_tools
+  tool_bin = configure_file(
+    input : tool + '.in',
+    output : tool,
+    configuration : python_tools_conf,
+    install : true,
+    install_dir : glib_bindir,
+  )
+
+  # Set variables for later use
+  set_variable(tool.underscorify(), tool_bin)
+  # Provide tools for others when we're a subproject and they use the Meson GNOME module
+  meson.override_find_program(tool, tool_bin)
+endforeach
+
+# We can't use gnome.mkenums() because the GNOME module looks for glib-mkenums
+# in PATH, which means you can't bootstrap glib with its own glib-mkenums.
+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',
   gobject_dtrace_obj, gobject_dtrace_hdr,
   sources : gobject_sources,
@@ -69,7 +116,7 @@ libgobject = library('gobject-2.0',
   darwin_versions : darwin_versions,
   install : true,
   include_directories : [configinc],
-  dependencies : [libffi_dep, libglib_dep],
+  dependencies : [libffi_dep, libglib_dep, gobjectenumtypes_dep],
   c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args,
   link_args : glib_link_flags,
 )
@@ -87,30 +134,6 @@ libgobject_dep = declare_dependency(link_with : libgobject,
   include_directories : [gobjectinc],
   dependencies : [libglib_dep])
 
-python_tools = [
-  'glib-genmarshal',
-  'glib-mkenums',
-]
-
-python_tools_conf = configuration_data()
-python_tools_conf.set('VERSION', glib_version)
-python_tools_conf.set('PYTHON', python_name)
-
-foreach tool: python_tools
-  tool_bin = configure_file(
-    input : tool + '.in',
-    output : tool,
-    configuration : python_tools_conf,
-    install : true,
-    install_dir : glib_bindir,
-  )
-
-  # Set variables for later use
-  set_variable(tool.underscorify(), tool_bin)
-  # Provide tools for others when we're a subproject and they use the Meson GNOME module
-  meson.override_find_program(tool, tool_bin)
-endforeach
-
 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]