[glib/ebassi/enum-type-macros: 7/9] docs: Mention alternatives for defining enumeration types




commit fa05ebe27c4209336a56bcd9ed27572bd7f21b43
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Jun 29 15:44:36 2022 +0100

    docs: Mention alternatives for defining enumeration types
    
    We should mention glib-mkenums in the documentation for
    G_DEFINE_ENUM_TYPE and G_DEFINE_FLAGS_TYPE.
    
    We should also mention the macros in the documentation for glib-mkenums.
    
    This way, developers can choose the most appropriate tool for their use
    case.

 docs/reference/gobject/glib-mkenums.xml | 6 ++++++
 gobject/genums.h                        | 8 ++++++++
 2 files changed, 14 insertions(+)
---
diff --git a/docs/reference/gobject/glib-mkenums.xml b/docs/reference/gobject/glib-mkenums.xml
index ce250a3ff5..29709853c1 100644
--- a/docs/reference/gobject/glib-mkenums.xml
+++ b/docs/reference/gobject/glib-mkenums.xml
@@ -44,6 +44,12 @@ input. The options specified control the text that generated, substituting vario
 keywords enclosed in <literal>@</literal> characters in the templates.
 </para>
 
+<para>Since version 2.74, GLib provides the <literal>G_DEFINE_ENUM_TYPE</literal>
+and <literal>G_DEFINE_FLAGS_TYPE</literal> C pre-processor macros. These macros
+can be used to define a GType for projects that have few, small enumeration
+types without going through the complexities of generating code at build
+time.</para>
+
 <refsect2><title>Production text substitutions</title>
 <para>
 Certain keywords enclosed in <literal>@</literal> characters will be substituted in the
diff --git a/gobject/genums.h b/gobject/genums.h
index dfa4e6fb2c..2cd5000f9c 100644
--- a/gobject/genums.h
+++ b/gobject/genums.h
@@ -307,6 +307,10 @@ void       g_flags_complete_type_info (GType              g_flags_type,
  *   G_DEFINE_ENUM_VALUE (GTK_ORIENTATION_VERTICAL, "vertical"))
  * ]|
  *
+ * For projects that have multiple enumeration types, or enumeration
+ * types with many values, you should consider using glib-mkenums to
+ * generate the type function.
+ *
  * Since: 2.74
  */
 #define G_DEFINE_ENUM_TYPE(TypeName, type_name, values) \
@@ -345,6 +349,10 @@ type_name ## _get_type (void) { \
  *   G_DEFINE_ENUM_VALUE (G_SETTINGS_BIND_INVERT_BOOLEAN, "invert-boolean"))
  * ]|
  *
+ * For projects that have multiple enumeration types, or enumeration
+ * types with many values, you should consider using glib-mkenums to
+ * generate the type function.
+ *
  * Since: 2.74
  */
 #define G_DEFINE_FLAGS_TYPE(TypeName, type_name, values) \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]