Merge branch 'script-enum' into 'master'

Define enum types for Unicode enums

See merge request GNOME/glib!481
This commit is contained in:
Philip Withnall 2019-02-04 12:28:02 +00:00
commit 5d719c782c
5 changed files with 116 additions and 27 deletions

View File

@ -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 = [

View File

@ -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>

View File

@ -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 ***/

View File

@ -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 ***/

View File

@ -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])