2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-07-02 11:07:41 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-07-02 11:07:41 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-07-02 11:07:41 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2003-07-02 11:07:41 +00:00
|
|
|
*/
|
|
|
|
|
2008-09-09 14:40:52 +00:00
|
|
|
#define DEBUG_SCRIPTS 0
|
2021-01-28 08:31:11 -05:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
#include <string.h>
|
2001-07-22 22:18:01 +00:00
|
|
|
|
2006-10-19 13:08:47 +00:00
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
2021-11-30 11:38:10 +01:00
|
|
|
#include <girepository.h>
|
|
|
|
|
2004-08-31 17:54:46 +00:00
|
|
|
#include <gtk/gtk.h>
|
2003-07-02 11:07:41 +00:00
|
|
|
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
#include "libgimp/gimp.h"
|
2003-07-02 11:07:41 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
#include "tinyscheme/scheme-private.h"
|
|
|
|
#if USE_DL
|
|
|
|
#include "tinyscheme/dynload.h"
|
|
|
|
#endif
|
|
|
|
#include "ftx/ftx.h"
|
2003-11-26 17:14:58 +00:00
|
|
|
|
2004-08-31 17:54:46 +00:00
|
|
|
#include "script-fu-types.h"
|
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
#include "script-fu-lib.h"
|
2008-09-10 23:10:15 +00:00
|
|
|
#include "script-fu-regex.h"
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
#include "script-fu-scripts.h"
|
2021-01-28 08:31:11 -05:00
|
|
|
#include "script-fu-errors.h"
|
2021-01-28 09:08:39 -05:00
|
|
|
#include "script-fu-compat.h"
|
2023-12-04 11:23:01 -05:00
|
|
|
#include "script-fu-version.h"
|
2024-04-08 06:43:05 -04:00
|
|
|
#include "script-fu-progress.h"
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
#include "scheme-wrapper.h"
|
2021-04-30 13:51:04 -04:00
|
|
|
#include "scheme-marshal.h"
|
2023-09-07 07:10:51 -04:00
|
|
|
#include "scheme-marshal-return.h"
|
2003-07-02 11:07:41 +00:00
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
#undef cons
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
static void ts_init_constants (scheme *sc,
|
|
|
|
GIRepository *repo);
|
|
|
|
static void ts_init_enums (scheme *sc,
|
|
|
|
GIRepository *repo,
|
|
|
|
const char *namespace);
|
|
|
|
static void ts_define_procedure (scheme *sc,
|
|
|
|
const gchar *symbol_name,
|
|
|
|
TsWrapperFunc func);
|
|
|
|
static void ts_init_procedures (scheme *sc,
|
|
|
|
gboolean register_scipts);
|
|
|
|
static void ts_load_init_and_compatibility_scripts (GList *paths);
|
|
|
|
|
|
|
|
static pointer script_fu_marshal_arg_to_value (scheme *sc,
|
|
|
|
pointer a,
|
|
|
|
const gchar *proc_name,
|
|
|
|
gint arg_index,
|
|
|
|
GParamSpec *arg_spec,
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GValue *value,
|
|
|
|
gchar **strvalue);
|
2024-12-16 23:11:06 +01:00
|
|
|
|
|
|
|
static pointer script_fu_marshal_procedure_call (scheme *sc,
|
|
|
|
pointer a,
|
|
|
|
gboolean permissive,
|
|
|
|
gboolean deprecated);
|
|
|
|
static pointer script_fu_marshal_procedure_call_strict (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_marshal_procedure_call_permissive (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_marshal_procedure_call_deprecated (scheme *sc,
|
|
|
|
pointer a);
|
2025-02-25 23:04:00 +01:00
|
|
|
static pointer script_fu_marshal_procedure_exists (scheme *sc,
|
|
|
|
pointer a);
|
2024-12-16 23:11:06 +01:00
|
|
|
|
|
|
|
static pointer script_fu_marshal_drawable_create_filter (scheme *sc,
|
|
|
|
pointer a,
|
|
|
|
const gchar *proc_name,
|
|
|
|
GimpDrawable **drawable,
|
|
|
|
GimpDrawableFilter **filter);
|
|
|
|
static pointer script_fu_marshal_drawable_filter_configure_call (scheme *sc,
|
|
|
|
pointer a);
|
2024-12-16 23:32:02 +01:00
|
|
|
static pointer script_fu_marshal_drawable_filter_set_aux_call (scheme *sc,
|
|
|
|
pointer a);
|
2024-12-16 23:11:06 +01:00
|
|
|
static pointer script_fu_marshal_drawable_merge_filter_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_marshal_drawable_append_filter_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_marshal_drawable_merge_new_filter_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_marshal_drawable_append_new_filter_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
|
|
|
|
static pointer script_fu_register_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_register_call_filter (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_register_call_procedure (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_menu_register_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_use_v3_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_use_v2_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_quit_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
static pointer script_fu_nil_call (scheme *sc,
|
|
|
|
pointer a);
|
|
|
|
|
|
|
|
static gboolean ts_load_file (const gchar *dirname,
|
|
|
|
const gchar *basename);
|
2008-09-11 18:00:18 +00:00
|
|
|
|
|
|
|
typedef struct
|
2007-06-20 10:54:28 +00:00
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
gint value;
|
2008-09-11 18:00:18 +00:00
|
|
|
} NamedConstant;
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2022-07-15 13:50:36 -04:00
|
|
|
/* LHS is text in a script, RHS is constant defined in C. */
|
2017-07-14 13:10:46 +02:00
|
|
|
static const NamedConstant script_constants[] =
|
2006-10-19 13:51:42 +00:00
|
|
|
{
|
2006-10-20 17:55:14 +00:00
|
|
|
/* Useful values from libgimpbase/gimplimits.h */
|
|
|
|
{ "MIN-IMAGE-SIZE", GIMP_MIN_IMAGE_SIZE },
|
|
|
|
{ "MAX-IMAGE-SIZE", GIMP_MAX_IMAGE_SIZE },
|
2024-02-03 09:32:10 -05:00
|
|
|
/* Note conversion to int, loss of precision: 0.005=>0 */
|
|
|
|
{ "MIN-RESOLUTION", (gint) GIMP_MIN_RESOLUTION },
|
2006-10-20 17:55:14 +00:00
|
|
|
{ "MAX-RESOLUTION", GIMP_MAX_RESOLUTION },
|
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
/* Useful misc stuff */
|
|
|
|
{ "TRUE", TRUE },
|
|
|
|
{ "FALSE", FALSE },
|
|
|
|
|
2007-06-20 10:54:28 +00:00
|
|
|
/* Builtin units */
|
|
|
|
{ "UNIT-PIXEL", GIMP_UNIT_PIXEL },
|
|
|
|
{ "UNIT-INCH", GIMP_UNIT_INCH },
|
|
|
|
{ "UNIT-MM", GIMP_UNIT_MM },
|
|
|
|
{ "UNIT-POINT", GIMP_UNIT_POINT },
|
|
|
|
{ "UNIT-PICA", GIMP_UNIT_PICA },
|
|
|
|
|
2006-11-01 17:14:17 +00:00
|
|
|
/* Script-Fu types */
|
2022-07-15 13:50:36 -04:00
|
|
|
|
|
|
|
/* Arg types. */
|
2006-10-16 01:08:54 +00:00
|
|
|
{ "SF-IMAGE", SF_IMAGE },
|
|
|
|
{ "SF-DRAWABLE", SF_DRAWABLE },
|
|
|
|
{ "SF-LAYER", SF_LAYER },
|
|
|
|
{ "SF-CHANNEL", SF_CHANNEL },
|
2006-11-16 01:29:49 +00:00
|
|
|
{ "SF-VECTORS", SF_VECTORS },
|
2006-10-16 01:08:54 +00:00
|
|
|
{ "SF-COLOR", SF_COLOR },
|
|
|
|
{ "SF-TOGGLE", SF_TOGGLE },
|
|
|
|
{ "SF-STRING", SF_STRING },
|
|
|
|
{ "SF-FILENAME", SF_FILENAME },
|
|
|
|
{ "SF-DIRNAME", SF_DIRNAME },
|
|
|
|
{ "SF-ADJUSTMENT", SF_ADJUSTMENT },
|
|
|
|
{ "SF-FONT", SF_FONT },
|
|
|
|
{ "SF-PATTERN", SF_PATTERN },
|
|
|
|
{ "SF-BRUSH", SF_BRUSH },
|
|
|
|
{ "SF-GRADIENT", SF_GRADIENT },
|
|
|
|
{ "SF-OPTION", SF_OPTION },
|
|
|
|
{ "SF-PALETTE", SF_PALETTE },
|
|
|
|
{ "SF-TEXT", SF_TEXT },
|
|
|
|
{ "SF-ENUM", SF_ENUM },
|
2007-04-12 15:56:57 +00:00
|
|
|
{ "SF-DISPLAY", SF_DISPLAY },
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2022-07-15 13:50:36 -04:00
|
|
|
/* PDB procedure drawable_arity, i.e. sensitivity.
|
|
|
|
* Used with script-fu-register-filter.
|
|
|
|
*
|
|
|
|
* This declares the arity of the algorithm,
|
|
|
|
* and not the signature of the PDB procedure.
|
|
|
|
* Since v3, PDB procedures that are image procedures,
|
|
|
|
* take a container of drawables.
|
|
|
|
* This only describes how many drawables the container *should* hold.
|
|
|
|
*
|
|
|
|
* For calls invoked by a user, this describes
|
|
|
|
* how many drawables the user is expected to select,
|
|
|
|
* which disables/enables the menu item for the procedure.
|
|
|
|
*
|
|
|
|
* Procedures are also called from other procedures.
|
|
|
|
* A call from another procedure may in fact
|
|
|
|
* pass more drawables than declared for drawable_arity.
|
|
|
|
* That is a programming error on behalf of the caller.
|
|
|
|
* A well-written callee that is passed more drawables than declared
|
|
|
|
* should return an error instead of processing any of the drawables.
|
|
|
|
*
|
|
|
|
* Similarly for fewer than declared.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Requires two drawables. Often an operation between them, yielding a new drawable */
|
|
|
|
{ "SF-TWO-OR-MORE-DRAWABLE", SF_TWO_OR_MORE_DRAWABLE },
|
|
|
|
/* Often processed independently, sequentially, with side effects on the drawables. */
|
|
|
|
{ "SF-ONE-OR-MORE-DRAWABLE", SF_ONE_OR_MORE_DRAWABLE },
|
|
|
|
/* Requires exactly one drawable. */
|
|
|
|
{ "SF-ONE-DRAWABLE", SF_ONE_DRAWABLE },
|
|
|
|
|
2006-11-01 17:14:17 +00:00
|
|
|
/* For SF-ADJUSTMENT */
|
2006-10-16 01:08:54 +00:00
|
|
|
{ "SF-SLIDER", SF_SLIDER },
|
|
|
|
{ "SF-SPINNER", SF_SPINNER },
|
|
|
|
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static scheme sc;
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2022-05-28 10:02:10 -04:00
|
|
|
/*
|
|
|
|
* These callbacks break the backwards compile-time dependence
|
|
|
|
* of inner scheme-wrapper on the outer script-fu-server.
|
|
|
|
* Only script-fu-server registers, when it runs.
|
|
|
|
*/
|
|
|
|
static TsCallbackFunc post_command_callback = NULL;
|
|
|
|
static TsCallbackFunc quit_callback = NULL;
|
|
|
|
|
2003-08-26 18:12:42 +00:00
|
|
|
void
|
2014-08-03 21:49:20 +02:00
|
|
|
tinyscheme_init (GList *path,
|
|
|
|
gboolean register_scripts)
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
{
|
2021-11-30 11:38:10 +01:00
|
|
|
GIRepository *repo;
|
|
|
|
GITypelib *typelib;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
/* init the interpreter */
|
2008-09-11 18:00:18 +00:00
|
|
|
if (! scheme_init (&sc))
|
2006-11-09 23:03:55 +00:00
|
|
|
{
|
2021-01-28 08:31:11 -05:00
|
|
|
g_warning ("Could not initialize TinyScheme!");
|
2006-11-09 23:03:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-06-12 10:25:29 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
scheme_set_input_port_file (&sc, stdin);
|
2007-08-30 00:21:20 +00:00
|
|
|
scheme_set_output_port_file (&sc, stdout);
|
|
|
|
ts_register_output_func (ts_stdout_output_func, NULL);
|
2006-10-16 01:08:54 +00:00
|
|
|
|
|
|
|
/* Initialize the TinyScheme extensions */
|
2007-08-30 00:21:20 +00:00
|
|
|
init_ftx (&sc);
|
2008-09-11 13:33:58 +00:00
|
|
|
script_fu_regex_init (&sc);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2021-11-30 11:38:10 +01:00
|
|
|
/* Fetch the typelib */
|
|
|
|
repo = g_irepository_get_default ();
|
|
|
|
typelib = g_irepository_require (repo, "Gimp", NULL, 0, &error);
|
|
|
|
if (!typelib)
|
|
|
|
{
|
|
|
|
g_warning ("%s", error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
/* register in the interpreter the gimp functions and types. */
|
2021-11-30 11:38:10 +01:00
|
|
|
ts_init_constants (&sc, repo);
|
2008-09-11 18:00:18 +00:00
|
|
|
ts_init_procedures (&sc, register_scripts);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2024-10-22 17:40:41 -04:00
|
|
|
ts_load_init_and_compatibility_scripts (path);
|
2006-10-16 01:08:54 +00:00
|
|
|
}
|
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
/* Create an SF-RUN-MODE constant for use in scripts.
|
|
|
|
* It is set to the run mode state determined by GIMP.
|
|
|
|
*/
|
2006-10-16 01:08:54 +00:00
|
|
|
void
|
2008-09-11 18:00:18 +00:00
|
|
|
ts_set_run_mode (GimpRunMode run_mode)
|
2007-09-27 19:54:28 +00:00
|
|
|
{
|
|
|
|
pointer symbol;
|
|
|
|
|
|
|
|
symbol = sc.vptr->mk_symbol (&sc, "SF-RUN-MODE");
|
|
|
|
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
|
|
|
sc.vptr->mk_integer (&sc, run_mode));
|
2008-09-11 13:33:58 +00:00
|
|
|
sc.vptr->setimmutable (symbol);
|
2007-09-27 19:54:28 +00:00
|
|
|
}
|
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
void
|
|
|
|
ts_set_print_flag (gint print_flag)
|
|
|
|
{
|
|
|
|
sc.print_output = print_flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ts_print_welcome (void)
|
|
|
|
{
|
|
|
|
ts_output_string (TS_OUTPUT_NORMAL,
|
2011-12-05 17:04:07 -05:00
|
|
|
"Welcome to TinyScheme, Version 1.40\n", -1);
|
2008-09-11 18:00:18 +00:00
|
|
|
ts_output_string (TS_OUTPUT_NORMAL,
|
|
|
|
"Copyright (c) Dimitrios Souflis\n", -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ts_interpret_stdin (void)
|
|
|
|
{
|
|
|
|
scheme_load_file (&sc, stdin);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
ts_interpret_string (const gchar *expr)
|
|
|
|
{
|
2022-07-15 13:50:36 -04:00
|
|
|
gint result;
|
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
#if DEBUG_SCRIPTS
|
|
|
|
sc.print_output = 1;
|
|
|
|
sc.tracing = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sc.vptr->load_string (&sc, (char *) expr);
|
|
|
|
|
2022-07-15 13:50:36 -04:00
|
|
|
result = sc.retcode;
|
|
|
|
|
|
|
|
g_debug ("ts_interpret_string returns: %i", result);
|
|
|
|
return result;
|
2008-09-11 18:00:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
|
|
|
ts_get_success_msg (void)
|
|
|
|
{
|
|
|
|
if (sc.vptr->is_string (sc.value))
|
|
|
|
return sc.vptr->string_value (sc.value);
|
|
|
|
|
|
|
|
return "Success";
|
|
|
|
}
|
|
|
|
|
2024-04-16 11:05:00 -04:00
|
|
|
/* Delegate. The caller doesn't know the scheme instance,
|
|
|
|
* and here we don't know TS internals.
|
|
|
|
*/
|
|
|
|
const gchar*
|
|
|
|
ts_get_error_msg (void)
|
|
|
|
{
|
|
|
|
return ts_get_error_string (&sc);
|
|
|
|
}
|
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
void
|
|
|
|
ts_stdout_output_func (TsOutputType type,
|
|
|
|
const char *string,
|
|
|
|
int len,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (len < 0)
|
|
|
|
len = strlen (string);
|
|
|
|
fprintf (stdout, "%.*s", len, string);
|
2009-05-28 21:06:53 +02:00
|
|
|
fflush (stdout);
|
2008-09-11 18:00:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ts_gstring_output_func (TsOutputType type,
|
|
|
|
const char *string,
|
|
|
|
int len,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GString *gstr = (GString *) user_data;
|
|
|
|
|
|
|
|
g_string_append_len (gstr, string, len);
|
|
|
|
}
|
2007-09-28 14:20:35 +00:00
|
|
|
|
2022-05-28 10:02:10 -04:00
|
|
|
void
|
|
|
|
ts_register_quit_callback (TsCallbackFunc callback)
|
|
|
|
{
|
|
|
|
quit_callback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ts_register_post_command_callback (TsCallbackFunc callback)
|
|
|
|
{
|
|
|
|
post_command_callback = callback;
|
|
|
|
}
|
|
|
|
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
/* private functions */
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2003-10-16 12:47:33 +00:00
|
|
|
/*
|
|
|
|
* Below can be found the functions responsible for registering the
|
|
|
|
* gimp functions and types against the scheme interpreter.
|
|
|
|
*/
|
2024-10-22 16:37:38 -04:00
|
|
|
|
|
|
|
/* Define a symbol into interpreter state, bound to a string, immutable. */
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
static void
|
2024-10-22 16:37:38 -04:00
|
|
|
ts_define_constant_string (scheme *sc,
|
|
|
|
const gchar *symbol_name,
|
|
|
|
const gchar *symbol_value)
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
{
|
2024-10-22 16:37:38 -04:00
|
|
|
pointer symbol = sc->vptr->mk_symbol (sc, symbol_name);
|
2004-09-22 17:31:44 +00:00
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
sc->vptr->scheme_define (sc, sc->global_env, symbol,
|
2024-10-22 16:37:38 -04:00
|
|
|
sc->vptr->mk_string (sc, symbol_value));
|
2008-09-11 18:00:18 +00:00
|
|
|
sc->vptr->setimmutable (symbol);
|
2024-10-22 16:37:38 -04:00
|
|
|
}
|
2004-09-22 17:31:44 +00:00
|
|
|
|
2024-10-22 16:37:38 -04:00
|
|
|
static void
|
|
|
|
ts_init_constants (scheme *sc,
|
|
|
|
GIRepository *repo)
|
|
|
|
{
|
|
|
|
ts_define_constant_string (sc, "gimp-directory", gimp_directory ());
|
|
|
|
ts_define_constant_string (sc, "gimp-data-directory", gimp_data_directory ());
|
|
|
|
ts_define_constant_string (sc, "gimp-plug-in-directory", gimp_plug_in_directory ());
|
|
|
|
ts_define_constant_string (sc, "gimp-locale-directory", gimp_locale_directory ());
|
|
|
|
ts_define_constant_string (sc, "gimp-sysconf-directory", gimp_sysconf_directory ());
|
2003-08-26 18:12:42 +00:00
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
{
|
|
|
|
gchar *path;
|
|
|
|
|
|
|
|
path = script_fu_sys_init_directory ();
|
|
|
|
ts_define_constant_string (sc, "script-fu-sys-init-directory", path);
|
|
|
|
g_free (path);
|
|
|
|
path = script_fu_user_init_directory ();
|
|
|
|
ts_define_constant_string (sc, "script-fu-user-init-directory", path);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
2021-11-30 11:38:10 +01:00
|
|
|
ts_init_enums (sc, repo, "Gimp");
|
|
|
|
ts_init_enums (sc, repo, "Gegl");
|
2004-10-25 19:29:00 +00:00
|
|
|
|
2024-10-22 16:37:38 -04:00
|
|
|
/* Constants used in the register block of scripts e.g. SF-ADJUSTMENT */
|
|
|
|
for (int i = 0; script_constants[i].name != NULL; ++i)
|
2006-10-20 09:54:05 +00:00
|
|
|
{
|
2024-10-22 16:37:38 -04:00
|
|
|
pointer symbol;
|
|
|
|
|
2008-09-11 18:00:18 +00:00
|
|
|
symbol = sc->vptr->mk_symbol (sc, script_constants[i].name);
|
|
|
|
sc->vptr->scheme_define (sc, sc->global_env, symbol,
|
|
|
|
sc->vptr->mk_integer (sc,
|
|
|
|
script_constants[i].value));
|
|
|
|
sc->vptr->setimmutable (symbol);
|
2006-10-20 09:54:05 +00:00
|
|
|
}
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2024-10-22 16:37:38 -04:00
|
|
|
/* use to build paths to files/directories */
|
|
|
|
ts_define_constant_string (sc, "DIR-SEPARATOR", G_DIR_SEPARATOR_S);
|
|
|
|
/* use to build search paths */
|
|
|
|
ts_define_constant_string (sc, "SEARCHPATH-SEPARATOR", G_SEARCHPATH_SEPARATOR_S);
|
2017-01-09 16:00:10 +01:00
|
|
|
}
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2017-01-09 16:00:10 +01:00
|
|
|
static void
|
2021-11-30 11:38:10 +01:00
|
|
|
ts_init_enum (scheme *sc,
|
|
|
|
GIEnumInfo *info,
|
|
|
|
const char *namespace)
|
2017-01-09 16:00:10 +01:00
|
|
|
{
|
2021-11-30 11:38:10 +01:00
|
|
|
int n_values;
|
2017-01-09 16:00:10 +01:00
|
|
|
|
2021-11-30 11:38:10 +01:00
|
|
|
n_values = g_enum_info_get_n_values ((GIEnumInfo *) info);
|
|
|
|
for (int j = 0; j < n_values; j++)
|
2006-10-20 09:54:05 +00:00
|
|
|
{
|
2021-11-30 11:38:10 +01:00
|
|
|
GIValueInfo *value_info;
|
|
|
|
const char *c_identifier;
|
|
|
|
char *scheme_name;
|
|
|
|
int int_value;
|
|
|
|
pointer symbol;
|
|
|
|
|
|
|
|
value_info = g_enum_info_get_value (info, j);
|
|
|
|
|
|
|
|
/* Get name & value. Normally, we would use the actual name of the
|
|
|
|
* GIBaseInfo here, but that would break bw-compatibility */
|
|
|
|
c_identifier = g_base_info_get_attribute ((GIBaseInfo *) value_info, "c:identifier");
|
|
|
|
if (c_identifier == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Problem in the GIR file: enum value without \"c:identifier\"!");
|
|
|
|
g_base_info_unref ((GIBaseInfo *) value_info);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Scheme-ify the name */
|
|
|
|
if (g_strcmp0 (namespace, "Gimp") == 0)
|
2017-01-09 16:00:10 +01:00
|
|
|
{
|
2021-11-30 11:38:10 +01:00
|
|
|
/* Skip the GIMP prefix for GIMP enums */
|
|
|
|
if (g_str_has_prefix (c_identifier, "GIMP_"))
|
|
|
|
c_identifier += strlen ("GIMP_");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Other namespaces: skip non-prefixed symbols, to prevent clashes */
|
|
|
|
if (g_ascii_strncasecmp (c_identifier, namespace, strlen (namespace)) != 0)
|
|
|
|
{
|
|
|
|
g_base_info_unref ((GIBaseInfo *) value_info);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scheme_name = g_strdelimit (g_strdup (c_identifier), "_", '-');
|
|
|
|
int_value = g_value_info_get_value (value_info);
|
|
|
|
|
|
|
|
/* Register the symbol */
|
|
|
|
symbol = sc->vptr->mk_symbol (sc, scheme_name);
|
|
|
|
sc->vptr->scheme_define (sc, sc->global_env, symbol,
|
|
|
|
sc->vptr->mk_integer (sc, int_value));
|
|
|
|
sc->vptr->setimmutable (symbol);
|
2017-01-09 16:00:10 +01:00
|
|
|
|
2021-11-30 11:38:10 +01:00
|
|
|
g_free (scheme_name);
|
|
|
|
g_base_info_unref ((GIBaseInfo *) value_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ts_init_enums (scheme *sc,
|
|
|
|
GIRepository *repo,
|
|
|
|
const char *namespace)
|
|
|
|
{
|
|
|
|
int i, n_infos;
|
2017-01-09 16:00:10 +01:00
|
|
|
|
2021-11-30 11:38:10 +01:00
|
|
|
n_infos = g_irepository_get_n_infos (repo, namespace);
|
|
|
|
for (i = 0; i < n_infos; i++)
|
|
|
|
{
|
|
|
|
GIBaseInfo *info;
|
2017-01-09 16:00:10 +01:00
|
|
|
|
2021-11-30 11:38:10 +01:00
|
|
|
info = g_irepository_get_info (repo, namespace, i);
|
|
|
|
if (GI_IS_ENUM_INFO (info))
|
|
|
|
{
|
|
|
|
ts_init_enum (sc, (GIEnumInfo *) info, namespace);
|
2017-01-09 16:00:10 +01:00
|
|
|
}
|
|
|
|
|
2021-11-30 11:38:10 +01:00
|
|
|
g_base_info_unref (info);
|
|
|
|
}
|
2006-10-16 01:08:54 +00:00
|
|
|
}
|
2005-02-17 00:24:31 +00:00
|
|
|
|
2022-07-15 13:50:36 -04:00
|
|
|
/* Define a symbol into interpreter state,
|
|
|
|
* bound to a foreign function, language C, defined here in ScriptFu source.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ts_define_procedure (scheme *sc,
|
|
|
|
const gchar *symbol_name,
|
|
|
|
TsWrapperFunc func)
|
|
|
|
{
|
|
|
|
pointer symbol;
|
|
|
|
|
|
|
|
symbol = sc->vptr->mk_symbol (sc, symbol_name);
|
|
|
|
sc->vptr->scheme_define (sc, sc->global_env, symbol,
|
|
|
|
sc->vptr->mk_foreign_func (sc, func));
|
|
|
|
sc->vptr->setimmutable (symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Define, into interpreter state,
|
|
|
|
* 1) Scheme functions that call wrapper functions in C here in ScriptFu.
|
|
|
|
* 2) Scheme functions wrapping every procedure in the PDB.
|
|
|
|
*/
|
2006-10-16 01:08:54 +00:00
|
|
|
static void
|
2008-09-11 18:00:18 +00:00
|
|
|
ts_init_procedures (scheme *sc,
|
|
|
|
gboolean register_scripts)
|
2006-10-16 01:08:54 +00:00
|
|
|
{
|
2008-09-19 12:15:26 +00:00
|
|
|
gchar **proc_list;
|
|
|
|
gint num_procs;
|
|
|
|
gint i;
|
2006-10-16 01:08:54 +00:00
|
|
|
|
|
|
|
#if USE_DL
|
2022-07-15 13:50:36 -04:00
|
|
|
/* scm_load_ext not same as other wrappers, defined in tinyscheme/dynload */
|
|
|
|
ts_define_procedure (sc, "load-extension", scm_load_ext);
|
2006-10-16 01:08:54 +00:00
|
|
|
#endif
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2023-12-04 11:23:01 -05:00
|
|
|
/* Define special functions used in scripts. */
|
2022-07-15 13:50:36 -04:00
|
|
|
if (register_scripts)
|
|
|
|
{
|
|
|
|
ts_define_procedure (sc, "script-fu-register", script_fu_register_call);
|
|
|
|
ts_define_procedure (sc, "script-fu-register-filter", script_fu_register_call_filter);
|
2024-09-27 05:44:07 -04:00
|
|
|
ts_define_procedure (sc, "script-fu-register-procedure", script_fu_register_call_procedure);
|
2022-07-15 13:50:36 -04:00
|
|
|
ts_define_procedure (sc, "script-fu-menu-register", script_fu_menu_register_call);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ts_define_procedure (sc, "script-fu-register", script_fu_nil_call);
|
|
|
|
ts_define_procedure (sc, "script-fu-register-filter", script_fu_nil_call);
|
2024-09-27 05:44:07 -04:00
|
|
|
ts_define_procedure (sc, "script-fu-register-procedure", script_fu_nil_call);
|
2022-07-15 13:50:36 -04:00
|
|
|
ts_define_procedure (sc, "script-fu-menu-register", script_fu_nil_call);
|
|
|
|
}
|
plug-ins: in script-fu, don't query PDB procedures' info on startup
script-fu used to query the information of every PDB procedure on
startup, in order to get the number of parameters for each
procedure. This was done so that nullary procedures were defined
in such a way as to accept (and ignore) any number of arguments
(and at least one of the scripts we ship relies on this behavior).
However, this requires expensive back-and-forth communication with
the main GIMP process, which notable slowed down script-fu's
startup, and had a non-negligible impact on GIMP's startup time.
Instead, avoid querying procedure information, and implement the
special behavior for nullary procedures at call time. We do this
by defining, in addition to the "strict" gimp-proc-db-call
procedure, a "permissive" -gimp-proc-db-call internal procedure,
and using the latter to call the predefined PDB procedures.
2018-09-26 14:28:34 -04:00
|
|
|
|
2023-12-04 11:23:01 -05:00
|
|
|
ts_define_procedure (sc, "script-fu-use-v3", script_fu_use_v3_call);
|
|
|
|
ts_define_procedure (sc, "script-fu-use-v2", script_fu_use_v2_call);
|
2022-07-15 13:50:36 -04:00
|
|
|
ts_define_procedure (sc, "script-fu-quit", script_fu_quit_call);
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2023-12-04 11:23:01 -05:00
|
|
|
/* Define wrapper functions, not used in scripts.
|
|
|
|
* FUTURE: eliminate all but one, deprecated and permissive is obsolete.
|
|
|
|
*/
|
2022-07-15 13:50:36 -04:00
|
|
|
ts_define_procedure (sc, "gimp-proc-db-call", script_fu_marshal_procedure_call_strict);
|
|
|
|
ts_define_procedure (sc, "-gimp-proc-db-call", script_fu_marshal_procedure_call_permissive);
|
|
|
|
ts_define_procedure (sc, "--gimp-proc-db-call", script_fu_marshal_procedure_call_deprecated);
|
2021-01-28 09:08:39 -05:00
|
|
|
|
2025-02-25 23:04:00 +01:00
|
|
|
ts_define_procedure (sc, "gimp-pdb-procedure-exists", script_fu_marshal_procedure_exists);
|
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
ts_define_procedure (sc, "gimp-drawable-filter-configure", script_fu_marshal_drawable_filter_configure_call);
|
2024-12-16 23:32:02 +01:00
|
|
|
ts_define_procedure (sc, "gimp-drawable-filter-set-aux-input", script_fu_marshal_drawable_filter_set_aux_call);
|
2024-12-16 23:11:06 +01:00
|
|
|
ts_define_procedure (sc, "gimp-drawable-merge-filter", script_fu_marshal_drawable_merge_filter_call);
|
|
|
|
ts_define_procedure (sc, "gimp-drawable-append-filter", script_fu_marshal_drawable_append_filter_call);
|
|
|
|
ts_define_procedure (sc, "gimp-drawable-merge-new-filter", script_fu_marshal_drawable_merge_new_filter_call);
|
|
|
|
ts_define_procedure (sc, "gimp-drawable-append-new-filter", script_fu_marshal_drawable_append_new_filter_call);
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2023-12-04 11:23:01 -05:00
|
|
|
/* Define each PDB procedure as a scheme func.
|
|
|
|
* Each call passes through one of the wrapper funcs.
|
|
|
|
*/
|
2019-08-12 20:11:45 +02:00
|
|
|
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
|
|
|
|
".*", ".*", ".*", ".*",
|
2020-12-23 21:15:43 +01:00
|
|
|
".*", ".*", ".*", ".*");
|
|
|
|
num_procs = proc_list ? g_strv_length (proc_list) : 0;
|
2006-10-16 01:08:54 +00:00
|
|
|
|
|
|
|
for (i = 0; i < num_procs; i++)
|
2006-11-09 23:03:55 +00:00
|
|
|
{
|
plug-ins: in script-fu, don't query PDB procedures' info on startup
script-fu used to query the information of every PDB procedure on
startup, in order to get the number of parameters for each
procedure. This was done so that nullary procedures were defined
in such a way as to accept (and ignore) any number of arguments
(and at least one of the scripts we ship relies on this behavior).
However, this requires expensive back-and-forth communication with
the main GIMP process, which notable slowed down script-fu's
startup, and had a non-negligible impact on GIMP's startup time.
Instead, avoid querying procedure information, and implement the
special behavior for nullary procedures at call time. We do this
by defining, in addition to the "strict" gimp-proc-db-call
procedure, a "permissive" -gimp-proc-db-call internal procedure,
and using the latter to call the predefined PDB procedures.
2018-09-26 14:28:34 -04:00
|
|
|
gchar *buff;
|
|
|
|
|
|
|
|
/* Build a define that will call the foreign function.
|
|
|
|
* The Scheme statement was suggested by Simon Budig.
|
|
|
|
*
|
2021-01-28 08:31:11 -05:00
|
|
|
* Call the procedure through -gimp-proc-db-call, which is a more
|
plug-ins: in script-fu, don't query PDB procedures' info on startup
script-fu used to query the information of every PDB procedure on
startup, in order to get the number of parameters for each
procedure. This was done so that nullary procedures were defined
in such a way as to accept (and ignore) any number of arguments
(and at least one of the scripts we ship relies on this behavior).
However, this requires expensive back-and-forth communication with
the main GIMP process, which notable slowed down script-fu's
startup, and had a non-negligible impact on GIMP's startup time.
Instead, avoid querying procedure information, and implement the
special behavior for nullary procedures at call time. We do this
by defining, in addition to the "strict" gimp-proc-db-call
procedure, a "permissive" -gimp-proc-db-call internal procedure,
and using the latter to call the predefined PDB procedures.
2018-09-26 14:28:34 -04:00
|
|
|
* permissive version of gimp-proc-db-call, that accepts (and ignores)
|
|
|
|
* any number of arguments for nullary procedures, for backward
|
|
|
|
* compatibility.
|
|
|
|
*/
|
|
|
|
buff = g_strdup_printf (" (define (%s . args)"
|
|
|
|
" (apply -gimp-proc-db-call \"%s\" args))",
|
|
|
|
proc_list[i], proc_list[i]);
|
2008-09-11 18:00:18 +00:00
|
|
|
|
plug-ins: in script-fu, don't query PDB procedures' info on startup
script-fu used to query the information of every PDB procedure on
startup, in order to get the number of parameters for each
procedure. This was done so that nullary procedures were defined
in such a way as to accept (and ignore) any number of arguments
(and at least one of the scripts we ship relies on this behavior).
However, this requires expensive back-and-forth communication with
the main GIMP process, which notable slowed down script-fu's
startup, and had a non-negligible impact on GIMP's startup time.
Instead, avoid querying procedure information, and implement the
special behavior for nullary procedures at call time. We do this
by defining, in addition to the "strict" gimp-proc-db-call
procedure, a "permissive" -gimp-proc-db-call internal procedure,
and using the latter to call the predefined PDB procedures.
2018-09-26 14:28:34 -04:00
|
|
|
/* Execute the 'define' */
|
|
|
|
sc->vptr->load_string (sc, buff);
|
2008-09-11 18:00:18 +00:00
|
|
|
|
plug-ins: in script-fu, don't query PDB procedures' info on startup
script-fu used to query the information of every PDB procedure on
startup, in order to get the number of parameters for each
procedure. This was done so that nullary procedures were defined
in such a way as to accept (and ignore) any number of arguments
(and at least one of the scripts we ship relies on this behavior).
However, this requires expensive back-and-forth communication with
the main GIMP process, which notable slowed down script-fu's
startup, and had a non-negligible impact on GIMP's startup time.
Instead, avoid querying procedure information, and implement the
special behavior for nullary procedures at call time. We do this
by defining, in addition to the "strict" gimp-proc-db-call
procedure, a "permissive" -gimp-proc-db-call internal procedure,
and using the latter to call the predefined PDB procedures.
2018-09-26 14:28:34 -04:00
|
|
|
g_free (buff);
|
2006-11-09 23:03:55 +00:00
|
|
|
}
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2012-11-27 21:16:26 +01:00
|
|
|
g_strfreev (proc_list);
|
2021-01-28 09:08:39 -05:00
|
|
|
|
|
|
|
/* Register more scheme funcs that call PDB procedures, for compatibility
|
|
|
|
* This can overwrite earlier scheme func definitions.
|
|
|
|
*/
|
|
|
|
define_compat_procs (sc);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
}
|
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
/* Load script defining much of Scheme in Scheme language.
|
|
|
|
* This hides the actual name.
|
2024-10-24 06:35:50 -04:00
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
* By convention in Scheme, the name is init.scm.
|
2024-10-24 06:35:50 -04:00
|
|
|
* Other Schemes use a same named file for the same purpose.
|
|
|
|
* The contents are more or less same as upstream TinyScheme.
|
|
|
|
* The contents only define a Lisp dialect,
|
|
|
|
* and not ScriptFu's additional bindings to the PDB.
|
2024-10-23 13:15:38 -04:00
|
|
|
*
|
|
|
|
* Returns TRUE on successful load.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
ts_load_main_init_script (gchar *dir)
|
|
|
|
{
|
2024-10-24 06:35:50 -04:00
|
|
|
return ts_load_file (dir, "init.scm");
|
2024-10-23 13:15:38 -04:00
|
|
|
}
|
|
|
|
|
2024-10-24 06:06:13 -04:00
|
|
|
/* Load certain Scheme init scripts from certain directories.
|
|
|
|
* Loads from two directories, user and sys, in that order.
|
|
|
|
* Only loads from directories named "scriptfu-init.""
|
|
|
|
* Only loads a small set of named files, not all .scm files in the directory.
|
|
|
|
* Only loads the first set of init scripts found,
|
|
|
|
* from the first directory where the main init script is found.
|
|
|
|
* Does not recursively descend into the directories.
|
|
|
|
*
|
|
|
|
* We recommend a user not shadow the sys init scripts,
|
|
|
|
* especially the main one: init.scm.
|
|
|
|
* Should not shadow in the user init script directory,
|
|
|
|
* or in any other script directory.
|
|
|
|
*/
|
2024-10-22 17:40:41 -04:00
|
|
|
static void
|
|
|
|
ts_load_init_and_compatibility_scripts (GList *paths)
|
|
|
|
{
|
|
|
|
gboolean did_find_main_init_script = FALSE;
|
|
|
|
|
|
|
|
g_debug ("%s", G_STRFUNC);
|
|
|
|
|
|
|
|
if (paths == NULL)
|
|
|
|
{
|
2024-10-23 13:15:38 -04:00
|
|
|
g_warning ("%s Missing paths.", G_STRFUNC);
|
2024-10-22 17:40:41 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-10-24 06:06:13 -04:00
|
|
|
/* paths is a list of dirs known by ScriptFu, user specific and system wide.
|
2024-10-23 13:15:38 -04:00
|
|
|
* The order is important, and this first searches user specific directories.
|
2024-10-22 17:40:41 -04:00
|
|
|
*/
|
|
|
|
for (GList *list = paths; list; list = g_list_next (list))
|
|
|
|
{
|
2024-10-24 06:06:13 -04:00
|
|
|
/* Load from a designated init subdirectory.
|
|
|
|
* Subsequent loading of ordinary scripts skips this subdir.
|
|
|
|
*/
|
|
|
|
gchar *dir = script_fu_get_init_subdirectory (list->data);
|
2024-10-22 17:40:41 -04:00
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
if (ts_load_main_init_script (dir))
|
2024-10-22 17:40:41 -04:00
|
|
|
{
|
|
|
|
did_find_main_init_script = TRUE;
|
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
/* Load small set of named other init scripts.
|
|
|
|
* Only from same dir as the main init script!
|
|
|
|
*
|
|
|
|
* We don't warn when they are missing.
|
|
|
|
*/
|
2024-10-22 17:40:41 -04:00
|
|
|
|
|
|
|
/* Improve compatibility with older Script-Fu scripts,
|
|
|
|
* load definitions for old dialects of Lisp (SIOD) or older ScriptFu.
|
|
|
|
*/
|
2024-10-24 06:35:50 -04:00
|
|
|
(void) ts_load_file (dir, "script-fu-compat.scm");
|
2024-10-22 17:40:41 -04:00
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
/* Improve compatibility with older GIMP version,
|
|
|
|
* load definitions that alias/adapt older PDB procedures or plugins.
|
2024-10-22 17:40:41 -04:00
|
|
|
*/
|
2024-10-24 06:35:50 -04:00
|
|
|
(void) ts_load_file (dir, "plug-in-compat.scm");
|
2024-10-22 17:40:41 -04:00
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
/* !!! Only load init scripts from the first dir found. */
|
2024-10-22 17:40:41 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
}
|
|
|
|
|
2024-10-23 13:15:38 -04:00
|
|
|
if (! did_find_main_init_script)
|
2024-10-22 17:40:41 -04:00
|
|
|
{
|
2024-10-23 13:15:38 -04:00
|
|
|
/* Continue, but the interpreter will be crippled. */
|
|
|
|
g_warning ("Failed to load main initialization file");
|
2024-10-22 17:40:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-19 08:17:28 +00:00
|
|
|
static gboolean
|
|
|
|
ts_load_file (const gchar *dirname,
|
|
|
|
const gchar *basename)
|
|
|
|
{
|
|
|
|
gchar *filename;
|
|
|
|
FILE *fin;
|
|
|
|
|
|
|
|
filename = g_build_filename (dirname, basename, NULL);
|
|
|
|
|
|
|
|
fin = g_fopen (filename, "rb");
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
if (fin)
|
|
|
|
{
|
|
|
|
scheme_load_file (&sc, fin);
|
|
|
|
fclose (fin);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2025-01-08 12:03:08 -05:00
|
|
|
/* Returns pointer to sc->NIL (normal) or pointer to error. */
|
2006-10-16 01:08:54 +00:00
|
|
|
static pointer
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
script_fu_marshal_arg_to_value (scheme *sc,
|
|
|
|
pointer a,
|
|
|
|
const gchar *proc_name,
|
|
|
|
gint arg_index,
|
|
|
|
GParamSpec *arg_spec,
|
|
|
|
GValue *value,
|
|
|
|
gchar **strvalue)
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
pointer arg_val;
|
|
|
|
pointer vector;
|
|
|
|
guint n_elements;
|
|
|
|
gint j;
|
|
|
|
gchar error_str[1024];
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
if (sc->vptr->is_pair (a))
|
2024-12-13 21:31:53 +01:00
|
|
|
arg_val = sc->vptr->pair_car (a);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
else
|
2024-12-13 21:31:53 +01:00
|
|
|
arg_val = a;
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (G_VALUE_HOLDS_INT (value))
|
2004-10-04 22:00:16 +00:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
if (! sc->vptr->is_number (arg_val))
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GParamSpecInt *ispec = G_PARAM_SPEC_INT (arg_spec);
|
|
|
|
gint v = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
2021-04-30 13:51:04 -04:00
|
|
|
|
2025-06-06 20:15:07 +00:00
|
|
|
if (! (arg_spec->flags & GIMP_PARAM_NO_VALIDATE) &&
|
|
|
|
(v < ispec->minimum || v > ispec->maximum))
|
|
|
|
return script_int_range_error (sc, arg_index, proc_name,
|
|
|
|
ispec->minimum, ispec->maximum, v);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_int (value, v);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", v);
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_UINT (value))
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2021-04-30 13:51:04 -04:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
2021-04-30 13:51:04 -04:00
|
|
|
}
|
|
|
|
else
|
2004-04-08 16:05:27 +00:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
GParamSpecUInt *ispec = G_PARAM_SPEC_UINT (arg_spec);
|
|
|
|
gint v = sc->vptr->ivalue (arg_val);
|
2023-10-21 02:42:33 +02:00
|
|
|
|
2025-06-06 20:15:07 +00:00
|
|
|
if (! (arg_spec->flags & GIMP_PARAM_NO_VALIDATE) &&
|
|
|
|
(v < ispec->minimum || v > ispec->maximum))
|
|
|
|
return script_int_range_error (sc, arg_index, proc_name,
|
|
|
|
ispec->minimum, ispec->maximum, v);
|
2023-10-21 02:42:33 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_uint (value, v);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%u", v);
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_UCHAR (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
2019-09-17 21:42:10 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
2019-09-17 21:42:10 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
GParamSpecUChar *cspec = G_PARAM_SPEC_UCHAR (arg_spec);
|
|
|
|
gint c = sc->vptr->ivalue (arg_val);
|
2023-10-21 02:42:33 +02:00
|
|
|
|
2025-06-06 20:15:07 +00:00
|
|
|
if (! (arg_spec->flags & GIMP_PARAM_NO_VALIDATE) &&
|
|
|
|
(c < cspec->minimum || c > cspec->maximum))
|
|
|
|
return script_int_range_error (sc, arg_index, proc_name,
|
|
|
|
cspec->minimum, cspec->maximum, c);
|
2023-10-21 02:42:33 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_uchar (value, c);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", c);
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_DOUBLE (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (arg_spec);
|
|
|
|
gdouble d = sc->vptr->rvalue (arg_val);
|
2023-10-21 02:42:33 +02:00
|
|
|
|
2025-06-06 20:15:07 +00:00
|
|
|
if (! (arg_spec->flags & GIMP_PARAM_NO_VALIDATE) &&
|
|
|
|
(d < dspec->minimum || d > dspec->maximum))
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_float_range_error (sc, arg_index, proc_name, dspec->minimum, dspec->maximum, d);
|
2023-10-21 02:42:33 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_double (value, d);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%f", d);
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_ENUM (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
{
|
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
{
|
|
|
|
gint e = sc->vptr->ivalue (arg_val);
|
|
|
|
|
|
|
|
g_value_set_enum (value, e);
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", e);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_BOOLEAN (value))
|
|
|
|
{
|
|
|
|
if (sc->vptr->is_number (arg_val))
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
gboolean b = sc->vptr->ivalue (arg_val);
|
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
/* Bind according to C idiom: 0 is false, other numeric values true.
|
|
|
|
* This is not strict Scheme: 0 is truthy in Scheme.
|
|
|
|
* This lets FALSE still work, where FALSE is a deprecated symbol for 0.
|
|
|
|
*/
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
g_value_set_boolean (value, b);
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%s", b ? "TRUE" : "FALSE");
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
if (is_interpret_v3_dialect ())
|
2023-12-04 11:23:01 -05:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
/* Use Scheme semantics: anything but #f is true.
|
|
|
|
* This allows Scheme expressions yielding any Scheme type.
|
|
|
|
*/
|
|
|
|
/* is_false is not exported from scheme.c (but should be.)
|
|
|
|
* This is the same code: compare Scheme pointers.
|
2023-12-04 11:23:01 -05:00
|
|
|
*/
|
2024-12-13 21:31:53 +01:00
|
|
|
gboolean truth_value = ! (arg_val == sc->F);
|
|
|
|
g_value_set_boolean (value, truth_value);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%s", truth_value ? "TRUE" : "FALSE");
|
2023-12-04 11:23:01 -05:00
|
|
|
}
|
2021-01-28 08:31:11 -05:00
|
|
|
else
|
2023-12-04 11:23:01 -05:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
/* v2 */
|
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
2023-12-04 11:23:01 -05:00
|
|
|
}
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_STRING (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_string (arg_val))
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
{
|
|
|
|
return script_type_error (sc, "string", arg_index, proc_name);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
{
|
|
|
|
const gchar *s = sc->vptr->string_value (arg_val);
|
|
|
|
|
|
|
|
g_value_set_string (value, s);
|
|
|
|
if (strvalue)
|
|
|
|
{
|
|
|
|
gchar *escaped = g_strescape (s, NULL);
|
|
|
|
*strvalue = g_strdup_printf ("\"%s\"", escaped);
|
|
|
|
g_free (escaped);
|
|
|
|
}
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
|
|
|
|
{
|
|
|
|
vector = arg_val; /* vector is pointing to a list */
|
|
|
|
if (! sc->vptr->is_list (sc, vector))
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "vector", arg_index, proc_name);
|
2019-09-04 10:28:50 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
2020-12-23 21:15:43 +01:00
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
gchar **array;
|
|
|
|
GString *v = NULL;
|
2020-12-23 21:15:43 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
n_elements = sc->vptr->list_length (sc, vector);
|
2020-12-23 21:15:43 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
array = g_new0 (gchar *, n_elements + 1);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
v = g_string_new ("");
|
2020-12-23 21:15:43 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
for (j = 0; j < n_elements; j++)
|
|
|
|
{
|
|
|
|
pointer v_element = sc->vptr->pair_car (vector);
|
2020-12-23 21:15:43 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (!sc->vptr->is_string (v_element))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Item %d in vector is not a string (argument %d for function %s)",
|
|
|
|
j+1, arg_index+1, proc_name);
|
|
|
|
g_strfreev (array);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_free (v, TRUE);
|
2024-12-13 21:31:53 +01:00
|
|
|
return foreign_error (sc, error_str, vector);
|
|
|
|
}
|
2020-12-23 21:15:43 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
array[j] = g_strdup (sc->vptr->string_value (v_element));
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
gchar *escaped = g_strescape (array[j], NULL);
|
|
|
|
g_string_append_printf (v, "%s\"%s\"", j == 0 ? "" : " ", escaped);
|
|
|
|
g_free (escaped);
|
|
|
|
}
|
2020-12-23 21:15:43 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
vector = sc->vptr->pair_cdr (vector);
|
|
|
|
}
|
2020-12-23 21:15:43 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_take_boxed (value, array);
|
2020-12-23 21:15:43 +01:00
|
|
|
|
|
|
|
#if DEBUG_MARSHALL
|
2024-12-13 21:31:53 +01:00
|
|
|
{
|
|
|
|
glong count = sc->vptr->list_length ( sc, arg_val );
|
|
|
|
g_printerr (" string vector has %ld elements\n", count);
|
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
g_printerr (" ");
|
|
|
|
for (j = 0; j < count; ++j)
|
|
|
|
g_printerr (" \"%s\"", array[j]);
|
|
|
|
g_printerr ("\n");
|
|
|
|
}
|
2020-12-23 21:15:43 +01:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
#endif
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
*strvalue = g_strdup_printf ("#(%s)", v->str);
|
|
|
|
g_string_free (v, TRUE);
|
|
|
|
}
|
2020-12-23 21:15:43 +01:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_DISPLAY (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-09-04 10:28:50 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
2019-09-04 10:28:50 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
2019-09-04 10:28:50 +02:00
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GimpDisplay *display;
|
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
|
|
|
|
|
|
|
display = gimp_display_get_by_id (id);
|
2019-09-04 10:28:50 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_object (value, display);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2019-09-04 10:28:50 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_IMAGE (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-09-04 10:28:50 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GimpImage *image;
|
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
|
|
|
|
|
|
|
image = gimp_image_get_by_id (id);
|
2019-09-04 10:28:50 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_object (value, image);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2019-09-17 21:42:10 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_LAYER (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-09-17 21:42:10 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GimpLayer *layer;
|
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
|
|
|
|
|
|
|
layer = gimp_layer_get_by_id (id);
|
2019-09-17 21:42:10 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_object (value, layer);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2019-09-04 10:28:50 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_LAYER_MASK (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-09-04 10:28:50 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GimpLayerMask *layer_mask;
|
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
|
|
|
|
|
|
|
layer_mask = gimp_layer_mask_get_by_id (id);
|
2019-09-04 10:28:50 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_object (value, layer_mask);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2019-09-04 10:28:50 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_CHANNEL (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-09-04 10:28:50 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GimpChannel *channel;
|
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
|
|
|
|
|
|
|
channel = gimp_channel_get_by_id (id);
|
2019-09-04 10:28:50 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_object (value, channel);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2019-09-04 10:28:50 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_DRAWABLE (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-09-04 10:28:50 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
2019-09-04 10:28:50 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
pointer error = marshal_ID_to_item (sc, a, id, value);
|
|
|
|
if (error)
|
|
|
|
return error;
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2019-09-17 21:42:10 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_PATH (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
2019-09-17 21:42:10 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GimpPath *path;
|
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
|
|
|
|
|
|
|
path = gimp_path_get_by_id (id);
|
2019-09-17 21:42:10 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_object (value, path);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_ITEM (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
2024-12-13 21:31:53 +01:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (gimp_item_id_is_valid (id))
|
2024-10-24 22:18:20 +02:00
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GimpItem *item = gimp_item_get_by_id (id);
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_object (value, item);
|
2024-10-24 22:18:20 +02:00
|
|
|
}
|
2021-01-28 08:31:11 -05:00
|
|
|
else
|
2004-04-08 16:05:27 +00:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
/* item ID is invalid.
|
|
|
|
* Usually 0 or -1, passed for a nullable arg.
|
2021-01-28 08:31:11 -05:00
|
|
|
*/
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_object (value, NULL);
|
2006-11-09 23:03:55 +00:00
|
|
|
}
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
2024-12-14 14:42:37 +01:00
|
|
|
else if (GIMP_VALUE_HOLDS_DRAWABLE_FILTER (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
2024-12-14 14:42:37 +01:00
|
|
|
|
|
|
|
if (gimp_drawable_filter_id_is_valid (id))
|
|
|
|
{
|
|
|
|
GimpDrawableFilter *filter = gimp_drawable_filter_get_by_id (id);
|
|
|
|
|
|
|
|
g_value_set_object (value, filter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Filter ID is invalid.
|
|
|
|
* Usually 0 or -1, passed for a nullable arg.
|
|
|
|
*/
|
|
|
|
g_value_set_object (value, NULL);
|
|
|
|
}
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
2025-02-17 18:51:57 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_UNIT (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_number (arg_val))
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "numeric", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpUnit *unit;
|
|
|
|
gint id = sc->vptr->ivalue (arg_val);
|
|
|
|
|
|
|
|
unit = gimp_unit_get_by_id (id);
|
|
|
|
|
|
|
|
g_value_set_object (value, unit);
|
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", id);
|
2024-12-14 14:42:37 +01:00
|
|
|
}
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else if (GIMP_VALUE_HOLDS_INT32_ARRAY (value))
|
|
|
|
{
|
|
|
|
vector = arg_val;
|
|
|
|
if (! sc->vptr->is_vector (vector))
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "vector", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* !!! Comments applying to all array args.
|
|
|
|
* n_elements is expected list length, from previous argument.
|
|
|
|
* A PDB procedure takes args paired: ...length, array...
|
|
|
|
* and a script passes the same paired args (..., 1, '("foo"))
|
|
|
|
* (FUTURE: a more object oriented design for the PDB API
|
|
|
|
* would obviate need for this discussion.)
|
|
|
|
*
|
|
|
|
* When a script passes a shorter or empty list,
|
|
|
|
* ensure we don't segfault on cdr past end of list.
|
|
|
|
*
|
|
|
|
* n_elements is unsigned, we don't need to check >= 0
|
|
|
|
*
|
|
|
|
* Since we are not checking for equality of passed length
|
|
|
|
* to actual container length, we adapt an array
|
|
|
|
* that is shorter than specified by the length arg.
|
|
|
|
* Ignoring a discrepancy by the script author.
|
|
|
|
* FUTURE: List must be *exactly* n_elements long.
|
|
|
|
* n_elements != sc->vptr->list_length (sc, vector))
|
|
|
|
*/
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
gint32 *array;
|
|
|
|
GString *v = NULL;
|
2019-08-12 20:11:45 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
n_elements = sc->vptr->vector_length (vector);
|
|
|
|
array = g_new0 (gint32, n_elements);
|
2004-10-04 22:00:16 +00:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
v = g_string_new ("");
|
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
for (j = 0; j < n_elements; j++)
|
|
|
|
{
|
|
|
|
pointer v_element = sc->vptr->vector_elem (vector, j);
|
2006-11-09 23:03:55 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
/* FIXME: Check values in vector stay within range for each type. */
|
|
|
|
if (! sc->vptr->is_number (v_element))
|
2006-11-09 23:03:55 +00:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
g_free (array);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_free (v, TRUE);
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error_in_container (sc, "numeric", arg_index, j, proc_name, vector);
|
2006-11-09 23:03:55 +00:00
|
|
|
}
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
array[j] = (gint32) sc->vptr->ivalue (v_element);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_append_printf (v, "%s%d", j == 0 ? "" : " ", array[j]);
|
2006-11-09 23:03:55 +00:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
gimp_value_take_int32_array (value, array, n_elements);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
*strvalue = g_strdup_printf ("#(%s)", v->str);
|
|
|
|
g_string_free (v, TRUE);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
debug_vector (sc, vector, "%ld");
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS (value, G_TYPE_BYTES))
|
|
|
|
{
|
|
|
|
vector = arg_val;
|
|
|
|
if (! sc->vptr->is_vector (vector))
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "vector", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
guint8 *array;
|
|
|
|
GString *v = NULL;
|
2019-08-12 20:11:45 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
n_elements = sc->vptr->vector_length (vector);
|
2006-11-09 23:03:55 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
array = g_new0 (guint8, n_elements);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
v = g_string_new ("");
|
2006-11-09 23:03:55 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
for (j = 0; j < n_elements; j++)
|
|
|
|
{
|
|
|
|
pointer v_element = sc->vptr->vector_elem (vector, j);
|
2006-11-09 23:03:55 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (!sc->vptr->is_number (v_element))
|
|
|
|
{
|
|
|
|
g_free (array);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_free (v, TRUE);
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error_in_container (sc, "numeric", arg_index, j, proc_name, vector);
|
2006-11-09 23:03:55 +00:00
|
|
|
}
|
2006-10-16 01:08:54 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
array[j] = (guint8) sc->vptr->ivalue (v_element);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_append_printf (v, "%s%d", j == 0 ? "" : " ", array[j]);
|
2006-11-09 23:03:55 +00:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
g_value_take_boxed (value, g_bytes_new_take (array, n_elements));
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
*strvalue = g_strdup_printf ("#(%s)", v->str);
|
|
|
|
g_string_free (v, TRUE);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
debug_vector (sc, vector, "%ld");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_DOUBLE_ARRAY (value))
|
|
|
|
{
|
|
|
|
vector = arg_val;
|
|
|
|
if (! sc->vptr->is_vector (vector))
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "vector", arg_index, proc_name);
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
2024-02-13 21:47:50 +01:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
gdouble *array;
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GString *v = NULL;
|
2024-02-13 21:47:50 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
n_elements = sc->vptr->vector_length (vector);
|
|
|
|
array = g_new0 (gdouble, n_elements);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
v = g_string_new ("");
|
2024-02-13 21:47:50 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
for (j = 0; j < n_elements; j++)
|
2024-02-13 21:47:50 +01:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
pointer v_element = sc->vptr->vector_elem (vector, j);
|
2024-02-13 21:47:50 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (!sc->vptr->is_number (v_element))
|
|
|
|
{
|
|
|
|
g_free (array);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_free (v, TRUE);
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error_in_container (sc, "numeric", arg_index, j, proc_name, vector);
|
|
|
|
}
|
|
|
|
|
|
|
|
array[j] = (gdouble) sc->vptr->rvalue (v_element);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_append_printf (v, "%s%f", j == 0 ? "" : " ", array[j]);
|
2024-02-13 21:47:50 +01:00
|
|
|
}
|
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
gimp_value_take_double_array (value, array, n_elements);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
*strvalue = g_strdup_printf ("#(%s)", v->str);
|
|
|
|
g_string_free (v, TRUE);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
debug_vector (sc, vector, "%f");
|
2024-02-13 21:47:50 +01:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_COLOR (value))
|
|
|
|
{
|
|
|
|
GeglColor *color = NULL;
|
|
|
|
|
|
|
|
if (sc->vptr->is_string (arg_val))
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
gchar *color_string = sc->vptr->string_value (arg_val);
|
2019-08-12 20:11:45 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (! (color = sf_color_get_color_from_name (color_string)))
|
|
|
|
return script_type_error (sc, "color string", arg_index, proc_name);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("\"%s\"", color_string);
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (sc->vptr->is_list (sc, arg_val))
|
|
|
|
{
|
|
|
|
pointer color_list = arg_val;
|
libgimp: PDB procedure arguments are not order-based anymore (API-wise).
As far as plug-in API is concerned, at least the calling API, order of arguments
when calling PDB procedures doesn't matter anymore.
Order still matters for creating procedures with standard arguments (for
instance, "run-mode" is first, then image, or file, drawables or whatnot,
depending on the subtype of procedure), but not for calling with libgimp.
Concretely in this commit:
- gimp_pdb_run_procedure_argv() was removed as it's intrinsically order-based.
- gimp_pdb_run_procedure() and gimp_pdb_run_procedure_valist() stay but their
semantic changes. Instead of an ordered list of (type, value) couple, it's now
an unordered list of (name, type, value) triplets. This way, you can also
ignore as many args as you want if you intend to keep them default. For
instance, say you have a procedure with 20 args and you only want to change
the last one and keep the 19 first with default values: while you used to have
to write down all 20 args annoyingly, now you can just list the only arg you
care about.
There are 2 important consequences here:
1. Calling PDB procedures becomes much more semantic, which means scripts with
PDB calls are simpler (smaller list of arguments) and easier to read (when
you had 5 int arguments in a row, you couldn't know what they refer to,
except by always checking the PDB source; now you'll have associated names,
such as "width", "height" and so on) hence maintain.
2. We will have the ability to add arguments and even order the new arguments in
middle of existing arguments without breaking compatibility. The only thing
which will matter will be that default values of new arguments will have to
behave like when the arg didn't exist. This way, existing scripts will not be
broken. This will avoid us having to always create variants of PDB procedure
(like original "file-bla-save", then variant "file-bla-save-2" and so on)
each time we add arguments.
Note: gimp_pdb_run_procedure_array() was not removed yet because it's currently
used by the PDB. To be followed.
2023-10-16 16:44:06 +02:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (! (color = marshal_component_list_to_color (sc, color_list, strvalue)))
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "color list of numeric components", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "color string or list", arg_index, proc_name);
|
|
|
|
}
|
2019-08-12 20:11:45 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
/* Transfer ownership. */
|
|
|
|
g_value_take_object (value, color);
|
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_COLOR_ARRAY (value))
|
|
|
|
{
|
|
|
|
vector = arg_val;
|
|
|
|
if (! sc->vptr->is_vector (vector))
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "vector", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GeglColor **colors;
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GString *v = NULL;
|
2008-07-14 14:09:16 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
n_elements = sc->vptr->vector_length (vector);
|
2008-07-14 14:09:16 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
colors = g_new0 (GeglColor *, n_elements + 1);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
v = g_string_new ("");
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
for (j = 0; j < n_elements; j++)
|
|
|
|
{
|
|
|
|
pointer v_element = sc->vptr->vector_elem (vector, j);
|
|
|
|
pointer color_list;
|
|
|
|
guchar rgb[3];
|
|
|
|
|
|
|
|
if (! (sc->vptr->is_list (sc,
|
|
|
|
sc->vptr->pair_car (v_element)) &&
|
|
|
|
sc->vptr->list_length (sc,
|
|
|
|
sc->vptr->pair_car (v_element)) == 3))
|
2008-07-14 14:09:16 +00:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
gimp_color_array_free (colors);
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Item %d in vector is not a color "
|
|
|
|
"(argument %d for function %s)",
|
|
|
|
j+1, arg_index+1, proc_name);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_free (v, TRUE);
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_error (sc, error_str, 0);
|
2008-07-14 14:09:16 +00:00
|
|
|
}
|
2019-08-12 20:11:45 +02:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
color_list = sc->vptr->pair_car (v_element);
|
|
|
|
rgb[0] = CLAMP (sc->vptr->ivalue (sc->vptr->pair_car (color_list)),
|
|
|
|
0, 255);
|
|
|
|
color_list = sc->vptr->pair_cdr (color_list);
|
|
|
|
rgb[1] = CLAMP (sc->vptr->ivalue (sc->vptr->pair_car (color_list)),
|
|
|
|
0, 255);
|
|
|
|
color_list = sc->vptr->pair_cdr (color_list);
|
|
|
|
rgb[2] = CLAMP (sc->vptr->ivalue (sc->vptr->pair_car (color_list)),
|
|
|
|
0, 255);
|
|
|
|
|
|
|
|
colors[j] = gegl_color_new (NULL);
|
|
|
|
gegl_color_set_pixel (colors[j], babl_format ("R'G'B' u8"), rgb);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
g_string_append_printf (v, " '(%d %d %d)", rgb[0], rgb[1], rgb[2]);
|
2008-07-14 14:09:16 +00:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
g_value_take_boxed (value, colors);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
*strvalue = g_strdup_printf ("#(%s)", v->str);
|
|
|
|
g_string_free (v, TRUE);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
g_debug ("color vector has %ld elements", sc->vptr->vector_length (vector));
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_PARASITE (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_list (sc, arg_val) ||
|
|
|
|
sc->vptr->list_length (sc, arg_val) != 3)
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "list", arg_index, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpParasite parasite;
|
|
|
|
pointer temp_val;
|
2008-09-19 12:15:26 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
/* parasite->name */
|
|
|
|
temp_val = arg_val;
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (! sc->vptr->is_string (sc->vptr->pair_car (temp_val)))
|
|
|
|
return script_type_error_in_container (sc, "string", arg_index, 0, proc_name, 0);
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
parasite.name =
|
|
|
|
sc->vptr->string_value (sc->vptr->pair_car (temp_val));
|
|
|
|
g_debug ("name '%s'", parasite.name);
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
/* parasite->flags */
|
|
|
|
temp_val = sc->vptr->pair_cdr (temp_val);
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (! sc->vptr->is_number (sc->vptr->pair_car (temp_val)))
|
|
|
|
return script_type_error_in_container (sc, "numeric", arg_index, 1, proc_name, 0);
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
parasite.flags =
|
|
|
|
sc->vptr->ivalue (sc->vptr->pair_car (temp_val));
|
|
|
|
g_debug ("flags %d", parasite.flags);
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
/* parasite->data */
|
|
|
|
temp_val = sc->vptr->pair_cdr (temp_val);
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (!sc->vptr->is_string (sc->vptr->pair_car (temp_val)))
|
|
|
|
return script_type_error_in_container (sc, "string", arg_index, 2, proc_name, 0);
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
parasite.data =
|
|
|
|
sc->vptr->string_value (sc->vptr->pair_car (temp_val));
|
|
|
|
parasite.size = strlen (parasite.data);
|
2008-09-19 12:15:26 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_debug ("size %d", parasite.size);
|
|
|
|
g_debug ("data '%s'", (char *)parasite.data);
|
2004-04-08 16:05:27 +00:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
g_value_set_boxed (value, ¶site);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
{
|
|
|
|
gchar *escaped_name = g_strescape (parasite.name, NULL);
|
|
|
|
gchar *escaped_data = g_strescape (parasite.data, NULL);
|
|
|
|
|
|
|
|
*strvalue = g_strdup_printf ("(\"%s\" %d \"%s\")",
|
|
|
|
escaped_name, parasite.flags, escaped_data);
|
|
|
|
g_free (escaped_name);
|
|
|
|
g_free (escaped_data);
|
|
|
|
}
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_CORE_OBJECT_ARRAY (value))
|
|
|
|
{
|
|
|
|
/* Now PDB procedures take arrays of Item (Drawable, Vectors, etc.).
|
|
|
|
* When future PDB procedures take arrays of Image, Display, Resource, etc.
|
|
|
|
* this will need changes.
|
|
|
|
*/
|
|
|
|
vector = arg_val;
|
2021-04-30 13:51:04 -04:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (sc->vptr->is_vector (vector))
|
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
pointer error = marshal_vector_to_item_array (sc, vector, value, strvalue);
|
2024-12-13 21:31:53 +01:00
|
|
|
if (error)
|
|
|
|
return error;
|
2021-04-30 13:51:04 -04:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
2021-04-30 13:51:04 -04:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "vector", arg_index, proc_name);
|
2021-04-30 13:51:04 -04:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_TYPE (value) == G_TYPE_FILE)
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_string (arg_val))
|
|
|
|
return script_type_error (sc, "string for path", arg_index, proc_name);
|
|
|
|
marshal_path_string_to_gfile (sc, a, value);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%s", sc->vptr->string_value (arg_val));
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (G_VALUE_TYPE (value) == GIMP_TYPE_PDB_STATUS_TYPE)
|
|
|
|
{
|
|
|
|
/* A PDB procedure signature wrongly requires a status. */
|
|
|
|
return implementation_error (sc,
|
|
|
|
"Status is for return types, not arguments",
|
|
|
|
arg_val);
|
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_RESOURCE (value))
|
|
|
|
{
|
|
|
|
if (! sc->vptr->is_integer (arg_val))
|
2019-08-12 20:11:45 +02:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_type_error (sc, "integer", arg_index, proc_name);
|
2019-08-12 20:11:45 +02:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else
|
2022-09-05 19:28:35 -04:00
|
|
|
{
|
2024-12-13 21:31:53 +01:00
|
|
|
/* Create new instance of a resource object. */
|
|
|
|
GimpResource *resource;
|
2023-09-09 06:57:37 -04:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
gint resource_id = sc->vptr->ivalue (arg_val);
|
|
|
|
/* Resource is abstract superclass. Concrete subclass is e.g. Brush.
|
|
|
|
* The gvalue holds arg_index.e. requires an instance of concrete subclass.
|
|
|
|
* ID's are unique across all instances of Resource.
|
|
|
|
*/
|
2022-09-05 19:28:35 -04:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (! gimp_resource_id_is_valid (resource_id))
|
|
|
|
{
|
|
|
|
/* Not the ID of any instance of Resource. */
|
|
|
|
return script_error (sc, "runtime: invalid resource ID", a);
|
2022-09-05 19:28:35 -04:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
resource = gimp_resource_get_by_id (resource_id);
|
|
|
|
if (! g_value_type_compatible (G_OBJECT_TYPE (resource), G_VALUE_TYPE (value)))
|
|
|
|
{
|
|
|
|
/* not the required subclass held by the gvalue */
|
|
|
|
return script_error (sc, "runtime: resource ID of improper subclass.", a);
|
|
|
|
}
|
|
|
|
g_value_set_object (value, resource);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", resource_id);
|
2022-09-05 19:28:35 -04:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else if (GIMP_VALUE_HOLDS_EXPORT_OPTIONS (value))
|
|
|
|
{
|
|
|
|
/* ExportOptions is work in progress.
|
|
|
|
* For now, you can't instantiate (no gimp_export_options_new())
|
|
|
|
* and a script must always pass the equivalent of NULL
|
|
|
|
* when calling PDB functions having formal arg type ExportOptions.
|
|
|
|
*
|
|
|
|
* TEMPORARY: eat the actual Scheme arg but bind to C NULL.
|
|
|
|
* FUTURE: (unlikely) ScriptFu plugins can use non-NULL export options.
|
|
|
|
* check Scheme type of actual arg, must be int ID
|
|
|
|
* create a GimpExportOptions (actually a proxy?)
|
|
|
|
*/
|
|
|
|
g_value_set_object (value, NULL);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (strvalue)
|
|
|
|
*strvalue = g_strdup_printf ("%d", -1);
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Argument %d for %s is unhandled type %s",
|
|
|
|
arg_index+1, proc_name, g_type_name (G_VALUE_TYPE (value)));
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sc->NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called by the Scheme interpreter on calls to GIMP PDB procedures */
|
|
|
|
static pointer
|
|
|
|
script_fu_marshal_procedure_call (scheme *sc,
|
|
|
|
pointer a,
|
|
|
|
gboolean permissive,
|
|
|
|
gboolean deprecated)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure;
|
|
|
|
GimpProcedureConfig *config;
|
|
|
|
GimpValueArray *values = NULL;
|
|
|
|
gchar *proc_name;
|
|
|
|
GParamSpec **arg_specs;
|
|
|
|
gint n_arg_specs;
|
|
|
|
gint actual_arg_count;
|
|
|
|
gint consumed_arg_count = 0;
|
|
|
|
gchar error_str[1024];
|
|
|
|
gint i;
|
|
|
|
pointer return_val = sc->NIL;
|
|
|
|
|
|
|
|
if (a == sc->NIL)
|
|
|
|
/* Some ScriptFu function is calling this incorrectly. */
|
|
|
|
return implementation_error (sc,
|
|
|
|
"Procedure argument marshaller was called with no arguments. "
|
|
|
|
"The procedure to be executed and the arguments it requires "
|
|
|
|
"(possibly none) must be specified.",
|
|
|
|
0);
|
|
|
|
|
|
|
|
/* The PDB procedure name is the argument or first argument of the list */
|
|
|
|
if (sc->vptr->is_pair (a))
|
|
|
|
proc_name = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a)));
|
|
|
|
else
|
|
|
|
proc_name = g_strdup (sc->vptr->string_value (a));
|
|
|
|
|
|
|
|
g_debug ("%s, proc name: %s, args rcvd: %d",
|
|
|
|
G_STRFUNC,
|
|
|
|
proc_name,
|
|
|
|
sc->vptr->list_length (sc, a)-1);
|
|
|
|
|
|
|
|
if (deprecated )
|
|
|
|
g_info ("PDB procedure name %s is deprecated, please use %s.",
|
|
|
|
deprecated_name_for (proc_name),
|
|
|
|
proc_name);
|
|
|
|
|
2025-02-26 15:13:55 +01:00
|
|
|
if (script_fu_report_progress ())
|
|
|
|
script_fu_progress_report (proc_name);
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
/* Attempt to fetch the procedure from the database */
|
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp_get_pdb (), proc_name);
|
|
|
|
|
|
|
|
if (! procedure)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid procedure name: %s", proc_name);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
config = gimp_procedure_create_config (procedure);
|
|
|
|
arg_specs = gimp_procedure_get_arguments (procedure, &n_arg_specs);
|
|
|
|
actual_arg_count = sc->vptr->list_length (sc, a) - 1;
|
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
/* Check the supplied number of arguments.
|
|
|
|
* This only gives messages to the console.
|
|
|
|
* It does not ensure that the count of supplied args equals the count of formal args.
|
|
|
|
* Subsequent code must not assume that.
|
|
|
|
*
|
|
|
|
* When too few supplied args, when permissive, scriptfu or downstream machinery
|
|
|
|
* can try to provide missing args e.g. defaults.
|
|
|
|
*
|
|
|
|
* Extra supplied args can be discarded.
|
|
|
|
* Formerly, this was a deprecated behavior depending on "permissive".
|
|
|
|
*/
|
2025-02-25 19:15:02 +01:00
|
|
|
if (gimp_procedure_is_internal (procedure))
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
{
|
|
|
|
if (actual_arg_count > n_arg_specs)
|
|
|
|
{
|
|
|
|
/* Permit extra args. Will discard args from script, to next right paren.*/
|
|
|
|
g_info ("in script, permitting too many args to %s", proc_name);
|
|
|
|
}
|
|
|
|
else if (actual_arg_count < n_arg_specs)
|
|
|
|
{
|
|
|
|
/* Permit too few args. The config carries a sane default for most types. */
|
|
|
|
g_info ("in script, permitting too few args to %s", proc_name);
|
|
|
|
}
|
|
|
|
/* else equal counts of args. */
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
|
|
|
/* Marshall the supplied arguments */
|
2025-02-25 19:15:02 +01:00
|
|
|
if (gimp_procedure_is_internal (procedure) ||
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
! sc->vptr->is_arg_name (sc->vptr->pair_car (a)))
|
2024-12-13 21:31:53 +01:00
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GString *deprecation_warning = NULL;
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2025-02-25 19:15:02 +01:00
|
|
|
if (! gimp_procedure_is_internal (procedure))
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
{
|
|
|
|
deprecation_warning = g_string_new ("Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.\n"
|
|
|
|
"Please use named arguments: (");
|
|
|
|
g_string_append (deprecation_warning, proc_name);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
for (i = 0; i < n_arg_specs; i++)
|
2024-08-28 08:13:11 -04:00
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GParamSpec *arg_spec = arg_specs[i];
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
gchar *strvalue = NULL;
|
2024-12-13 21:31:53 +01:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
consumed_arg_count++;
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2025-02-26 14:09:05 +01:00
|
|
|
if (gimp_procedure_is_internal (procedure) &&
|
|
|
|
sc->vptr->is_arg_name (sc->vptr->pair_car (a)))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Calling Internal PDB procedures with named arguments is not authorized.\n"
|
|
|
|
"Only use the named arguments syntax for Plug-In PDB procedures.");
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (consumed_arg_count > actual_arg_count)
|
|
|
|
{
|
|
|
|
/* Exhausted supplied arguments before formal specs. */
|
2024-12-13 21:31:53 +01:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
/* Say formal type of first missing arg. */
|
|
|
|
g_warning ("Missing arg type: %s", g_type_name (G_PARAM_SPEC_VALUE_TYPE (arg_spec)));
|
2024-12-13 21:31:53 +01:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
/* Break loop over formal specs. Continuation is to call PDB with partial args. */
|
|
|
|
break;
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (arg_spec));
|
2025-01-08 12:03:08 -05:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
debug_in_arg (sc, a, i, g_type_name (G_VALUE_TYPE (&value)));
|
|
|
|
|
|
|
|
return_val = script_fu_marshal_arg_to_value (sc, a, proc_name, i, arg_spec, &value, &strvalue);
|
|
|
|
|
|
|
|
if (return_val != sc->NIL)
|
|
|
|
{
|
|
|
|
g_value_unset (&value);
|
|
|
|
return return_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug_gvalue (&value);
|
2025-06-06 20:15:07 +00:00
|
|
|
if (! (arg_spec->flags & GIMP_PARAM_NO_VALIDATE) &&
|
|
|
|
g_param_value_validate (arg_spec, &value))
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
{
|
|
|
|
gchar error_message[1024];
|
|
|
|
|
|
|
|
g_snprintf (error_message, sizeof (error_message),
|
|
|
|
"Invalid value for argument %d",
|
|
|
|
i);
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
return script_error (sc, error_message, 0);
|
|
|
|
}
|
|
|
|
g_object_set_property (G_OBJECT (config), arg_specs[i]->name, &value);
|
2025-01-08 12:03:08 -05:00
|
|
|
g_value_unset (&value);
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
|
|
|
|
if (deprecation_warning != NULL)
|
|
|
|
g_string_append_printf (deprecation_warning, " #:%s %s",
|
|
|
|
arg_specs[i]->name, strvalue);
|
|
|
|
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
|
|
|
|
g_free (strvalue);
|
2025-01-08 12:03:08 -05:00
|
|
|
}
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
if (deprecation_warning != NULL)
|
|
|
|
{
|
|
|
|
g_string_append (deprecation_warning, ")");
|
|
|
|
g_warning ("%s", deprecation_warning->str);
|
2024-12-13 21:31:53 +01:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
g_string_free (deprecation_warning, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < actual_arg_count; i++)
|
2023-10-21 02:42:33 +02:00
|
|
|
{
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
GParamSpec *arg_spec;
|
|
|
|
gchar *arg_name;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
if (! sc->vptr->is_arg_name (sc->vptr->pair_car (a)))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Expected argument name for argument %d", i);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
arg_name = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a)));
|
2023-10-21 02:42:33 +02:00
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
arg_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (config), arg_name);
|
|
|
|
if (arg_spec == NULL)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid argument name: %s", arg_name);
|
|
|
|
g_free (arg_name);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == actual_arg_count - 1)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Lonely argument with no value: %s", arg_name);
|
|
|
|
g_free (arg_name);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init (&value, arg_spec->value_type);
|
|
|
|
return_val = script_fu_marshal_arg_to_value (sc, a, proc_name, i, arg_spec, &value, NULL);
|
|
|
|
if (return_val != sc->NIL)
|
|
|
|
{
|
|
|
|
g_value_unset (&value);
|
|
|
|
g_free (arg_name);
|
|
|
|
return return_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_property (G_OBJECT (config), arg_name, &value);
|
2023-10-21 02:42:33 +02:00
|
|
|
g_value_unset (&value);
|
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
a = sc->vptr->pair_cdr (a);
|
2023-10-21 02:42:33 +02:00
|
|
|
}
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
}
|
|
|
|
|
2021-01-28 08:31:11 -05:00
|
|
|
/* Omit refresh scripts from a script, better than crashing, see #575830. */
|
|
|
|
if (strcmp (proc_name, "script-fu-refresh") == 0)
|
|
|
|
return script_error (sc, "A script cannot refresh scripts", 0);
|
|
|
|
|
2024-12-08 14:20:14 -05:00
|
|
|
g_debug ("%s, calling:%s", G_STRFUNC, proc_name);
|
libgimp, plug-ins: move gimp_pdb_run_procedure*() to gimp_procedure_run*().
The gimp_procedure_run() already existed, though it was with an ordered
GimpValueArray array of arguments. Its usage feels redundant to the series of
gimp_pdb_run_procedure*() functions (which is confusing), but
gimp_procedure_run() was actually a bit more generic, because it does not
necessarily calls GimpProcedure-s through the PDB! For instance, it can runs a
local GimpProcedure, such as the case of one procedure which would want to call
another procedure in the same plug-in, but without having to go through PDB. Of
course, for local code, you may as well run relevant functions directly, yet it
makes sense that if one of the redundant-looking function is removed, it should
be the more specific one. Also gimp_procedure_run() feels a lot simpler and
logical, API wise.
A main difference in usage is that now, plug-in developers have to first
explicitly look up the GimpPdbProcedure with gimp_pdb_lookup_procedure() when
they wish to call PDB procedures on the wire. This was done anyway in the
gimp_pdb_run_procedure*() code, now it's explicit (rather than calling by name
directly).
Concretely:
* gimp_pdb_run_procedure(), gimp_pdb_run_procedure_config() and
gimp_pdb_run_procedure_valist() are removed.
* gimp_procedure_run() API is modified to use a variable args list instead of a
GimpValueArray.
* gimp_procedure_run_config() and gimp_procedure_run_valist() are added.
* gimp_procedure_run_config() in particular will be the one used in bindings
which don't have variable args support through a (rename-to
gimp_procedure_run) annotation.
2023-10-18 17:11:20 +02:00
|
|
|
values = gimp_procedure_run_config (procedure, config);
|
libgimp: PDB procedure arguments are not order-based anymore (API-wise).
As far as plug-in API is concerned, at least the calling API, order of arguments
when calling PDB procedures doesn't matter anymore.
Order still matters for creating procedures with standard arguments (for
instance, "run-mode" is first, then image, or file, drawables or whatnot,
depending on the subtype of procedure), but not for calling with libgimp.
Concretely in this commit:
- gimp_pdb_run_procedure_argv() was removed as it's intrinsically order-based.
- gimp_pdb_run_procedure() and gimp_pdb_run_procedure_valist() stay but their
semantic changes. Instead of an ordered list of (type, value) couple, it's now
an unordered list of (name, type, value) triplets. This way, you can also
ignore as many args as you want if you intend to keep them default. For
instance, say you have a procedure with 20 args and you only want to change
the last one and keep the 19 first with default values: while you used to have
to write down all 20 args annoyingly, now you can just list the only arg you
care about.
There are 2 important consequences here:
1. Calling PDB procedures becomes much more semantic, which means scripts with
PDB calls are simpler (smaller list of arguments) and easier to read (when
you had 5 int arguments in a row, you couldn't know what they refer to,
except by always checking the PDB source; now you'll have associated names,
such as "width", "height" and so on) hence maintain.
2. We will have the ability to add arguments and even order the new arguments in
middle of existing arguments without breaking compatibility. The only thing
which will matter will be that default values of new arguments will have to
behave like when the arg didn't exist. This way, existing scripts will not be
broken. This will avoid us having to always create variants of PDB procedure
(like original "file-bla-save", then variant "file-bla-save-2" and so on)
each time we add arguments.
Note: gimp_pdb_run_procedure_array() was not removed yet because it's currently
used by the PDB. To be followed.
2023-10-16 16:44:06 +02:00
|
|
|
g_clear_object (&config);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
|
|
|
/* Check the return status */
|
|
|
|
if (! values)
|
|
|
|
{
|
2021-01-28 08:31:11 -05:00
|
|
|
/* Usually a plugin that crashed, wire error */
|
2006-10-16 01:08:54 +00:00
|
|
|
g_snprintf (error_str, sizeof(error_str),
|
2021-01-28 08:31:11 -05:00
|
|
|
"in script, called procedure %s failed to return a status",
|
2007-09-27 10:27:46 +00:00
|
|
|
proc_name);
|
2021-01-28 08:31:11 -05:00
|
|
|
return script_error (sc, error_str, 0);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
}
|
|
|
|
|
2023-09-07 16:09:10 -04:00
|
|
|
{
|
|
|
|
pointer calling_error;
|
|
|
|
return_val = marshal_PDB_return (sc, values, proc_name, &calling_error);
|
|
|
|
|
|
|
|
/* Now returns error immediately.
|
|
|
|
* Which leaks memory normally freed below.
|
|
|
|
* Most plugins, except extension script-fu, will exit soon anyway.
|
|
|
|
* FUTURE: don't leak.
|
|
|
|
*/
|
|
|
|
if (calling_error != NULL)
|
|
|
|
/* calling error is foreign_error or similar. */
|
|
|
|
return calling_error;
|
|
|
|
}
|
2006-11-18 22:30:23 +00:00
|
|
|
|
2004-10-04 22:00:16 +00:00
|
|
|
g_free (proc_name);
|
|
|
|
|
2021-01-28 08:31:11 -05:00
|
|
|
/* free executed procedure return values */
|
2019-08-12 20:11:45 +02:00
|
|
|
gimp_value_array_unref (values);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2021-01-28 08:31:11 -05:00
|
|
|
/* free arguments and values */
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2022-05-28 10:02:10 -04:00
|
|
|
/* The callback is NULL except for script-fu-server. See explanation there. */
|
|
|
|
if (post_command_callback != NULL)
|
|
|
|
post_command_callback ();
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
|
|
|
#ifdef GDK_WINDOWING_WIN32
|
|
|
|
/* This seems to help a lot on Windoze. */
|
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return return_val;
|
2007-09-28 14:20:35 +00:00
|
|
|
}
|
|
|
|
|
plug-ins: in script-fu, don't query PDB procedures' info on startup
script-fu used to query the information of every PDB procedure on
startup, in order to get the number of parameters for each
procedure. This was done so that nullary procedures were defined
in such a way as to accept (and ignore) any number of arguments
(and at least one of the scripts we ship relies on this behavior).
However, this requires expensive back-and-forth communication with
the main GIMP process, which notable slowed down script-fu's
startup, and had a non-negligible impact on GIMP's startup time.
Instead, avoid querying procedure information, and implement the
special behavior for nullary procedures at call time. We do this
by defining, in addition to the "strict" gimp-proc-db-call
procedure, a "permissive" -gimp-proc-db-call internal procedure,
and using the latter to call the predefined PDB procedures.
2018-09-26 14:28:34 -04:00
|
|
|
static pointer
|
|
|
|
script_fu_marshal_procedure_call_strict (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
2021-01-28 09:08:39 -05:00
|
|
|
return script_fu_marshal_procedure_call (sc, a, FALSE, FALSE);
|
plug-ins: in script-fu, don't query PDB procedures' info on startup
script-fu used to query the information of every PDB procedure on
startup, in order to get the number of parameters for each
procedure. This was done so that nullary procedures were defined
in such a way as to accept (and ignore) any number of arguments
(and at least one of the scripts we ship relies on this behavior).
However, this requires expensive back-and-forth communication with
the main GIMP process, which notable slowed down script-fu's
startup, and had a non-negligible impact on GIMP's startup time.
Instead, avoid querying procedure information, and implement the
special behavior for nullary procedures at call time. We do this
by defining, in addition to the "strict" gimp-proc-db-call
procedure, a "permissive" -gimp-proc-db-call internal procedure,
and using the latter to call the predefined PDB procedures.
2018-09-26 14:28:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static pointer
|
|
|
|
script_fu_marshal_procedure_call_permissive (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
2021-01-28 09:08:39 -05:00
|
|
|
return script_fu_marshal_procedure_call (sc, a, TRUE, FALSE);
|
|
|
|
}
|
|
|
|
|
2025-02-25 23:04:00 +01:00
|
|
|
static pointer
|
|
|
|
script_fu_marshal_procedure_exists (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
const gchar *proc_name = "gimp-pdb-procedure-exists";
|
|
|
|
const gchar *test_proc_name;
|
|
|
|
gboolean exists = FALSE;
|
|
|
|
gchar error_str[1024];
|
|
|
|
|
|
|
|
if (a == sc->NIL)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"(%s) was called with no arguments. "
|
|
|
|
"A procedure name must be specified.",
|
|
|
|
proc_name);
|
|
|
|
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->vptr->list_length (sc, a) != 1)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"(%s) was called with %d arguments. "
|
|
|
|
"Only a procedure name must be specified.",
|
|
|
|
proc_name, sc->vptr->list_length (sc, a));
|
|
|
|
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! sc->vptr->is_string (sc->vptr->pair_car (a)))
|
|
|
|
return script_type_error (sc, "string", 1, proc_name);
|
|
|
|
|
|
|
|
test_proc_name = sc->vptr->string_value (sc->vptr->pair_car (a));
|
|
|
|
|
|
|
|
exists = gimp_pdb_procedure_exists (gimp_get_pdb (), test_proc_name);
|
|
|
|
|
2025-02-26 22:30:01 +01:00
|
|
|
if (is_interpret_v3_dialect ())
|
|
|
|
return exists ? sc->T : sc->F;
|
|
|
|
else
|
2025-02-27 13:59:05 +01:00
|
|
|
return sc->vptr->cons (sc,
|
|
|
|
sc->vptr->mk_integer (sc, exists),
|
|
|
|
sc->NIL);
|
2025-02-25 23:04:00 +01:00
|
|
|
}
|
|
|
|
|
2021-01-28 09:08:39 -05:00
|
|
|
static pointer
|
|
|
|
script_fu_marshal_procedure_call_deprecated (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
return script_fu_marshal_procedure_call (sc, a, TRUE, TRUE);
|
plug-ins: in script-fu, don't query PDB procedures' info on startup
script-fu used to query the information of every PDB procedure on
startup, in order to get the number of parameters for each
procedure. This was done so that nullary procedures were defined
in such a way as to accept (and ignore) any number of arguments
(and at least one of the scripts we ship relies on this behavior).
However, this requires expensive back-and-forth communication with
the main GIMP process, which notable slowed down script-fu's
startup, and had a non-negligible impact on GIMP's startup time.
Instead, avoid querying procedure information, and implement the
special behavior for nullary procedures at call time. We do this
by defining, in addition to the "strict" gimp-proc-db-call
procedure, a "permissive" -gimp-proc-db-call internal procedure,
and using the latter to call the predefined PDB procedures.
2018-09-26 14:28:34 -04:00
|
|
|
}
|
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
static pointer
|
2024-12-16 23:11:06 +01:00
|
|
|
script_fu_marshal_drawable_filter_configure (scheme *sc,
|
|
|
|
pointer a,
|
|
|
|
const gchar *proc_name,
|
2025-01-20 15:25:32 +01:00
|
|
|
gint arg_index,
|
2024-12-16 23:11:06 +01:00
|
|
|
GimpDrawableFilter *filter)
|
2024-12-13 21:31:53 +01:00
|
|
|
{
|
|
|
|
pointer return_val = sc->NIL;
|
|
|
|
GimpLayerMode mode = GIMP_LAYER_MODE_REPLACE;
|
|
|
|
gdouble opacity = 1.0;
|
|
|
|
GimpDrawableFilterConfig *config;
|
|
|
|
gchar error_str[1024];
|
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
if (sc->vptr->list_length (sc, a) > 0)
|
|
|
|
{
|
|
|
|
mode = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->vptr->list_length (sc, a) > 0)
|
|
|
|
{
|
|
|
|
opacity = sc->vptr->rvalue (sc->vptr->pair_car (a));
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
}
|
|
|
|
gimp_drawable_filter_set_opacity (filter, opacity);
|
|
|
|
gimp_drawable_filter_set_blend_mode (filter, mode);
|
|
|
|
|
2025-01-20 15:25:32 +01:00
|
|
|
config = gimp_drawable_filter_get_config (filter);
|
2024-12-16 23:11:06 +01:00
|
|
|
while (sc->vptr->list_length (sc, a) > 1)
|
|
|
|
{
|
|
|
|
gchar *argname;
|
|
|
|
GParamSpec *arg_spec;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
2025-01-20 15:25:32 +01:00
|
|
|
if (! sc->vptr->is_arg_name (sc->vptr->pair_car (a)) &&
|
|
|
|
! sc->vptr->is_string (sc->vptr->pair_car (a)))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Expected argument name for argument %d", arg_index);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
argname = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a)));
|
|
|
|
arg_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (config), argname);
|
|
|
|
if (arg_spec == NULL)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid argument name: %s", argname);
|
|
|
|
g_free (argname);
|
|
|
|
gimp_drawable_filter_delete (filter);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
g_value_init (&value, arg_spec->value_type);
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
|
plug-ins: new named argument syntax in Script-Fu.
This syntax is now the official syntax for non-core PDB procedures.
I.e. that while core procedures will still use ordered arguments (e.g.:
`(gimp-image-get-layers 1)`), plug-in PDB procedures called from
Script-Fu will have named arguments in any order.
Say for instance that you want to call python-fu-foggify from Script-Fu.
Whereas we used to run:
> (python-fu-foggify RUN-NONINTERACTIVE 1 (car (gimp-image-get-layers 1)) "Clouds" '(50 4 4) 1.0 50.0)
Now we should call:
> (python-fu-foggify #:image 1 #:drawables (car (gimp-image-get-layers 1)) #:opacity 50.0 #:color '(50 4 4))
Now we can note:
* Every argument is preceded by a #:label which is the argument name.
This makes these calls much more readable (some plug-in procedures can
have dozen of arguments and these end up as list of integers, floats
and strings, which are hard to read and hard to debug) and semantic.
* Order doesn't matter anymore. For instance here, I put #:opacity
before #:color.
* As a direct consequence, we can drop any argument which we wish to
keep with default value. E.g. in the old style, we had to put the
#:run-mode, #:name ("Clouds") and #:turbulence (1.0) because we were
changing the last argument #:opacity (50.0). Now we can drop all 3
default arguments.
Having non-ordered argument is in fact the starter of this feature,
because it is already the case for calling PDB procedures in the libgimp
API (and therefore in all GIR bindings). By saying that the order of PDB
procedures is not part of the API, we actually allow to add arguments
and even to reorder them in the future without breaking existing scripts
in the 3.0 series.
This became even more serious when I was considering to make the generic
metadata arguments public. Since they are appended to the end, after all
plug-in-specific arguments, if I do this, adding any argument in an
export plug-in would break order. It won't matter anymore!
Note that it doesn't matter for core PDB procedures (where this syntax
is not used) because these are also C functions and therefore order and
number of arguments matter anyway. Also these don't have dozens of
arguments.
As a helper for Script-Fu developer, in particular as we already
released 2 RCs and therefore some people already started to port their
scripts, the old syntax will still work yet will produce a warning
showing how to call the same thing with the new syntax. For instance,
with the above first call, the warning will be:
> (script-fu:2059912): scriptfu-WARNING **: 22:54:47.507: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
> Please use named arguments: (python-fu-foggify #:run-mode 1 #:image 1 #:drawables (2) #:name "Clouds" #:color '(50 4 4) #:turbulence 1.000000 #:opacity 50.000000)
Note that the argument name syntax is coming from the Racket scheme
variant: https://docs.racket-lang.org/arguments/index.html
Common Lisp has a similar syntax, either with just a colon, or also a
sharp + colon (it's unclear to me the difference, something about
interned vs. uninterned symbols).
After discussion with Liam on IRC, we decided to go with the #: syntax
of Racket.
2025-01-19 22:21:54 +01:00
|
|
|
return_val = script_fu_marshal_arg_to_value (sc, a, proc_name, arg_index, arg_spec, &value, NULL);
|
2024-12-16 23:11:06 +01:00
|
|
|
|
|
|
|
if (return_val != sc->NIL)
|
|
|
|
{
|
|
|
|
g_value_unset (&value);
|
|
|
|
g_free (argname);
|
|
|
|
gimp_drawable_filter_delete (filter);
|
|
|
|
return return_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_property (G_OBJECT (config), argname, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
arg_index += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sc->NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pointer
|
|
|
|
script_fu_marshal_drawable_create_filter (scheme *sc,
|
|
|
|
pointer a,
|
|
|
|
const gchar *proc_name,
|
|
|
|
GimpDrawable **drawable,
|
|
|
|
GimpDrawableFilter **filter)
|
|
|
|
{
|
|
|
|
gchar *operation_name;
|
|
|
|
gchar *filter_name = NULL;
|
|
|
|
gchar error_str[1024];
|
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
if (sc->vptr->list_length (sc, a) < 2)
|
2024-12-14 13:38:51 +01:00
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Drawable Filter marshaller was called with missing arguments. "
|
|
|
|
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
|
|
|
|
"and the arguments' names and values it requires (possibly none) must be specified: "
|
2024-12-16 23:11:06 +01:00
|
|
|
"(%s drawable op title mode opacity arg1 val1 arg2 val2...)",
|
2024-12-14 13:38:51 +01:00
|
|
|
proc_name);
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
else if (sc->vptr->list_length (sc, a) > 5 && sc->vptr->list_length (sc, a) % 2 != 1)
|
|
|
|
{
|
2024-12-14 13:38:51 +01:00
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Drawable Filter marshaller was called with an even number of arguments. "
|
|
|
|
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
|
|
|
|
"and the arguments' names and values it requires (possibly none) must be specified: "
|
2024-12-16 23:11:06 +01:00
|
|
|
"(%s drawable op title mode opacity arg1 val1 arg2 val2...)",
|
2024-12-14 13:38:51 +01:00
|
|
|
proc_name);
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
else if (! sc->vptr->is_number (sc->vptr->pair_car (a)))
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "numeric", 0, proc_name);
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpItem *item;
|
|
|
|
gint id;
|
|
|
|
|
|
|
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
item = gimp_item_get_by_id (id);
|
|
|
|
|
|
|
|
if (item == NULL || ! GIMP_IS_DRAWABLE (item))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid Drawable ID: %d", id);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
2024-12-14 13:38:51 +01:00
|
|
|
*drawable = GIMP_DRAWABLE (item);
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
operation_name = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a)));
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
|
|
|
|
if (sc->vptr->list_length (sc, a) > 0)
|
|
|
|
{
|
|
|
|
if (sc->vptr->is_string (sc->vptr->pair_car (a)))
|
|
|
|
filter_name = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a)));
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
}
|
|
|
|
|
2024-12-14 13:38:51 +01:00
|
|
|
*filter = gimp_drawable_filter_new (*drawable, operation_name, filter_name);
|
2024-12-13 21:31:53 +01:00
|
|
|
g_free (filter_name);
|
|
|
|
|
2024-12-14 13:38:51 +01:00
|
|
|
if (*filter == NULL)
|
2024-12-13 21:31:53 +01:00
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Unknown GEGL Operation: %s", operation_name);
|
|
|
|
g_free (operation_name);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
g_free (operation_name);
|
|
|
|
|
2025-01-20 15:25:32 +01:00
|
|
|
return script_fu_marshal_drawable_filter_configure (sc, a, proc_name, 5, *filter);
|
2024-12-16 23:11:06 +01:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
static pointer
|
|
|
|
script_fu_marshal_drawable_filter_configure_call (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
GimpDrawableFilter *filter = NULL;
|
|
|
|
const gchar *proc_name = "gimp-drawable-filter-configure";
|
|
|
|
gchar error_str[1024];
|
|
|
|
|
|
|
|
if (sc->vptr->list_length (sc, a) < 3)
|
2024-12-13 21:31:53 +01:00
|
|
|
{
|
2024-12-16 23:11:06 +01:00
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Drawable Filter marshaller was called with missing arguments. "
|
|
|
|
"The filter ID, blend mode, opacity and the arguments' names "
|
|
|
|
"and values it requires (possibly none) must be specified: "
|
|
|
|
"(%s mode opacity arg1 val1 arg2 val2...)",
|
|
|
|
proc_name);
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
else if (sc->vptr->list_length (sc, a) > 3 && sc->vptr->list_length (sc, a) % 2 != 1)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Drawable Filter marshaller was called with an even number of arguments. "
|
|
|
|
"The drawable ID, the GEGL operation, filter name, blend mode, opacity "
|
|
|
|
"and the arguments' names and values it requires (possibly none) must be specified: "
|
|
|
|
"(%s mode opacity arg1 val1 arg2 val2...)",
|
|
|
|
proc_name);
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
else if (! sc->vptr->is_number (sc->vptr->pair_car (a)))
|
|
|
|
{
|
|
|
|
return script_type_error (sc, "numeric", 0, proc_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint id;
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
filter = gimp_drawable_filter_get_by_id (id);
|
|
|
|
|
|
|
|
if (filter == NULL || ! GIMP_IS_DRAWABLE_FILTER (filter))
|
2024-12-13 21:31:53 +01:00
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
2024-12-16 23:11:06 +01:00
|
|
|
"Invalid Drawable Filter ID: %d", id);
|
2024-12-13 21:31:53 +01:00
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
2024-12-16 23:11:06 +01:00
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
a = sc->vptr->pair_cdr (a);
|
2024-12-16 23:11:06 +01:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2025-01-20 15:25:32 +01:00
|
|
|
return script_fu_marshal_drawable_filter_configure (sc, a, proc_name, 3, filter);
|
2024-12-16 23:11:06 +01:00
|
|
|
}
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2024-12-16 23:32:02 +01:00
|
|
|
static pointer
|
|
|
|
script_fu_marshal_drawable_filter_set_aux_call (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
const gchar *proc_name = "gimp-drawable-filter-set-aux-input";
|
|
|
|
GimpDrawableFilter *filter = NULL;
|
|
|
|
GimpItem *input = NULL;
|
|
|
|
gchar *pad_name = NULL;
|
|
|
|
gint id;
|
|
|
|
gchar error_str[1024];
|
|
|
|
|
|
|
|
if (sc->vptr->list_length (sc, a) != 3)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Drawable Filter marshaller was called with missing arguments. "
|
|
|
|
"The filter ID, aux pad name and the aux drawable: "
|
|
|
|
"(%s filter-id pad-name drawable-id)",
|
|
|
|
proc_name);
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! sc->vptr->is_number (sc->vptr->pair_car (a)))
|
|
|
|
return script_type_error (sc, "numeric", 0, proc_name);
|
|
|
|
|
|
|
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
filter = gimp_drawable_filter_get_by_id (id);
|
|
|
|
if (filter == NULL || ! GIMP_IS_DRAWABLE_FILTER (filter))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid Drawable Filter ID: %d", id);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
|
|
|
|
if (! sc->vptr->is_string (sc->vptr->pair_car (a)))
|
2025-02-25 22:40:43 +01:00
|
|
|
return script_type_error (sc, "string", 1, proc_name);
|
2024-12-16 23:32:02 +01:00
|
|
|
|
|
|
|
pad_name = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a)));
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
|
|
|
|
if (! sc->vptr->is_number (sc->vptr->pair_car (a)))
|
|
|
|
return script_type_error (sc, "numeric", 2, proc_name);
|
|
|
|
|
|
|
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
input = gimp_item_get_by_id (id);
|
|
|
|
if (input == NULL || ! GIMP_IS_DRAWABLE (input))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid Drawable ID: %d", id);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_drawable_filter_set_aux_input (filter, pad_name, GIMP_DRAWABLE (input));
|
|
|
|
|
|
|
|
return sc->NIL;
|
|
|
|
}
|
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
static pointer
|
|
|
|
script_fu_marshal_drawable_merge_filter_call (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
const gchar *proc_name = "gimp-drawable-merge-filter";
|
|
|
|
GimpItem *item;
|
|
|
|
GimpDrawableFilter *filter;
|
|
|
|
gint id;
|
|
|
|
gchar error_str[1024];
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
if (sc->vptr->list_length (sc, a) != 2)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Drawable Filter marshaller was called with missing arguments. "
|
|
|
|
"The drawable and filter IDs are required: "
|
|
|
|
"(%s mode opacity arg1 val1 arg2 val2...)",
|
|
|
|
proc_name);
|
2024-12-13 21:31:53 +01:00
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
return implementation_error (sc, error_str, 0);
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
|
2024-12-16 23:11:06 +01:00
|
|
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
item = gimp_item_get_by_id (id);
|
|
|
|
if (item == NULL || ! GIMP_IS_DRAWABLE (item))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid Drawable ID: %d", id);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
|
|
|
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
filter = gimp_drawable_filter_get_by_id (id);
|
|
|
|
if (filter == NULL || ! GIMP_IS_DRAWABLE_FILTER (filter))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid Drawable Filter ID: %d", id);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_drawable_merge_filter (GIMP_DRAWABLE (item), filter);
|
|
|
|
|
2024-12-14 13:38:51 +01:00
|
|
|
return sc->NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pointer
|
2024-12-16 23:11:06 +01:00
|
|
|
script_fu_marshal_drawable_append_filter_call (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
const gchar *proc_name = "gimp-drawable-append-filter";
|
|
|
|
GimpItem *item;
|
|
|
|
GimpDrawableFilter *filter;
|
|
|
|
gint id;
|
|
|
|
gchar error_str[1024];
|
|
|
|
|
|
|
|
if (sc->vptr->list_length (sc, a) != 2)
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Drawable Filter marshaller was called with missing arguments. "
|
|
|
|
"The drawable and filter IDs are required: "
|
|
|
|
"(%s mode opacity arg1 val1 arg2 val2...)",
|
|
|
|
proc_name);
|
|
|
|
|
|
|
|
return implementation_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
item = gimp_item_get_by_id (id);
|
|
|
|
if (item == NULL || ! GIMP_IS_DRAWABLE (item))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid Drawable ID: %d", id);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
a = sc->vptr->pair_cdr (a);
|
|
|
|
|
|
|
|
id = sc->vptr->ivalue (sc->vptr->pair_car (a));
|
|
|
|
filter = gimp_drawable_filter_get_by_id (id);
|
|
|
|
if (filter == NULL || ! GIMP_IS_DRAWABLE_FILTER (filter))
|
|
|
|
{
|
|
|
|
g_snprintf (error_str, sizeof (error_str),
|
|
|
|
"Invalid Drawable Filter ID: %d", id);
|
|
|
|
return script_error (sc, error_str, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_drawable_append_filter (GIMP_DRAWABLE (item), filter);
|
|
|
|
|
|
|
|
return sc->NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pointer
|
|
|
|
script_fu_marshal_drawable_merge_new_filter_call (scheme *sc,
|
|
|
|
pointer a)
|
2024-12-14 13:38:51 +01:00
|
|
|
{
|
|
|
|
GimpDrawable *drawable = NULL;
|
|
|
|
GimpDrawableFilter *filter = NULL;
|
|
|
|
pointer return_val;
|
|
|
|
|
|
|
|
return_val = script_fu_marshal_drawable_create_filter (sc, a,
|
|
|
|
"gimp-drawable-merge-new-filter",
|
|
|
|
&drawable, &filter);
|
|
|
|
if (return_val != sc->NIL)
|
|
|
|
return return_val;
|
|
|
|
|
2024-12-13 21:31:53 +01:00
|
|
|
gimp_drawable_merge_filter (drawable, filter);
|
|
|
|
|
2024-12-14 13:38:51 +01:00
|
|
|
return sc->NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pointer
|
2024-12-16 23:11:06 +01:00
|
|
|
script_fu_marshal_drawable_append_new_filter_call (scheme *sc,
|
|
|
|
pointer a)
|
2024-12-14 13:38:51 +01:00
|
|
|
{
|
|
|
|
GimpDrawable *drawable = NULL;
|
|
|
|
GimpDrawableFilter *filter = NULL;
|
|
|
|
pointer return_val;
|
|
|
|
|
|
|
|
return_val = script_fu_marshal_drawable_create_filter (sc, a,
|
|
|
|
"gimp-drawable-append-new-filter",
|
|
|
|
&drawable, &filter);
|
|
|
|
if (return_val != sc->NIL)
|
|
|
|
return return_val;
|
|
|
|
|
|
|
|
gimp_drawable_append_filter (drawable, filter);
|
|
|
|
|
|
|
|
return sc->vptr->mk_integer (sc, gimp_drawable_filter_get_id (filter));
|
2024-12-13 21:31:53 +01:00
|
|
|
}
|
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
static pointer
|
2008-09-09 14:22:44 +00:00
|
|
|
script_fu_register_call (scheme *sc,
|
|
|
|
pointer a)
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
{
|
2008-09-11 18:00:18 +00:00
|
|
|
return script_fu_add_script (sc, a);
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
}
|
|
|
|
|
2022-07-15 13:50:36 -04:00
|
|
|
static pointer
|
|
|
|
script_fu_register_call_filter (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
return script_fu_add_script_filter (sc, a);
|
|
|
|
}
|
|
|
|
|
2024-09-21 12:03:42 -04:00
|
|
|
static pointer
|
2024-09-27 05:44:07 -04:00
|
|
|
script_fu_register_call_procedure (scheme *sc,
|
2024-09-21 12:03:42 -04:00
|
|
|
pointer a)
|
|
|
|
{
|
2024-09-27 05:44:07 -04:00
|
|
|
/* Internally "regular" means general "procedure" */
|
2024-09-21 12:03:42 -04:00
|
|
|
return script_fu_add_script_regular (sc, a);
|
|
|
|
}
|
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
static pointer
|
2008-09-09 14:22:44 +00:00
|
|
|
script_fu_menu_register_call (scheme *sc,
|
|
|
|
pointer a)
|
2004-11-17 15:24:07 +00:00
|
|
|
{
|
2008-09-11 18:00:18 +00:00
|
|
|
return script_fu_add_menu (sc, a);
|
2004-11-17 15:24:07 +00:00
|
|
|
}
|
|
|
|
|
2023-12-04 11:23:01 -05:00
|
|
|
static pointer
|
|
|
|
script_fu_use_v3_call (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
begin_interpret_v3_dialect ();
|
|
|
|
return sc->NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pointer
|
|
|
|
script_fu_use_v2_call (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
begin_interpret_v2_dialect ();
|
|
|
|
return sc->NIL;
|
|
|
|
}
|
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
static pointer
|
2008-09-09 14:22:44 +00:00
|
|
|
script_fu_quit_call (scheme *sc,
|
|
|
|
pointer a)
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
{
|
2022-05-28 10:02:10 -04:00
|
|
|
/* If script-fu-server running, tell it. */
|
|
|
|
if (quit_callback != NULL)
|
|
|
|
quit_callback ();
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
scheme_deinit (sc);
|
|
|
|
|
|
|
|
return sc->NIL;
|
new code to call the script_fuc_text_console pdb function. remove batch
2001-07-17 Mathieu Lacage <mathieu@gnome.org>
* app/batch.c: new code to call the script_fuc_text_console pdb function.
* app/main.c: (main): remove batch command code.
* plug-ins/script-fu/Makefile.am: add siod-wrapper.h/c
* plug-ins/script-fu/script-fu-console.c:
(script_fu_cc_key_function),
(script_fu_open_siod_console),
(script_fu_close_siod_console):
* plug-ins/script-fu/script-fu-scripts.h:
* plug-ins/script-fu/script-fu-server.c:
(script_fu_server_quit),
(script_fu_server_get_mode),
(execute_command):
Replace all direct calls to the scheme interpreter with calls to the siod-wrapper.
* plug-ins/script-fu/script-fu-console.h: remove run_eval.
* plug-ins/script-fu/script-fu-server.h:
* plug-ins/script-fu/script-fu-text-console.c:
(script_fu_text_console_run),
(read_command),
(script_fu_text_console_interface):
The actual new text console.
* plug-ins/script-fu/script-fu-text-console.h: header.
* plug-ins/script-fu/script-fu.c:
(script_fu_quit),
(script_fu_query),
(script_fu_run): rename to better words.
move most of the code to siod-wrapper.c/h
* plug-ins/script-fu/siod-wrapper.c:
(siod_get_output_file),
(siod_set_output_file),
(siod_get_verbose_level),
(siod_set_verbose_level),
(siod_print_welcome),
(siod_interpret_string),
(siod_get_error_msg),
(siod_get_success_msg),
(siod_init),
(init_procedures),
(init_constants),
(convert_string),
(sputs_fcn),
(lprin1s),
(marshall_proc_db_call),
(script_fu_register_call),
(script_fu_quit_call):
All the funcitons dealing with the internals of the scheme interpreter.
* plug-ins/script-fu/siod-wrapper.h: the header.
2001-07-17 22:53:21 +00:00
|
|
|
}
|
2008-09-11 18:00:18 +00:00
|
|
|
|
|
|
|
static pointer
|
|
|
|
script_fu_nil_call (scheme *sc,
|
|
|
|
pointer a)
|
|
|
|
{
|
|
|
|
return sc->NIL;
|
|
|
|
}
|