Merge branch 'gi-267-rename-header' into 'master'

Rename gobjectenumtypes.[ch] to glib-enumtypes.[ch]

See merge request GNOME/glib!702
This commit is contained in:
Christoph Reiter
2019-03-04 15:03:40 +00:00
7 changed files with 58 additions and 48 deletions

View File

@@ -35,20 +35,21 @@
<para><command>glib-mkenums</command> is a small utility that parses C code to <para><command>glib-mkenums</command> is a small utility that parses C code to
extract enum definitions and produces enum descriptions based on text templates extract enum definitions and produces enum descriptions based on text templates
specified by the user. Typically, you can use this tool to generate enumeration 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; types for the GType type system, for GObject properties and signal marshalling;
additionally, you can use it to generate enumeration values of #GSettings schemas. additionally, you can use it to generate enumeration values of GSettings schemas.
</para> </para>
<para><command>glib-mkenums</command> takes a list of valid C code files as <para><command>glib-mkenums</command> takes a list of valid C code files as
input. The options specified control the text that generated, substituting various input. The options specified control the text that generated, substituting various
keywords enclosed in @ characters in the templates. keywords enclosed in <literal>@</literal> characters in the templates.
</para> </para>
<refsect2><title>Production text substitutions</title> <refsect2><title>Production text substitutions</title>
<para> <para>
Certain keywords enclosed in @ characters will be substituted in the Certain keywords enclosed in <literal>@</literal> characters will be substituted in the
emitted text. For the substitution examples of the keywords below, emitted text. For the substitution examples of the keywords below,
the following example enum definition is assumed: the following example enum definition is assumed:
</para>
<informalexample><programlisting> <informalexample><programlisting>
typedef enum typedef enum
{ {
@@ -58,7 +59,7 @@ typedef enum
</programlisting></informalexample> </programlisting></informalexample>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term>@EnumName@</term> <term><literal>@EnumName@</literal>></term>
<listitem><para> <listitem><para>
The name of the enum currently being processed, enum names are assumed to be The name of the enum currently being processed, enum names are assumed to be
properly namespaced and to use mixed capitalization to separate properly namespaced and to use mixed capitalization to separate
@@ -67,7 +68,7 @@ words (e.g. <literal>PrefixTheXEnum</literal>).
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@enum_name@</term> <term><literal>@enum_name@</literal></term>
<listitem><para> <listitem><para>
The enum name with words lowercase and word-separated by underscores The enum name with words lowercase and word-separated by underscores
(e.g. <literal>prefix_the_xenum</literal>). (e.g. <literal>prefix_the_xenum</literal>).
@@ -75,7 +76,7 @@ The enum name with words lowercase and word-separated by underscores
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@ENUMNAME@</term> <term><literal>@ENUMNAME@</literal></term>
<listitem><para> <listitem><para>
The enum name with words uppercase and word-separated by underscores The enum name with words uppercase and word-separated by underscores
(e.g. <literal>PREFIX_THE_XENUM</literal>). (e.g. <literal>PREFIX_THE_XENUM</literal>).
@@ -83,7 +84,7 @@ The enum name with words uppercase and word-separated by underscores
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@ENUMSHORT@</term> <term><literal>@ENUMSHORT@</literal></term>
<listitem><para> <listitem><para>
The enum name with words uppercase and word-separated by underscores, The enum name with words uppercase and word-separated by underscores,
prefix stripped (e.g. <literal>THE_XENUM</literal>). prefix stripped (e.g. <literal>THE_XENUM</literal>).
@@ -91,14 +92,14 @@ prefix stripped (e.g. <literal>THE_XENUM</literal>).
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@ENUMPREFIX@</term> <term><literal>@ENUMPREFIX@</literal></term>
<listitem><para> <listitem><para>
The prefix of the enum name (e.g. <literal>PREFIX</literal>). The prefix of the enum name (e.g. <literal>PREFIX</literal>).
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@VALUENAME@</term> <term><literal>@VALUENAME@</literal></term>
<listitem><para> <listitem><para>
The enum value name currently being processed with words uppercase and The enum value name currently being processed with words uppercase and
word-separated by underscores, word-separated by underscores,
@@ -108,7 +109,7 @@ this is the assumed literal notation of enum values in the C sources
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@valuenick@</term> <term><literal>@valuenick@</literal></term>
<listitem><para> <listitem><para>
A nick name for the enum value currently being processed, this is usually 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 generated by stripping common prefix words of all the enum values of the
@@ -118,7 +119,7 @@ minus (e.g. <literal>the-xvalue</literal>).
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@valuenum@</term> <term><literal>@valuenum@</literal></term>
<listitem><para> <listitem><para>
The integer value for the enum value currently being processed. If the The integer value for the enum value currently being processed. If the
evaluation fails then <command>glib-mkenums</command> will exit with an evaluation fails then <command>glib-mkenums</command> will exit with an
@@ -128,61 +129,61 @@ appears in your value production template. (Since: 2.26)
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@type@</term> <term><literal>@type@</literal></term>
<listitem><para> <listitem><para>
This is substituted either by "enum" or "flags", depending on whether the 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. <literal>flags</literal>).
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@Type@</term> <term><literal>@Type@</literal></term>
<listitem><para> <listitem><para>
The same as <literal>@type@</literal> with the first letter capitalized (e.g. Flags). The same as <literal>@type@</literal> with the first letter capitalized (e.g. <literal>Flags</literal>).
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@TYPE@</term> <term><literal>@TYPE@</literal></term>
<listitem><para> <listitem><para>
The same as <literal>@type@</literal> with all letters uppercased (e.g. FLAGS). The same as <literal>@type@</literal> with all letters uppercased (e.g. <literal>FLAGS</literal>).
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@filename@</term> <term><literal>@filename@</literal></term>
<listitem><para> <listitem><para>
The name of the input file currently being processed (e.g. foo.h). The name of the input file currently being processed (e.g. <literal>foo.h</literal>).
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>@basename@</term> <term><literal>@basename@</literal></term>
<listitem><para> <listitem><para>
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. <literal>foo.h</literal>). Typically
you want to use <literal>@basename@</literal> in place of <literal>@filename@</literal> in your templates, to improve the reproducibility of the build. (Since: 2.22) you want to use <literal>@basename@</literal> in place of <literal>@filename@</literal> in your templates, to improve the reproducibility of the build. (Since: 2.22)
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</para>
</refsect2> </refsect2>
<refsect2><title>Trigraph extensions</title> <refsect2><title>Trigraph extensions</title>
<para> <para>
Some C comments are treated specially in the parsed enum definitions, Some C comments are treated specially in the parsed enum definitions,
such comments start out with the trigraph sequence <literal>/*&lt;</literal> such comments start out with the trigraph sequence <literal>/*&lt;</literal>
and end with the trigraph sequence <literal>&gt;*/</literal>. and end with the trigraph sequence <literal>&gt;*/</literal>.
Per enum definition, the options "skip" and "flags" can be specified, to Per enum definition, the options <literal>skip</literal> and <literal>flags</literal> can be specified, to
indicate this enum definition to be skipped, or for it to be treated as 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 a flags definition, or to specify the common prefix to be stripped from
all values to generate value nicknames, respectively. The "underscore_name" all values to generate value nicknames, respectively. The <literal>underscore_name</literal>
option can be used to specify the word separation used in the *_get_type() option can be used to specify the word separation used in the <function>*_get_type()</function>
function. For instance, <literal>/*&lt; underscore_name=gnome_vfs_uri_hide_options &gt;*/</literal>. function. For instance, <literal>/*&lt; underscore_name=gnome_vfs_uri_hide_options &gt;*/</literal>.
</para> </para>
<para> <para>
Per value definition, the options "skip" and "nick" are supported. Per value definition, the options <literal>skip</literal> and <literal>nick</literal> are supported.
The former causes the value to be skipped, and the latter can be used to The former causes the value to be skipped, and the latter can be used to
specify the otherwise auto-generated nickname. specify the otherwise auto-generated nickname.
Examples: Examples:
</para>
<informalexample><programlisting> <informalexample><programlisting>
typedef enum /*&lt; skip &gt;*/ typedef enum /*&lt; skip &gt;*/
{ {
@@ -196,7 +197,6 @@ typedef enum /*&lt; flags,prefix=PREFIX &gt;*/
PREFIX_THE_THIRD_VALUE, /*&lt; nick=the-last-value &gt;*/ PREFIX_THE_THIRD_VALUE, /*&lt; nick=the-last-value &gt;*/
} PrefixTheFlagsEnum; } PrefixTheFlagsEnum;
</programlisting></informalexample> </programlisting></informalexample>
</para>
</refsect2> </refsect2>
</refsect1> </refsect1>
@@ -317,12 +317,14 @@ Template for auto-generated comments, the default (for C code generations) is
<term><option>--template</option> <replaceable>FILE</replaceable></term> <term><option>--template</option> <replaceable>FILE</replaceable></term>
<listitem><para> <listitem><para>
Read templates from the given file. The templates are enclosed in Read templates from the given file. The templates are enclosed in
specially-formatted C comments specially-formatted C comments:
</para>
<informalexample><programlisting> <informalexample><programlisting>
/*** BEGIN section ***/ /*** BEGIN section ***/
/*** END section ***/ /*** END section ***/
</programlisting></informalexample> </programlisting></informalexample>
where section may be <literal>file-header</literal>, <para>
<replaceable>section</replaceable> may be <literal>file-header</literal>,
<literal>file-production</literal>, <literal>file-tail</literal>, <literal>file-production</literal>, <literal>file-tail</literal>,
<literal>enumeration-production</literal>, <literal>value-header</literal>, <literal>enumeration-production</literal>, <literal>value-header</literal>,
<literal>value-production</literal>, <literal>value-tail</literal> or <literal>value-production</literal>, <literal>value-tail</literal> or

