From c3ac761a18d82aa8cd46d71afe9015fbf35a2a03 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 4 Mar 2019 11:12:59 +0000 Subject: [PATCH 1/2] build: Rename gobjectenumtypes.[ch] to glib-enumtypes.[ch] To reflect the fact that they contain the GObject types for various enums defined in libglib. See https://gitlab.gnome.org/GNOME/glib/merge_requests/481#note_451086. Signed-off-by: Philip Withnall Helps: GNOME/gobject-introspection#267 --- docs/reference/gobject/meson.build | 2 +- gio/meson.build | 2 +- glib/glib-object.h | 2 +- ...s.c.template => glib-enumtypes.c.template} | 2 +- ...s.h.template => glib-enumtypes.h.template} | 0 gobject/meson.build | 36 +++++++++++-------- 6 files changed, 26 insertions(+), 18 deletions(-) rename gobject/{gobjectenumtypes.c.template => glib-enumtypes.c.template} (96%) rename gobject/{gobjectenumtypes.h.template => glib-enumtypes.h.template} (100%) diff --git a/docs/reference/gobject/meson.build b/docs/reference/gobject/meson.build index e955e9907..175520b64 100644 --- a/docs/reference/gobject/meson.build +++ b/docs/reference/gobject/meson.build @@ -7,7 +7,7 @@ if get_option('gtk_doc') 'gobject_probes.h', 'gobject_trace.h', 'gtype-private.h', - 'gobjectenumtypes.h' + 'glib-enumtypes.h', ] ignore_decorators = [ diff --git a/gio/meson.build b/gio/meson.build index 8f989bfe9..88575ec75 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -754,7 +754,7 @@ gioenumtypes_c = custom_target('gioenumtypes_c', '--template', files('gioenumtypes.c.template'), '@INPUT@', gnetworking_h]) -gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h, gobjectenumtypes_h]) +gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h, glib_enumtypes_h]) # inotify if glib_conf.has('HAVE_SYS_INOTIFY_H') and have_func_inotify_init1 diff --git a/glib/glib-object.h b/glib/glib-object.h index 53b53d50f..9561a6528 100644 --- a/glib/glib-object.h +++ b/glib/glib-object.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include diff --git a/gobject/gobjectenumtypes.c.template b/gobject/glib-enumtypes.c.template similarity index 96% rename from gobject/gobjectenumtypes.c.template rename to gobject/glib-enumtypes.c.template index f926a463a..b7d36728f 100644 --- a/gobject/gobjectenumtypes.c.template +++ b/gobject/glib-enumtypes.c.template @@ -1,6 +1,6 @@ /*** BEGIN file-header ***/ #include "config.h" -#include "gobjectenumtypes.h" +#include "glib-enumtypes.h" #include /*** END file-header ***/ diff --git a/gobject/gobjectenumtypes.h.template b/gobject/glib-enumtypes.h.template similarity index 100% rename from gobject/gobjectenumtypes.h.template rename to gobject/glib-enumtypes.h.template diff --git a/gobject/meson.build b/gobject/meson.build index 159f33ee3..db8d3c4e9 100644 --- a/gobject/meson.build +++ b/gobject/meson.build @@ -85,33 +85,41 @@ foreach tool: python_tools meson.override_find_program(tool, tool_bin) endforeach +# Generate a header file containing the GObject enum types for the enums defined +# in libglib. +# +# For now, we only include gunicode.h here, since GScriptType is needed for +# Pango. More headers can be added as needed in future. +# # 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', +glib_enumtypes_input_headers = files( + '../glib/gunicode.h', +) + +glib_enumtypes_h = custom_target('glib_enumtypes_h', + output : 'glib-enumtypes.h', capture : true, - input : '../glib/gunicode.h', + input : glib_enumtypes_input_headers, install : true, install_dir : join_paths(get_option('includedir'), 'glib-2.0/gobject'), command : [python, glib_mkenums, - '--template', files('gobjectenumtypes.h.template'), + '--template', files('glib-enumtypes.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', +glib_enumtypes_c = custom_target('glib_enumtypes_c', + output : 'glib-enumtypes.c', capture : true, - input : '../glib/gunicode.h', - depends : [gobjectenumtypes_h], + input : glib_enumtypes_input_headers, + depends : [glib_enumtypes_h], command : [python, glib_mkenums, - '--template', files('gobjectenumtypes.c.template'), + '--template', files('glib-enumtypes.c.template'), '@INPUT@']) -gobjectenumtypes_dep = declare_dependency(sources : [gobjectenumtypes_h]) +glib_enumtypes_dep = declare_dependency(sources : [glib_enumtypes_h]) libgobject = library('gobject-2.0', - gobject_dtrace_obj, gobject_dtrace_hdr, gobjectenumtypes_h, gobjectenumtypes_c, + gobject_dtrace_obj, gobject_dtrace_hdr, glib_enumtypes_h, glib_enumtypes_c, sources : gobject_sources, version : library_version, soversion : soversion, @@ -134,7 +142,7 @@ pkg.generate(libgobject, libgobject_dep = declare_dependency(link_with : libgobject, include_directories : [gobjectinc], - dependencies : [libglib_dep, gobjectenumtypes_dep]) + dependencies : [libglib_dep, glib_enumtypes_dep]) executable('gobject-query', 'gobject-query.c', install : true, From 95e00c75812f86753286a925ff41ace8e4879f3d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 4 Mar 2019 11:14:22 +0000 Subject: [PATCH 2/2] docs: Various markup improvements to glib-mkenums man page Signed-off-by: Philip Withnall --- docs/reference/gobject/glib-mkenums.xml | 62 +++++++++++++------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/docs/reference/gobject/glib-mkenums.xml b/docs/reference/gobject/glib-mkenums.xml index 84023e9b1..4c8641657 100644 --- a/docs/reference/gobject/glib-mkenums.xml +++ b/docs/reference/gobject/glib-mkenums.xml @@ -35,20 +35,21 @@ glib-mkenums is a small utility that parses C code to extract enum definitions and produces enum descriptions based on text templates specified by the user. Typically, you can use this tool to generate enumeration -types for the GType type system, for #GObject properties and signal marshalling; -additionally, you can use it to generate enumeration values of #GSettings schemas. +types for the GType type system, for GObject properties and signal marshalling; +additionally, you can use it to generate enumeration values of GSettings schemas. glib-mkenums takes a list of valid C code files as input. The options specified control the text that generated, substituting various -keywords enclosed in @ characters in the templates. +keywords enclosed in @ characters in the templates. Production text substitutions -Certain keywords enclosed in @ characters will be substituted in the +Certain keywords enclosed in @ characters will be substituted in the emitted text. For the substitution examples of the keywords below, the following example enum definition is assumed: + typedef enum { @@ -58,7 +59,7 @@ typedef enum -@EnumName@ +@EnumName@> The name of the enum currently being processed, enum names are assumed to be properly namespaced and to use mixed capitalization to separate @@ -67,7 +68,7 @@ words (e.g. PrefixTheXEnum). -@enum_name@ +@enum_name@ The enum name with words lowercase and word-separated by underscores (e.g. prefix_the_xenum). @@ -75,7 +76,7 @@ The enum name with words lowercase and word-separated by underscores -@ENUMNAME@ +@ENUMNAME@ The enum name with words uppercase and word-separated by underscores (e.g. PREFIX_THE_XENUM). @@ -83,7 +84,7 @@ The enum name with words uppercase and word-separated by underscores -@ENUMSHORT@ +@ENUMSHORT@ The enum name with words uppercase and word-separated by underscores, prefix stripped (e.g. THE_XENUM). @@ -91,14 +92,14 @@ prefix stripped (e.g. THE_XENUM). -@ENUMPREFIX@ +@ENUMPREFIX@ The prefix of the enum name (e.g. PREFIX). -@VALUENAME@ +@VALUENAME@ The enum value name currently being processed with words uppercase and word-separated by underscores, @@ -108,7 +109,7 @@ this is the assumed literal notation of enum values in the C sources -@valuenick@ +@valuenick@ A nick name for the enum value currently being processed, this is usually generated by stripping common prefix words of all the enum values of the @@ -118,7 +119,7 @@ minus (e.g. the-xvalue). -@valuenum@ +@valuenum@ The integer value for the enum value currently being processed. If the evaluation fails then glib-mkenums will exit with an @@ -128,61 +129,61 @@ appears in your value production template. (Since: 2.26) -@type@ +@type@ This is substituted either by "enum" or "flags", depending on whether the -enum value definitions contained bit-shift operators or not (e.g. flags). +enum value definitions contained bit-shift operators or not (e.g. flags). -@Type@ +@Type@ -The same as @type@ with the first letter capitalized (e.g. Flags). +The same as @type@ with the first letter capitalized (e.g. Flags). -@TYPE@ +@TYPE@ -The same as @type@ with all letters uppercased (e.g. FLAGS). +The same as @type@ with all letters uppercased (e.g. FLAGS). -@filename@ +@filename@ -The name of the input file currently being processed (e.g. foo.h). +The name of the input file currently being processed (e.g. foo.h). -@basename@ +@basename@ -The base name of the input file currently being processed (e.g. foo.h). Typically +The base name of the input file currently being processed (e.g. foo.h). Typically you want to use @basename@ in place of @filename@ in your templates, to improve the reproducibility of the build. (Since: 2.22) - Trigraph extensions Some C comments are treated specially in the parsed enum definitions, such comments start out with the trigraph sequence /*< and end with the trigraph sequence >*/. -Per enum definition, the options "skip" and "flags" can be specified, to +Per enum definition, the options skip and flags can be specified, to indicate this enum definition to be skipped, or for it to be treated as a flags definition, or to specify the common prefix to be stripped from -all values to generate value nicknames, respectively. The "underscore_name" -option can be used to specify the word separation used in the *_get_type() +all values to generate value nicknames, respectively. The underscore_name +option can be used to specify the word separation used in the *_get_type() function. For instance, /*< underscore_name=gnome_vfs_uri_hide_options >*/. -Per value definition, the options "skip" and "nick" are supported. +Per value definition, the options skip and nick are supported. The former causes the value to be skipped, and the latter can be used to specify the otherwise auto-generated nickname. Examples: + typedef enum /*< skip >*/ { @@ -196,7 +197,6 @@ typedef enum /*< flags,prefix=PREFIX >*/ PREFIX_THE_THIRD_VALUE, /*< nick=the-last-value >*/ } PrefixTheFlagsEnum; - @@ -317,12 +317,14 @@ Template for auto-generated comments, the default (for C code generations) is FILE Read templates from the given file. The templates are enclosed in -specially-formatted C comments +specially-formatted C comments: + /*** BEGIN section ***/ /*** END section ***/ -where section may be file-header, + +section may be file-header, file-production, file-tail, enumeration-production, value-header, value-production, value-tail or