? app/file/file-open.foo ? tools/pdbgen/app.foo Index: app/batch.c =================================================================== RCS file: /cvs/gnome/gimp/app/batch.c,v retrieving revision 1.49 diff -u -p -r1.49 batch.c --- app/batch.c 20 Oct 2005 10:44:22 -0000 1.49 +++ app/batch.c 29 Mar 2006 22:02:00 -0000 @@ -129,23 +129,23 @@ batch_run_cmd (Gimp *gimp, const gchar *cmd) { Argument *args; - Argument *vals; - gint i; + Argument *return_vals; + gint n_return_vals; - args = g_new0 (Argument, proc->num_args); - for (i = 0; i < proc->num_args; i++) - args[i].arg_type = proc->args[i].arg_type; + args = procedural_db_arguments (proc); - args[0].value.pdb_int = run_mode; + g_value_set_int (&args[0].value, run_mode); if (proc->num_args > 1) - args[1].value.pdb_pointer = (gpointer) cmd; + g_value_set_static_string (&args[1].value, cmd); - vals = procedural_db_execute (gimp, - gimp_get_user_context (gimp), NULL, - proc_name, args); + return_vals = procedural_db_execute (gimp, + gimp_get_user_context (gimp), NULL, + proc_name, + args, proc->num_args, + &n_return_vals); - switch (vals[0].value.pdb_int) + switch (g_value_get_enum (&return_vals[0].value)) { case GIMP_PDB_EXECUTION_ERROR: g_printerr ("batch command: experienced an execution error.\n"); @@ -160,8 +160,8 @@ batch_run_cmd (Gimp *gimp, break; } - procedural_db_destroy_args (vals, proc->num_values); - g_free (args); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); + procedural_db_destroy_args (args, proc->num_args, TRUE); return; } Index: app/dialogs/about-dialog.c =================================================================== RCS file: /cvs/gnome/gimp/app/dialogs/about-dialog.c,v retrieving revision 1.128 diff -u -p -r1.128 about-dialog.c --- app/dialogs/about-dialog.c 28 Dec 2005 20:45:51 -0000 1.128 +++ app/dialogs/about-dialog.c 29 Mar 2006 22:02:01 -0000 @@ -223,7 +223,7 @@ about_dialog_load_url (GtkAboutDialog *d &nreturn_vals, GIMP_PDB_STRING, url, GIMP_PDB_END); - procedural_db_destroy_args (return_vals, nreturn_vals); + procedural_db_destroy_args (return_vals, nreturn_vals, TRUE); } Index: app/pdb/procedural_db.c =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/procedural_db.c,v retrieving revision 1.61 diff -u -p -r1.61 procedural_db.c --- app/pdb/procedural_db.c 29 Mar 2006 21:47:49 -0000 1.61 +++ app/pdb/procedural_db.c 29 Mar 2006 22:02:01 -0000 @@ -235,20 +235,126 @@ procedural_db_lookup (Gimp *gimp, return NULL; } +static Argument * +procedural_db_execute_proc (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + ProcRecord *procedure, + Argument *args, + gint n_args, + gint *n_return_vals) +{ + Argument *return_vals = NULL; + gint i; + + *n_return_vals = procedure->num_values + 1; + + for (i = 0; i < MIN (n_args, procedure->num_args); i++) + { + if (args[i].arg_type != procedure->args[i].arg_type) + { + gchar *type_name; + gchar *got; + + type_name = procedural_db_type_name (procedure->args[i].arg_type); + got = procedural_db_type_name (args[i].arg_type); + + g_message (_("PDB calling error for procedure '%s':\n" + "Argument '%s' (#%d, type %s) type mismatch " + "(got %s)."), + procedure->name, + g_param_spec_get_name (procedure->args[i].pspec), + i + 1, type_name, got); + + g_free (type_name); + g_free (got); + + return_vals = procedural_db_return_values (procedure, FALSE); + g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR); + + return return_vals; + } + else if (! (procedure->args[i].pspec->flags & GIMP_PARAM_NO_VALIDATE) && + g_param_value_validate (procedure->args[i].pspec, + &args[i].value)) + { + gchar *type_name; + + type_name = procedural_db_type_name (procedure->args[i].arg_type); + + g_message (_("PDB calling error for procedure '%s':\n" + "Argument '%s' (#%d, type %s) out of bounds."), + procedure->name, + g_param_spec_get_name (procedure->args[i].pspec), + i + 1, type_name); + + g_free (type_name); + + return_vals = procedural_db_return_values (procedure, FALSE); + g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR); + + return return_vals; + } + } + + /* call the procedure */ + switch (procedure->proc_type) + { + case GIMP_INTERNAL: + return_vals = procedure->exec_method.internal.marshal_func (procedure, + gimp, context, + progress, + args); + break; + + case GIMP_PLUGIN: + case GIMP_EXTENSION: + case GIMP_TEMPORARY: + return_vals = plug_in_run (gimp, context, progress, procedure, + args, n_args, + TRUE, FALSE, -1); + break; + + default: + break; + } + + /* If there are no return arguments, assume an execution error */ + if (! return_vals) + { + return_vals = procedural_db_return_values (procedure, FALSE); + g_value_set_enum (&return_vals->value, GIMP_PDB_EXECUTION_ERROR); + + return return_vals; + } + + if (g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS && + g_value_get_enum (&return_vals[0].value) != GIMP_PDB_PASS_THROUGH && + procedure->num_values > 0) + { + memset (&return_vals[1], 0, sizeof (Argument) * procedure->num_values); + } + + return return_vals; +} + Argument * procedural_db_execute (Gimp *gimp, GimpContext *context, GimpProgress *progress, const gchar *name, - Argument *args) + Argument *args, + gint n_args, + gint *n_return_vals) { - Argument *return_args = NULL; + Argument *return_vals = NULL; GList *list; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (n_return_vals != NULL, NULL); list = g_hash_table_lookup (gimp->procedural_ht, name); @@ -256,94 +362,33 @@ procedural_db_execute (Gimp *gim { g_message (_("PDB calling error:\nprocedure '%s' not found"), name); - return_args = g_new (Argument, 1); - return_args->arg_type = GIMP_PDB_STATUS; - return_args->value.pdb_int = GIMP_PDB_CALLING_ERROR; + return_vals = procedural_db_return_values (NULL, FALSE); + g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR); + + *n_return_vals = 1; - return return_args; + return return_vals; } for (; list; list = g_list_next (list)) { ProcRecord *procedure = list->data; - gint i; g_return_val_if_fail (procedure != NULL, NULL); - /* check the arguments */ - for (i = 0; i < procedure->num_args; i++) - { - if (args[i].arg_type != procedure->args[i].arg_type) - { - gchar *expected; - gchar *got; - - expected = procedural_db_type_name (procedure->args[i].arg_type); - got = procedural_db_type_name (args[i].arg_type); - - g_message (_("PDB calling error for procedure '%s':\n" - "Argument #%d type mismatch (expected %s, got %s)"), - procedure->name, i + 1, expected, got); - - g_free (expected); - g_free (got); + return_vals = procedural_db_execute_proc (gimp, context, progress, + procedure, + args, n_args, + n_return_vals); - return_args = g_new (Argument, 1); - return_args->arg_type = GIMP_PDB_STATUS; - return_args->value.pdb_int = GIMP_PDB_CALLING_ERROR; - - return return_args; - } - } - - /* call the procedure */ - switch (procedure->proc_type) - { - case GIMP_INTERNAL: - return_args = - (* procedure->exec_method.internal.marshal_func) (procedure, - gimp, context, - progress, - args); - break; - - case GIMP_PLUGIN: - case GIMP_EXTENSION: - case GIMP_TEMPORARY: - return_args = plug_in_run (gimp, context, progress, procedure, - args, procedure->num_args, - TRUE, FALSE, -1); - - /* If there are no return arguments, assume - * an execution error and fall through. - */ - if (return_args) - break; - - default: - return_args = g_new (Argument, 1); - return_args->arg_type = GIMP_PDB_STATUS; - return_args->value.pdb_int = GIMP_PDB_EXECUTION_ERROR; - - return return_args; - } - - if (return_args[0].value.pdb_int != GIMP_PDB_SUCCESS && - return_args[0].value.pdb_int != GIMP_PDB_PASS_THROUGH && - procedure->num_values > 0) - { - memset (&return_args[1], - 0, sizeof (Argument) * procedure->num_values); - } - - if (return_args[0].value.pdb_int == GIMP_PDB_PASS_THROUGH) + if (g_value_get_enum (&return_vals[0].value) == GIMP_PDB_PASS_THROUGH) { /* If the return value is GIMP_PDB_PASS_THROUGH and there is * a next procedure in the list, destroy the return values * and run the next procedure. */ if (g_list_next (list)) - procedural_db_destroy_args (return_args, procedure->num_values); + procedural_db_destroy_args (return_vals, *n_return_vals, TRUE); } else { @@ -354,7 +399,7 @@ procedural_db_execute (Gimp *gim } } - return return_args; + return return_vals; } Argument * @@ -362,7 +407,7 @@ procedural_db_run_proc (Gimp *gi GimpContext *context, GimpProgress *progress, const gchar *name, - gint *nreturn_vals, + gint *n_return_vals, ...) { ProcRecord *proc; @@ -375,7 +420,7 @@ procedural_db_run_proc (Gimp *gi g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (nreturn_vals != NULL, NULL); + g_return_val_if_fail (n_return_vals != NULL, NULL); proc = procedural_db_lookup (gimp, name); @@ -383,37 +428,34 @@ procedural_db_run_proc (Gimp *gi { g_message (_("PDB calling error:\nprocedure '%s' not found"), name); - *nreturn_vals = 1; + return_vals = procedural_db_return_values (NULL, FALSE); + g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR); - return_vals = g_new (Argument, 1); - return_vals->arg_type = GIMP_PDB_STATUS; - return_vals->value.pdb_int = GIMP_PDB_CALLING_ERROR; + *n_return_vals = 1; return return_vals; } + *n_return_vals = proc->num_values + 1; + params = procedural_db_arguments (proc); - va_start (args, nreturn_vals); + va_start (args, n_return_vals); for (i = 0; i < proc->num_args; i++) { - GimpPDBArgType arg_type; - - arg_type = va_arg (args, GimpPDBArgType); + GimpPDBArgType arg_type = va_arg (args, GimpPDBArgType); + GValue *value; if (arg_type == GIMP_PDB_END) break; if (arg_type != params[i].arg_type) { - gchar *expected; - gchar *got; - - expected = procedural_db_type_name (proc->args[i].arg_type); - got = procedural_db_type_name (arg_type); + gchar *expected = procedural_db_type_name (proc->args[i].arg_type); + gchar *got = procedural_db_type_name (arg_type); - g_free (params); + procedural_db_destroy_args (params, proc->num_args, FALSE); g_message (_("PDB calling error for procedure '%s':\n" "Argument #%d type mismatch (expected %s, got %s)"), @@ -422,51 +464,79 @@ procedural_db_run_proc (Gimp *gi g_free (expected); g_free (got); - *nreturn_vals = 1; - - return_vals = g_new (Argument, 1); - return_vals->arg_type = GIMP_PDB_STATUS; - return_vals->value.pdb_int = GIMP_PDB_CALLING_ERROR; + return_vals = procedural_db_return_values (proc, FALSE); + g_value_set_enum (&return_vals->value, GIMP_PDB_CALLING_ERROR); return return_vals; } + value = ¶ms[i].value; + switch (arg_type) { case GIMP_PDB_INT32: + if (G_VALUE_HOLDS_INT (value)) + g_value_set_int (value, va_arg (args, gint)); + else if (G_VALUE_HOLDS_ENUM (value)) + g_value_set_enum (value, va_arg (args, gint)); + else if (G_VALUE_HOLDS_BOOLEAN (value)) + g_value_set_boolean (value, va_arg (args, gint) ? TRUE : FALSE); + else + g_return_val_if_reached (NULL); + break; + case GIMP_PDB_INT16: + g_value_set_int (value, va_arg (args, gint)); + break; + case GIMP_PDB_INT8: - case GIMP_PDB_DISPLAY: - case GIMP_PDB_IMAGE: - case GIMP_PDB_LAYER: - case GIMP_PDB_CHANNEL: - case GIMP_PDB_DRAWABLE: - case GIMP_PDB_SELECTION: - case GIMP_PDB_VECTORS: - case GIMP_PDB_STATUS: - params[i].value.pdb_int = (gint32) va_arg (args, gint); + g_value_set_uint (value, va_arg (args, guint)); break; case GIMP_PDB_FLOAT: - params[i].value.pdb_float = (gdouble) va_arg (args, gdouble); + g_value_set_double (value, va_arg (args, gdouble)); break; case GIMP_PDB_STRING: + g_value_set_static_string (value, va_arg (args, gchar *)); + break; + case GIMP_PDB_INT32ARRAY: case GIMP_PDB_INT16ARRAY: case GIMP_PDB_INT8ARRAY: case GIMP_PDB_FLOATARRAY: case GIMP_PDB_STRINGARRAY: - case GIMP_PDB_PARASITE: - params[i].value.pdb_pointer = va_arg (args, gpointer); + g_value_set_pointer (value, va_arg (args, gpointer)); break; case GIMP_PDB_COLOR: - params[i].value.pdb_color = va_arg (args, GimpRGB); + { + GimpRGB color = va_arg (args, GimpRGB); + g_value_set_boxed (value, &color); + } break; case GIMP_PDB_REGION: case GIMP_PDB_BOUNDARY: + break; + + case GIMP_PDB_DISPLAY: + case GIMP_PDB_IMAGE: + case GIMP_PDB_LAYER: + case GIMP_PDB_CHANNEL: + case GIMP_PDB_DRAWABLE: + case GIMP_PDB_SELECTION: + case GIMP_PDB_VECTORS: + g_value_set_int (value, va_arg (args, gint)); + break; + + case GIMP_PDB_PARASITE: + g_value_set_static_boxed (value, va_arg (args, gpointer)); + break; + + case GIMP_PDB_STATUS: + g_value_set_enum (value, va_arg (args, gint)); + case GIMP_PDB_END: break; } @@ -474,17 +544,17 @@ procedural_db_run_proc (Gimp *gi va_end (args); - return_vals = procedural_db_execute (gimp, context, progress, name, params); + return_vals = procedural_db_execute (gimp, context, progress, name, + params, proc->num_args, + n_return_vals); - g_free (params); - - *nreturn_vals = proc->num_values + 1; + procedural_db_destroy_args (params, proc->num_args, FALSE); return return_vals; } Argument * -procedural_db_arguments (ProcRecord *procedure) +procedural_db_arguments (const ProcRecord *procedure) { Argument *args; gint i; @@ -494,46 +564,53 @@ procedural_db_arguments (ProcRecord *pro args = g_new0 (Argument, procedure->num_args); for (i = 0; i < procedure->num_args; i++) - args[i].arg_type = procedure->args[i].arg_type; + procedural_db_argument_init (&args[i], &procedure->args[i]); return args; } Argument * -procedural_db_return_values (ProcRecord *procedure, - gboolean success) +procedural_db_return_values (const ProcRecord *procedure, + gboolean success) { Argument *args; + gint n_args; gint i; - g_return_val_if_fail (procedure != NULL, NULL); + g_return_val_if_fail (procedure != NULL || success == FALSE, NULL); - args = g_new0 (Argument, procedure->num_values + 1); + if (procedure) + n_args = procedure->num_values + 1; + else + n_args = 1; - args[0].arg_type = GIMP_PDB_STATUS; + args = g_new0 (Argument, n_args); + + procedural_db_compat_arg_init (&args[0], GIMP_PDB_STATUS); if (success) - args[0].value.pdb_int = GIMP_PDB_SUCCESS; + g_value_set_enum (&args[0].value, GIMP_PDB_SUCCESS); else - args[0].value.pdb_int = GIMP_PDB_EXECUTION_ERROR; + g_value_set_enum (&args[0].value, GIMP_PDB_EXECUTION_ERROR); - /* Set the arg types for the return values */ - for (i = 0; i < procedure->num_values; i++) - args[i + 1].arg_type = procedure->values[i].arg_type; + if (procedure) + for (i = 0; i < procedure->num_values; i++) + procedural_db_argument_init (&args[i + 1], &procedure->values[i]); return args; } void procedural_db_destroy_args (Argument *args, - gint nargs) + gint n_args, + gboolean full_destroy) { gint i; - if (! args) + if (! args && n_args) return; - for (i = 0; i < nargs; i++) + for (i = n_args - 1; i >= 0; i--) { switch (args[i].arg_type) { @@ -541,30 +618,32 @@ procedural_db_destroy_args (Argument *ar case GIMP_PDB_INT16: case GIMP_PDB_INT8: case GIMP_PDB_FLOAT: + case GIMP_PDB_STRING: break; - case GIMP_PDB_STRING: case GIMP_PDB_INT32ARRAY: case GIMP_PDB_INT16ARRAY: case GIMP_PDB_INT8ARRAY: case GIMP_PDB_FLOATARRAY: - g_free (args[i].value.pdb_pointer); + if (full_destroy) + g_free (g_value_get_pointer (&args[i].value)); break; case GIMP_PDB_STRINGARRAY: - { - gchar **stringarray; - gint count; - gint j; + if (full_destroy) + { + gchar **array; + gint count; + gint j; - count = args[i - 1].value.pdb_int; - stringarray = args[i].value.pdb_pointer; + count = g_value_get_int (&args[i - 1].value); + array = g_value_get_pointer (&args[i].value); - for (j = 0; j < count; j++) - g_free (stringarray[j]); + for (j = 0; j < count; j++) + g_free (array[j]); - g_free (args[i].value.pdb_pointer); - } + g_free (array); + } break; case GIMP_PDB_COLOR: @@ -577,16 +656,13 @@ procedural_db_destroy_args (Argument *ar case GIMP_PDB_SELECTION: case GIMP_PDB_BOUNDARY: case GIMP_PDB_VECTORS: - break; - case GIMP_PDB_PARASITE: - gimp_parasite_free (args[i].value.pdb_pointer); - break; - case GIMP_PDB_STATUS: case GIMP_PDB_END: break; } + + g_value_unset (&args[i].value); } g_free (args); @@ -664,6 +740,17 @@ procedural_db_add_return_value (ProcReco G_STRFUNC, procedure->num_values, procedure->name); } +void +procedural_db_argument_init (Argument *arg, + ProcArg *proc_arg) +{ + g_return_if_fail (arg != NULL); + g_return_if_fail (proc_arg != NULL); + + arg->arg_type = proc_arg->arg_type; + g_value_init (&arg->value, proc_arg->pspec->value_type); +} + static GParamSpec * procedural_db_compat_pspec (Gimp *gimp, GimpPDBArgType arg_type, @@ -821,6 +908,73 @@ procedural_db_add_compat_value (ProcReco procedural_db_compat_pspec (gimp, arg_type, name, desc)); } + +void +procedural_db_compat_arg_init (Argument *arg, + GimpPDBArgType arg_type) +{ + g_return_if_fail (arg != NULL); + + arg->arg_type = arg_type; + + switch (arg_type) + { + case GIMP_PDB_INT32: + case GIMP_PDB_INT16: + g_value_init (&arg->value, G_TYPE_INT); + break; + + case GIMP_PDB_INT8: + g_value_init (&arg->value, G_TYPE_UINT); + break; + + case GIMP_PDB_FLOAT: + g_value_init (&arg->value, G_TYPE_DOUBLE); + break; + + case GIMP_PDB_STRING: + g_value_init (&arg->value, G_TYPE_STRING); + break; + + case GIMP_PDB_INT32ARRAY: + case GIMP_PDB_INT16ARRAY: + case GIMP_PDB_INT8ARRAY: + case GIMP_PDB_FLOATARRAY: + case GIMP_PDB_STRINGARRAY: + g_value_init (&arg->value, G_TYPE_POINTER); + break; + + case GIMP_PDB_COLOR: + g_value_init (&arg->value, GIMP_TYPE_RGB); + break; + + case GIMP_PDB_REGION: + case GIMP_PDB_BOUNDARY: + break; + + case GIMP_PDB_DISPLAY: + case GIMP_PDB_IMAGE: + case GIMP_PDB_LAYER: + case GIMP_PDB_CHANNEL: + case GIMP_PDB_DRAWABLE: + case GIMP_PDB_SELECTION: + case GIMP_PDB_VECTORS: + g_value_init (&arg->value, G_TYPE_INT); + break; + + case GIMP_PDB_PARASITE: + g_value_init (&arg->value, GIMP_TYPE_PARASITE); + break; + + case GIMP_PDB_STATUS: + g_value_init (&arg->value, GIMP_TYPE_PDB_STATUS_TYPE); + break; + + case GIMP_PDB_END: + break; + } +} + /* private functions */ Index: app/pdb/procedural_db.h =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/procedural_db.h,v retrieving revision 1.22 diff -u -p -r1.22 procedural_db.h --- app/pdb/procedural_db.h 29 Mar 2006 20:27:46 -0000 1.22 +++ app/pdb/procedural_db.h 29 Mar 2006 22:02:01 -0000 @@ -22,15 +22,8 @@ struct _Argument { - GimpPDBArgType arg_type; /* argument type */ - - union _ArgValue - { - gint32 pdb_int; /* Integer type */ - gdouble pdb_float; /* Floating point type */ - gpointer pdb_pointer; /* Pointer type */ - GimpRGB pdb_color; /* Color type */ - } value; + GimpPDBArgType arg_type; + GValue value; }; @@ -118,57 +111,64 @@ struct _ProcRecord /* Functions */ -void procedural_db_init (Gimp *gimp); -void procedural_db_free (Gimp *gimp); +void procedural_db_init (Gimp *gimp); +void procedural_db_free (Gimp *gimp); -void procedural_db_init_procs (Gimp *gimp); +void procedural_db_init_procs (Gimp *gimp); -void procedural_db_register (Gimp *gimp, - ProcRecord *procedure); -void procedural_db_unregister (Gimp *gimp, - const gchar *name); -ProcRecord * procedural_db_lookup (Gimp *gimp, - const gchar *name); - -Argument * procedural_db_execute (Gimp *gimp, - GimpContext *context, - GimpProgress *progress, - const gchar *name, - Argument *args); -Argument * procedural_db_run_proc (Gimp *gimp, - GimpContext *context, - GimpProgress *progress, - const gchar *name, - gint *nreturn_vals, +void procedural_db_register (Gimp *gimp, + ProcRecord *procedure); +void procedural_db_unregister (Gimp *gimp, + const gchar *name); +ProcRecord * procedural_db_lookup (Gimp *gimp, + const gchar *name); + +Argument * procedural_db_execute (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const gchar *name, + Argument *args, + gint n_args, + gint *n_return_vals); +Argument * procedural_db_run_proc (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const gchar *name, + gint *n_return_vals, ...); -Argument * procedural_db_arguments (ProcRecord *procedure); -Argument * procedural_db_return_values (ProcRecord *procedure, - gboolean success); -void procedural_db_destroy_args (Argument *args, - gint nargs); - -ProcRecord * procedural_db_init_proc (ProcRecord *procedure, - gint n_arguments, - gint n_return_values); - -void procedural_db_add_argument (ProcRecord *procedure, - GimpPDBArgType arg_type, - GParamSpec *pspec); -void procedural_db_add_return_value (ProcRecord *procedure, - GimpPDBArgType arg_type, - GParamSpec *pspec); - -void procedural_db_add_compat_arg (ProcRecord *procedure, - Gimp *gimp, - GimpPDBArgType arg_type, - const gchar *name, - const gchar *desc); -void procedural_db_add_compat_value (ProcRecord *procedure, - Gimp *gimp, - GimpPDBArgType arg_type, - const gchar *name, - const gchar *desc); +Argument * procedural_db_arguments (const ProcRecord *procedure); +Argument * procedural_db_return_values (const ProcRecord *procedure, + gboolean success); +void procedural_db_destroy_args (Argument *args, + gint n_args, + gboolean full_destroy); + +ProcRecord * procedural_db_init_proc (ProcRecord *procedure, + gint n_arguments, + gint n_return_vals); + +void procedural_db_add_argument (ProcRecord *procedure, + GimpPDBArgType arg_type, + GParamSpec *pspec); +void procedural_db_add_return_value (ProcRecord *procedure, + GimpPDBArgType arg_type, + GParamSpec *pspec); +void procedural_db_argument_init (Argument *arg, + ProcArg *proc_arg); + +void procedural_db_add_compat_arg (ProcRecord *procedure, + Gimp *gimp, + GimpPDBArgType arg_type, + const gchar *name, + const gchar *desc); +void procedural_db_add_compat_value (ProcRecord *procedure, + Gimp *gimp, + GimpPDBArgType arg_type, + const gchar *name, + const gchar *desc); +void procedural_db_compat_arg_init (Argument *arg, + GimpPDBArgType arg_type); #endif /* __PROCEDURAL_DB_H__ */ Index: app/actions/plug-in-commands.c =================================================================== RCS file: /cvs/gnome/gimp/app/actions/plug-in-commands.c,v retrieving revision 1.203 diff -u -p -r1.203 plug-in-commands.c --- app/actions/plug-in-commands.c 28 Mar 2006 17:55:49 -0000 1.203 +++ app/actions/plug-in-commands.c 29 Mar 2006 22:02:01 -0000 @@ -30,6 +30,7 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpitem.h" +#include "core/gimpparamspecs.h" #include "core/gimpprogress.h" #include "plug-in/plug-in-data.h" @@ -77,7 +78,7 @@ plug_in_run_cmd_callback (GtkAction args = procedural_db_arguments (proc_rec); /* initialize the first argument */ - args[n_args].value.pdb_int = GIMP_RUN_INTERACTIVE; + g_value_set_int (&args[n_args].value, GIMP_RUN_INTERACTIVE); n_args++; switch (proc_rec->proc_type) @@ -94,7 +95,7 @@ plug_in_run_cmd_callback (GtkAction if (display) { - args[n_args].value.pdb_int = gimp_image_get_ID (display->image); + gimp_value_set_image (&args[n_args].value, display->image); n_args++; if (proc_rec->num_args > n_args && @@ -106,15 +107,14 @@ plug_in_run_cmd_callback (GtkAction if (drawable) { - args[n_args].value.pdb_int = - gimp_item_get_ID (GIMP_ITEM (drawable)); + gimp_value_set_item (&args[n_args].value, + GIMP_ITEM (drawable)); n_args++; } else { g_warning ("Uh-oh, no active drawable for the plug-in!"); - g_free (args); - return; + goto error; } } } @@ -123,8 +123,7 @@ plug_in_run_cmd_callback (GtkAction default: g_error ("Unknown procedure type."); - g_free (args); - return; + goto error; } /* run the plug-in procedure */ @@ -142,7 +141,8 @@ plug_in_run_cmd_callback (GtkAction gimp_set_last_plug_in (gimp, proc_def); } - g_free (args); + error: + procedural_db_destroy_args (args, proc_rec->num_args, TRUE); } void Index: app/actions/vectors-commands.c =================================================================== RCS file: /cvs/gnome/gimp/app/actions/vectors-commands.c,v retrieving revision 1.106 diff -u -p -r1.106 vectors-commands.c --- app/actions/vectors-commands.c 28 Mar 2006 17:55:49 -0000 1.106 +++ app/actions/vectors-commands.c 29 Mar 2006 22:02:01 -0000 @@ -35,6 +35,7 @@ #include "core/gimpimage-merge.h" #include "core/gimpimage-undo.h" #include "core/gimpitemundo.h" +#include "core/gimpparamspecs.h" #include "core/gimpprogress.h" #include "core/gimpstrokedesc.h" #include "core/gimptoolinfo.h" @@ -332,16 +333,16 @@ vectors_selection_to_vectors_cmd_callbac /* plug-in arguments as if called by /Filters/... */ args = procedural_db_arguments (proc_rec); - args[0].value.pdb_int = GIMP_RUN_INTERACTIVE; - args[1].value.pdb_int = (gint32) gimp_image_get_ID (image); - args[2].value.pdb_int = -1; /* unused */ + g_value_set_enum (&args[0].value, GIMP_RUN_INTERACTIVE); + gimp_value_set_image (&args[1].value, image); + gimp_value_set_item (&args[2].value, NULL /* unused */); plug_in_run (image->gimp, action_data_get_context (data), GIMP_PROGRESS (display), proc_rec, args, 3 /* not proc_rec->num_args */, FALSE, TRUE, display ? gimp_display_get_ID (display) : 0); - g_free (args); + procedural_db_destroy_args (args, proc_rec->num_args, TRUE); } void Index: app/core/gimppdbprogress.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimppdbprogress.c,v retrieving revision 1.7 diff -u -p -r1.7 gimppdbprogress.c --- app/core/gimppdbprogress.c 18 Jan 2006 20:29:35 -0000 1.7 +++ app/core/gimppdbprogress.c 29 Mar 2006 22:02:02 -0000 @@ -259,7 +259,8 @@ gimp_pdb_progress_run_callback (GimpPdbP GIMP_PDB_FLOAT, value, GIMP_PDB_END); - if (! return_vals || return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS) + if (! return_vals || + g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS) { g_message (_("Unable to run %s callback. " "The corresponding plug-in may have crashed."), @@ -267,11 +268,11 @@ gimp_pdb_progress_run_callback (GimpPdbP } else if (n_return_vals >= 2 && return_vals[1].arg_type == GIMP_PDB_FLOAT) { - retval = return_vals[1].value.pdb_float; + retval = g_value_get_double (&return_vals[1].value); } if (return_vals) - procedural_db_destroy_args (return_vals, n_return_vals); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); progress->callback_busy = FALSE; } Index: app/file/file-open.c =================================================================== RCS file: /cvs/gnome/gimp/app/file/file-open.c,v retrieving revision 1.70 diff -u -p -r1.70 file-open.c --- app/file/file-open.c 28 Mar 2006 17:08:29 -0000 1.70 +++ app/file/file-open.c 29 Mar 2006 22:02:02 -0000 @@ -53,6 +53,7 @@ #include "core/gimpimage-undo.h" #include "core/gimpimagefile.h" #include "core/gimplayer.h" +#include "core/gimpparamspecs.h" #include "core/gimpprogress.h" #include "pdb/procedural_db.h" @@ -88,7 +89,7 @@ file_open_image (Gimp *gim Argument *return_vals; gint n_return_vals; gchar *filename; - gint image_id; + GimpImage *image; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); @@ -149,17 +150,15 @@ file_open_image (Gimp *gim g_free (filename); - *status = return_vals[0].value.pdb_int; - image_id = return_vals[1].value.pdb_int; + *status = g_value_get_enum (&return_vals[0].value); + image = gimp_value_get_image (&return_vals[1].value, gimp); - procedural_db_destroy_args (return_vals, n_return_vals); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); if (*status == GIMP_PDB_SUCCESS) { - if (image_id != -1) + if (image) { - GimpImage *image = gimp_image_get_by_ID (gimp, image_id); - file_open_sanitize_image (image); if (mime_type) @@ -221,7 +220,7 @@ file_open_thumbnail (Gimp *gimp Argument *return_vals; gint n_return_vals; gchar *filename; - gint image_id; + GimpImage *image; filename = file_utils_filename_from_uri (uri); @@ -237,21 +236,19 @@ file_open_thumbnail (Gimp *gimp g_free (filename); - status = return_vals[0].value.pdb_int; - image_id = return_vals[1].value.pdb_int; + status = g_value_get_enum (&return_vals[0].value); + image = gimp_value_get_image (&return_vals[1].value, gimp); if (proc->num_values >= 3) { - *image_width = MAX (0, return_vals[2].value.pdb_int); - *image_height = MAX (0, return_vals[3].value.pdb_int); + *image_width = MAX (0, g_value_get_int (&return_vals[2].value)); + *image_height = MAX (0, g_value_get_int (&return_vals[3].value)); } - procedural_db_destroy_args (return_vals, n_return_vals); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); - if (status == GIMP_PDB_SUCCESS && image_id != -1) + if (status == GIMP_PDB_SUCCESS && image != NULL) { - GimpImage *image = gimp_image_get_by_ID (gimp, image_id); - file_open_sanitize_image (image); *mime_type = file_proc->mime_type; Index: app/file/file-save.c =================================================================== RCS file: /cvs/gnome/gimp/app/file/file-save.c,v retrieving revision 1.65 diff -u -p -r1.65 file-save.c --- app/file/file-save.c 28 Mar 2006 17:08:29 -0000 1.65 +++ app/file/file-save.c 29 Mar 2006 22:02:02 -0000 @@ -140,9 +140,9 @@ file_save (GimpImage *image, GIMP_PDB_STRING, uri, GIMP_PDB_END); - status = return_vals[0].value.pdb_int; + status = g_value_get_enum (&return_vals[0].value); - procedural_db_destroy_args (return_vals, n_return_vals); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); if (status == GIMP_PDB_SUCCESS) { Index: app/plug-in/plug-in-message.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-message.c,v retrieving revision 1.234 diff -u -p -r1.234 plug-in-message.c --- app/plug-in/plug-in-message.c 29 Mar 2006 10:45:17 -0000 1.234 +++ app/plug-in/plug-in-message.c 29 Mar 2006 22:02:02 -0000 @@ -348,10 +348,12 @@ plug_in_handle_proc_run (PlugIn *plug { PlugInProcFrame *proc_frame; gchar *canonical; - const gchar *proc_name = NULL; + const gchar *proc_name = NULL; ProcRecord *proc_rec; - Argument *args; - Argument *return_vals; + Argument *args = NULL; + gint n_args = 0; + Argument *return_vals = NULL; + gint n_return_vals = 0; canonical = gimp_canonicalize_identifier (proc_run->name); @@ -410,7 +412,13 @@ plug_in_handle_proc_run (PlugIn *plug if (! proc_name) proc_name = canonical; - args = plug_in_params_to_args (proc_run->params, proc_run->nparams, FALSE); + if (proc_rec) + { + n_args = proc_run->nparams; + args = plug_in_params_to_args (proc_rec->args, proc_rec->num_args, + proc_run->params, n_args, + FALSE); + } plug_in_push (plug_in->gimp, plug_in); @@ -422,7 +430,9 @@ plug_in_handle_proc_run (PlugIn *plug proc_frame->context_stack->data : proc_frame->main_context, proc_frame->progress, - proc_name, args); + proc_name, + args, n_args, + &n_return_vals); plug_in_pop (plug_in->gimp); @@ -436,20 +446,10 @@ plug_in_handle_proc_run (PlugIn *plug * since proc_name may have been remapped by gimp->procedural_compat_ht * and canonical may be different too. */ - proc_return.name = proc_run->name; - - if (proc_rec) - { - proc_return.nparams = proc_rec->num_values + 1; - proc_return.params = plug_in_args_to_params (return_vals, - proc_return.nparams, - FALSE); - } - else - { - proc_return.nparams = 1; - proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); - } + proc_return.name = proc_run->name; + proc_return.nparams = n_return_vals; + proc_return.params = plug_in_args_to_params (return_vals, n_return_vals, + FALSE); if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { @@ -458,13 +458,8 @@ plug_in_handle_proc_run (PlugIn *plug return; } - plug_in_args_destroy (args, proc_run->nparams, FALSE); - - if (proc_rec) - plug_in_args_destroy (return_vals, proc_rec->num_values + 1, TRUE); - else - plug_in_args_destroy (return_vals, 1, TRUE); - + procedural_db_destroy_args (args, n_args, FALSE); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); plug_in_params_destroy (proc_return.params, proc_return.nparams, FALSE); } else @@ -499,7 +494,9 @@ plug_in_handle_proc_return_priv (PlugIn if (proc_frame->main_loop) { - proc_frame->return_vals = plug_in_params_to_args (proc_return->params, + proc_frame->return_vals = plug_in_params_to_args (proc_frame->proc_rec->values, + proc_frame->proc_rec->num_values, + proc_return->params, proc_return->nparams, TRUE); proc_frame->n_return_vals = proc_return->nparams; Index: app/plug-in/plug-in-params.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-params.c,v retrieving revision 1.186 diff -u -p -r1.186 plug-in-params.c --- app/plug-in/plug-in-params.c 29 Mar 2006 10:45:17 -0000 1.186 +++ app/plug-in/plug-in-params.c 29 Mar 2006 22:02:02 -0000 @@ -24,9 +24,12 @@ #include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpprotocol.h" +#include "libgimpcolor/gimpcolor.h" #include "plug-in-types.h" +#include "core/gimpparamspecs.h" + #include "pdb/procedural_db.h" #include "plug-in.h" @@ -34,151 +37,198 @@ Argument * -plug_in_params_to_args (GPParam *params, - gint nparams, +plug_in_params_to_args (ProcArg *proc_args, + gint n_proc_args, + GPParam *params, + gint n_params, gboolean full_copy) { - Argument *args; - gchar **stringarray; - gint count; - gint i, j; + Argument *args; + gint count; + gint i; + + g_return_val_if_fail ((proc_args != NULL && n_proc_args > 0) || + (proc_args == NULL && n_proc_args == 0), NULL); + g_return_val_if_fail ((params != NULL && n_params > 0) || + (params == NULL && n_params == 0), NULL); - if (! (params && nparams)) + if (! params) return NULL; - args = g_new0 (Argument, nparams); + args = g_new0 (Argument, n_params); - for (i = 0; i < nparams; i++) + for (i = 0; i < n_params; i++) { - args[i].arg_type = params[i].type; + GValue *value = &args[i].value; + + if (i < n_proc_args && proc_args[i].arg_type == params[i].type) + { + procedural_db_argument_init (&args[i], &proc_args[i]); + } + else + { + procedural_db_compat_arg_init (&args[i], params[i].type); + } switch (args[i].arg_type) { case GIMP_PDB_INT32: - args[i].value.pdb_int = params[i].data.d_int32; + if (G_VALUE_HOLDS_INT (value)) + g_value_set_int (value, params[i].data.d_int32); + else if (G_VALUE_HOLDS_ENUM (value)) + g_value_set_enum (value, params[i].data.d_int32); + else if (G_VALUE_HOLDS_BOOLEAN (value)) + g_value_set_boolean (value, params[i].data.d_int32 ? TRUE : FALSE); + else + g_return_val_if_reached (args); break; + case GIMP_PDB_INT16: - args[i].value.pdb_int = params[i].data.d_int16; + g_value_set_int (value, params[i].data.d_int16); break; + case GIMP_PDB_INT8: - args[i].value.pdb_int = params[i].data.d_int8; + g_value_set_uint (value, params[i].data.d_int8); break; + case GIMP_PDB_FLOAT: - args[i].value.pdb_float = params[i].data.d_float; + g_value_set_double (value, params[i].data.d_float); break; + case GIMP_PDB_STRING: if (full_copy) - args[i].value.pdb_pointer = g_strdup (params[i].data.d_string); + g_value_set_string (value, params[i].data.d_string); else - args[i].value.pdb_pointer = params[i].data.d_string; + g_value_set_static_string (value, params[i].data.d_string); break; + case GIMP_PDB_INT32ARRAY: if (full_copy) { - count = args[i-1].value.pdb_int; - args[i].value.pdb_pointer = g_new (gint32, count); - memcpy (args[i].value.pdb_pointer, - params[i].data.d_int32array, count * 4); + count = g_value_get_int (&args[i - 1].value); + g_value_set_pointer (value, + g_memdup (params[i].data.d_int32array, + count * sizeof (gint32))); } else { - args[i].value.pdb_pointer = params[i].data.d_int32array; + g_value_set_pointer (value, params[i].data.d_int32array); } break; + case GIMP_PDB_INT16ARRAY: if (full_copy) { - count = args[i-1].value.pdb_int; - args[i].value.pdb_pointer = g_new (gint16, count); - memcpy (args[i].value.pdb_pointer, - params[i].data.d_int16array, count * 2); + count = g_value_get_int (&args[i - 1].value); + g_value_set_pointer (value, + g_memdup (params[i].data.d_int16array, + count * sizeof (gint16))); } else { - args[i].value.pdb_pointer = params[i].data.d_int16array; + g_value_set_pointer (value, params[i].data.d_int16array); } break; + case GIMP_PDB_INT8ARRAY: if (full_copy) { - count = args[i-1].value.pdb_int; - args[i].value.pdb_pointer = g_new (gint8, count); - memcpy (args[i].value.pdb_pointer, - params[i].data.d_int8array, count); + count = g_value_get_int (&args[i - 1].value); + g_value_set_pointer (value, + g_memdup (params[i].data.d_int8array, + count)); } else { - args[i].value.pdb_pointer = params[i].data.d_int8array; + g_value_set_pointer (value, params[i].data.d_int8array); } break; + case GIMP_PDB_FLOATARRAY: if (full_copy) { - count = args[i-1].value.pdb_int; - args[i].value.pdb_pointer = g_new (gdouble, count); - memcpy (args[i].value.pdb_pointer, - params[i].data.d_floatarray, count * 8); + count = g_value_get_int (&args[i - 1].value); + g_value_set_pointer (value, + g_memdup (params[i].data.d_floatarray, + count * sizeof (gdouble))); } else { - args[i].value.pdb_pointer = params[i].data.d_floatarray; + g_value_set_pointer (value, params[i].data.d_floatarray); } break; + case GIMP_PDB_STRINGARRAY: if (full_copy) { - args[i].value.pdb_pointer = g_new (gchar *, - args[i-1].value.pdb_int); - stringarray = args[i].value.pdb_pointer; + gchar **array; + gint j; + + count = g_value_get_int (&args[i - 1].value); + + array = g_new (gchar *, count); + g_value_set_pointer (value, array); - for (j = 0; j < args[i-1].value.pdb_int; j++) - stringarray[j] = g_strdup (params[i].data.d_stringarray[j]); + for (j = 0; j < count; j++) + array[j] = g_strdup (params[i].data.d_stringarray[j]); } else { - args[i].value.pdb_pointer = params[i].data.d_stringarray; + g_value_set_pointer (value, params[i].data.d_stringarray); } break; + case GIMP_PDB_COLOR: - args[i].value.pdb_color = params[i].data.d_color; + gimp_value_set_rgb (value, ¶ms[i].data.d_color); break; + case GIMP_PDB_REGION: g_message ("the \"region\" argument type is not supported"); break; + case GIMP_PDB_DISPLAY: - args[i].value.pdb_int = params[i].data.d_display; + g_value_set_int (value, params[i].data.d_display); break; + case GIMP_PDB_IMAGE: - args[i].value.pdb_int = params[i].data.d_image; + g_value_set_int (value, params[i].data.d_image); break; + case GIMP_PDB_LAYER: - args[i].value.pdb_int = params[i].data.d_layer; + g_value_set_int (value, params[i].data.d_layer); break; + case GIMP_PDB_CHANNEL: - args[i].value.pdb_int = params[i].data.d_channel; + g_value_set_int (value, params[i].data.d_channel); break; + case GIMP_PDB_DRAWABLE: - args[i].value.pdb_int = params[i].data.d_drawable; + g_value_set_int (value, params[i].data.d_drawable); break; + case GIMP_PDB_SELECTION: - args[i].value.pdb_int = params[i].data.d_selection; + g_value_set_int (value, params[i].data.d_selection); break; + case GIMP_PDB_BOUNDARY: - args[i].value.pdb_int = params[i].data.d_boundary; + g_message ("the \"boundary\" arg type is not currently supported"); break; + case GIMP_PDB_VECTORS: - args[i].value.pdb_int = params[i].data.d_vectors; + g_value_set_int (value, params[i].data.d_vectors); break; + case GIMP_PDB_PARASITE: if (full_copy) - args[i].value.pdb_pointer = - gimp_parasite_copy ((GimpParasite *) &(params[i].data.d_parasite)); + g_value_set_boxed (value, ¶ms[i].data.d_parasite); else - args[i].value.pdb_pointer = (gpointer) &(params[i].data.d_parasite); + g_value_set_static_boxed (value, ¶ms[i].data.d_parasite); break; + case GIMP_PDB_STATUS: - args[i].value.pdb_int = params[i].data.d_status; + g_value_set_enum (value, params[i].data.d_status); break; + case GIMP_PDB_END: break; } @@ -189,176 +239,208 @@ plug_in_params_to_args (GPParam *params GPParam * plug_in_args_to_params (Argument *args, - gint nargs, + gint n_args, gboolean full_copy) { GPParam *params; - gchar **stringarray; - gint i, j; + gint count; + gint i; + + g_return_val_if_fail ((args != NULL && n_args > 0) || + (args == NULL && n_args == 0), NULL); - if (! (args && nargs)) + if (! args) return NULL; - params = g_new0 (GPParam, nargs); + params = g_new0 (GPParam, n_args); - for (i = 0; i < nargs; i++) + for (i = 0; i < n_args; i++) { + GValue *value = &args[i].value; + params[i].type = args[i].arg_type; switch (args[i].arg_type) { case GIMP_PDB_INT32: - params[i].data.d_int32 = args[i].value.pdb_int; + if (G_VALUE_HOLDS_INT (value)) + params[i].data.d_int32 = g_value_get_int (value); + else if (G_VALUE_HOLDS_ENUM (value)) + params[i].data.d_int32 = g_value_get_enum (value); + else if (G_VALUE_HOLDS_BOOLEAN (value)) + params[i].data.d_int32 = g_value_get_boolean (value); + else + { + g_printerr ("unhandled GIMP_PDB_INT32 type: %s\n", + g_type_name (value->g_type)); + g_return_val_if_reached (params); + } break; + case GIMP_PDB_INT16: - params[i].data.d_int16 = args[i].value.pdb_int; + params[i].data.d_int16 = g_value_get_int (value); break; + case GIMP_PDB_INT8: - params[i].data.d_int8 = args[i].value.pdb_int; + params[i].data.d_int8 = g_value_get_int (value); break; + case GIMP_PDB_FLOAT: - params[i].data.d_float = args[i].value.pdb_float; + params[i].data.d_float = g_value_get_double (value); break; + case GIMP_PDB_STRING: if (full_copy) - params[i].data.d_string = g_strdup (args[i].value.pdb_pointer); + params[i].data.d_string = g_value_dup_string (value); else - params[i].data.d_string = args[i].value.pdb_pointer; + params[i].data.d_string = (gchar *) g_value_get_string (value); break; + case GIMP_PDB_INT32ARRAY: if (full_copy) { - params[i].data.d_int32array = g_new (gint32, params[i-1].data.d_int32); - memcpy (params[i].data.d_int32array, - args[i].value.pdb_pointer, - params[i-1].data.d_int32 * 4); + count = g_value_get_int (&args[i - 1].value); + params[i].data.d_int32array = + g_memdup (g_value_get_pointer (value), + count * sizeof (gint32)); } else { - params[i].data.d_int32array = args[i].value.pdb_pointer; + params[i].data.d_int32array = g_value_get_pointer (value); } break; + case GIMP_PDB_INT16ARRAY: if (full_copy) { - params[i].data.d_int16array = g_new (gint16, params[i-1].data.d_int32); - memcpy (params[i].data.d_int16array, - args[i].value.pdb_pointer, - params[i-1].data.d_int32 * 2); + count = g_value_get_int (&args[i - 1].value); + params[i].data.d_int16array = + g_memdup (g_value_get_pointer (value), + count * sizeof (gint16)); } else { - params[i].data.d_int16array = args[i].value.pdb_pointer; + params[i].data.d_int16array = g_value_get_pointer (value); } break; + case GIMP_PDB_INT8ARRAY: if (full_copy) { - params[i].data.d_int8array = g_new (gint8, params[i-1].data.d_int32); - memcpy (params[i].data.d_int8array, - args[i].value.pdb_pointer, - params[i-1].data.d_int32); + count = g_value_get_int (&args[i - 1].value); + params[i].data.d_int8array = + g_memdup (g_value_get_pointer (value), count); } else { - params[i].data.d_int8array = args[i].value.pdb_pointer; + params[i].data.d_int8array = g_value_get_pointer (value); } break; + case GIMP_PDB_FLOATARRAY: if (full_copy) { - params[i].data.d_floatarray = g_new (gdouble, params[i-1].data.d_int32); - memcpy (params[i].data.d_floatarray, - args[i].value.pdb_pointer, - params[i-1].data.d_int32 * 8); + count = g_value_get_int (&args[i - 1].value); + params[i].data.d_floatarray = + g_memdup (g_value_get_pointer (value), + count * sizeof (gdouble)); } else { - params[i].data.d_floatarray = args[i].value.pdb_pointer; + params[i].data.d_floatarray = g_value_get_pointer (value); } break; + case GIMP_PDB_STRINGARRAY: if (full_copy) { - params[i].data.d_stringarray = g_new (gchar*, params[i-1].data.d_int32); - stringarray = args[i].value.pdb_pointer; + gchar **array; + gint j; + + count = g_value_get_int (&args[i - 1].value); - for (j = 0; j < params[i-1].data.d_int32; j++) - params[i].data.d_stringarray[j] = g_strdup (stringarray[j]); + array = g_value_get_pointer (value); + params[i].data.d_stringarray = g_new (gchar *, count); + + for (j = 0; j < count; j++) + params[i].data.d_stringarray[j] = g_strdup (array[j]); } else { - params[i].data.d_stringarray = args[i].value.pdb_pointer; + params[i].data.d_stringarray = g_value_get_pointer (value); } break; + case GIMP_PDB_COLOR: - params[i].data.d_color = args[i].value.pdb_color; + gimp_value_get_rgb (value, ¶ms[i].data.d_color); break; + case GIMP_PDB_REGION: g_message ("the \"region\" argument type is not supported"); break; + case GIMP_PDB_DISPLAY: - params[i].data.d_display = args[i].value.pdb_int; + params[i].data.d_display = g_value_get_int (value); break; + case GIMP_PDB_IMAGE: - params[i].data.d_image = args[i].value.pdb_int; + params[i].data.d_image = g_value_get_int (value); break; + case GIMP_PDB_LAYER: - params[i].data.d_layer = args[i].value.pdb_int; + params[i].data.d_layer = g_value_get_int (value); break; + case GIMP_PDB_CHANNEL: - params[i].data.d_channel = args[i].value.pdb_int; + params[i].data.d_channel = g_value_get_int (value); break; + case GIMP_PDB_DRAWABLE: - params[i].data.d_drawable = args[i].value.pdb_int; + params[i].data.d_drawable = g_value_get_int (value); break; + case GIMP_PDB_SELECTION: - params[i].data.d_selection = args[i].value.pdb_int; + params[i].data.d_selection = g_value_get_int (value); break; + case GIMP_PDB_BOUNDARY: - params[i].data.d_boundary = args[i].value.pdb_int; + g_message ("the \"boundary\" arg type is not currently supported"); break; + case GIMP_PDB_VECTORS: - params[i].data.d_vectors = args[i].value.pdb_int; + params[i].data.d_vectors = g_value_get_int (value); break; - case GIMP_PDB_PARASITE: - if (full_copy) - { - GimpParasite *tmp; - tmp = gimp_parasite_copy (args[i].value.pdb_pointer); - if (tmp == NULL) - { - params[i].data.d_parasite.name = NULL; - params[i].data.d_parasite.flags = 0; - params[i].data.d_parasite.size = 0; - params[i].data.d_parasite.data = NULL; - } - else - { - memcpy (¶ms[i].data.d_parasite, tmp, - sizeof (GimpParasite)); - g_free (tmp); - } - } - else - { - if (args[i].value.pdb_pointer == NULL) - { - params[i].data.d_parasite.name = NULL; - params[i].data.d_parasite.flags = 0; - params[i].data.d_parasite.size = 0; - params[i].data.d_parasite.data = NULL; - } - else - memcpy (¶ms[i].data.d_parasite, - (GimpParasite *) (args[i].value.pdb_pointer), - sizeof (GimpParasite)); - } + case GIMP_PDB_PARASITE: + { + GimpParasite *parasite = (full_copy ? + g_value_dup_boxed (value) : + g_value_get_boxed (value)); + + if (parasite) + { + params[i].data.d_parasite.name = parasite->name; + params[i].data.d_parasite.flags = parasite->flags; + params[i].data.d_parasite.size = parasite->size; + params[i].data.d_parasite.data = parasite->data; + + if (full_copy) + g_free (parasite); + } + else + { + params[i].data.d_parasite.name = NULL; + params[i].data.d_parasite.flags = 0; + params[i].data.d_parasite.size = 0; + params[i].data.d_parasite.data = NULL; + } + } break; + case GIMP_PDB_STATUS: - params[i].data.d_status = args[i].value.pdb_int; + params[i].data.d_status = g_value_get_enum (value); break; + case GIMP_PDB_END: break; } @@ -369,14 +451,14 @@ plug_in_args_to_params (Argument *args, void plug_in_params_destroy (GPParam *params, - gint nparams, + gint n_params, gboolean full_destroy) { gint i, j; if (full_destroy) { - for (i = 0; i < nparams; i++) + for (i = 0; i < n_params; i++) { switch (params[i].type) { @@ -389,28 +471,36 @@ plug_in_params_destroy (GPParam *params case GIMP_PDB_STRING: g_free (params[i].data.d_string); break; + case GIMP_PDB_INT32ARRAY: g_free (params[i].data.d_int32array); break; + case GIMP_PDB_INT16ARRAY: g_free (params[i].data.d_int16array); break; + case GIMP_PDB_INT8ARRAY: g_free (params[i].data.d_int8array); break; + case GIMP_PDB_FLOATARRAY: g_free (params[i].data.d_floatarray); break; + case GIMP_PDB_STRINGARRAY: for (j = 0; j < params[i-1].data.d_int32; j++) g_free (params[i].data.d_stringarray[j]); g_free (params[i].data.d_stringarray); break; + case GIMP_PDB_COLOR: break; + case GIMP_PDB_REGION: g_message ("the \"region\" argument type is not supported"); break; + case GIMP_PDB_DISPLAY: case GIMP_PDB_IMAGE: case GIMP_PDB_LAYER: @@ -418,8 +508,12 @@ plug_in_params_destroy (GPParam *params case GIMP_PDB_DRAWABLE: case GIMP_PDB_SELECTION: case GIMP_PDB_BOUNDARY: + g_message ("the \"boundary\" arg type is not currently supported"); + break; + case GIMP_PDB_VECTORS: break; + case GIMP_PDB_PARASITE: if (params[i].data.d_parasite.data) { @@ -428,9 +522,9 @@ plug_in_params_destroy (GPParam *params params[i].data.d_parasite.name = NULL; params[i].data.d_parasite.data = NULL; } - break; - case GIMP_PDB_STATUS: break; + + case GIMP_PDB_STATUS: case GIMP_PDB_END: break; } @@ -440,17 +534,6 @@ plug_in_params_destroy (GPParam *params g_free (params); } -void -plug_in_args_destroy (Argument *args, - gint nargs, - gboolean full_destroy) -{ - if (full_destroy) - procedural_db_destroy_args (args, nargs); - else - g_free (args); -} - gboolean plug_in_param_defs_check (const gchar *plug_in_name, const gchar *plug_in_prog, @@ -462,15 +545,33 @@ plug_in_param_defs_check (const gchar *p guint32 n_return_vals, GError **error) { - return plug_in_proc_args_check (plug_in_name, - plug_in_prog, - procedure_name, - menu_path, - (ProcArg *) params, - n_args, - (ProcArg *) return_vals, - n_return_vals, - error); + ProcArg *args; + ProcArg *return_args; + gboolean success; + gint i; + + args = g_new0 (ProcArg, n_args); + for (i = 0; i < n_args; i++) + args[i].arg_type = params[i].type; + + return_args = g_new0 (ProcArg, n_return_vals); + for (i = 0; i < n_return_vals; i++) + return_args[i].arg_type = return_vals[i].type; + + success = plug_in_proc_args_check (plug_in_name, + plug_in_prog, + procedure_name, + menu_path, + args, + n_args, + return_args, + n_return_vals, + error); + + g_free (args); + g_free (return_args); + + return success; } gboolean Index: app/plug-in/plug-in-params.h =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-params.h,v retrieving revision 1.40 diff -u -p -r1.40 plug-in-params.h --- app/plug-in/plug-in-params.h 7 May 2004 00:30:23 -0000 1.40 +++ app/plug-in/plug-in-params.h 29 Mar 2006 22:02:02 -0000 @@ -20,7 +20,9 @@ #define __PLUG_IN_PARAMS_H__ -Argument * plug_in_params_to_args (GPParam *params, +Argument * plug_in_params_to_args (ProcArg *proc_args, + gint n_proc_args, + GPParam *params, gint n_params, gboolean full_copy); GPParam * plug_in_args_to_params (Argument *args, @@ -29,9 +31,6 @@ GPParam * plug_in_args_to_params (Arg void plug_in_params_destroy (GPParam *params, gint n_params, - gboolean full_destroy); -void plug_in_args_destroy (Argument *args, - gint n_args, gboolean full_destroy); gboolean plug_in_param_defs_check (const gchar *plug_in_name, Index: app/plug-in/plug-in-progress.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-progress.c,v retrieving revision 1.204 diff -u -p -r1.204 plug-in-progress.c --- app/plug-in/plug-in-progress.c 23 Mar 2006 21:56:11 -0000 1.204 +++ app/plug-in/plug-in-progress.c 29 Mar 2006 22:02:02 -0000 @@ -307,11 +307,10 @@ plug_in_progress_cancel_callback (GimpPr if (proc_frame->main_loop) { - proc_frame->return_vals = g_new (Argument, 1); + proc_frame->return_vals = procedural_db_return_values (NULL, FALSE); proc_frame->n_return_vals = 1; - proc_frame->return_vals->arg_type = GIMP_PDB_STATUS; - proc_frame->return_vals->value.pdb_int = GIMP_PDB_CANCEL; + g_value_set_enum (&proc_frame->return_vals->value, GIMP_PDB_CANCEL); } for (list = plug_in->temp_proc_frames; list; list = g_list_next (list)) @@ -320,11 +319,10 @@ plug_in_progress_cancel_callback (GimpPr if (proc_frame->main_loop) { - proc_frame->return_vals = g_new (Argument, 1); + proc_frame->return_vals = procedural_db_return_values (NULL, FALSE); proc_frame->n_return_vals = 1; - proc_frame->return_vals->arg_type = GIMP_PDB_STATUS; - proc_frame->return_vals->value.pdb_int = GIMP_PDB_CANCEL; + g_value_set_enum (&proc_frame->return_vals->value, GIMP_PDB_CANCEL); } } Index: app/plug-in/plug-in-run.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-run.c,v retrieving revision 1.228 diff -u -p -r1.228 plug-in-run.c --- app/plug-in/plug-in-run.c 28 Mar 2006 17:55:51 -0000 1.228 +++ app/plug-in/plug-in-run.c 29 Mar 2006 22:02:02 -0000 @@ -57,7 +57,8 @@ static Argument * plug_in_temp_run Argument *args, gint n_args); static Argument * plug_in_get_return_vals (PlugIn *plug_in, - PlugInProcFrame *proc_frame); + PlugInProcFrame *proc_frame, + gint *n_return_vals); /* public functions */ @@ -73,7 +74,8 @@ plug_in_run (Gimp *gimp, gboolean destroy_return_vals, gint display_ID) { - Argument *return_vals = NULL; + Argument *return_vals = NULL; + gint n_return_vals = 0; PlugIn *plug_in; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); @@ -179,7 +181,8 @@ plug_in_run (Gimp *gimp, plug_in->main_proc_frame.main_loop = NULL; return_vals = plug_in_get_return_vals (plug_in, - &plug_in->main_proc_frame); + &plug_in->main_proc_frame, + &n_return_vals); } plug_in_unref (plug_in); @@ -188,7 +191,7 @@ plug_in_run (Gimp *gimp, done: if (return_vals && destroy_return_vals) { - procedural_db_destroy_args (return_vals, proc_rec->num_values); + procedural_db_destroy_args (return_vals, proc_rec->num_values, TRUE); return_vals = NULL; } @@ -220,17 +223,18 @@ plug_in_repeat (Gimp *gimp, /* construct the procedures arguments */ args = procedural_db_arguments (&proc_def->db_info); - args[0].value.pdb_int = (with_interface ? - GIMP_RUN_INTERACTIVE : GIMP_RUN_WITH_LAST_VALS); - args[1].value.pdb_int = image_ID; - args[2].value.pdb_int = drawable_ID; + g_value_set_int (&args[0].value, + with_interface ? + GIMP_RUN_INTERACTIVE : GIMP_RUN_WITH_LAST_VALS); + g_value_set_int (&args[1].value, image_ID); + g_value_set_int (&args[2].value, drawable_ID); /* run the plug-in procedure */ plug_in_run (gimp, context, progress, &proc_def->db_info, args, 3 /* not proc_def->db_info.num_args */, FALSE, TRUE, display_ID); - g_free (args); + procedural_db_destroy_args (args, proc_def->db_info.num_args, TRUE); } } @@ -244,7 +248,8 @@ plug_in_temp_run (ProcRecord *proc_rec Argument *args, gint n_args) { - Argument *return_vals = NULL; + Argument *return_vals = NULL; + gint n_return_vals = 0; PlugIn *plug_in; plug_in = (PlugIn *) proc_rec->exec_method.temporary.plug_in; @@ -278,7 +283,8 @@ plug_in_temp_run (ProcRecord *proc_rec plug_in_main_loop (plug_in); - return_vals = plug_in_get_return_vals (plug_in, proc_frame); + return_vals = plug_in_get_return_vals (plug_in, proc_frame, + &n_return_vals); /* main_loop is quit and proc_frame is popped in * plug_in_handle_temp_proc_return() @@ -294,18 +300,20 @@ plug_in_temp_run (ProcRecord *proc_rec static Argument * plug_in_get_return_vals (PlugIn *plug_in, - PlugInProcFrame *proc_frame) + PlugInProcFrame *proc_frame, + gint *n_return_vals) { Argument *return_vals; - gint nargs; g_return_val_if_fail (plug_in != NULL, NULL); g_return_val_if_fail (proc_frame != NULL, NULL); + g_return_val_if_fail (n_return_vals != NULL, NULL); /* Return the status code plus the current return values. */ - nargs = proc_frame->proc_rec->num_values + 1; + *n_return_vals = proc_frame->proc_rec->num_values + 1; - if (proc_frame->return_vals && proc_frame->n_return_vals == nargs) + if (proc_frame->return_vals && + proc_frame->n_return_vals == *n_return_vals) { return_vals = proc_frame->return_vals; } @@ -316,7 +324,8 @@ plug_in_get_return_vals (PlugIn /* Copy all of the arguments we can. */ memcpy (return_vals, proc_frame->return_vals, - sizeof (Argument) * MIN (proc_frame->n_return_vals, nargs)); + sizeof (Argument) * MIN (proc_frame->n_return_vals, + *n_return_vals)); /* Free the old argument pointer. This will cause a memory leak * only if there were more values returned than we need (which Index: app/plug-in/plug-in-run.h =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-run.h,v retrieving revision 1.7 diff -u -p -r1.7 plug-in-run.h --- app/plug-in/plug-in-run.h 28 Mar 2006 17:59:17 -0000 1.7 +++ app/plug-in/plug-in-run.h 29 Mar 2006 22:02:02 -0000 @@ -29,7 +29,7 @@ Argument * plug_in_run (Gimp GimpProgress *progress, ProcRecord *proc_rec, Argument *args, - gint argc, + gint n_args, gboolean synchronous, gboolean destroy_return_vals, gint display_ID); Index: app/plug-in/plug-in.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-in.c,v retrieving revision 1.245 diff -u -p -r1.245 plug-in.c --- app/plug-in/plug-in.c 29 Mar 2006 10:45:18 -0000 1.245 +++ app/plug-in/plug-in.c 29 Mar 2006 22:02:03 -0000 @@ -1091,4 +1091,3 @@ plug_in_menu_register (PlugIn *plug return TRUE; } - Index: app/plug-in/plug-ins.c =================================================================== RCS file: /cvs/gnome/gimp/app/plug-in/plug-ins.c,v retrieving revision 1.245 diff -u -p -r1.245 plug-ins.c --- app/plug-in/plug-ins.c 27 Mar 2006 11:40:00 -0000 1.245 +++ app/plug-in/plug-ins.c 29 Mar 2006 22:02:03 -0000 @@ -1082,7 +1082,7 @@ plug_ins_add_to_db (Gimp *gimp, GIMP_PDB_END); } - procedural_db_destroy_args (return_vals, n_return_vals); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); } } } Index: app/widgets/gimphelp.c =================================================================== RCS file: /cvs/gnome/gimp/app/widgets/gimphelp.c,v retrieving revision 1.74 diff -u -p -r1.74 gimphelp.c --- app/widgets/gimphelp.c 27 Mar 2006 21:04:35 -0000 1.74 +++ app/widgets/gimphelp.c 29 Mar 2006 22:02:03 -0000 @@ -195,12 +195,12 @@ gimp_help_browser (Gimp *gimp) args = procedural_db_arguments (proc_rec); - args[0].value.pdb_int = GIMP_RUN_INTERACTIVE; + g_value_set_enum (&args[0].value, GIMP_RUN_INTERACTIVE); plug_in_run (gimp, gimp_get_user_context (gimp), NULL, proc_rec, args, 1, FALSE, TRUE, -1); - procedural_db_destroy_args (args, 1); + procedural_db_destroy_args (args, 1, TRUE); } /* Check if the help browser started properly */ @@ -280,15 +280,15 @@ gimp_help_call (Gimp *gimp, args = procedural_db_arguments (proc_rec); - args[0].value.pdb_int = n_domains; - args[1].value.pdb_pointer = help_domains; - args[2].value.pdb_int = n_domains; - args[3].value.pdb_pointer = help_uris; + g_value_set_int (&args[0].value, n_domains); + g_value_set_pointer (&args[1].value, help_domains); + g_value_set_int (&args[2].value, n_domains); + g_value_set_pointer (&args[3].value, help_uris); plug_in_run (gimp, gimp_get_user_context (gimp), NULL, proc_rec, args, 4, FALSE, TRUE, -1); - procedural_db_destroy_args (args, 4); + procedural_db_destroy_args (args, 4, TRUE); } /* Check if the help parser started properly */ @@ -319,7 +319,7 @@ gimp_help_call (Gimp *gimp, GIMP_PDB_STRING, help_id, GIMP_PDB_END); - procedural_db_destroy_args (return_vals, n_return_vals); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); } } Index: app/widgets/gimppdbdialog.c =================================================================== RCS file: /cvs/gnome/gimp/app/widgets/gimppdbdialog.c,v retrieving revision 1.5 diff -u -p -r1.5 gimppdbdialog.c --- app/widgets/gimppdbdialog.c 18 Jan 2006 20:29:40 -0000 1.5 +++ app/widgets/gimppdbdialog.c 29 Mar 2006 22:02:03 -0000 @@ -315,7 +315,7 @@ gimp_pdb_dialog_run_callback (GimpPdbDia &n_return_vals); if (! return_vals || - return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS) + g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS) { g_message (_("Unable to run %s callback. " "The corresponding plug-in may have crashed."), @@ -323,7 +323,7 @@ gimp_pdb_dialog_run_callback (GimpPdbDia } if (return_vals) - procedural_db_destroy_args (return_vals, n_return_vals); + procedural_db_destroy_args (return_vals, n_return_vals, TRUE); } dialog->callback_busy = FALSE; Index: app/xcf/xcf.c =================================================================== RCS file: /cvs/gnome/gimp/app/xcf/xcf.c,v retrieving revision 1.138 diff -u -p -r1.138 xcf.c --- app/xcf/xcf.c 28 Mar 2006 19:58:00 -0000 1.138 +++ app/xcf/xcf.c 29 Mar 2006 22:02:03 -0000 @@ -31,6 +31,7 @@ #include "core/gimp.h" #include "core/gimpimage.h" +#include "core/gimpparamspecs.h" #include "pdb/procedural_db.h" @@ -231,7 +232,7 @@ xcf_load_invoker (ProcRecord *procedur gimp_set_busy (gimp); - filename = args[1].value.pdb_pointer; + filename = g_value_get_string (&args[1].value); info.fp = g_fopen (filename, "rb"); @@ -296,7 +297,7 @@ xcf_load_invoker (ProcRecord *procedur return_vals = procedural_db_return_values (procedure, success); if (success) - return_vals[1].value.pdb_int = gimp_image_get_ID (image); + gimp_value_set_image (&return_vals[1].value, image); gimp_unset_busy (gimp); @@ -318,8 +319,8 @@ xcf_save_invoker (ProcRecord *procedur gimp_set_busy (gimp); - image = gimp_image_get_by_ID (gimp, args[1].value.pdb_int); - filename = args[3].value.pdb_pointer; + image = gimp_value_get_image (&args[1].value, gimp); + filename = g_value_get_string (&args[3].value); info.fp = g_fopen (filename, "wb"); Index: tools/pdbgen/app.pl =================================================================== RCS file: /cvs/gnome/gimp/tools/pdbgen/app.pl,v retrieving revision 1.81 diff -u -p -r1.81 app.pl --- tools/pdbgen/app.pl 29 Mar 2006 20:27:46 -0000 1.81 +++ tools/pdbgen/app.pl 29 Mar 2006 22:02:04 -0000 @@ -21,8 +21,6 @@ $destdir = "$main::destdir/app/pdb"; *arg_types = \%Gimp::CodeGen::pdb::arg_types; *arg_parse = \&Gimp::CodeGen::pdb::arg_parse; -*arg_ptype = \&Gimp::CodeGen::pdb::arg_ptype; -*arg_vname = \&Gimp::CodeGen::pdb::arg_vname; *enums = \%Gimp::CodeGen::enums::enums; @@ -61,33 +59,6 @@ sub format_code_frag { $code; } -sub arg_value { - my ($arg, $argc) = @_; - my $cast = ""; - - my $type = &arg_ptype($arg); - - if ($type eq 'pointer' || $arg->{type} =~ /int(16|8)$/) { - $cast = "($arg->{type}) "; - } - - return "${cast}args[$argc].value.pdb_$type"; -} - -sub make_arg_test { - my ($arg, $reverse, $test) = @_; - my $result = ""; - - if (!exists $arg->{no_success}) { - $result .= ' ' x 2 . "if ($test)\n"; - $result .= ' ' x 4 . "success = FALSE;\n"; - - $success = 1; - } - - $result; -} - sub declare_args { my $proc = shift; my $out = shift; @@ -107,7 +78,7 @@ sub declare_args { } unless (exists $_->{no_declare}) { - $result .= ' ' x 2 . $arg->{type} . &arg_vname($_); + $result .= ' ' x 2 . $arg->{type} . $_->{name}; if ($init) { $result .= " = $arg->{init_value}"; } @@ -161,168 +132,20 @@ sub marshal_inargs { foreach (@inargs) { my($pdbtype, @typeinfo) = &arg_parse($_->{type}); my $arg = $arg_types{$pdbtype}; - my $var = &arg_vname($_); - my $value = &arg_value($arg, $argc++); - - if (exists $arg->{id_func}) { - my $id_func = $arg->{id_func}; + my $var = $_->{name}; + my $value; - $result .= " $var = $id_func (gimp, $value);\n"; + $value = "&args[$argc].value"; + $result .= eval qq/" $arg->{get_value_func};\n"/; - if (exists $arg->{check_func}) { - my $check_func = eval qq/"$arg->{check_func}"/; + $argc++; - $result .= &make_arg_test($_, sub { ${$_[0]} =~ s/==/!=/ }, - "! $check_func"); - } else { - $result .= &make_arg_test($_, sub { ${$_[0]} =~ s/==/!=/ }, - "$var == NULL"); - } + if (!exists $_->{no_success}) { + $success = 1; } - else { - $result .= ' ' x 2 . "$var = $value"; - $result .= ' ? TRUE : FALSE' if $pdbtype eq 'boolean'; - $result .= ";\n"; - - if ($pdbtype eq 'string' || $pdbtype eq 'parasite') { - my ($reverse, $test, $utf8, $utf8testvar); - - $test = "$var == NULL"; - $utf8 = 1; - - if ($pdbtype eq 'parasite') { - $test .= " || $var->name == NULL"; - $utf8testvar = "$var->name"; - } - else { - $utf8 = !exists $_->{no_validate}; - $utf8testvar = "$var"; - } - - if (exists $_->{null_ok}) { - $reverse = sub { ${$_[0]} =~ s/!//; }; - $test = "$var && !g_utf8_validate ($var, -1, NULL)"; - } - elsif ($utf8) { - $reverse = sub { ${$_[0]} =~ s/!//; - ${$_[0]} =~ s/||/&&/g; - ${$_[0]} =~ s/==/!=/g }; - $test .= " || !g_utf8_validate ($utf8testvar, -1, NULL)"; - } - else { - $reverse = sub { ${$_[0]} =~ s/||/&&/g; - ${$_[0]} =~ s/==/!=/g }; - } - - $result .= &make_arg_test($_, $reverse, $test); - } - elsif ($pdbtype eq 'tattoo') { - $result .= &make_arg_test($_, sub { ${$_[0]} =~ s/==/!=/ }, - "$var == 0"); - } - elsif ($pdbtype eq 'unit') { - $typeinfo[0] = 'GIMP_UNIT_PIXEL' unless defined $typeinfo[0]; - $result .= &make_arg_test($_, sub { ${$_[0]} = "!(${$_[0]})" }, - "$var < $typeinfo[0] || $var >= " . - '_gimp_unit_get_number_of_units (gimp)'); - } - elsif ($pdbtype eq 'enum' && !$enums{$typeinfo[0]}->{contig}) { - if (!exists $_->{no_success}) { - my %vals; my $symbols = $enums{pop @typeinfo}->{symbols}; - @vals{@$symbols}++; delete @vals{@typeinfo}; - - my $okvals = ""; my $failvals = ""; - - my $once = 0; - foreach (@$symbols) { - if (exists $vals{$_}) { - $okvals .= ' ' x 4 if $once++; - $okvals .= "case $_:\n"; - } - } - - $failvals .= "default:\n"; - if (!exists $_->{no_success}) { - $success = 1; - $failvals .= ' ' x 6 . "success = FALSE;\n" - } - - $result .= <{symbols}; - - my ($start, $end) = (0, $#$symbols); - - my $syms = "@$symbols "; my $test = $syms; - foreach (@typeinfo) { $test =~ s/$_ // } - - if ($syms =~ /$test/g) { - if (pos $syms == length $syms) { - $start = @typeinfo; - } - else { - $end -= @typeinfo; - } - } - else { - foreach (@typeinfo) { - $extra .= " || $var == $_"; - } - } - - $typeinfo[0] = $symbols->[$start]; - if ($start != $end) { - $typeinfo[1] = '<'; - $typeinfo[2] = $symbols->[$end]; - $typeinfo[3] = '>'; - } - else { - $typeinfo[1] = '!='; - undef @typeinf[2..3]; - } - } - elsif ($pdbtype eq 'float') { - foreach (@typeinfo[0, 2]) { - $_ .= '.0' if defined $_ && !/\./ - } - } - - if (defined $typeinfo[0]) { - $code .= "$var $typeinfo[1] $typeinfo[0]"; - $code .= '.0' if $pdbtype eq 'float' && $typeinfo[0] !~ /\./; - $tests++; - } - - if (defined $typeinfo[2]) { - $code .= ' || ' if $tests; - $code .= "$var $typeinfo[3] $typeinfo[2]"; - } - - $code .= $extra; - - $result .= &make_arg_test($_, sub { ${$_[0]} = "!(${$_[0]})" }, - $code); - } - } - - $result .= "\n"; - } - - $result = "\n" . $result if $result; + $result = "\n" . $result . "\n" if $result; $result; } @@ -342,16 +165,14 @@ CODE foreach (@{$proc->{outargs}}) { my ($pdbtype) = &arg_parse($_->{type}); my $arg = $arg_types{$pdbtype}; - my $type = &arg_ptype($arg); - my $var = &arg_vname($_); + my $var = $_->{name}; + my $value; - $argc++; $outargs .= ' ' x 2; + $argc++; - if (exists $arg->{id_ret_func}) { - $var = eval qq/"$arg->{id_ret_func}"/; - } + $value = "&return_vals[$argc].value"; - $outargs .= "return_vals[$argc].value.pdb_$type = $var;\n"; + $outargs .= eval qq/" $arg->{set_value_func};\n"/; } $outargs =~ s/^/' ' x 2/meg if $success; @@ -374,9 +195,7 @@ CODE sub generate_pspec { my $arg = shift; - - my($pdbtype, @typeinfo) = &arg_parse($arg->{type}); - + my ($pdbtype, @typeinfo) = &arg_parse($arg->{type}); my $name = $arg->{canonical_name}; my $nick = $arg->{canonical_name}; my $blurb = &make_desc($arg); @@ -385,6 +204,7 @@ sub generate_pspec { my $default; my $flags = 'GIMP_PARAM_READWRITE'; my $pspec = ""; + my $postproc = ""; $nick =~ s/-/ /g; @@ -566,7 +386,16 @@ CODE $enum_type =~ tr/[a-z]/[A-Z]/; $enum_type =~ s/^GIMP/GIMP_TYPE/; $default = exists $arg->{default} ? $arg->{default} : $enums{$typeinfo[0]}->{symbols}[0]; - $pspec = <{type}); + + foreach (@remove) { + $postproc .= 'gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM ($pspec),'; + $postproc .= "\n $_);\n"; + } + + if ($postproc eq '') { + $pspec = <{register} .= eval qq/"$postproc"/; + } + + $argc++; } foreach $arg (@outargs) { - my $pspec = &generate_pspec($arg); + my ($pspec, $postproc) = &generate_pspec($arg); + my $argc = 0; $pspec =~ s/^/' ' x length(" procedural_db_add_return_value (")/meg; @@ -676,6 +526,14 @@ CODE procedural_db_add_return_value (procedure, ${pspec}); CODE + + if (! ($postproc eq '')) { + $pspec = "procedure->values[$argc].pspec"; + $postproc =~ s/^/' '/meg; + $out->{register} .= eval qq/"$postproc"/; + } + + $argc++; } $out->{register} .= <{type}); my $argtype = $arg_types{$type}; - if (exists $argtype->{id_func} || $arg->{type} =~ /guide/) { + if (exists $argtype->{id}) { return 'gint32 '; } @@ -131,7 +131,7 @@ sub generate { my ($type) = &arg_parse($_->{type}); my $desc = &desc_clean($_->{desc}); my $arg = $arg_types{$type}; - my $id = exists $arg->{id_func} || $_->{type} =~ /guide/; + my $id = exists $arg->{id}; $wrapped = "_" if exists $_->{wrap}; $attribute = " G_GNUC_INTERNAL" if exists $_->{wrap}; @@ -184,7 +184,7 @@ sub generate { foreach (@outargs) { my ($type) = &arg_parse($_->{type}); my $arg = $arg_types{$type}; - my $id = $arg->{id_ret_func} || $_->{type} =~ /guide/; + my $id = $arg->{id}; my $var; $return_marshal = "" unless $once++; @@ -277,7 +277,7 @@ CODE my ($type) = &arg_parse($_->{type}); my $desc = &desc_clean($_->{desc}); my $arg = $arg_types{$type}; - my $id = $arg->{id_ret_func} || $_->{type} =~ /guide/; + my $id = $arg->{id}; my $var; my $ch = ""; my $cf = ""; Index: tools/pdbgen/pdb.pl =================================================================== RCS file: /cvs/gnome/gimp/tools/pdbgen/pdb.pl,v retrieving revision 1.37 diff -u -p -r1.37 pdb.pl --- tools/pdbgen/pdb.pl 17 Mar 2006 14:09:19 -0000 1.37 +++ tools/pdbgen/pdb.pl 29 Mar 2006 22:02:04 -0000 @@ -18,98 +18,165 @@ package Gimp::CodeGen::pdb; %arg_types = ( - int32 => { name => 'INT32', type => 'gint32 ', init_value => '0' }, - int16 => { name => 'INT16', type => 'gint16 ', init_value => '0' }, - int8 => { name => 'INT8' , type => 'guint8 ', init_value => '0' }, - - float => { name => 'FLOAT' , type => 'gdouble ', init_value => '0.0' }, - string => { name => 'STRING', type => 'gchar *', init_value => 'NULL' }, - - int32array => { name => 'INT32ARRAY' , type => 'gint32 *' , array => 1, - init_value => 'NULL' }, - int16array => { name => 'INT16ARRAY' , type => 'gint16 *' , array => 1, - init_value => 'NULL' }, - int8array => { name => 'INT8ARRAY' , type => 'guint8 *' , array => 1, - init_value => 'NULL' }, - floatarray => { name => 'FLOATARRAY' , type => 'gdouble *', array => 1, - init_value => 'NULL' }, - stringarray => { name => 'STRINGARRAY', type => 'gchar **' , array => 1, - init_value => 'NULL' }, - - color => { name => 'COLOR' , - type => 'GimpRGB ', - init_value => '{ 0.0, 0.0, 0.0, 1.0 }', - headers => [ qw("libgimpcolor/gimpcolor.h") ], - struct => 1 }, - display => { name => 'DISPLAY', - type => 'GimpObject *', - init_value => 'NULL', - id_func => 'gimp_get_display_by_ID', - id_ret_func => '$var ? gimp_get_display_ID (gimp, $var) : -1', - check_func => 'GIMP_IS_OBJECT ($var)' }, - image => { name => 'IMAGE', - type => 'GimpImage *', - init_value => 'NULL', - headers => [ qw("core/gimpimage.h") ], - id_func => 'gimp_image_get_by_ID', - id_ret_func => '$var ? gimp_image_get_ID ($var) : -1', - check_func => 'GIMP_IS_IMAGE ($var)' }, - layer => { name => 'LAYER', - type => 'GimpLayer *', - init_value => 'NULL', - headers => [ qw("core/gimplayer.h") ], - id_func => '(GimpLayer *) gimp_item_get_by_ID', - id_ret_func => '$var ? gimp_item_get_ID (GIMP_ITEM ($var)) : -1', - check_func => '(GIMP_IS_LAYER ($var) && ! gimp_item_is_removed (GIMP_ITEM ($var)))' }, - channel => { name => 'CHANNEL', - type => 'GimpChannel *', - init_value => 'NULL', - headers => [ qw("core/gimpchannel.h") ], - id_func => '(GimpChannel *) gimp_item_get_by_ID', - id_ret_func => '$var ? gimp_item_get_ID (GIMP_ITEM ($var)) : -1', - check_func => '(GIMP_IS_CHANNEL ($var) && ! gimp_item_is_removed (GIMP_ITEM ($var)))' }, - drawable => { name => 'DRAWABLE', - type => 'GimpDrawable *', - init_value => 'NULL', - headers => [ qw("core/gimpdrawable.h") ], - id_func => '(GimpDrawable *) gimp_item_get_by_ID', - id_ret_func => '$var ? gimp_item_get_ID (GIMP_ITEM ($var)) : -1', - check_func => '(GIMP_IS_DRAWABLE ($var) && ! gimp_item_is_removed (GIMP_ITEM ($var)))' }, - selection => { name => 'SELECTION', - type => 'GimpChannel *', - init_value => 'NULL', - headers => [ qw("core/gimpchannel.h") ], - id_func => '(GimpChannel *) gimp_item_get_by_ID', - id_ret_func => '$var ? gimp_item_get_ID (GIMP_ITEM ($var)) : -1', - check_func => '(GIMP_IS_CHANNEL ($var) && ! gimp_item_is_removed (GIMP_ITEM ($var)))' }, - layer_mask => { name => 'CHANNEL', - type => 'GimpLayerMask *', - init_value => 'NULL', - headers => [ qw("core/gimplayermask.h") ], - id_func => '(GimpLayerMask *) gimp_item_get_by_ID', - id_ret_func => '$var ? gimp_item_get_ID (GIMP_ITEM ($var)) : -1', - check_func => '(GIMP_IS_LAYER_MASK ($var) && ! gimp_item_is_removed (GIMP_ITEM ($var)))' }, - vectors => { name => 'VECTORS', - type => 'GimpVectors *', - init_value => 'NULL', - headers => [ qw("vectors/gimpvectors.h") ], - id_func => '(GimpVectors *) gimp_item_get_by_ID', - id_ret_func => '$var ? gimp_item_get_ID (GIMP_ITEM ($var)) : -1', - check_func => '(GIMP_IS_VECTORS ($var) && ! gimp_item_is_removed (GIMP_ITEM ($var)))' }, - parasite => { name => 'PARASITE', - type => 'GimpParasite *', - init_value => 'NULL', - headers => [ qw("libgimpbase/gimpbase.h") ] }, + int32 => { name => 'INT32', + type => 'gint32 ', + init_value => '0', + get_value_func => '$var = g_value_get_int ($value)', + set_value_func => 'g_value_set_int ($value, $var)' }, + int16 => { name => 'INT16', + type => 'gint16 ', + init_value => '0', + get_value_func => '$var = g_value_get_int ($value)', + set_value_func => 'g_value_set_int ($value, $var)' }, + int8 => { name => 'INT8' , + type => 'guint8 ', + init_value => '0', + get_value_func => '$var = g_value_get_int ($value)', + set_value_func => 'g_value_set_int ($value, $var)' }, + + float => { name => 'FLOAT', + type => 'gdouble ', + init_value => '0.0', + get_value_func => '$var = g_value_get_double ($value)', + set_value_func => 'g_value_set_double ($value, $var)' }, + string => { name => 'STRING', + type => 'gchar *', + init_value => 'NULL', + get_value_func => '$var = (gchar *) g_value_get_string ($value)', + set_value_func => 'g_value_take_string ($value, $var)' }, + + int32array => { name => 'INT32ARRAY', + type => 'gint32 *', + array => 1, + init_value => 'NULL', + get_value_func => '$var = g_value_get_pointer ($value)', + set_value_func => 'g_value_set_pointer ($value, $var)' }, + int16array => { name => 'INT16ARRAY', + type => 'gint16 *', + array => 1, + init_value => 'NULL', + get_value_func => '$var = g_value_get_pointer ($value)', + set_value_func => 'g_value_set_pointer ($value, $var)' }, + int8array => { name => 'INT8ARRAY', + type => 'guint8 *', + array => 1, + init_value => 'NULL', + get_value_func => '$var = g_value_get_pointer ($value)', + set_value_func => 'g_value_set_pointer ($value, $var)' }, + floatarray => { name => 'FLOATARRAY', + type => 'gdouble *', + array => 1, + init_value => 'NULL', + get_value_func => '$var = g_value_get_pointer ($value)', + set_value_func => 'g_value_set_pointer ($value, $var)' }, + stringarray => { name => 'STRINGARRAY', + type => 'gchar **', + array => 1, + init_value => 'NULL', + get_value_func => '$var = g_value_get_pointer ($value)', + set_value_func => 'g_value_set_pointer ($value, $var)' }, + + color => { name => 'COLOR' , + type => 'GimpRGB ', + struct => 1, + init_value => '{ 0.0, 0.0, 0.0, 1.0 }', + get_value_func => 'gimp_value_get_rgb ($value, &$var)', + set_value_func => 'gimp_value_set_rgb ($value, &$var)', + headers => [ qw("libgimpcolor/gimpcolor.h") ] }, + + display => { name => 'DISPLAY', + type => 'GimpObject *', + id => 1, + init_value => 'NULL', + get_value_func => '$var = gimp_value_get_display ($value, gimp)', + set_value_func => 'gimp_value_set_display ($value, $var)' }, + image => { name => 'IMAGE', + type => 'GimpImage *', + id => 1, + init_value => 'NULL', + get_value_func => '$var = gimp_value_get_image ($value, gimp)', + set_value_func => 'gimp_value_set_image ($value, $var)', + headers => [ qw("core/gimpimage.h") ] }, + layer => { name => 'LAYER', + type => 'GimpLayer *', + id => 1, + init_value => 'NULL', + get_value_func => '$var = (GimpLayer *) gimp_value_get_item ($value, gimp, GIMP_TYPE_LAYER)', + set_value_func => 'gimp_value_set_item ($value, GIMP_ITEM ($var))', + headers => [ qw("core/gimplayer.h") ] }, + channel => { name => 'CHANNEL', + type => 'GimpChannel *', + id => 1, + init_value => 'NULL', + get_value_func => '$var = (GimpChannel *) gimp_value_get_item ($value, gimp, GIMP_TYPE_CHANNEL)', + set_value_func => 'gimp_value_set_item ($value, GIMP_ITEM ($var))', + headers => [ qw("core/gimpchannel.h") ] }, + drawable => { name => 'DRAWABLE', + type => 'GimpDrawable *', + id => 1, + init_value => 'NULL', + get_value_func => '$var = (GimpDrawable *) gimp_value_get_item ($value, gimp, GIMP_TYPE_DRAWABLE)', + set_value_func => 'gimp_value_set_item ($value, GIMP_ITEM ($var))', + headers => [ qw("core/gimpdrawable.h") ] }, + selection => { name => 'SELECTION', + type => 'GimpChannel *', + id => 1, + init_value => 'NULL', + get_value_func => '$var = (GimpChannel *) gimp_value_get_item ($value, gimp, GIMP_TYPE_CHANNEL)', + set_value_func => 'gimp_value_set_item ($value, GIMP_ITEM ($var))', + headers => [ qw("core/gimpchannel.h") ] }, + layer_mask => { name => 'CHANNEL', + type => 'GimpLayerMask *', + id => 1, + init_value => 'NULL', + get_value_func => '$var = (GimpLayerMask *) gimp_value_get_item ($value, gimp, GIMP_TYPE_LAYER_MASK)', + set_value_func => 'gimp_value_set_item ($value, GIMP_ITEM ($var))', + headers => [ qw("core/gimplayermask.h") ] }, + vectors => { name => 'VECTORS', + type => 'GimpVectors *', + id => 1, + init_value => 'NULL', + get_value_func => '$var = (GimpVectors *) gimp_value_get_item ($value, gimp, GIMP_TYPE_VECTORS)', + set_value_func => 'gimp_value_set_item ($value, GIMP_ITEM ($var))', + headers => [ qw("vectors/gimpvectors.h") ] }, + + parasite => { name => 'PARASITE', + type => 'GimpParasite *', + init_value => 'NULL', + get_value_func => '$var = g_value_get_boxed ($value)', + set_value_func => 'g_value_take_boxed ($value, $var)', + headers => [ qw("libgimpbase/gimpbase.h") ] }, boundary => { name => 'BOUNDARY', type => 'gpointer ' }, # ??? FIXME status => { name => 'STATUS' , type => 'gpointer ' }, # ??? FIXME # Special cases - enum => { name => 'INT32', type => 'gint32 ', init_value => '0' }, - boolean => { name => 'INT32', type => 'gboolean ', init_value => 'FALSE' }, - tattoo => { name => 'INT32', type => 'gint32 ', init_value => '0' }, - guide => { name => 'INT32', type => 'gint32 ', init_value => '0' }, - unit => { name => 'INT32', type => 'GimpUnit ', init_value => '0' }, + enum => { name => 'INT32', + type => 'gint32 ', + init_value => '0', + get_value_func => '$var = g_value_get_enum ($value)', + set_value_func => 'g_value_set_enum ($value, $var)' }, + boolean => { name => 'INT32', + type => 'gboolean ', + init_value => 'FALSE', + get_value_func => '$var = g_value_get_boolean ($value)', + set_value_func => 'g_value_set_boolean ($value, $var)' }, + tattoo => { name => 'INT32', + type => 'gint32 ', + init_value => '0', + get_value_func => '$var = g_value_get_uint ($value)', + set_value_func => 'g_value_set_uint ($value, $var)' }, + guide => { name => 'INT32', + type => 'gint32 ', + id => 1, + init_value => '0', + get_value_func => '$var = g_value_get_uint ($value)', + set_value_func => 'g_value_set_uint ($value, $var)' }, + unit => { name => 'INT32', + type => 'GimpUnit ', + init_value => '0', + get_value_func => '$var = g_value_get_int ($value)', + set_value_func => 'g_value_set_int ($value, $var)' }, region => { name => 'REGION', type => 'gpointer ' } # not supported ); @@ -155,25 +222,5 @@ sub arg_parse { return ($3, $1, $2 ? $premap{$2} : $2, $5, $4 ? $postmap{$4} : $4); } } - -# Return the marshaller data type -sub arg_ptype { - my $arg = shift; - do { - if (exists $arg->{id_func}) { 'int' } - elsif ($arg->{type} =~ /\*/) { 'pointer' } - elsif ($arg->{type} =~ /boolean/) { 'int' } - elsif ($arg->{type} =~ /GimpUnit/) { 'int' } - elsif ($arg->{type} =~ /int/) { 'int' } - elsif ($arg->{type} =~ /double/) { 'float' } - elsif ($arg->{type} =~ /GimpRGB/) { 'color' } - else { 'pointer' } - }; -} - -# Return the alias if defined, otherwise the name -sub arg_vname { exists $_[0]->{alias} ? $_[0]->{alias} : $_[0]->{name} } - -sub arg_numtype () { 'gint32 ' } 1; Index: tools/pdbgen/pdb/fileops.pdb =================================================================== RCS file: /cvs/gnome/gimp/tools/pdbgen/pdb/fileops.pdb,v retrieving revision 1.75 diff -u -p -r1.75 fileops.pdb --- tools/pdbgen/pdb/fileops.pdb 29 Mar 2006 21:02:21 -0000 1.75 +++ tools/pdbgen/pdb/fileops.pdb 29 Mar 2006 22:02:04 -0000 @@ -56,10 +56,12 @@ HELP PlugInProcDef *file_proc; const ProcRecord *proc; gchar *uri; + gint n_return_vals; gint i; uri = file_utils_filename_to_uri (gimp->load_procs, - args[1].value.pdb_pointer, NULL); + g_value_get_string (&args[1].value), + NULL); if (! uri) return procedural_db_return_values (proc_record, FALSE); @@ -73,19 +75,21 @@ HELP proc = plug_in_proc_def_get_proc (file_proc); - new_args = g_new0 (Argument, proc->num_args); - memcpy (new_args, args, sizeof (Argument) * 3); + new_args = procedural_db_arguments (proc); + + for (i = 0; i < 3; i++) + g_value_copy (&args[i].value, &new_args[i].value); for (i = 3; i < proc->num_args; i++) - { - new_args[i].arg_type = proc->args[i].arg_type; - if (proc->args[i].arg_type == GIMP_PDB_STRING) - new_args[i].value.pdb_pointer = g_strdup (""); - } + if (proc->args[i].arg_type == GIMP_PDB_STRING) + g_value_set_string (&new_args[i].value, ""); return_vals = procedural_db_execute (gimp, context, progress, - proc->name, new_args); - g_free (new_args); + proc->name, + new_args, proc->num_args, + &n_return_vals); + + procedural_db_destroy_args (new_args, proc->num_args, FALSE); return return_vals; } @@ -181,10 +185,12 @@ HELP PlugInProcDef *file_proc; const ProcRecord *proc; gchar *uri; + gint n_return_vals; gint i; uri = file_utils_filename_to_uri (gimp->load_procs, - args[3].value.pdb_pointer, NULL); + g_value_get_string (&args[3].value), + NULL); if (! uri) return procedural_db_return_values (proc_record, FALSE); @@ -198,19 +204,21 @@ HELP proc = plug_in_proc_def_get_proc (file_proc); - new_args = g_new0 (Argument, proc->num_args); - memcpy (new_args, args, sizeof (Argument) * 5); + new_args = procedural_db_arguments (proc); + + for (i = 0; i < 5; i++) + g_value_copy (&args[i].value, &new_args[i].value); for (i = 5; i < proc->num_args; i++) - { - new_args[i].arg_type = proc->args[i].arg_type; - if (proc->args[i].arg_type == GIMP_PDB_STRING) - new_args[i].value.pdb_pointer = g_strdup (""); - } + if (proc->args[i].arg_type == GIMP_PDB_STRING) + g_value_set_string (&new_args[i].value, ""); return_vals = procedural_db_execute (gimp, context, progress, - proc->name, new_args); - g_free (new_args); + proc->name, + new_args, proc->num_args, + &n_return_vals); + + procedural_db_destroy_args (new_args, proc->num_args, FALSE); return return_vals; }