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



commit fc6044a4b1546c13a87985896b825f67f89861ee
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                 | 77 ++++++++++++++++++++++++-------------
 5 files changed, 116 insertions(+), 27 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..159f33ee3 100644
--- a/gobject/meson.build
+++ b/gobject/meson.build
@@ -61,32 +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(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],
-  dependencies : [libglib_dep])
-
 python_tools = [
   'glib-genmarshal',
   'glib-mkenums',
@@ -111,6 +85,57 @@ foreach tool: python_tools
   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@'])
+
+# For now, we only include gunicode.h here, since GScriptType is needed for pango
+# More headers can be added as needed
+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_h])
+
+libgobject = library('gobject-2.0',
+  gobject_dtrace_obj, gobject_dtrace_hdr, gobjectenumtypes_h, gobjectenumtypes_c,
+  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(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],
+  dependencies : [libglib_dep, gobjectenumtypes_dep])
+
 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]