View File

@@ -7,7 +7,7 @@ if get_option('gtk_doc')
'gobject_probes.h', 'gobject_probes.h',
'gobject_trace.h', 'gobject_trace.h',
'gtype-private.h', 'gtype-private.h',
'gobjectenumtypes.h' 'glib-enumtypes.h',
] ]
ignore_decorators = [ ignore_decorators = [

View File

@@ -754,7 +754,7 @@ gioenumtypes_c = custom_target('gioenumtypes_c',
'--template', files('gioenumtypes.c.template'), '--template', files('gioenumtypes.c.template'),
'@INPUT@', gnetworking_h]) '@INPUT@', gnetworking_h])
gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h, gobjectenumtypes_h]) gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h, glib_enumtypes_h])
# inotify # inotify
if glib_conf.has('HAVE_SYS_INOTIFY_H') and have_func_inotify_init1 if glib_conf.has('HAVE_SYS_INOTIFY_H') and have_func_inotify_init1

View File

@@ -34,7 +34,7 @@
#include <gobject/gvalue.h> #include <gobject/gvalue.h>
#include <gobject/gvaluearray.h> #include <gobject/gvaluearray.h>
#include <gobject/gvaluetypes.h> #include <gobject/gvaluetypes.h>
#include <gobject/gobjectenumtypes.h> #include <gobject/glib-enumtypes.h>
#include <gobject/gobject-autocleanups.h> #include <gobject/gobject-autocleanups.h>

