[gimp/meson: 34/128] Implement enums for app/*. TODO : there's a lot of code duplication. Solutions: * shared variable (m



commit 1ecac758a69cfa2e469a97d8cbc308de90b1b263
Author: Félix Piédallu <felix piedallu me>
Date:   Fri Nov 17 16:33:22 2017 +0100

    Implement enums for app/*.
    TODO : there's a lot of code duplication. Solutions:
    * shared variable (modified on-the-fly for specific includes)
    * external bash script called by meson

 app/display/meson.build    |   48 +++++++++++++++++++++++++++++++++++++----
 app/gegl/meson.build       |   49 ++++++++++++++++++++++++++++++++++++++----
 app/operations/meson.build |   50 +++++++++++++++++++++++++++++++++++++++----
 app/paint/meson.build      |   50 +++++++++++++++++++++++++++++++++++++++----
 app/plug-in/meson.build    |   50 +++++++++++++++++++++++++++++++++++++++----
 app/text/meson.build       |   49 ++++++++++++++++++++++++++++++++++++++----
 app/tools/meson.build      |   50 ++++++++++++++++++++++++++++++++++++++-----
 app/widgets/meson.build    |   50 +++++++++++++++++++++++++++++++++++++++----
 meson_todo.md              |    9 --------
 9 files changed, 355 insertions(+), 50 deletions(-)
---
diff --git a/app/display/meson.build b/app/display/meson.build
index 76f2820..c7542d8 100644
--- a/app/display/meson.build
+++ b/app/display/meson.build
@@ -1,3 +1,45 @@
+
+appdisplayenums = custom_target('display-enums.c',
+  input : [ 'display-enums.h', ],
+  output: [ 'display-enums.c', ],
+  command: [
+    gimp_mkenums,
+    '--fhead','#include "config.h"\n'+
+              '#include <gio/gio.h>\n'+
+              '#include "libgimpbase/gimpbase.h"\n'+
+              '#include "display-enums.h"\n'+
+              '#include"gimp-intl.h"\n',
+    '--fprod','/* enumerations from "@basename@" */\n',
+    '--vhead','GType\n'+
+              '@enum_name@_get_type (void)\n'+
+              '{\n'+
+              '  static const G@Type@Value values[] =\n'+
+              '  {',
+    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+    '--vtail','    { 0, NULL, NULL }\n'+
+              '  };\n',
+    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+              '  {',
+    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+    '--dtail','    { 0, NULL, NULL }\n'+
+              '  };\n'+
+              '\n'+
+              '  static GType type = 0;\n'+
+              '\n'+
+              '  if (G_UNLIKELY (! type))\n'+
+              '    {\n'+
+              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+              '    }\n'+
+              '\n'+
+              '  return type;\n'+
+              '}\n',
+    '@INPUT@',
+  ],
+  capture: true,
+)
+
 libappdisplay_sources = [
   'gimpcanvas-style.c',
   'gimpcanvas.c',
@@ -81,14 +123,10 @@ libappdisplay_sources = [
   'gimptoolsheargrid.c',
   'gimptooltransformgrid.c',
   'gimptoolwidget.c',
+  appdisplayenums,
   gitversion_h,
 ]
 
-# TODO mkenums
-libappdisplay_sources += [
-  'display-enums.c'
-]
-
 libappdisplay = static_library('appdisplay',
   libappdisplay_sources,
   include_directories: [ rootInclude, rootAppInclude, ],
diff --git a/app/gegl/meson.build b/app/gegl/meson.build
index 6b88d0c..6017dae 100644
--- a/app/gegl/meson.build
+++ b/app/gegl/meson.build
@@ -1,3 +1,46 @@
+
+appgeglenums = custom_target('gimp-gegl-enums.c',
+  input : [ 'gimp-gegl-enums.h', ],
+  output: [ 'gimp-gegl-enums.c', ],
+  command: [
+    gimp_mkenums,
+    '--fhead','#include "config.h"\n'+
+              '#include <gio/gio.h>\n'+
+              '#include "libgimpbase/gimpbase.h"\n'+
+              '#include "core/core-enums.h"\n'+
+              '#include "gimp-gegl-enums.h"\n'+
+              '#include"gimp-intl.h"\n',
+    '--fprod','/* enumerations from "@basename@" */\n',
+    '--vhead','GType\n'+
+              '@enum_name@_get_type (void)\n'+
+              '{\n'+
+              '  static const G@Type@Value values[] =\n'+
+              '  {',
+    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+    '--vtail','    { 0, NULL, NULL }\n'+
+              '  };\n',
+    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+              '  {',
+    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+    '--dtail','    { 0, NULL, NULL }\n'+
+              '  };\n'+
+              '\n'+
+              '  static GType type = 0;\n'+
+              '\n'+
+              '  if (G_UNLIKELY (! type))\n'+
+              '    {\n'+
+              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+              '    }\n'+
+              '\n'+
+              '  return type;\n'+
+              '}\n',
+    '@INPUT@',
+  ],
+  capture: true,
+)
+
 libappgegl_sources = [
   'gimp-babl-compat.c',
   'gimp-babl.c',
@@ -12,11 +55,7 @@ libappgegl_sources = [
   'gimp-gegl.c',
   'gimpapplicator.c',
   'gimptilehandlervalidate.c',
-]
-
-# TODO mkenums
-libappgegl_sources += [
-  'gimp-gegl-enums.c',
+  appgeglenums,
 ]
 
 libappgegl = static_library('appgegl',
diff --git a/app/operations/meson.build b/app/operations/meson.build
index eee7923..6412a93 100644
--- a/app/operations/meson.build
+++ b/app/operations/meson.build
@@ -1,3 +1,47 @@
+
+appoperationsenums = custom_target('operations-enums.c',
+  input : [ 'operations-enums.h', ],
+  output: [ 'operations-enums.c', ],
+  command: [
+    gimp_mkenums,
+    '--fhead','#include "config.h"\n'+
+              '#include <gio/gio.h>\n'+
+              '#include "libgimpbase/gimpbase.h"\n'+
+              '#include "core/core-enums.h"\n'+
+              '#include "operations-enums.h"\n'+
+              '#include"gimp-intl.h"\n',
+    '--fprod','/* enumerations from "@basename@" */\n',
+    '--vhead','GType\n'+
+              '@enum_name@_get_type (void)\n'+
+              '{\n'+
+              '  static const G@Type@Value values[] =\n'+
+              '  {',
+    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+    '--vtail','    { 0, NULL, NULL }\n'+
+              '  };\n',
+    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+              '  {',
+    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+    '--dtail','    { 0, NULL, NULL }\n'+
+              '  };\n'+
+              '\n'+
+              '  static GType type = 0;\n'+
+              '\n'+
+              '  if (G_UNLIKELY (! type))\n'+
+              '    {\n'+
+              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+              '    }\n'+
+              '\n'+
+              '  return type;\n'+
+              '}\n',
+    '@INPUT@',
+  ],
+  capture: true,
+)
+
+
 libappoperations_sources = [
   'gimp-operation-config.c',
   'gimp-operations.c',
@@ -34,11 +78,7 @@ libappoperations_sources = [
   'gimpoperationshrink.c',
   'gimpoperationthreshold.c',
   'gimpoperationthresholdalpha.c',
-]
-
-# TODO mkenums
-libappoperations_sources += [
-  'operations-enums.c',
+  appoperationsenums
 ]
 
 libappoperations = static_library('appoperations',
diff --git a/app/paint/meson.build b/app/paint/meson.build
index b545fcb..121e7e4 100644
--- a/app/paint/meson.build
+++ b/app/paint/meson.build
@@ -1,3 +1,47 @@
+
+apppaintenums = custom_target('paint-enums.c',
+  input : [ 'paint-enums.h', ],
+  output: [ 'paint-enums.c', ],
+  command: [
+    gimp_mkenums,
+    '--fhead','#include "config.h"\n'+
+              '#include <gio/gio.h>\n'+
+              '#include "libgimpbase/gimpbase.h"\n'+
+              '#include "core/core-enums.h"\n'+
+              '#include "paint-enums.h"\n'+
+              '#include"gimp-intl.h"\n',
+    '--fprod','/* enumerations from "@basename@" */\n',
+    '--vhead','GType\n'+
+              '@enum_name@_get_type (void)\n'+
+              '{\n'+
+              '  static const G@Type@Value values[] =\n'+
+              '  {',
+    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+    '--vtail','    { 0, NULL, NULL }\n'+
+              '  };\n',
+    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+              '  {',
+    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+    '--dtail','    { 0, NULL, NULL }\n'+
+              '  };\n'+
+              '\n'+
+              '  static GType type = 0;\n'+
+              '\n'+
+              '  if (G_UNLIKELY (! type))\n'+
+              '    {\n'+
+              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+              '    }\n'+
+              '\n'+
+              '  return type;\n'+
+              '}\n',
+    '@INPUT@',
+  ],
+  capture: true,
+)
+
+
 libapppaint_sources = [
   'gimp-paint.c',
   'gimpairbrush.c',
@@ -33,11 +77,7 @@ libapppaint_sources = [
   'gimpsmudgeoptions.c',
   'gimpsourcecore.c',
   'gimpsourceoptions.c',
-]
-
-# TODO mkenums
-libapppaint_sources += [
-  'paint-enums.c',
+  apppaintenums
 ]
 
 libapppaint = static_library('apppaint',
diff --git a/app/plug-in/meson.build b/app/plug-in/meson.build
index 422ccb0..f272af9 100644
--- a/app/plug-in/meson.build
+++ b/app/plug-in/meson.build
@@ -1,3 +1,47 @@
+
+apppluginenums = custom_target('plug-in-enums.c',
+  input : [ 'plug-in-enums.h', ],
+  output: [ 'plug-in-enums.c', ],
+  command: [
+    gimp_mkenums,
+    '--fhead','#include "config.h"\n'+
+              '#include <gio/gio.h>\n'+
+              '#include "libgimpbase/gimpbase.h"\n'+
+              '#include "core/core-enums.h"\n'+
+              '#include "plug-in-enums.h"\n'+
+              '#include"gimp-intl.h"\n',
+    '--fprod','/* enumerations from "@basename@" */\n',
+    '--vhead','GType\n'+
+              '@enum_name@_get_type (void)\n'+
+              '{\n'+
+              '  static const G@Type@Value values[] =\n'+
+              '  {',
+    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+    '--vtail','    { 0, NULL, NULL }\n'+
+              '  };\n',
+    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+              '  {',
+    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+    '--dtail','    { 0, NULL, NULL }\n'+
+              '  };\n'+
+              '\n'+
+              '  static GType type = 0;\n'+
+              '\n'+
+              '  if (G_UNLIKELY (! type))\n'+
+              '    {\n'+
+              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+              '    }\n'+
+              '\n'+
+              '  return type;\n'+
+              '}\n',
+    '@INPUT@',
+  ],
+  capture: true,
+)
+
+
 libappplugin_sources = [
   'gimpenvirontable.c',
   'gimpinterpreterdb.c',
@@ -26,11 +70,7 @@ libappplugin_sources = [
   'plug-in-menu-path.c',
   'plug-in-params.c',
   'plug-in-rc.c',
-]
-
-# TODO mkenums
-libappplugin_sources += [
-  'plug-in-enums.c',
+  apppluginenums,
 ]
 
 libappplugin = static_library('appplug-in',
diff --git a/app/text/meson.build b/app/text/meson.build
index 4fe2177..7115413 100644
--- a/app/text/meson.build
+++ b/app/text/meson.build
@@ -1,3 +1,46 @@
+
+apptextenums = custom_target('text-enums.c',
+  input : [ 'text-enums.h', ],
+  output: [ 'text-enums.c', ],
+  command: [
+    gimp_mkenums,
+    '--fhead','#include "config.h"\n'+
+              '#include <gio/gio.h>\n'+
+              '#include "libgimpbase/gimpbase.h"\n'+
+              '#include "core/core-enums.h"\n'+
+              '#include "text-enums.h"\n'+
+              '#include"gimp-intl.h"\n',
+    '--fprod','/* enumerations from "@basename@" */\n',
+    '--vhead','GType\n'+
+              '@enum_name@_get_type (void)\n'+
+              '{\n'+
+              '  static const G@Type@Value values[] =\n'+
+              '  {',
+    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+    '--vtail','    { 0, NULL, NULL }\n'+
+              '  };\n',
+    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+              '  {',
+    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+    '--dtail','    { 0, NULL, NULL }\n'+
+              '  };\n'+
+              '\n'+
+              '  static GType type = 0;\n'+
+              '\n'+
+              '  if (G_UNLIKELY (! type))\n'+
+              '    {\n'+
+              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+              '    }\n'+
+              '\n'+
+              '  return type;\n'+
+              '}\n',
+    '@INPUT@',
+  ],
+  capture: true,
+)
+
 libapptext_sources = [
   'gimp-fonts.c',
   'gimpfont.c',
@@ -13,11 +56,7 @@ libapptext_sources = [
   'gimptextlayout-render.c',
   'gimptextlayout.c',
   'gimptextundo.c',
-]
-
-# TODO mkenums
-libapptext_sources += [
-  'text-enums.c',
+  apptextenums,
 ]
 
 
diff --git a/app/tools/meson.build b/app/tools/meson.build
index 42046f8..33dd3d5 100644
--- a/app/tools/meson.build
+++ b/app/tools/meson.build
@@ -1,3 +1,46 @@
+
+apptoolsenums = custom_target('tools-enums.c',
+  input : [ 'tools-enums.h', ],
+  output: [ 'tools-enums.c', ],
+  command: [
+    gimp_mkenums,
+    '--fhead','#include "config.h"\n'+
+              '#include <gio/gio.h>\n'+
+              '#include "libgimpbase/gimpbase.h"\n'+
+              '#include "core/core-enums.h"\n'+
+              '#include "tools-enums.h"\n'+
+              '#include"gimp-intl.h"\n',
+    '--fprod','/* enumerations from "@basename@" */\n',
+    '--vhead','GType\n'+
+              '@enum_name@_get_type (void)\n'+
+              '{\n'+
+              '  static const G@Type@Value values[] =\n'+
+              '  {',
+    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+    '--vtail','    { 0, NULL, NULL }\n'+
+              '  };\n',
+    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+              '  {',
+    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+    '--dtail','    { 0, NULL, NULL }\n'+
+              '  };\n'+
+              '\n'+
+              '  static GType type = 0;\n'+
+              '\n'+
+              '  if (G_UNLIKELY (! type))\n'+
+              '    {\n'+
+              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+              '    }\n'+
+              '\n'+
+              '  return type;\n'+
+              '}\n',
+    '@INPUT@',
+  ],
+  capture: true,
+)
+
 libapptools_sources = [
   'gimp-tools.c',
   'gimpairbrushtool.c',
@@ -100,14 +143,9 @@ libapptools_sources = [
   'gimpwarpoptions.c',
   'gimpwarptool.c',
   'tool_manager.c',
+  apptoolsenums
 ]
 
-# TODO mkenums
-libapptools_sources += [
-  'tools-enums.c',
-]
-
-
 libapptools = static_library('apptools',
   libapptools_sources,
   include_directories: [ rootInclude, rootAppInclude, ],
diff --git a/app/widgets/meson.build b/app/widgets/meson.build
index 60815f7..9400423 100644
--- a/app/widgets/meson.build
+++ b/app/widgets/meson.build
@@ -1,3 +1,47 @@
+
+appwidgetsenums = custom_target('widgets-enums.c',
+  input : [ 'widgets-enums.h', ],
+  output: [ 'widgets-enums.c', ],
+  command: [
+    gimp_mkenums,
+    '--fhead','#include "config.h"\n'+
+              '#include <gio/gio.h>\n'+
+              '#include "libgimpbase/gimpbase.h"\n'+
+              '#include "core/core-enums.h"\n'+
+              '#include "widgets-enums.h"\n'+
+              '#include"gimp-intl.h"\n',
+    '--fprod','/* enumerations from "@basename@" */\n',
+    '--vhead','GType\n'+
+              '@enum_name@_get_type (void)\n'+
+              '{\n'+
+              '  static const G@Type@Value values[] =\n'+
+              '  {',
+    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+    '--vtail','    { 0, NULL, NULL }\n'+
+              '  };\n',
+    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+              '  {',
+    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+    '--dtail','    { 0, NULL, NULL }\n'+
+              '  };\n'+
+              '\n'+
+              '  static GType type = 0;\n'+
+              '\n'+
+              '  if (G_UNLIKELY (! type))\n'+
+              '    {\n'+
+              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+              '    }\n'+
+              '\n'+
+              '  return type;\n'+
+              '}\n',
+    '@INPUT@',
+  ],
+  capture: true,
+)
+
+
 libappwidgets_sources = [
   'gimpaction-history.c',
   'gimpaction.c',
@@ -210,11 +254,7 @@ libappwidgets_sources = [
   'gimpwindowstrategy.c',
   'gtkhwrapbox.c',
   'gtkwrapbox.c',
-]
-
-# TODO mkenums
-libappwidgets_sources += [
-  'widgets-enums.c',
+  appwidgetsenums,
 ]
 
 
diff --git a/meson_todo.md b/meson_todo.md
index cdc698e..5c3517f 100644
--- a/meson_todo.md
+++ b/meson_todo.md
@@ -2,14 +2,6 @@ Meson Port
 -----------
 
 * app
-  * display
-  * gegl
-  * operations
-  * paint
-  * plug-in
-  * text
-  * tools
-  * widgets
 * devel-docs
   * app
   * libgimp
@@ -23,7 +15,6 @@ Meson Port
     * images
     * tmpl
   * tools
-* docs
 * icons
   * Legacy
   * Symbolic-Inverted


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