View File

@@ -1,6 +1,6 @@
/*** BEGIN file-header ***/ /*** BEGIN file-header ***/
#include "config.h" #include "config.h"
#include "gobjectenumtypes.h" #include "glib-enumtypes.h"
#include <glib-object.h> #include <glib-object.h>
/*** END file-header ***/ /*** END file-header ***/

View File

@@ -85,33 +85,41 @@ foreach tool: python_tools
meson.override_find_program(tool, tool_bin) meson.override_find_program(tool, tool_bin)
endforeach 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 # 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. # in PATH, which means you can't bootstrap glib with its own glib-mkenums.
gobjectenumtypes_h = custom_target('gobjectenumtypes_h', glib_enumtypes_input_headers = files(
output : 'gobjectenumtypes.h', '../glib/gunicode.h',
)
glib_enumtypes_h = custom_target('glib_enumtypes_h',
output : 'glib-enumtypes.h',
capture : true, capture : true,
input : '../glib/gunicode.h', input : glib_enumtypes_input_headers,
install : true, install : true,
install_dir : join_paths(get_option('includedir'), 'glib-2.0/gobject'), install_dir : join_paths(get_option('includedir'), 'glib-2.0/gobject'),
command : [python, glib_mkenums, command : [python, glib_mkenums,
'--template', files('gobjectenumtypes.h.template'), '--template', files('glib-enumtypes.h.template'),
'@INPUT@']) '@INPUT@'])
# For now, we only include gunicode.h here, since GScriptType is needed for pango glib_enumtypes_c = custom_target('glib_enumtypes_c',
# More headers can be added as needed output : 'glib-enumtypes.c',
gobjectenumtypes_c = custom_target('gobjectenumtypes_c',
output : 'gobjectenumtypes.c',
capture : true, capture : true,
input : '../glib/gunicode.h', input : glib_enumtypes_input_headers,
depends : [gobjectenumtypes_h], depends : [glib_enumtypes_h],
command : [python, glib_mkenums, command : [python, glib_mkenums,
'--template', files('gobjectenumtypes.c.template'), '--template', files('glib-enumtypes.c.template'),
'@INPUT@']) '@INPUT@'])
gobjectenumtypes_dep = declare_dependency(sources : [gobjectenumtypes_h]) glib_enumtypes_dep = declare_dependency(sources : [glib_enumtypes_h])
libgobject = library('gobject-2.0', 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, sources : gobject_sources,
version : library_version, version : library_version,
soversion : soversion, soversion : soversion,
@@ -134,7 +142,7 @@ pkg.generate(libgobject,
libgobject_dep = declare_dependency(link_with : libgobject, libgobject_dep = declare_dependency(link_with : libgobject,
include_directories : [gobjectinc], include_directories : [gobjectinc],
dependencies : [libglib_dep, gobjectenumtypes_dep]) dependencies : [libglib_dep, glib_enumtypes_dep])
executable('gobject-query', 'gobject-query.c', executable('gobject-query', 'gobject-query.c',
install : true, install : true,