replace the value union by a GValue.

2006-03-30  Michael Natterer  <mitch@gimp.org>

	* app/pdb/procedural_db.[ch] (struct Argument): replace the value
	union by a GValue.

	(procedural_db_argument_init)
	(procedural_db_compat_arg_init): new functions to initialize
	an Argument. They call g_value_init() on the Argument's value.

	(procedural_db_arguments)
	(procedural_db_return_values): initialize the returned Argument
	arrays so their GValues are ready to use. Allow to get the
	(unsuccessful) return values of a NULL ProcRecord.

	(procedural_db_destroy_args): g_value_unset() the values. Added a
	"gboolean full_destroy" parameter. Its only effect is to destroy
	PDB arrays, everything else is nicely memory managed by GValue.

	(procedural_db_execute)
	(procedural_db_run_proc): do GValue stuff. Added n_args and
	n_return_vals parameters to execute().

	(procedural_db_execute_proc): private function to execute a
	procedure. Validates the passed in arguments using the registered
	GParamSpecs before passing them to the resp. exec method.

	* app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs
	an array of ProcArgs now in order to initialize the Arguments'
	GValues correctly. Passing NULL ProcArgs uses
	procedural_db_compat_arg_init(), so procedures (plug-ins)
	returning more values than expected work.

	(plug_in_args_to_params): do GValue stuff here too.

	(plug_in_args_destroy): removed this function,
	procedural_db_destroy_args() does the same now.

	* app/plug-in/plug-in-message.c (plug_in_handle_proc_run):
	simplified quite a bit because everything returns n_return_values
	now. Call plug_in_params_to_args() only of the procedure was found.

	(plug_in_handle_proc_return_priv): pass ProcRecs to
	plug_in_params_to_args().

	* app/batch.c
	* app/actions/plug-in-commands.c
	* app/actions/vectors-commands.c
	* app/core/gimppdbprogress.c
	* app/dialogs/about-dialog.c
	* app/file/file-open.c
	* app/file/file-save.c
	* app/plug-in/plug-ins.c
	* app/plug-in/plug-in-progress.c
	* app/plug-in/plug-in-run.[ch]
	* app/widgets/gimphelp.c
	* app/widgets/gimppdbdialog.c
	* app/xcf/xcf.c
	* tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't
	g_new/g_free Argument arrays, always use procedural_db_foo()
	functions. Use GValue functions to get/set Arguments.

	* tools/pdbgen/pdb.pl: added get_value_func and set_value_func to
	all PDB types. Removed id_func, id_ret_func and check_func. Added
	flags which indicated that a type is an ID. Removed unused utility
	functions.

	* tools/pdbgen/lib.pl: use the flag instead of looking at
	functions and value types.

	* tools/pdbgen/app.pl: use the get_value_func and set_value_func
	to marshal inargs and outargs. Removed all checks performed on
	inargs because that's done by GParamSpec validation now. Added the
	missing bits to register excluded values with GimpParamSpecEnum.

	* app/pdb/*_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2006-03-29 23:56:07 +00:00 committed by Michael Natterer
parent d69e93ceb1
commit afd88f0bf4
83 changed files with 4011 additions and 5678 deletions

View File

@ -1,3 +1,79 @@
2006-03-30 Michael Natterer <mitch@gimp.org>
* app/pdb/procedural_db.[ch] (struct Argument): replace the value
union by a GValue.
(procedural_db_argument_init)
(procedural_db_compat_arg_init): new functions to initialize
an Argument. They call g_value_init() on the Argument's value.
(procedural_db_arguments)
(procedural_db_return_values): initialize the returned Argument
arrays so their GValues are ready to use. Allow to get the
(unsuccessful) return values of a NULL ProcRecord.
(procedural_db_destroy_args): g_value_unset() the values. Added a
"gboolean full_destroy" parameter. Its only effect is to destroy
PDB arrays, everything else is nicely memory managed by GValue.
(procedural_db_execute)
(procedural_db_run_proc): do GValue stuff. Added n_args and
n_return_vals parameters to execute().
(procedural_db_execute_proc): private function to execute a
procedure. Validates the passed in arguments using the registered
GParamSpecs before passing them to the resp. exec method.
* app/plug-in/plug-in-params.[ch] (plug_in_params_to_args): needs
an array of ProcArgs now in order to initialize the Arguments'
GValues correctly. Passing NULL ProcArgs uses
procedural_db_compat_arg_init(), so procedures (plug-ins)
returning more values than expected work.
(plug_in_args_to_params): do GValue stuff here too.
(plug_in_args_destroy): removed this function,
procedural_db_destroy_args() does the same now.
* app/plug-in/plug-in-message.c (plug_in_handle_proc_run):
simplified quite a bit because everything returns n_return_values
now. Call plug_in_params_to_args() only of the procedure was found.
(plug_in_handle_proc_return_priv): pass ProcRecs to
plug_in_params_to_args().
* app/batch.c
* app/actions/plug-in-commands.c
* app/actions/vectors-commands.c
* app/core/gimppdbprogress.c
* app/dialogs/about-dialog.c
* app/file/file-open.c
* app/file/file-save.c
* app/plug-in/plug-ins.c
* app/plug-in/plug-in-progress.c
* app/plug-in/plug-in-run.[ch]
* app/widgets/gimphelp.c
* app/widgets/gimppdbdialog.c
* app/xcf/xcf.c
* tools/pdbgen/pdb/fileops.pdb: changed accordingly: don't
g_new/g_free Argument arrays, always use procedural_db_foo()
functions. Use GValue functions to get/set Arguments.
* tools/pdbgen/pdb.pl: added get_value_func and set_value_func to
all PDB types. Removed id_func, id_ret_func and check_func. Added
flags which indicated that a type is an ID. Removed unused utility
functions.
* tools/pdbgen/lib.pl: use the flag instead of looking at
functions and value types.
* tools/pdbgen/app.pl: use the get_value_func and set_value_func
to marshal inargs and outargs. Removed all checks performed on
inargs because that's done by GParamSpec validation now. Added the
missing bits to register excluded values with GimpParamSpecEnum.
* app/pdb/*_cmds.c: regenerated.
2006-03-30 Michael Natterer <mitch@gimp.org>
* app/plug-in/plug-in-params.c (plug_in_param_defs_check): can't

View File

@ -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 *action,
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 *action,
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 *action,
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 *action,
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 *action,
gimp_set_last_plug_in (gimp, proc_def);
}
g_free (args);
error:
procedural_db_destroy_args (args, proc_rec->num_args, TRUE);
}
void

View File

@ -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_callback (GtkAction *action,
/* plug-in arguments as if called by <Image>/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

View File

@ -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;
}

View File

@ -259,7 +259,8 @@ gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
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 (GimpPdbProgress *progress,
}
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;
}

View File

@ -223,7 +223,7 @@ about_dialog_load_url (GtkAboutDialog *dialog,
&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);
}

View File

@ -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 *gimp,
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 *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);
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;

View File

@ -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)
{

View File

@ -657,9 +657,7 @@ brush_new_invoker (ProcRecord *proc_record,
gchar *name;
gchar *actual_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -679,7 +677,7 @@ brush_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = actual_name;
g_value_take_string (&return_vals[1].value, actual_name);
return return_vals;
}
@ -711,9 +709,7 @@ brush_duplicate_invoker (ProcRecord *proc_record,
gchar *name;
gchar *copy_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -738,7 +734,7 @@ brush_duplicate_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = copy_name;
g_value_take_string (&return_vals[1].value, copy_name);
return return_vals;
}
@ -770,9 +766,7 @@ brush_is_generated_invoker (ProcRecord *proc_record,
gchar *name;
gboolean generated = FALSE;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -788,7 +782,7 @@ brush_is_generated_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = generated;
g_value_set_boolean (&return_vals[1].value, generated);
return return_vals;
}
@ -821,13 +815,8 @@ brush_rename_invoker (ProcRecord *proc_record,
gchar *new_name;
gchar *actual_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
new_name = (gchar *) args[1].value.pdb_pointer;
if (new_name == NULL || !g_utf8_validate (new_name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
new_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -846,7 +835,7 @@ brush_rename_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = actual_name;
g_value_take_string (&return_vals[1].value, actual_name);
return return_vals;
}
@ -876,9 +865,7 @@ brush_delete_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -933,9 +920,7 @@ brush_is_editable_invoker (ProcRecord *proc_record,
gchar *name;
gboolean editable = FALSE;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -951,7 +936,7 @@ brush_is_editable_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = editable;
g_value_set_boolean (&return_vals[1].value, editable);
return return_vals;
}
@ -986,9 +971,7 @@ brush_get_info_invoker (ProcRecord *proc_record,
gint32 mask_bpp = 0;
gint32 color_bpp = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1010,10 +993,10 @@ brush_get_info_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = width;
return_vals[2].value.pdb_int = height;
return_vals[3].value.pdb_int = mask_bpp;
return_vals[4].value.pdb_int = color_bpp;
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, mask_bpp);
g_value_set_int (&return_vals[4].value, color_bpp);
}
return return_vals;
@ -1053,9 +1036,7 @@ brush_get_pixels_invoker (ProcRecord *proc_record,
gint32 num_color_bytes = 0;
guint8 *color_bytes = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1086,14 +1067,14 @@ brush_get_pixels_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = width;
return_vals[2].value.pdb_int = height;
return_vals[3].value.pdb_int = mask_bpp;
return_vals[4].value.pdb_int = num_mask_bytes;
return_vals[5].value.pdb_pointer = mask_bytes;
return_vals[6].value.pdb_int = color_bpp;
return_vals[7].value.pdb_int = num_color_bytes;
return_vals[8].value.pdb_pointer = color_bytes;
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, mask_bpp);
g_value_set_int (&return_vals[4].value, num_mask_bytes);
g_value_set_pointer (&return_vals[5].value, mask_bytes);
g_value_set_int (&return_vals[6].value, color_bpp);
g_value_set_int (&return_vals[7].value, num_color_bytes);
g_value_set_pointer (&return_vals[8].value, color_bytes);
}
return return_vals;
@ -1126,9 +1107,7 @@ brush_get_spacing_invoker (ProcRecord *proc_record,
gchar *name;
gint32 spacing = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1144,7 +1123,7 @@ brush_get_spacing_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = spacing;
g_value_set_int (&return_vals[1].value, spacing);
return return_vals;
}
@ -1175,13 +1154,8 @@ brush_set_spacing_invoker (ProcRecord *proc_record,
gchar *name;
gint32 spacing;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
spacing = args[1].value.pdb_int;
if (spacing < 0 || spacing > 1000)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
spacing = g_value_get_int (&args[1].value);
if (success)
{
@ -1224,9 +1198,7 @@ brush_get_shape_invoker (ProcRecord *proc_record,
gchar *name;
gint32 shape = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1242,7 +1214,7 @@ brush_get_shape_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = shape;
g_value_set_enum (&return_vals[1].value, shape);
return return_vals;
}
@ -1274,9 +1246,7 @@ brush_get_radius_invoker (ProcRecord *proc_record,
gchar *name;
gdouble radius = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1292,7 +1262,7 @@ brush_get_radius_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = radius;
g_value_set_double (&return_vals[1].value, radius);
return return_vals;
}
@ -1324,9 +1294,7 @@ brush_get_spikes_invoker (ProcRecord *proc_record,
gchar *name;
gint32 spikes = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1342,7 +1310,7 @@ brush_get_spikes_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = spikes;
g_value_set_int (&return_vals[1].value, spikes);
return return_vals;
}
@ -1374,9 +1342,7 @@ brush_get_hardness_invoker (ProcRecord *proc_record,
gchar *name;
gdouble hardness = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1392,7 +1358,7 @@ brush_get_hardness_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = hardness;
g_value_set_double (&return_vals[1].value, hardness);
return return_vals;
}
@ -1424,9 +1390,7 @@ brush_get_aspect_ratio_invoker (ProcRecord *proc_record,
gchar *name;
gdouble aspect_ratio = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1442,7 +1406,7 @@ brush_get_aspect_ratio_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = aspect_ratio;
g_value_set_double (&return_vals[1].value, aspect_ratio);
return return_vals;
}
@ -1474,9 +1438,7 @@ brush_get_angle_invoker (ProcRecord *proc_record,
gchar *name;
gdouble angle = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1492,7 +1454,7 @@ brush_get_angle_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = angle;
g_value_set_double (&return_vals[1].value, angle);
return return_vals;
}
@ -1525,13 +1487,8 @@ brush_set_shape_invoker (ProcRecord *proc_record,
gint32 shape_in;
gint32 shape_out = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
shape_in = args[1].value.pdb_int;
if (shape_in < GIMP_BRUSH_GENERATED_CIRCLE || shape_in > GIMP_BRUSH_GENERATED_DIAMOND)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
shape_in = g_value_get_enum (&args[1].value);
if (success)
{
@ -1551,7 +1508,7 @@ brush_set_shape_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = shape_out;
g_value_set_enum (&return_vals[1].value, shape_out);
return return_vals;
}
@ -1584,11 +1541,8 @@ brush_set_radius_invoker (ProcRecord *proc_record,
gdouble radius_in;
gdouble radius_out = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
radius_in = args[1].value.pdb_float;
name = (gchar *) g_value_get_string (&args[0].value);
radius_in = g_value_get_double (&args[1].value);
if (success)
{
@ -1608,7 +1562,7 @@ brush_set_radius_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = radius_out;
g_value_set_double (&return_vals[1].value, radius_out);
return return_vals;
}
@ -1641,11 +1595,8 @@ brush_set_spikes_invoker (ProcRecord *proc_record,
gint32 spikes_in;
gint32 spikes_out = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
spikes_in = args[1].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
spikes_in = g_value_get_int (&args[1].value);
if (success)
{
@ -1665,7 +1616,7 @@ brush_set_spikes_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = spikes_out;
g_value_set_int (&return_vals[1].value, spikes_out);
return return_vals;
}
@ -1698,11 +1649,8 @@ brush_set_hardness_invoker (ProcRecord *proc_record,
gdouble hardness_in;
gdouble hardness_out = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
hardness_in = args[1].value.pdb_float;
name = (gchar *) g_value_get_string (&args[0].value);
hardness_in = g_value_get_double (&args[1].value);
if (success)
{
@ -1722,7 +1670,7 @@ brush_set_hardness_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = hardness_out;
g_value_set_double (&return_vals[1].value, hardness_out);
return return_vals;
}
@ -1755,11 +1703,8 @@ brush_set_aspect_ratio_invoker (ProcRecord *proc_record,
gdouble aspect_ratio_in;
gdouble aspect_ratio_out = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
aspect_ratio_in = args[1].value.pdb_float;
name = (gchar *) g_value_get_string (&args[0].value);
aspect_ratio_in = g_value_get_double (&args[1].value);
if (success)
{
@ -1779,7 +1724,7 @@ brush_set_aspect_ratio_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = aspect_ratio_out;
g_value_set_double (&return_vals[1].value, aspect_ratio_out);
return return_vals;
}
@ -1812,11 +1757,8 @@ brush_set_angle_invoker (ProcRecord *proc_record,
gdouble angle_in;
gdouble angle_out = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
angle_in = args[1].value.pdb_float;
name = (gchar *) g_value_get_string (&args[0].value);
angle_in = g_value_get_double (&args[1].value);
if (success)
{
@ -1836,7 +1778,7 @@ brush_set_angle_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = angle_out;
g_value_set_double (&return_vals[1].value, angle_out);
return return_vals;
}

View File

@ -166,29 +166,12 @@ brushes_popup_invoker (ProcRecord *proc_record,
gint32 spacing;
gint32 paint_mode;
brush_callback = (gchar *) args[0].value.pdb_pointer;
if (brush_callback == NULL || !g_utf8_validate (brush_callback, -1, NULL))
success = FALSE;
popup_title = (gchar *) args[1].value.pdb_pointer;
if (popup_title == NULL || !g_utf8_validate (popup_title, -1, NULL))
success = FALSE;
initial_brush = (gchar *) args[2].value.pdb_pointer;
if (initial_brush && !g_utf8_validate (initial_brush, -1, NULL))
success = FALSE;
opacity = args[3].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
spacing = args[4].value.pdb_int;
if (spacing > 1000)
success = FALSE;
paint_mode = args[5].value.pdb_int;
if (paint_mode < GIMP_NORMAL_MODE || paint_mode > GIMP_COLOR_ERASE_MODE)
success = FALSE;
brush_callback = (gchar *) g_value_get_string (&args[0].value);
popup_title = (gchar *) g_value_get_string (&args[1].value);
initial_brush = (gchar *) g_value_get_string (&args[2].value);
opacity = g_value_get_double (&args[3].value);
spacing = g_value_get_int (&args[4].value);
paint_mode = g_value_get_enum (&args[5].value);
if (success)
{
@ -231,9 +214,7 @@ brushes_close_popup_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *brush_callback;
brush_callback = (gchar *) args[0].value.pdb_pointer;
if (brush_callback == NULL || !g_utf8_validate (brush_callback, -1, NULL))
success = FALSE;
brush_callback = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -276,25 +257,11 @@ brushes_set_popup_invoker (ProcRecord *proc_record,
gint32 spacing;
gint32 paint_mode;
brush_callback = (gchar *) args[0].value.pdb_pointer;
if (brush_callback == NULL || !g_utf8_validate (brush_callback, -1, NULL))
success = FALSE;
brush_name = (gchar *) args[1].value.pdb_pointer;
if (brush_name == NULL || !g_utf8_validate (brush_name, -1, NULL))
success = FALSE;
opacity = args[2].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
spacing = args[3].value.pdb_int;
if (spacing > 1000)
success = FALSE;
paint_mode = args[4].value.pdb_int;
if (paint_mode < GIMP_NORMAL_MODE || paint_mode > GIMP_COLOR_ERASE_MODE)
success = FALSE;
brush_callback = (gchar *) g_value_get_string (&args[0].value);
brush_name = (gchar *) g_value_get_string (&args[1].value);
opacity = g_value_get_double (&args[2].value);
spacing = g_value_get_int (&args[3].value);
paint_mode = g_value_get_enum (&args[4].value);
if (success)
{

View File

@ -254,9 +254,7 @@ brushes_get_list_invoker (ProcRecord *proc_record,
gint32 num_brushes = 0;
gchar **brush_list = NULL;
filter = (gchar *) args[0].value.pdb_pointer;
if (filter && !g_utf8_validate (filter, -1, NULL))
success = FALSE;
filter = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -268,8 +266,8 @@ brushes_get_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_brushes;
return_vals[2].value.pdb_pointer = brush_list;
g_value_set_int (&return_vals[1].value, num_brushes);
g_value_set_pointer (&return_vals[2].value, brush_list);
}
return return_vals;
@ -320,10 +318,10 @@ brushes_get_brush_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_pointer = name;
return_vals[2].value.pdb_int = width;
return_vals[3].value.pdb_int = height;
return_vals[4].value.pdb_int = spacing;
g_value_take_string (&return_vals[1].value, name);
g_value_set_int (&return_vals[2].value, width);
g_value_set_int (&return_vals[3].value, height);
g_value_set_int (&return_vals[4].value, spacing);
}
return return_vals;
@ -365,7 +363,7 @@ brushes_get_spacing_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = spacing;
g_value_set_int (&return_vals[1].value, spacing);
return return_vals;
}
@ -395,9 +393,7 @@ brushes_set_spacing_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gint32 spacing;
spacing = args[0].value.pdb_int;
if (spacing < 0 || spacing > 1000)
success = FALSE;
spacing = g_value_get_int (&args[0].value);
if (success)
{
@ -441,9 +437,7 @@ brushes_get_brush_data_invoker (ProcRecord *proc_record,
gint32 length = 0;
guint8 *mask_data = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -478,14 +472,14 @@ brushes_get_brush_data_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_pointer = actual_name;
return_vals[2].value.pdb_float = opacity;
return_vals[3].value.pdb_int = spacing;
return_vals[4].value.pdb_int = paint_mode;
return_vals[5].value.pdb_int = width;
return_vals[6].value.pdb_int = height;
return_vals[7].value.pdb_int = length;
return_vals[8].value.pdb_pointer = mask_data;
g_value_take_string (&return_vals[1].value, actual_name);
g_value_set_double (&return_vals[2].value, opacity);
g_value_set_int (&return_vals[3].value, spacing);
g_value_set_enum (&return_vals[4].value, paint_mode);
g_value_set_int (&return_vals[5].value, width);
g_value_set_int (&return_vals[6].value, height);
g_value_set_int (&return_vals[7].value, length);
g_value_set_pointer (&return_vals[8].value, mask_data);
}
return return_vals;

View File

@ -218,9 +218,7 @@ buffers_get_list_invoker (ProcRecord *proc_record,
gint32 num_buffers = 0;
gchar **buffer_list = NULL;
filter = (gchar *) args[0].value.pdb_pointer;
if (filter && !g_utf8_validate (filter, -1, NULL))
success = FALSE;
filter = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -232,8 +230,8 @@ buffers_get_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_buffers;
return_vals[2].value.pdb_pointer = buffer_list;
g_value_set_int (&return_vals[1].value, num_buffers);
g_value_set_pointer (&return_vals[2].value, buffer_list);
}
return return_vals;
@ -267,13 +265,8 @@ buffer_rename_invoker (ProcRecord *proc_record,
gchar *new_name;
gchar *real_name = NULL;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
new_name = (gchar *) args[1].value.pdb_pointer;
if (new_name == NULL || !g_utf8_validate (new_name, -1, NULL))
success = FALSE;
buffer_name = (gchar *) g_value_get_string (&args[0].value);
new_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -292,7 +285,7 @@ buffer_rename_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = real_name;
g_value_take_string (&return_vals[1].value, real_name);
return return_vals;
}
@ -322,9 +315,7 @@ buffer_delete_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *buffer_name;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
buffer_name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -367,9 +358,7 @@ buffer_get_width_invoker (ProcRecord *proc_record,
gchar *buffer_name;
gint32 width = 0;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
buffer_name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -385,7 +374,7 @@ buffer_get_width_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = width;
g_value_set_int (&return_vals[1].value, width);
return return_vals;
}
@ -417,9 +406,7 @@ buffer_get_height_invoker (ProcRecord *proc_record,
gchar *buffer_name;
gint32 height = 0;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
buffer_name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -435,7 +422,7 @@ buffer_get_height_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = height;
g_value_set_int (&return_vals[1].value, height);
return return_vals;
}
@ -467,9 +454,7 @@ buffer_get_bytes_invoker (ProcRecord *proc_record,
gchar *buffer_name;
gint32 bytes = 0;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
buffer_name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -485,7 +470,7 @@ buffer_get_bytes_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = bytes;
g_value_set_int (&return_vals[1].value, bytes);
return return_vals;
}
@ -517,9 +502,7 @@ buffer_get_image_type_invoker (ProcRecord *proc_record,
gchar *buffer_name;
gint32 image_type = 0;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
buffer_name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -535,7 +518,7 @@ buffer_get_image_type_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = image_type;
g_value_set_enum (&return_vals[1].value, image_type);
return return_vals;
}

View File

@ -354,27 +354,12 @@ channel_new_invoker (ProcRecord *proc_record,
GimpRGB color;
GimpChannel *channel = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
width = args[1].value.pdb_int;
if (width < 1)
success = FALSE;
height = args[2].value.pdb_int;
if (height < 1)
success = FALSE;
name = (gchar *) args[3].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
opacity = args[4].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
color = args[5].value.pdb_color;
image = gimp_value_get_image (&args[0].value, gimp);
width = g_value_get_int (&args[1].value);
height = g_value_get_int (&args[2].value);
name = (gchar *) g_value_get_string (&args[3].value);
opacity = g_value_get_double (&args[4].value);
gimp_value_get_rgb (&args[5].value, &color);
if (success)
{
@ -390,7 +375,7 @@ channel_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = channel ? gimp_item_get_ID (GIMP_ITEM (channel)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (channel));
return return_vals;
}
@ -424,17 +409,9 @@ channel_new_from_component_invoker (ProcRecord *proc_record,
gchar *name;
GimpChannel *channel = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
component = args[1].value.pdb_int;
if (component < GIMP_RED_CHANNEL || component > GIMP_ALPHA_CHANNEL)
success = FALSE;
name = (gchar *) args[2].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
component = g_value_get_enum (&args[1].value);
name = (gchar *) g_value_get_string (&args[2].value);
if (success)
{
@ -451,7 +428,7 @@ channel_new_from_component_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = channel ? gimp_item_get_ID (GIMP_ITEM (channel)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (channel));
return return_vals;
}
@ -483,9 +460,7 @@ channel_copy_invoker (ProcRecord *proc_record,
GimpChannel *channel;
GimpChannel *channel_copy = NULL;
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
if (success)
{
@ -499,7 +474,7 @@ channel_copy_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = channel_copy ? gimp_item_get_ID (GIMP_ITEM (channel_copy)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (channel_copy));
return return_vals;
}
@ -533,21 +508,11 @@ channel_combine_masks_invoker (ProcRecord *proc_record,
gint32 offx;
gint32 offy;
channel1 = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel1) && ! gimp_item_is_removed (GIMP_ITEM (channel1))))
success = FALSE;
channel2 = (GimpChannel *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel2) && ! gimp_item_is_removed (GIMP_ITEM (channel2))))
success = FALSE;
operation = args[2].value.pdb_int;
if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
success = FALSE;
offx = args[3].value.pdb_int;
offy = args[4].value.pdb_int;
channel1 = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
channel2 = (GimpChannel *) gimp_value_get_item (&args[1].value, gimp, GIMP_TYPE_CHANNEL);
operation = g_value_get_enum (&args[2].value);
offx = g_value_get_int (&args[3].value);
offy = g_value_get_int (&args[4].value);
if (success)
{
@ -584,9 +549,7 @@ channel_get_show_masked_invoker (ProcRecord *proc_record,
GimpChannel *channel;
gboolean show_masked = FALSE;
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
if (success)
{
@ -596,7 +559,7 @@ channel_get_show_masked_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = show_masked;
g_value_set_boolean (&return_vals[1].value, show_masked);
return return_vals;
}
@ -627,11 +590,8 @@ channel_set_show_masked_invoker (ProcRecord *proc_record,
GimpChannel *channel;
gboolean show_masked;
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
show_masked = args[1].value.pdb_int ? TRUE : FALSE;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
show_masked = g_value_get_boolean (&args[1].value);
if (success)
{
@ -668,9 +628,7 @@ channel_get_opacity_invoker (ProcRecord *proc_record,
GimpChannel *channel;
gdouble opacity = 0.0;
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
if (success)
{
@ -680,7 +638,7 @@ channel_get_opacity_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = opacity;
g_value_set_double (&return_vals[1].value, opacity);
return return_vals;
}
@ -711,13 +669,8 @@ channel_set_opacity_invoker (ProcRecord *proc_record,
GimpChannel *channel;
gdouble opacity;
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
opacity = args[1].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
opacity = g_value_get_double (&args[1].value);
if (success)
{
@ -754,9 +707,7 @@ channel_get_color_invoker (ProcRecord *proc_record,
GimpChannel *channel;
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
if (success)
{
@ -766,7 +717,7 @@ channel_get_color_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_color = color;
gimp_value_set_rgb (&return_vals[1].value, &color);
return return_vals;
}
@ -797,11 +748,8 @@ channel_set_color_invoker (ProcRecord *proc_record,
GimpChannel *channel;
GimpRGB color;
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
color = args[1].value.pdb_color;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
gimp_value_get_rgb (&args[1].value, &color);
if (success)
{

View File

@ -593,17 +593,9 @@ brightness_contrast_invoker (ProcRecord *proc_record,
gint32 brightness;
gint32 contrast;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
brightness = args[1].value.pdb_int;
if (brightness < -127 || brightness > 127)
success = FALSE;
contrast = args[2].value.pdb_int;
if (contrast < -127 || contrast > 127)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
brightness = g_value_get_int (&args[1].value);
contrast = g_value_get_int (&args[2].value);
if (success)
{
@ -676,33 +668,13 @@ levels_invoker (ProcRecord *proc_record,
gint32 low_output;
gint32 high_output;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
channel = args[1].value.pdb_int;
if (channel < GIMP_HISTOGRAM_VALUE || channel > GIMP_HISTOGRAM_ALPHA)
success = FALSE;
low_input = args[2].value.pdb_int;
if (low_input < 0 || low_input > 255)
success = FALSE;
high_input = args[3].value.pdb_int;
if (high_input < 0 || high_input > 255)
success = FALSE;
gamma = args[4].value.pdb_float;
if (gamma < 0.1 || gamma > 10.0)
success = FALSE;
low_output = args[5].value.pdb_int;
if (low_output < 0 || low_output > 255)
success = FALSE;
high_output = args[6].value.pdb_int;
if (high_output < 0 || high_output > 255)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
channel = g_value_get_enum (&args[1].value);
low_input = g_value_get_int (&args[2].value);
high_input = g_value_get_int (&args[3].value);
gamma = g_value_get_double (&args[4].value);
low_output = g_value_get_int (&args[5].value);
high_output = g_value_get_int (&args[6].value);
if (success)
{
@ -750,9 +722,7 @@ levels_auto_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -792,9 +762,7 @@ levels_stretch_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -835,13 +803,8 @@ posterize_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 levels;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
levels = args[1].value.pdb_int;
if (levels < 2 || levels > 255)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
levels = g_value_get_int (&args[1].value);
if (success)
{
@ -906,9 +869,7 @@ desaturate_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -949,13 +910,8 @@ desaturate_full_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 desaturate_mode;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
desaturate_mode = args[1].value.pdb_int;
if (desaturate_mode < GIMP_DESATURATE_LIGHTNESS || desaturate_mode > GIMP_DESATURATE_AVERAGE)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
desaturate_mode = g_value_get_enum (&args[1].value);
if (success)
{
@ -996,11 +952,8 @@ equalize_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean mask_only;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
mask_only = args[1].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
mask_only = g_value_get_boolean (&args[1].value);
if (success)
{
@ -1040,9 +993,7 @@ invert_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1085,19 +1036,10 @@ curves_spline_invoker (ProcRecord *proc_record,
gint32 num_points;
guint8 *control_pts;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
channel = args[1].value.pdb_int;
if (channel < GIMP_HISTOGRAM_VALUE || channel > GIMP_HISTOGRAM_ALPHA)
success = FALSE;
num_points = args[2].value.pdb_int;
if (num_points < 4 || num_points > 34)
success = FALSE;
control_pts = (guint8 *) args[3].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
channel = g_value_get_enum (&args[1].value);
num_points = g_value_get_int (&args[2].value);
control_pts = g_value_get_pointer (&args[3].value);
if (success)
{
@ -1195,19 +1137,10 @@ curves_explicit_invoker (ProcRecord *proc_record,
gint32 num_bytes;
guint8 *curve;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
channel = args[1].value.pdb_int;
if (channel < GIMP_HISTOGRAM_VALUE || channel > GIMP_HISTOGRAM_ALPHA)
success = FALSE;
num_bytes = args[2].value.pdb_int;
if (num_bytes <= 0)
success = FALSE;
curve = (guint8 *) args[3].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
channel = g_value_get_enum (&args[1].value);
num_bytes = g_value_get_int (&args[2].value);
curve = g_value_get_pointer (&args[3].value);
if (success)
{
@ -1298,27 +1231,12 @@ color_balance_invoker (ProcRecord *proc_record,
gdouble magenta_green;
gdouble yellow_blue;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
transfer_mode = args[1].value.pdb_int;
if (transfer_mode < GIMP_SHADOWS || transfer_mode > GIMP_HIGHLIGHTS)
success = FALSE;
preserve_lum = args[2].value.pdb_int ? TRUE : FALSE;
cyan_red = args[3].value.pdb_float;
if (cyan_red < -100.0 || cyan_red > 100.0)
success = FALSE;
magenta_green = args[4].value.pdb_float;
if (magenta_green < -100.0 || magenta_green > 100.0)
success = FALSE;
yellow_blue = args[5].value.pdb_float;
if (yellow_blue < -100.0 || yellow_blue > 100.0)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
transfer_mode = g_value_get_enum (&args[1].value);
preserve_lum = g_value_get_boolean (&args[2].value);
cyan_red = g_value_get_double (&args[3].value);
magenta_green = g_value_get_double (&args[4].value);
yellow_blue = g_value_get_double (&args[5].value);
if (success)
{
@ -1391,21 +1309,10 @@ colorize_invoker (ProcRecord *proc_record,
gdouble saturation;
gdouble lightness;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
hue = args[1].value.pdb_float;
if (hue < 0.0 || hue > 360.0)
success = FALSE;
saturation = args[2].value.pdb_float;
if (saturation < 0.0 || saturation > 100.0)
success = FALSE;
lightness = args[3].value.pdb_float;
if (lightness < -100.0 || lightness > 100.0)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
hue = g_value_get_double (&args[1].value);
saturation = g_value_get_double (&args[2].value);
lightness = g_value_get_double (&args[3].value);
if (success)
{
@ -1483,21 +1390,10 @@ histogram_invoker (ProcRecord *proc_record,
gdouble count = 0.0;
gdouble percentile = 0.0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
channel = args[1].value.pdb_int;
if (channel < GIMP_HISTOGRAM_VALUE || channel > GIMP_HISTOGRAM_ALPHA)
success = FALSE;
start_range = args[2].value.pdb_int;
if (start_range < 0 || start_range >= 256)
success = FALSE;
end_range = args[3].value.pdb_int;
if (end_range < 0 || end_range >= 256)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
channel = g_value_get_enum (&args[1].value);
start_range = g_value_get_int (&args[2].value);
end_range = g_value_get_int (&args[3].value);
if (success)
{
@ -1534,12 +1430,12 @@ histogram_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_float = mean;
return_vals[2].value.pdb_float = std_dev;
return_vals[3].value.pdb_float = median;
return_vals[4].value.pdb_float = pixels;
return_vals[5].value.pdb_float = count;
return_vals[6].value.pdb_float = percentile;
g_value_set_double (&return_vals[1].value, mean);
g_value_set_double (&return_vals[2].value, std_dev);
g_value_set_double (&return_vals[3].value, median);
g_value_set_double (&return_vals[4].value, pixels);
g_value_set_double (&return_vals[5].value, count);
g_value_set_double (&return_vals[6].value, percentile);
}
return return_vals;
@ -1574,25 +1470,11 @@ hue_saturation_invoker (ProcRecord *proc_record,
gdouble lightness;
gdouble saturation;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
hue_range = args[1].value.pdb_int;
if (hue_range < GIMP_ALL_HUES || hue_range > GIMP_MAGENTA_HUES)
success = FALSE;
hue_offset = args[2].value.pdb_float;
if (hue_offset < -180.0 || hue_offset > 180.0)
success = FALSE;
lightness = args[3].value.pdb_float;
if (lightness < -100.0 || lightness > 100.0)
success = FALSE;
saturation = args[4].value.pdb_float;
if (saturation < -100.0 || saturation > 100.0)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
hue_range = g_value_get_enum (&args[1].value);
hue_offset = g_value_get_double (&args[2].value);
lightness = g_value_get_double (&args[3].value);
saturation = g_value_get_double (&args[4].value);
if (success)
{
@ -1663,17 +1545,9 @@ threshold_invoker (ProcRecord *proc_record,
gint32 low_threshold;
gint32 high_threshold;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
low_threshold = args[1].value.pdb_int;
if (low_threshold < 0 || low_threshold > 255)
success = FALSE;
high_threshold = args[2].value.pdb_int;
if (high_threshold < 0 || high_threshold > 255)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
low_threshold = g_value_get_int (&args[1].value);
high_threshold = g_value_get_int (&args[2].value);
if (success)
{

View File

@ -447,7 +447,7 @@ context_get_paint_method_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -477,9 +477,7 @@ context_set_paint_method_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -523,7 +521,7 @@ context_get_foreground_invoker (ProcRecord *proc_record,
gimp_context_get_foreground (context, &foreground);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_color = foreground;
gimp_value_set_rgb (&return_vals[1].value, &foreground);
return return_vals;
}
@ -550,14 +548,18 @@ context_set_foreground_invoker (ProcRecord *proc_record,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpRGB foreground;
foreground = args[0].value.pdb_color;
gimp_value_get_rgb (&args[0].value, &foreground);
gimp_rgb_set_alpha (&foreground, 1.0);
gimp_context_set_foreground (context, &foreground);
if (success)
{
gimp_rgb_set_alpha (&foreground, 1.0);
gimp_context_set_foreground (context, &foreground);
}
return procedural_db_return_values (proc_record, TRUE);
return procedural_db_return_values (proc_record, success);
}
static ProcRecord context_set_foreground_proc =
@ -588,7 +590,7 @@ context_get_background_invoker (ProcRecord *proc_record,
gimp_context_get_background (context, &background);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_color = background;
gimp_value_set_rgb (&return_vals[1].value, &background);
return return_vals;
}
@ -615,14 +617,18 @@ context_set_background_invoker (ProcRecord *proc_record,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpRGB background;
background = args[0].value.pdb_color;
gimp_value_get_rgb (&args[0].value, &background);
gimp_rgb_set_alpha (&background, 1.0);
gimp_context_set_background (context, &background);
if (success)
{
gimp_rgb_set_alpha (&background, 1.0);
gimp_context_set_background (context, &background);
}
return procedural_db_return_values (proc_record, TRUE);
return procedural_db_return_values (proc_record, success);
}
static ProcRecord context_set_background_proc =
@ -705,7 +711,7 @@ context_get_opacity_invoker (ProcRecord *proc_record,
opacity = gimp_context_get_opacity (context) * 100.0;
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_float = opacity;
g_value_set_double (&return_vals[1].value, opacity);
return return_vals;
}
@ -735,9 +741,7 @@ context_set_opacity_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gdouble opacity;
opacity = args[0].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
opacity = g_value_get_double (&args[0].value);
if (success)
{
@ -775,7 +779,7 @@ context_get_paint_mode_invoker (ProcRecord *proc_record,
paint_mode = gimp_context_get_paint_mode (context);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_int = paint_mode;
g_value_set_enum (&return_vals[1].value, paint_mode);
return return_vals;
}
@ -805,9 +809,7 @@ context_set_paint_mode_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gint32 paint_mode;
paint_mode = args[0].value.pdb_int;
if (paint_mode < GIMP_NORMAL_MODE || paint_mode > GIMP_COLOR_ERASE_MODE)
success = FALSE;
paint_mode = g_value_get_enum (&args[0].value);
if (success)
{
@ -853,7 +855,7 @@ context_get_brush_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -883,9 +885,7 @@ context_set_brush_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -937,7 +937,7 @@ context_get_pattern_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -967,9 +967,7 @@ context_set_pattern_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1021,7 +1019,7 @@ context_get_gradient_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -1051,9 +1049,7 @@ context_set_gradient_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1105,7 +1101,7 @@ context_get_palette_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -1135,9 +1131,7 @@ context_set_palette_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1189,7 +1183,7 @@ context_get_font_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -1219,9 +1213,7 @@ context_set_font_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{

View File

@ -139,9 +139,7 @@ image_convert_rgb_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -179,9 +177,7 @@ image_convert_grayscale_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -225,27 +221,13 @@ image_convert_indexed_invoker (ProcRecord *proc_record,
gboolean remove_unused;
gchar *palette;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
dither_type = args[1].value.pdb_int;
if (dither_type < GIMP_NO_DITHER || dither_type > GIMP_FIXED_DITHER)
success = FALSE;
palette_type = args[2].value.pdb_int;
if (palette_type < GIMP_MAKE_PALETTE || palette_type > GIMP_CUSTOM_PALETTE)
success = FALSE;
num_cols = args[3].value.pdb_int;
alpha_dither = args[4].value.pdb_int ? TRUE : FALSE;
remove_unused = args[5].value.pdb_int ? TRUE : FALSE;
palette = (gchar *) args[6].value.pdb_pointer;
if (palette == NULL || !g_utf8_validate (palette, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
dither_type = g_value_get_enum (&args[1].value);
palette_type = g_value_get_enum (&args[2].value);
num_cols = g_value_get_int (&args[3].value);
alpha_dither = g_value_get_boolean (&args[4].value);
remove_unused = g_value_get_boolean (&args[5].value);
palette = (gchar *) g_value_get_string (&args[6].value);
if (success)
{

View File

@ -135,9 +135,7 @@ display_new_invoker (ProcRecord *proc_record,
GimpImage *image;
GimpObject *display = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -156,7 +154,7 @@ display_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = display ? gimp_get_display_ID (gimp, display) : -1;
gimp_value_set_display (&return_vals[1].value, display);
return return_vals;
}
@ -186,9 +184,7 @@ display_delete_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpObject *display;
display = gimp_get_display_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_OBJECT (display))
success = FALSE;
display = gimp_value_get_display (&args[0].value, gimp);
if (success)
{
@ -225,9 +221,7 @@ display_get_window_handle_invoker (ProcRecord *proc_record,
GimpObject *display;
gint32 window = 0;
display = gimp_get_display_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_OBJECT (display))
success = FALSE;
display = gimp_value_get_display (&args[0].value, gimp);
if (success)
{
@ -237,7 +231,7 @@ display_get_window_handle_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = window;
g_value_set_int (&return_vals[1].value, window);
return return_vals;
}
@ -294,13 +288,8 @@ displays_reconnect_invoker (ProcRecord *proc_record,
GimpImage *old_image;
GimpImage *new_image;
old_image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (old_image))
success = FALSE;
new_image = gimp_image_get_by_ID (gimp, args[1].value.pdb_int);
if (! GIMP_IS_IMAGE (new_image))
success = FALSE;
old_image = gimp_value_get_image (&args[0].value, gimp);
new_image = gimp_value_get_image (&args[1].value, gimp);
if (success)
{

View File

@ -196,12 +196,18 @@ register_drawable_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("type-with-alpha",
"type with alpha",
"The drawable's type with alpha: { GIMP_RGBA_IMAGE (1), GIMP_GRAYA_IMAGE (3), GIMP_INDEXEDA_IMAGE (5) }",
GIMP_TYPE_IMAGE_TYPE,
GIMP_RGB_IMAGE,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("type-with-alpha",
"type with alpha",
"The drawable's type with alpha: { GIMP_RGBA_IMAGE (1), GIMP_GRAYA_IMAGE (3), GIMP_INDEXEDA_IMAGE (5) }",
GIMP_TYPE_IMAGE_TYPE,
GIMP_RGB_IMAGE,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0].pspec),
GIMP_RGB_IMAGE);
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0].pspec),
GIMP_GRAY_IMAGE);
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0].pspec),
GIMP_INDEXED_IMAGE);
procedural_db_register (gimp, procedure);
/*
@ -1093,9 +1099,7 @@ drawable_delete_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1135,9 +1139,7 @@ drawable_is_layer_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean layer = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1147,7 +1149,7 @@ drawable_is_layer_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = layer;
g_value_set_boolean (&return_vals[1].value, layer);
return return_vals;
}
@ -1179,9 +1181,7 @@ drawable_is_layer_mask_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean layer_mask = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1191,7 +1191,7 @@ drawable_is_layer_mask_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = layer_mask;
g_value_set_boolean (&return_vals[1].value, layer_mask);
return return_vals;
}
@ -1223,9 +1223,7 @@ drawable_is_channel_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean channel = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1235,7 +1233,7 @@ drawable_is_channel_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = channel;
g_value_set_boolean (&return_vals[1].value, channel);
return return_vals;
}
@ -1267,9 +1265,7 @@ drawable_type_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 type = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1279,7 +1275,7 @@ drawable_type_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = type;
g_value_set_enum (&return_vals[1].value, type);
return return_vals;
}
@ -1311,9 +1307,7 @@ drawable_type_with_alpha_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 type_with_alpha = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1323,7 +1317,7 @@ drawable_type_with_alpha_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = type_with_alpha;
g_value_set_enum (&return_vals[1].value, type_with_alpha);
return return_vals;
}
@ -1355,9 +1349,7 @@ drawable_has_alpha_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean has_alpha = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1367,7 +1359,7 @@ drawable_has_alpha_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = has_alpha;
g_value_set_boolean (&return_vals[1].value, has_alpha);
return return_vals;
}
@ -1399,9 +1391,7 @@ drawable_is_rgb_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean is_rgb = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1411,7 +1401,7 @@ drawable_is_rgb_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = is_rgb;
g_value_set_boolean (&return_vals[1].value, is_rgb);
return return_vals;
}
@ -1443,9 +1433,7 @@ drawable_is_gray_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean is_gray = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1455,7 +1443,7 @@ drawable_is_gray_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = is_gray;
g_value_set_boolean (&return_vals[1].value, is_gray);
return return_vals;
}
@ -1487,9 +1475,7 @@ drawable_is_indexed_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean is_indexed = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1499,7 +1485,7 @@ drawable_is_indexed_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = is_indexed;
g_value_set_boolean (&return_vals[1].value, is_indexed);
return return_vals;
}
@ -1531,9 +1517,7 @@ drawable_bpp_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 bpp = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1543,7 +1527,7 @@ drawable_bpp_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = bpp;
g_value_set_int (&return_vals[1].value, bpp);
return return_vals;
}
@ -1575,9 +1559,7 @@ drawable_width_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 width = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1587,7 +1569,7 @@ drawable_width_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = width;
g_value_set_int (&return_vals[1].value, width);
return return_vals;
}
@ -1619,9 +1601,7 @@ drawable_height_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 height = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1631,7 +1611,7 @@ drawable_height_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = height;
g_value_set_int (&return_vals[1].value, height);
return return_vals;
}
@ -1664,9 +1644,7 @@ drawable_offsets_invoker (ProcRecord *proc_record,
gint32 offset_x = 0;
gint32 offset_y = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1677,8 +1655,8 @@ drawable_offsets_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = offset_x;
return_vals[2].value.pdb_int = offset_y;
g_value_set_int (&return_vals[1].value, offset_x);
g_value_set_int (&return_vals[2].value, offset_y);
}
return return_vals;
@ -1711,9 +1689,7 @@ drawable_get_image_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
GimpImage *image = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1723,7 +1699,7 @@ drawable_get_image_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = image ? gimp_image_get_ID (image) : -1;
gimp_value_set_image (&return_vals[1].value, image);
return return_vals;
}
@ -1754,13 +1730,8 @@ drawable_set_image_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
GimpImage *image;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
image = gimp_image_get_by_ID (gimp, args[1].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
image = gimp_value_get_image (&args[1].value, gimp);
if (success)
{
@ -1798,9 +1769,7 @@ drawable_get_name_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gchar *name = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1810,7 +1779,7 @@ drawable_get_name_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -1841,13 +1810,8 @@ drawable_set_name_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gchar *name;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -1884,9 +1848,7 @@ drawable_get_visible_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean visible = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1896,7 +1858,7 @@ drawable_get_visible_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = visible;
g_value_set_boolean (&return_vals[1].value, visible);
return return_vals;
}
@ -1927,11 +1889,8 @@ drawable_set_visible_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean visible;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
visible = args[1].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
visible = g_value_get_boolean (&args[1].value);
if (success)
{
@ -1968,9 +1927,7 @@ drawable_get_linked_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean linked = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1980,7 +1937,7 @@ drawable_get_linked_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = linked;
g_value_set_boolean (&return_vals[1].value, linked);
return return_vals;
}
@ -2011,11 +1968,8 @@ drawable_set_linked_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean linked;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
linked = args[1].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
linked = g_value_get_boolean (&args[1].value);
if (success)
{
@ -2052,9 +2006,7 @@ drawable_get_tattoo_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 tattoo = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -2064,7 +2016,7 @@ drawable_get_tattoo_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = tattoo;
g_value_set_uint (&return_vals[1].value, tattoo);
return return_vals;
}
@ -2095,13 +2047,8 @@ drawable_set_tattoo_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 tattoo;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
tattoo = args[1].value.pdb_int;
if (tattoo == 0)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
tattoo = g_value_get_uint (&args[1].value);
if (success)
{
@ -2142,9 +2089,7 @@ drawable_mask_bounds_invoker (ProcRecord *proc_record,
gint32 x2 = 0;
gint32 y2 = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -2155,11 +2100,11 @@ drawable_mask_bounds_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = non_empty;
return_vals[2].value.pdb_int = x1;
return_vals[3].value.pdb_int = y1;
return_vals[4].value.pdb_int = x2;
return_vals[5].value.pdb_int = y2;
g_value_set_boolean (&return_vals[1].value, non_empty);
g_value_set_int (&return_vals[2].value, x1);
g_value_set_int (&return_vals[3].value, y1);
g_value_set_int (&return_vals[4].value, x2);
g_value_set_int (&return_vals[5].value, y2);
}
return return_vals;
@ -2196,9 +2141,7 @@ drawable_mask_intersect_invoker (ProcRecord *proc_record,
gint32 width = 0;
gint32 height = 0;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -2209,11 +2152,11 @@ drawable_mask_intersect_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = non_empty;
return_vals[2].value.pdb_int = x;
return_vals[3].value.pdb_int = y;
return_vals[4].value.pdb_int = width;
return_vals[5].value.pdb_int = height;
g_value_set_boolean (&return_vals[1].value, non_empty);
g_value_set_int (&return_vals[2].value, x);
g_value_set_int (&return_vals[3].value, y);
g_value_set_int (&return_vals[4].value, width);
g_value_set_int (&return_vals[5].value, height);
}
return return_vals;
@ -2245,11 +2188,8 @@ drawable_merge_shadow_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean undo;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
undo = args[1].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
undo = g_value_get_boolean (&args[1].value);
if (success)
{
@ -2303,17 +2243,11 @@ drawable_update_invoker (ProcRecord *proc_record,
gint32 width;
gint32 height;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x = args[1].value.pdb_int;
y = args[2].value.pdb_int;
width = args[3].value.pdb_int;
height = args[4].value.pdb_int;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x = g_value_get_int (&args[1].value);
y = g_value_get_int (&args[2].value);
width = g_value_get_int (&args[3].value);
height = g_value_get_int (&args[4].value);
if (success)
{
@ -2353,17 +2287,9 @@ drawable_get_pixel_invoker (ProcRecord *proc_record,
gint32 num_channels = 0;
guint8 *pixel = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x_coord = args[1].value.pdb_int;
if (x_coord < 0)
success = FALSE;
y_coord = args[2].value.pdb_int;
if (y_coord < 0)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x_coord = g_value_get_int (&args[1].value);
y_coord = g_value_get_int (&args[2].value);
if (success)
{
@ -2398,8 +2324,8 @@ drawable_get_pixel_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_channels;
return_vals[2].value.pdb_pointer = pixel;
g_value_set_int (&return_vals[1].value, num_channels);
g_value_set_pointer (&return_vals[2].value, pixel);
}
return return_vals;
@ -2434,21 +2360,11 @@ drawable_set_pixel_invoker (ProcRecord *proc_record,
gint32 num_channels;
guint8 *pixel;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x_coord = args[1].value.pdb_int;
if (x_coord < 0)
success = FALSE;
y_coord = args[2].value.pdb_int;
if (y_coord < 0)
success = FALSE;
num_channels = args[3].value.pdb_int;
pixel = (guint8 *) args[4].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x_coord = g_value_get_int (&args[1].value);
y_coord = g_value_get_int (&args[2].value);
num_channels = g_value_get_int (&args[3].value);
pixel = g_value_get_pointer (&args[4].value);
if (success)
{
@ -2506,13 +2422,8 @@ drawable_fill_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 fill_type;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
fill_type = args[1].value.pdb_int;
if (fill_type < GIMP_FOREGROUND_FILL || fill_type > GIMP_PATTERN_FILL)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
fill_type = g_value_get_enum (&args[1].value);
if (success)
{
@ -2551,19 +2462,11 @@ drawable_offset_invoker (ProcRecord *proc_record,
gint32 offset_x;
gint32 offset_y;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
wrap_around = args[1].value.pdb_int ? TRUE : FALSE;
fill_type = args[2].value.pdb_int;
if (fill_type < GIMP_OFFSET_BACKGROUND || fill_type > GIMP_OFFSET_TRANSPARENT)
success = FALSE;
offset_x = args[3].value.pdb_int;
offset_y = args[4].value.pdb_int;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
wrap_around = g_value_get_boolean (&args[1].value);
fill_type = g_value_get_enum (&args[2].value);
offset_x = g_value_get_int (&args[3].value);
offset_y = g_value_get_int (&args[4].value);
if (success)
{
@ -2610,17 +2513,9 @@ drawable_thumbnail_invoker (ProcRecord *proc_record,
gint32 thumbnail_data_count = 0;
guint8 *thumbnail_data = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
width = args[1].value.pdb_int;
if (width < 1 || width > 512)
success = FALSE;
height = args[2].value.pdb_int;
if (height < 1 || height > 512)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
width = g_value_get_int (&args[1].value);
height = g_value_get_int (&args[2].value);
if (success)
{
@ -2665,11 +2560,11 @@ drawable_thumbnail_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = actual_width;
return_vals[2].value.pdb_int = actual_height;
return_vals[3].value.pdb_int = bpp;
return_vals[4].value.pdb_int = thumbnail_data_count;
return_vals[5].value.pdb_pointer = thumbnail_data;
g_value_set_int (&return_vals[1].value, actual_width);
g_value_set_int (&return_vals[2].value, actual_height);
g_value_set_int (&return_vals[3].value, bpp);
g_value_set_int (&return_vals[4].value, thumbnail_data_count);
g_value_set_pointer (&return_vals[5].value, thumbnail_data);
}
return return_vals;
@ -2712,33 +2607,13 @@ drawable_sub_thumbnail_invoker (ProcRecord *proc_record,
gint32 thumbnail_data_count = 0;
guint8 *thumbnail_data = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
src_x = args[1].value.pdb_int;
if (src_x < 0)
success = FALSE;
src_y = args[2].value.pdb_int;
if (src_y < 0)
success = FALSE;
src_width = args[3].value.pdb_int;
if (src_width < 1)
success = FALSE;
src_height = args[4].value.pdb_int;
if (src_height < 1)
success = FALSE;
dest_width = args[5].value.pdb_int;
if (dest_width < 1 || dest_width > 512)
success = FALSE;
dest_height = args[6].value.pdb_int;
if (dest_height < 1 || dest_height > 512)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
src_x = g_value_get_int (&args[1].value);
src_y = g_value_get_int (&args[2].value);
src_width = g_value_get_int (&args[3].value);
src_height = g_value_get_int (&args[4].value);
dest_width = g_value_get_int (&args[5].value);
dest_height = g_value_get_int (&args[6].value);
if (success)
{
@ -2781,11 +2656,11 @@ drawable_sub_thumbnail_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = width;
return_vals[2].value.pdb_int = height;
return_vals[3].value.pdb_int = bpp;
return_vals[4].value.pdb_int = thumbnail_data_count;
return_vals[5].value.pdb_pointer = thumbnail_data;
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, bpp);
g_value_set_int (&return_vals[4].value, thumbnail_data_count);
g_value_set_pointer (&return_vals[5].value, thumbnail_data);
}
return return_vals;
@ -2818,17 +2693,9 @@ drawable_foreground_extract_invoker (ProcRecord *proc_record,
gint32 mode;
GimpDrawable *mask;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
mode = args[1].value.pdb_int;
if (mode != GIMP_FOREGROUND_EXTRACT_SIOX)
success = FALSE;
mask = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[2].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (mask) && ! gimp_item_is_removed (GIMP_ITEM (mask))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
mode = g_value_get_enum (&args[1].value);
mask = (GimpDrawable *) gimp_value_get_item (&args[2].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{

View File

@ -74,12 +74,14 @@ register_drawable_transform_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("flip-type",
"flip type",
"Type of flip: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("flip-type",
"flip type",
"Type of flip: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1].pspec),
GIMP_ORIENTATION_UNKNOWN);
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("auto-center",
@ -843,12 +845,14 @@ register_drawable_transform_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("shear-type",
"shear type",
"Type of shear: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("shear-type",
"shear type",
"Type of shear: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1].pspec),
GIMP_ORIENTATION_UNKNOWN);
procedural_db_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("magnitude",
@ -917,12 +921,14 @@ register_drawable_transform_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("shear-type",
"shear type",
"Type of shear: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("shear-type",
"shear type",
"Type of shear: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1].pspec),
GIMP_ORIENTATION_UNKNOWN);
procedural_db_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("magnitude",
@ -1385,19 +1391,11 @@ drawable_transform_flip_simple_invoker (ProcRecord *proc_record,
gdouble axis;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
flip_type = args[1].value.pdb_int;
if (flip_type < GIMP_ORIENTATION_HORIZONTAL || flip_type > GIMP_ORIENTATION_VERTICAL)
success = FALSE;
auto_center = args[2].value.pdb_int ? TRUE : FALSE;
axis = args[3].value.pdb_float;
clip_result = args[4].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
flip_type = g_value_get_enum (&args[1].value);
auto_center = g_value_get_boolean (&args[2].value);
axis = g_value_get_double (&args[3].value);
clip_result = g_value_get_boolean (&args[4].value);
if (success)
{
@ -1418,7 +1416,7 @@ drawable_transform_flip_simple_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -1458,33 +1456,16 @@ drawable_transform_flip_invoker (ProcRecord *proc_record,
gint32 recursion_level;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x0 = args[1].value.pdb_float;
y0 = args[2].value.pdb_float;
x1 = args[3].value.pdb_float;
y1 = args[4].value.pdb_float;
transform_direction = args[5].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
interpolation = args[6].value.pdb_int;
if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_LANCZOS)
success = FALSE;
supersample = args[7].value.pdb_int ? TRUE : FALSE;
recursion_level = args[8].value.pdb_int;
if (recursion_level < 1)
success = FALSE;
clip_result = args[9].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x0 = g_value_get_double (&args[1].value);
y0 = g_value_get_double (&args[2].value);
x1 = g_value_get_double (&args[3].value);
y1 = g_value_get_double (&args[4].value);
transform_direction = g_value_get_enum (&args[5].value);
interpolation = g_value_get_enum (&args[6].value);
supersample = g_value_get_boolean (&args[7].value);
recursion_level = g_value_get_int (&args[8].value);
clip_result = g_value_get_boolean (&args[9].value);
if (success)
{
@ -1520,7 +1501,7 @@ drawable_transform_flip_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -1557,21 +1538,13 @@ drawable_transform_flip_default_invoker (ProcRecord *proc_record,
gboolean interpolate;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x0 = args[1].value.pdb_float;
y0 = args[2].value.pdb_float;
x1 = args[3].value.pdb_float;
y1 = args[4].value.pdb_float;
interpolate = args[5].value.pdb_int ? TRUE : FALSE;
clip_result = args[6].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x0 = g_value_get_double (&args[1].value);
y0 = g_value_get_double (&args[2].value);
x1 = g_value_get_double (&args[3].value);
y1 = g_value_get_double (&args[4].value);
interpolate = g_value_get_boolean (&args[5].value);
clip_result = g_value_get_boolean (&args[6].value);
if (success)
{
@ -1611,7 +1584,7 @@ drawable_transform_flip_default_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -1655,41 +1628,20 @@ drawable_transform_perspective_invoker (ProcRecord *proc_record,
gint32 recursion_level;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x0 = args[1].value.pdb_float;
y0 = args[2].value.pdb_float;
x1 = args[3].value.pdb_float;
y1 = args[4].value.pdb_float;
x2 = args[5].value.pdb_float;
y2 = args[6].value.pdb_float;
x3 = args[7].value.pdb_float;
y3 = args[8].value.pdb_float;
transform_direction = args[9].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
interpolation = args[10].value.pdb_int;
if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_LANCZOS)
success = FALSE;
supersample = args[11].value.pdb_int ? TRUE : FALSE;
recursion_level = args[12].value.pdb_int;
if (recursion_level < 1)
success = FALSE;
clip_result = args[13].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x0 = g_value_get_double (&args[1].value);
y0 = g_value_get_double (&args[2].value);
x1 = g_value_get_double (&args[3].value);
y1 = g_value_get_double (&args[4].value);
x2 = g_value_get_double (&args[5].value);
y2 = g_value_get_double (&args[6].value);
x3 = g_value_get_double (&args[7].value);
y3 = g_value_get_double (&args[8].value);
transform_direction = g_value_get_enum (&args[9].value);
interpolation = g_value_get_enum (&args[10].value);
supersample = g_value_get_boolean (&args[11].value);
recursion_level = g_value_get_int (&args[12].value);
clip_result = g_value_get_boolean (&args[13].value);
if (success)
{
@ -1729,7 +1681,7 @@ drawable_transform_perspective_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -1770,29 +1722,17 @@ drawable_transform_perspective_default_invoker (ProcRecord *proc_record,
gboolean interpolate;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x0 = args[1].value.pdb_float;
y0 = args[2].value.pdb_float;
x1 = args[3].value.pdb_float;
y1 = args[4].value.pdb_float;
x2 = args[5].value.pdb_float;
y2 = args[6].value.pdb_float;
x3 = args[7].value.pdb_float;
y3 = args[8].value.pdb_float;
interpolate = args[9].value.pdb_int ? TRUE : FALSE;
clip_result = args[10].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x0 = g_value_get_double (&args[1].value);
y0 = g_value_get_double (&args[2].value);
x1 = g_value_get_double (&args[3].value);
y1 = g_value_get_double (&args[4].value);
x2 = g_value_get_double (&args[5].value);
y2 = g_value_get_double (&args[6].value);
x3 = g_value_get_double (&args[7].value);
y3 = g_value_get_double (&args[8].value);
interpolate = g_value_get_boolean (&args[9].value);
clip_result = g_value_get_boolean (&args[10].value);
if (success)
{
@ -1836,7 +1776,7 @@ drawable_transform_perspective_default_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -1872,21 +1812,12 @@ drawable_transform_rotate_simple_invoker (ProcRecord *proc_record,
gint32 center_y;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
rotate_type = args[1].value.pdb_int;
if (rotate_type < GIMP_ROTATE_90 || rotate_type > GIMP_ROTATE_270)
success = FALSE;
auto_center = args[2].value.pdb_int ? TRUE : FALSE;
center_x = args[3].value.pdb_int;
center_y = args[4].value.pdb_int;
clip_result = args[5].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
rotate_type = g_value_get_enum (&args[1].value);
auto_center = g_value_get_boolean (&args[2].value);
center_x = g_value_get_int (&args[3].value);
center_y = g_value_get_int (&args[4].value);
clip_result = g_value_get_boolean (&args[5].value);
if (success)
{
@ -1907,7 +1838,7 @@ drawable_transform_rotate_simple_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -1947,33 +1878,16 @@ drawable_transform_rotate_invoker (ProcRecord *proc_record,
gint32 recursion_level;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
angle = args[1].value.pdb_float;
auto_center = args[2].value.pdb_int ? TRUE : FALSE;
center_x = args[3].value.pdb_int;
center_y = args[4].value.pdb_int;
transform_direction = args[5].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
interpolation = args[6].value.pdb_int;
if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_LANCZOS)
success = FALSE;
supersample = args[7].value.pdb_int ? TRUE : FALSE;
recursion_level = args[8].value.pdb_int;
if (recursion_level < 1)
success = FALSE;
clip_result = args[9].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
angle = g_value_get_double (&args[1].value);
auto_center = g_value_get_boolean (&args[2].value);
center_x = g_value_get_int (&args[3].value);
center_y = g_value_get_int (&args[4].value);
transform_direction = g_value_get_enum (&args[5].value);
interpolation = g_value_get_enum (&args[6].value);
supersample = g_value_get_boolean (&args[7].value);
recursion_level = g_value_get_int (&args[8].value);
clip_result = g_value_get_boolean (&args[9].value);
if (success)
{
@ -2012,7 +1926,7 @@ drawable_transform_rotate_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2049,21 +1963,13 @@ drawable_transform_rotate_default_invoker (ProcRecord *proc_record,
gboolean interpolate;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
angle = args[1].value.pdb_float;
auto_center = args[2].value.pdb_int ? TRUE : FALSE;
center_x = args[3].value.pdb_int;
center_y = args[4].value.pdb_int;
interpolate = args[5].value.pdb_int ? TRUE : FALSE;
clip_result = args[6].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
angle = g_value_get_double (&args[1].value);
auto_center = g_value_get_boolean (&args[2].value);
center_x = g_value_get_int (&args[3].value);
center_y = g_value_get_int (&args[4].value);
interpolate = g_value_get_boolean (&args[5].value);
clip_result = g_value_get_boolean (&args[6].value);
if (success)
{
@ -2106,7 +2012,7 @@ drawable_transform_rotate_default_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2146,33 +2052,16 @@ drawable_transform_scale_invoker (ProcRecord *proc_record,
gint32 recursion_level;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x0 = args[1].value.pdb_float;
y0 = args[2].value.pdb_float;
x1 = args[3].value.pdb_float;
y1 = args[4].value.pdb_float;
transform_direction = args[5].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
interpolation = args[6].value.pdb_int;
if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_LANCZOS)
success = FALSE;
supersample = args[7].value.pdb_int ? TRUE : FALSE;
recursion_level = args[8].value.pdb_int;
if (recursion_level < 1)
success = FALSE;
clip_result = args[9].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x0 = g_value_get_double (&args[1].value);
y0 = g_value_get_double (&args[2].value);
x1 = g_value_get_double (&args[3].value);
y1 = g_value_get_double (&args[4].value);
transform_direction = g_value_get_enum (&args[5].value);
interpolation = g_value_get_enum (&args[6].value);
supersample = g_value_get_boolean (&args[7].value);
recursion_level = g_value_get_int (&args[8].value);
clip_result = g_value_get_boolean (&args[9].value);
if (success)
{
@ -2211,7 +2100,7 @@ drawable_transform_scale_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2248,21 +2137,13 @@ drawable_transform_scale_default_invoker (ProcRecord *proc_record,
gboolean interpolate;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x0 = args[1].value.pdb_float;
y0 = args[2].value.pdb_float;
x1 = args[3].value.pdb_float;
y1 = args[4].value.pdb_float;
interpolate = args[5].value.pdb_int ? TRUE : FALSE;
clip_result = args[6].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x0 = g_value_get_double (&args[1].value);
y0 = g_value_get_double (&args[2].value);
x1 = g_value_get_double (&args[3].value);
y1 = g_value_get_double (&args[4].value);
interpolate = g_value_get_boolean (&args[5].value);
clip_result = g_value_get_boolean (&args[6].value);
if (success)
{
@ -2305,7 +2186,7 @@ drawable_transform_scale_default_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2343,31 +2224,14 @@ drawable_transform_shear_invoker (ProcRecord *proc_record,
gint32 recursion_level;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
shear_type = args[1].value.pdb_int;
if (shear_type < GIMP_ORIENTATION_HORIZONTAL || shear_type > GIMP_ORIENTATION_VERTICAL)
success = FALSE;
magnitude = args[2].value.pdb_float;
transform_direction = args[3].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
interpolation = args[4].value.pdb_int;
if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_LANCZOS)
success = FALSE;
supersample = args[5].value.pdb_int ? TRUE : FALSE;
recursion_level = args[6].value.pdb_int;
if (recursion_level < 1)
success = FALSE;
clip_result = args[7].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
shear_type = g_value_get_enum (&args[1].value);
magnitude = g_value_get_double (&args[2].value);
transform_direction = g_value_get_enum (&args[3].value);
interpolation = g_value_get_enum (&args[4].value);
supersample = g_value_get_boolean (&args[5].value);
recursion_level = g_value_get_int (&args[6].value);
clip_result = g_value_get_boolean (&args[7].value);
if (success)
{
@ -2404,7 +2268,7 @@ drawable_transform_shear_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2439,19 +2303,11 @@ drawable_transform_shear_default_invoker (ProcRecord *proc_record,
gboolean interpolate;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
shear_type = args[1].value.pdb_int;
if (shear_type < GIMP_ORIENTATION_HORIZONTAL || shear_type > GIMP_ORIENTATION_VERTICAL)
success = FALSE;
magnitude = args[2].value.pdb_float;
interpolate = args[3].value.pdb_int ? TRUE : FALSE;
clip_result = args[4].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
shear_type = g_value_get_enum (&args[1].value);
magnitude = g_value_get_double (&args[2].value);
interpolate = g_value_get_boolean (&args[3].value);
clip_result = g_value_get_boolean (&args[4].value);
if (success)
{
@ -2492,7 +2348,7 @@ drawable_transform_shear_default_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2535,39 +2391,19 @@ drawable_transform_2d_invoker (ProcRecord *proc_record,
gint32 recursion_level;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
source_x = args[1].value.pdb_float;
source_y = args[2].value.pdb_float;
scale_x = args[3].value.pdb_float;
scale_y = args[4].value.pdb_float;
angle = args[5].value.pdb_float;
dest_x = args[6].value.pdb_float;
dest_y = args[7].value.pdb_float;
transform_direction = args[8].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
interpolation = args[9].value.pdb_int;
if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_LANCZOS)
success = FALSE;
supersample = args[10].value.pdb_int ? TRUE : FALSE;
recursion_level = args[11].value.pdb_int;
if (recursion_level < 1)
success = FALSE;
clip_result = args[12].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
source_x = g_value_get_double (&args[1].value);
source_y = g_value_get_double (&args[2].value);
scale_x = g_value_get_double (&args[3].value);
scale_y = g_value_get_double (&args[4].value);
angle = g_value_get_double (&args[5].value);
dest_x = g_value_get_double (&args[6].value);
dest_y = g_value_get_double (&args[7].value);
transform_direction = g_value_get_enum (&args[8].value);
interpolation = g_value_get_enum (&args[9].value);
supersample = g_value_get_boolean (&args[10].value);
recursion_level = g_value_get_int (&args[11].value);
clip_result = g_value_get_boolean (&args[12].value);
if (success)
{
@ -2605,7 +2441,7 @@ drawable_transform_2d_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2645,27 +2481,16 @@ drawable_transform_2d_default_invoker (ProcRecord *proc_record,
gboolean interpolate;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
source_x = args[1].value.pdb_float;
source_y = args[2].value.pdb_float;
scale_x = args[3].value.pdb_float;
scale_y = args[4].value.pdb_float;
angle = args[5].value.pdb_float;
dest_x = args[6].value.pdb_float;
dest_y = args[7].value.pdb_float;
interpolate = args[8].value.pdb_int ? TRUE : FALSE;
clip_result = args[9].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
source_x = g_value_get_double (&args[1].value);
source_y = g_value_get_double (&args[2].value);
scale_x = g_value_get_double (&args[3].value);
scale_y = g_value_get_double (&args[4].value);
angle = g_value_get_double (&args[5].value);
dest_x = g_value_get_double (&args[6].value);
dest_y = g_value_get_double (&args[7].value);
interpolate = g_value_get_boolean (&args[8].value);
clip_result = g_value_get_boolean (&args[9].value);
if (success)
{
@ -2707,7 +2532,7 @@ drawable_transform_2d_default_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2752,43 +2577,21 @@ drawable_transform_matrix_invoker (ProcRecord *proc_record,
gint32 recursion_level;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
coeff_0_0 = args[1].value.pdb_float;
coeff_0_1 = args[2].value.pdb_float;
coeff_0_2 = args[3].value.pdb_float;
coeff_1_0 = args[4].value.pdb_float;
coeff_1_1 = args[5].value.pdb_float;
coeff_1_2 = args[6].value.pdb_float;
coeff_2_0 = args[7].value.pdb_float;
coeff_2_1 = args[8].value.pdb_float;
coeff_2_2 = args[9].value.pdb_float;
transform_direction = args[10].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
interpolation = args[11].value.pdb_int;
if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_LANCZOS)
success = FALSE;
supersample = args[12].value.pdb_int ? TRUE : FALSE;
recursion_level = args[13].value.pdb_int;
if (recursion_level < 1)
success = FALSE;
clip_result = args[14].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
coeff_0_0 = g_value_get_double (&args[1].value);
coeff_0_1 = g_value_get_double (&args[2].value);
coeff_0_2 = g_value_get_double (&args[3].value);
coeff_1_0 = g_value_get_double (&args[4].value);
coeff_1_1 = g_value_get_double (&args[5].value);
coeff_1_2 = g_value_get_double (&args[6].value);
coeff_2_0 = g_value_get_double (&args[7].value);
coeff_2_1 = g_value_get_double (&args[8].value);
coeff_2_2 = g_value_get_double (&args[9].value);
transform_direction = g_value_get_enum (&args[10].value);
interpolation = g_value_get_enum (&args[11].value);
supersample = g_value_get_boolean (&args[12].value);
recursion_level = g_value_get_int (&args[13].value);
clip_result = g_value_get_boolean (&args[14].value);
if (success)
{
@ -2830,7 +2633,7 @@ drawable_transform_matrix_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -2872,31 +2675,18 @@ drawable_transform_matrix_default_invoker (ProcRecord *proc_record,
gboolean interpolate;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
coeff_0_0 = args[1].value.pdb_float;
coeff_0_1 = args[2].value.pdb_float;
coeff_0_2 = args[3].value.pdb_float;
coeff_1_0 = args[4].value.pdb_float;
coeff_1_1 = args[5].value.pdb_float;
coeff_1_2 = args[6].value.pdb_float;
coeff_2_0 = args[7].value.pdb_float;
coeff_2_1 = args[8].value.pdb_float;
coeff_2_2 = args[9].value.pdb_float;
interpolate = args[10].value.pdb_int ? TRUE : FALSE;
clip_result = args[11].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
coeff_0_0 = g_value_get_double (&args[1].value);
coeff_0_1 = g_value_get_double (&args[2].value);
coeff_0_2 = g_value_get_double (&args[3].value);
coeff_1_0 = g_value_get_double (&args[4].value);
coeff_1_1 = g_value_get_double (&args[5].value);
coeff_1_2 = g_value_get_double (&args[6].value);
coeff_2_0 = g_value_get_double (&args[7].value);
coeff_2_1 = g_value_get_double (&args[8].value);
coeff_2_2 = g_value_get_double (&args[9].value);
interpolate = g_value_get_boolean (&args[10].value);
clip_result = g_value_get_boolean (&args[11].value);
if (success)
{
@ -2942,7 +2732,7 @@ drawable_transform_matrix_default_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}

View File

@ -565,9 +565,7 @@ edit_cut_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean non_empty = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -584,7 +582,7 @@ edit_cut_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = non_empty;
g_value_set_boolean (&return_vals[1].value, non_empty);
return return_vals;
}
@ -616,9 +614,7 @@ edit_copy_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gboolean non_empty = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -635,7 +631,7 @@ edit_copy_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = non_empty;
g_value_set_boolean (&return_vals[1].value, non_empty);
return return_vals;
}
@ -667,9 +663,7 @@ edit_copy_visible_invoker (ProcRecord *proc_record,
GimpImage *image;
gboolean non_empty = FALSE;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -679,7 +673,7 @@ edit_copy_visible_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = non_empty;
g_value_set_boolean (&return_vals[1].value, non_empty);
return return_vals;
}
@ -712,11 +706,8 @@ edit_paste_invoker (ProcRecord *proc_record,
gboolean paste_into;
GimpLayer *floating_sel = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
paste_into = args[1].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
paste_into = g_value_get_boolean (&args[1].value);
if (success)
{
@ -736,7 +727,7 @@ edit_paste_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = floating_sel ? gimp_item_get_ID (GIMP_ITEM (floating_sel)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (floating_sel));
return return_vals;
}
@ -780,7 +771,7 @@ edit_paste_as_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = image ? gimp_image_get_ID (image) : -1;
gimp_value_set_image (&return_vals[1].value, image);
return return_vals;
}
@ -813,13 +804,8 @@ edit_named_cut_invoker (ProcRecord *proc_record,
gchar *buffer_name;
gchar *real_name = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
buffer_name = (gchar *) args[1].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
buffer_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -842,7 +828,7 @@ edit_named_cut_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = real_name;
g_value_take_string (&return_vals[1].value, real_name);
return return_vals;
}
@ -875,13 +861,8 @@ edit_named_copy_invoker (ProcRecord *proc_record,
gchar *buffer_name;
gchar *real_name = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
buffer_name = (gchar *) args[1].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
buffer_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -904,7 +885,7 @@ edit_named_copy_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = real_name;
g_value_take_string (&return_vals[1].value, real_name);
return return_vals;
}
@ -937,13 +918,8 @@ edit_named_copy_visible_invoker (ProcRecord *proc_record,
gchar *buffer_name;
gchar *real_name = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
buffer_name = (gchar *) args[1].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
buffer_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -964,7 +940,7 @@ edit_named_copy_visible_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = real_name;
g_value_take_string (&return_vals[1].value, real_name);
return return_vals;
}
@ -998,15 +974,9 @@ edit_named_paste_invoker (ProcRecord *proc_record,
gboolean paste_into;
GimpLayer *floating_sel = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
buffer_name = (gchar *) args[1].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
paste_into = args[2].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
buffer_name = (gchar *) g_value_get_string (&args[1].value);
paste_into = g_value_get_boolean (&args[2].value);
if (success)
{
@ -1028,7 +998,7 @@ edit_named_paste_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = floating_sel ? gimp_item_get_ID (GIMP_ITEM (floating_sel)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (floating_sel));
return return_vals;
}
@ -1060,9 +1030,7 @@ edit_named_paste_as_new_invoker (ProcRecord *proc_record,
gchar *buffer_name;
GimpImage *image = NULL;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
buffer_name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1083,7 +1051,7 @@ edit_named_paste_as_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = image ? gimp_image_get_ID (image) : -1;
gimp_value_set_image (&return_vals[1].value, image);
return return_vals;
}
@ -1113,9 +1081,7 @@ edit_clear_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -1158,13 +1124,8 @@ edit_fill_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 fill_type;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
fill_type = args[1].value.pdb_int;
if (fill_type < GIMP_FOREGROUND_FILL || fill_type > GIMP_PATTERN_FILL)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
fill_type = g_value_get_enum (&args[1].value);
if (success)
{
@ -1214,31 +1175,14 @@ edit_bucket_fill_invoker (ProcRecord *proc_record,
gdouble x;
gdouble y;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
fill_mode = args[1].value.pdb_int;
if (fill_mode < GIMP_FG_BUCKET_FILL || fill_mode > GIMP_PATTERN_BUCKET_FILL)
success = FALSE;
paint_mode = args[2].value.pdb_int;
if (paint_mode < GIMP_NORMAL_MODE || paint_mode > GIMP_COLOR_ERASE_MODE)
success = FALSE;
opacity = args[3].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
threshold = args[4].value.pdb_float;
if (threshold < 0.0 || threshold > 255.0)
success = FALSE;
sample_merged = args[5].value.pdb_int ? TRUE : FALSE;
x = args[6].value.pdb_float;
y = args[7].value.pdb_float;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
fill_mode = g_value_get_enum (&args[1].value);
paint_mode = g_value_get_enum (&args[2].value);
opacity = g_value_get_double (&args[3].value);
threshold = g_value_get_double (&args[4].value);
sample_merged = g_value_get_boolean (&args[5].value);
x = g_value_get_double (&args[6].value);
y = g_value_get_double (&args[7].value);
if (success)
{
@ -1302,51 +1246,22 @@ edit_blend_invoker (ProcRecord *proc_record,
gdouble x2;
gdouble y2;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
blend_mode = args[1].value.pdb_int;
if (blend_mode < GIMP_FG_BG_RGB_MODE || blend_mode > GIMP_CUSTOM_MODE)
success = FALSE;
paint_mode = args[2].value.pdb_int;
if (paint_mode < GIMP_NORMAL_MODE || paint_mode > GIMP_COLOR_ERASE_MODE)
success = FALSE;
gradient_type = args[3].value.pdb_int;
if (gradient_type < GIMP_GRADIENT_LINEAR || gradient_type > GIMP_GRADIENT_SPIRAL_ANTICLOCKWISE)
success = FALSE;
opacity = args[4].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
offset = args[5].value.pdb_float;
if (offset < 0.0)
success = FALSE;
repeat = args[6].value.pdb_int;
if (repeat < GIMP_REPEAT_NONE || repeat > GIMP_REPEAT_TRIANGULAR)
success = FALSE;
reverse = args[7].value.pdb_int ? TRUE : FALSE;
supersample = args[8].value.pdb_int ? TRUE : FALSE;
max_depth = args[9].value.pdb_int;
threshold = args[10].value.pdb_float;
dither = args[11].value.pdb_int ? TRUE : FALSE;
x1 = args[12].value.pdb_float;
y1 = args[13].value.pdb_float;
x2 = args[14].value.pdb_float;
y2 = args[15].value.pdb_float;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
blend_mode = g_value_get_enum (&args[1].value);
paint_mode = g_value_get_enum (&args[2].value);
gradient_type = g_value_get_enum (&args[3].value);
opacity = g_value_get_double (&args[4].value);
offset = g_value_get_double (&args[5].value);
repeat = g_value_get_enum (&args[6].value);
reverse = g_value_get_boolean (&args[7].value);
supersample = g_value_get_boolean (&args[8].value);
max_depth = g_value_get_int (&args[9].value);
threshold = g_value_get_double (&args[10].value);
dither = g_value_get_boolean (&args[11].value);
x1 = g_value_get_double (&args[12].value);
y1 = g_value_get_double (&args[13].value);
x2 = g_value_get_double (&args[14].value);
y2 = g_value_get_double (&args[15].value);
if (success)
{
@ -1411,9 +1326,7 @@ edit_stroke_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{

View File

@ -80,12 +80,14 @@ register_fileops_procs (Gimp *gimp)
procedure = procedural_db_init_proc (&file_load_proc, 3, 1);
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode: { GIMP_RUN_INTERACTIVE (0), GIMP_RUN_NONINTERACTIVE (1) }",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("run-mode",
"run mode",
"The run mode: { GIMP_RUN_INTERACTIVE (0), GIMP_RUN_NONINTERACTIVE (1) }",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[0].pspec),
GIMP_RUN_WITH_LAST_VALS);
procedural_db_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("filename",
@ -117,12 +119,14 @@ register_fileops_procs (Gimp *gimp)
procedure = procedural_db_init_proc (&file_load_layer_proc, 3, 1);
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode: { GIMP_RUN_INTERACTIVE (0), GIMP_RUN_NONINTERACTIVE (1) }",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("run-mode",
"run mode",
"The run mode: { GIMP_RUN_INTERACTIVE (0), GIMP_RUN_NONINTERACTIVE (1) }",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[0].pspec),
GIMP_RUN_WITH_LAST_VALS);
procedural_db_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
@ -195,12 +199,14 @@ register_fileops_procs (Gimp *gimp)
procedure = procedural_db_init_proc (&file_save_proc, 5, 0);
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode: { GIMP_RUN_INTERACTIVE (0), GIMP_RUN_NONINTERACTIVE (1) }",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("run-mode",
"run mode",
"The run mode: { GIMP_RUN_INTERACTIVE (0), GIMP_RUN_NONINTERACTIVE (1) }",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[0].pspec),
GIMP_RUN_WITH_LAST_VALS);
procedural_db_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
@ -482,10 +488,12 @@ file_load_invoker (ProcRecord *proc_record,
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);
@ -499,19 +507,21 @@ file_load_invoker (ProcRecord *proc_record,
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_transform (&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;
}
@ -545,17 +555,9 @@ file_load_layer_invoker (ProcRecord *proc_record,
gchar *filename;
GimpLayer *layer = NULL;
run_mode = args[0].value.pdb_int;
if (run_mode < GIMP_RUN_INTERACTIVE || run_mode > GIMP_RUN_NONINTERACTIVE)
success = FALSE;
image = gimp_image_get_by_ID (gimp, args[1].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
filename = (gchar *) args[2].value.pdb_pointer;
if (filename == NULL)
success = FALSE;
run_mode = g_value_get_enum (&args[0].value);
image = gimp_value_get_image (&args[1].value, gimp);
filename = (gchar *) g_value_get_string (&args[2].value);
if (success)
{
@ -579,7 +581,7 @@ file_load_layer_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = layer ? gimp_item_get_ID (GIMP_ITEM (layer)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (layer));
return return_vals;
}
@ -614,9 +616,7 @@ file_load_thumbnail_invoker (ProcRecord *proc_record,
gint32 thumb_data_count = 0;
guint8 *thumb_data = NULL;
filename = (gchar *) args[0].value.pdb_pointer;
if (filename == NULL)
success = FALSE;
filename = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -672,10 +672,10 @@ file_load_thumbnail_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = width;
return_vals[2].value.pdb_int = height;
return_vals[3].value.pdb_int = thumb_data_count;
return_vals[4].value.pdb_pointer = thumb_data;
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, thumb_data_count);
g_value_set_pointer (&return_vals[4].value, thumb_data);
}
return return_vals;
@ -708,10 +708,12 @@ file_save_invoker (ProcRecord *proc_record,
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);
@ -725,19 +727,21 @@ file_save_invoker (ProcRecord *proc_record,
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_transform (&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;
}
@ -768,13 +772,8 @@ file_save_thumbnail_invoker (ProcRecord *proc_record,
GimpImage *image;
gchar *filename;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
filename = (gchar *) args[1].value.pdb_pointer;
if (filename == NULL)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
filename = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -836,9 +835,7 @@ temp_name_invoker (ProcRecord *proc_record,
gchar *extension;
gchar *name = NULL;
extension = (gchar *) args[0].value.pdb_pointer;
if (extension == NULL)
success = FALSE;
extension = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -865,7 +862,7 @@ temp_name_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -898,15 +895,10 @@ register_magic_load_handler_invoker (ProcRecord *proc_record,
gchar *prefixes;
gchar *magics;
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
extensions = (gchar *) args[1].value.pdb_pointer;
prefixes = (gchar *) args[2].value.pdb_pointer;
magics = (gchar *) args[3].value.pdb_pointer;
procedure_name = (gchar *) g_value_get_string (&args[0].value);
extensions = (gchar *) g_value_get_string (&args[1].value);
prefixes = (gchar *) g_value_get_string (&args[2].value);
magics = (gchar *) g_value_get_string (&args[3].value);
if (success)
{
@ -945,13 +937,9 @@ register_load_handler_invoker (ProcRecord *proc_record,
gchar *extensions;
gchar *prefixes;
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
extensions = (gchar *) args[1].value.pdb_pointer;
prefixes = (gchar *) args[2].value.pdb_pointer;
procedure_name = (gchar *) g_value_get_string (&args[0].value);
extensions = (gchar *) g_value_get_string (&args[1].value);
prefixes = (gchar *) g_value_get_string (&args[2].value);
if (success)
{
@ -990,13 +978,9 @@ register_save_handler_invoker (ProcRecord *proc_record,
gchar *extensions;
gchar *prefixes;
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
extensions = (gchar *) args[1].value.pdb_pointer;
prefixes = (gchar *) args[2].value.pdb_pointer;
procedure_name = (gchar *) g_value_get_string (&args[0].value);
extensions = (gchar *) g_value_get_string (&args[1].value);
prefixes = (gchar *) g_value_get_string (&args[2].value);
if (success)
{
@ -1070,13 +1054,8 @@ register_file_handler_mime_invoker (ProcRecord *proc_record,
gchar *procedure_name;
gchar *mime_type;
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
mime_type = (gchar *) args[1].value.pdb_pointer;
if (mime_type == NULL || !g_utf8_validate (mime_type, -1, NULL))
success = FALSE;
procedure_name = (gchar *) g_value_get_string (&args[0].value);
mime_type = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -1119,13 +1098,8 @@ register_thumbnail_loader_invoker (ProcRecord *proc_record,
gchar *load_proc;
gchar *thumb_proc;
load_proc = (gchar *) args[0].value.pdb_pointer;
if (load_proc == NULL || !g_utf8_validate (load_proc, -1, NULL))
success = FALSE;
thumb_proc = (gchar *) args[1].value.pdb_pointer;
if (thumb_proc == NULL || !g_utf8_validate (thumb_proc, -1, NULL))
success = FALSE;
load_proc = (gchar *) g_value_get_string (&args[0].value);
thumb_proc = (gchar *) g_value_get_string (&args[1].value);
if (success)
{

View File

@ -161,9 +161,7 @@ floating_sel_remove_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpLayer *floating_sel;
floating_sel = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (floating_sel) && ! gimp_item_is_removed (GIMP_ITEM (floating_sel))))
success = FALSE;
floating_sel = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -201,9 +199,7 @@ floating_sel_anchor_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpLayer *floating_sel;
floating_sel = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (floating_sel) && ! gimp_item_is_removed (GIMP_ITEM (floating_sel))))
success = FALSE;
floating_sel = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -241,9 +237,7 @@ floating_sel_to_layer_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpLayer *floating_sel;
floating_sel = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (floating_sel) && ! gimp_item_is_removed (GIMP_ITEM (floating_sel))))
success = FALSE;
floating_sel = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -282,13 +276,8 @@ floating_sel_attach_invoker (ProcRecord *proc_record,
GimpLayer *layer;
GimpDrawable *drawable;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
drawable = (GimpDrawable *) gimp_value_get_item (&args[1].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -327,11 +316,8 @@ floating_sel_rigor_invoker (ProcRecord *proc_record,
GimpLayer *floating_sel;
gboolean undo;
floating_sel = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (floating_sel) && ! gimp_item_is_removed (GIMP_ITEM (floating_sel))))
success = FALSE;
undo = args[1].value.pdb_int ? TRUE : FALSE;
floating_sel = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
undo = g_value_get_boolean (&args[1].value);
if (success)
{
@ -370,11 +356,8 @@ floating_sel_relax_invoker (ProcRecord *proc_record,
GimpLayer *floating_sel;
gboolean undo;
floating_sel = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (floating_sel) && ! gimp_item_is_removed (GIMP_ITEM (floating_sel))))
success = FALSE;
undo = args[1].value.pdb_int ? TRUE : FALSE;
floating_sel = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
undo = g_value_get_boolean (&args[1].value);
if (success)
{

View File

@ -118,17 +118,9 @@ fonts_popup_invoker (ProcRecord *proc_record,
gchar *popup_title;
gchar *initial_font;
font_callback = (gchar *) args[0].value.pdb_pointer;
if (font_callback == NULL || !g_utf8_validate (font_callback, -1, NULL))
success = FALSE;
popup_title = (gchar *) args[1].value.pdb_pointer;
if (popup_title == NULL || !g_utf8_validate (popup_title, -1, NULL))
success = FALSE;
initial_font = (gchar *) args[2].value.pdb_pointer;
if (initial_font && !g_utf8_validate (initial_font, -1, NULL))
success = FALSE;
font_callback = (gchar *) g_value_get_string (&args[0].value);
popup_title = (gchar *) g_value_get_string (&args[1].value);
initial_font = (gchar *) g_value_get_string (&args[2].value);
if (success)
{
@ -168,9 +160,7 @@ fonts_close_popup_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *font_callback;
font_callback = (gchar *) args[0].value.pdb_pointer;
if (font_callback == NULL || !g_utf8_validate (font_callback, -1, NULL))
success = FALSE;
font_callback = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -209,13 +199,8 @@ fonts_set_popup_invoker (ProcRecord *proc_record,
gchar *font_callback;
gchar *font_name;
font_callback = (gchar *) args[0].value.pdb_pointer;
if (font_callback == NULL || !g_utf8_validate (font_callback, -1, NULL))
success = FALSE;
font_name = (gchar *) args[1].value.pdb_pointer;
if (font_name == NULL || !g_utf8_validate (font_name, -1, NULL))
success = FALSE;
font_callback = (gchar *) g_value_get_string (&args[0].value);
font_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{

View File

@ -114,9 +114,7 @@ fonts_get_list_invoker (ProcRecord *proc_record,
gint32 num_fonts = 0;
gchar **font_list = NULL;
filter = (gchar *) args[0].value.pdb_pointer;
if (filter && !g_utf8_validate (filter, -1, NULL))
success = FALSE;
filter = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -128,8 +126,8 @@ fonts_get_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_fonts;
return_vals[2].value.pdb_pointer = font_list;
g_value_set_int (&return_vals[1].value, num_fonts);
g_value_set_pointer (&return_vals[2].value, font_list);
}
return return_vals;

View File

@ -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 *gimp,
{
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);
return return_args;
*n_return_vals = 1;
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;
return_vals = procedural_db_execute_proc (gimp, context, progress,
procedure,
args, n_args,
n_return_vals);
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_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 *gimp,
}
}
return return_args;
return return_vals;
}
Argument *
@ -362,7 +407,7 @@ procedural_db_run_proc (Gimp *gimp,
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 *gimp,
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 *gimp,
{
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;
gchar *expected = procedural_db_type_name (proc->args[i].arg_type);
gchar *got = procedural_db_type_name (arg_type);
expected = procedural_db_type_name (proc->args[i].arg_type);
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,20 +464,62 @@ procedural_db_run_proc (Gimp *gimp,
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 = &params[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:
g_value_set_uint (value, va_arg (args, guint));
break;
case GIMP_PDB_FLOAT:
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:
g_value_set_pointer (value, va_arg (args, gpointer));
break;
case GIMP_PDB_COLOR:
{
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:
@ -443,30 +527,16 @@ procedural_db_run_proc (Gimp *gimp,
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_int (value, va_arg (args, gint));
break;
case GIMP_PDB_FLOAT:
params[i].value.pdb_float = (gdouble) va_arg (args, gdouble);
break;
case GIMP_PDB_STRING:
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_static_boxed (value, va_arg (args, gpointer));
break;
case GIMP_PDB_COLOR:
params[i].value.pdb_color = va_arg (args, GimpRGB);
break;
case GIMP_PDB_STATUS:
g_value_set_enum (value, va_arg (args, gint));
case GIMP_PDB_REGION:
case GIMP_PDB_BOUNDARY:
case GIMP_PDB_END:
break;
}
@ -474,17 +544,17 @@ procedural_db_run_proc (Gimp *gimp,
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 *procedure)
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 *args,
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 *args,
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 (ProcRecord *procedure,
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,
@ -822,6 +909,73 @@ procedural_db_add_compat_value (ProcRecord *procedure,
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 */
gchar *

View File

@ -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);
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,
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);
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_values);
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_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_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__ */

View File

@ -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 *gimp,
{
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);
return return_args;
*n_return_vals = 1;
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;
return_vals = procedural_db_execute_proc (gimp, context, progress,
procedure,
args, n_args,
n_return_vals);
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_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 *gimp,
}
}
return return_args;
return return_vals;
}
Argument *
@ -362,7 +407,7 @@ procedural_db_run_proc (Gimp *gimp,
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 *gimp,
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 *gimp,
{
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;
gchar *expected = procedural_db_type_name (proc->args[i].arg_type);
gchar *got = procedural_db_type_name (arg_type);
expected = procedural_db_type_name (proc->args[i].arg_type);
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,20 +464,62 @@ procedural_db_run_proc (Gimp *gimp,
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 = &params[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:
g_value_set_uint (value, va_arg (args, guint));
break;
case GIMP_PDB_FLOAT:
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:
g_value_set_pointer (value, va_arg (args, gpointer));
break;
case GIMP_PDB_COLOR:
{
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:
@ -443,30 +527,16 @@ procedural_db_run_proc (Gimp *gimp,
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_int (value, va_arg (args, gint));
break;
case GIMP_PDB_FLOAT:
params[i].value.pdb_float = (gdouble) va_arg (args, gdouble);
break;
case GIMP_PDB_STRING:
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_static_boxed (value, va_arg (args, gpointer));
break;
case GIMP_PDB_COLOR:
params[i].value.pdb_color = va_arg (args, GimpRGB);
break;
case GIMP_PDB_STATUS:
g_value_set_enum (value, va_arg (args, gint));
case GIMP_PDB_REGION:
case GIMP_PDB_BOUNDARY:
case GIMP_PDB_END:
break;
}
@ -474,17 +544,17 @@ procedural_db_run_proc (Gimp *gimp,
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 *procedure)
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 *args,
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 *args,
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 (ProcRecord *procedure,
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,
@ -822,6 +909,73 @@ procedural_db_add_compat_value (ProcRecord *procedure,
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 */
gchar *

View File

@ -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);
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,
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);
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_values);
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_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_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__ */

View File

@ -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 *gimp,
{
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);
return return_args;
*n_return_vals = 1;
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;
return_vals = procedural_db_execute_proc (gimp, context, progress,
procedure,
args, n_args,
n_return_vals);
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_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 *gimp,
}
}
return return_args;
return return_vals;
}
Argument *
@ -362,7 +407,7 @@ procedural_db_run_proc (Gimp *gimp,
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 *gimp,
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 *gimp,
{
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;
gchar *expected = procedural_db_type_name (proc->args[i].arg_type);
gchar *got = procedural_db_type_name (arg_type);
expected = procedural_db_type_name (proc->args[i].arg_type);
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,20 +464,62 @@ procedural_db_run_proc (Gimp *gimp,
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 = &params[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:
g_value_set_uint (value, va_arg (args, guint));
break;
case GIMP_PDB_FLOAT:
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:
g_value_set_pointer (value, va_arg (args, gpointer));
break;
case GIMP_PDB_COLOR:
{
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:
@ -443,30 +527,16 @@ procedural_db_run_proc (Gimp *gimp,
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_int (value, va_arg (args, gint));
break;
case GIMP_PDB_FLOAT:
params[i].value.pdb_float = (gdouble) va_arg (args, gdouble);
break;
case GIMP_PDB_STRING:
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_static_boxed (value, va_arg (args, gpointer));
break;
case GIMP_PDB_COLOR:
params[i].value.pdb_color = va_arg (args, GimpRGB);
break;
case GIMP_PDB_STATUS:
g_value_set_enum (value, va_arg (args, gint));
case GIMP_PDB_REGION:
case GIMP_PDB_BOUNDARY:
case GIMP_PDB_END:
break;
}
@ -474,17 +544,17 @@ procedural_db_run_proc (Gimp *gimp,
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 *procedure)
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 *args,
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 *args,
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 (ProcRecord *procedure,
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,
@ -822,6 +909,73 @@ procedural_db_add_compat_value (ProcRecord *procedure,
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 */
gchar *

View File

@ -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);
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,
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);
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_values);
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_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_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__ */

View File

@ -182,9 +182,7 @@ gimprc_query_invoker (ProcRecord *proc_record,
gchar *token;
gchar *value = NULL;
token = (gchar *) args[0].value.pdb_pointer;
if (token == NULL || !g_utf8_validate (token, -1, NULL))
success = FALSE;
token = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -203,7 +201,7 @@ gimprc_query_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = value;
g_value_take_string (&return_vals[1].value, value);
return return_vals;
}
@ -234,13 +232,8 @@ gimprc_set_invoker (ProcRecord *proc_record,
gchar *token;
gchar *value;
token = (gchar *) args[0].value.pdb_pointer;
if (token == NULL || !g_utf8_validate (token, -1, NULL))
success = FALSE;
value = (gchar *) args[1].value.pdb_pointer;
if (value == NULL || !g_utf8_validate (value, -1, NULL))
success = FALSE;
token = (gchar *) g_value_get_string (&args[0].value);
value = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -284,7 +277,7 @@ get_default_comment_invoker (ProcRecord *proc_record,
comment = g_strdup (gimp->config->default_image->comment);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_pointer = comment;
g_value_take_string (&return_vals[1].value, comment);
return return_vals;
}
@ -320,8 +313,8 @@ get_monitor_resolution_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_float = xres;
return_vals[2].value.pdb_float = yres;
g_value_set_double (&return_vals[1].value, xres);
g_value_set_double (&return_vals[2].value, yres);
return return_vals;
}
@ -354,7 +347,7 @@ get_theme_dir_invoker (ProcRecord *proc_record,
theme_dir = g_strdup (gimp_get_theme_dir (gimp));
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_pointer = theme_dir;
g_value_take_string (&return_vals[1].value, theme_dir);
return return_vals;
}
@ -387,7 +380,7 @@ get_color_configuration_invoker (ProcRecord *proc_record,
config = gimp_config_serialize_to_string (GIMP_CONFIG (gimp->config->color_management), NULL);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_pointer = config;
g_value_take_string (&return_vals[1].value, config);
return return_vals;
}
@ -420,7 +413,7 @@ get_module_load_inhibit_invoker (ProcRecord *proc_record,
load_inhibit = g_strdup (gimp_module_db_get_load_inhibit (gimp->module_db));
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_pointer = load_inhibit;
g_value_take_string (&return_vals[1].value, load_inhibit);
return return_vals;
}

View File

@ -1078,9 +1078,7 @@ gradient_new_invoker (ProcRecord *proc_record,
gchar *name;
gchar *actual_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1100,7 +1098,7 @@ gradient_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = actual_name;
g_value_take_string (&return_vals[1].value, actual_name);
return return_vals;
}
@ -1132,9 +1130,7 @@ gradient_duplicate_invoker (ProcRecord *proc_record,
gchar *name;
gchar *copy_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1159,7 +1155,7 @@ gradient_duplicate_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = copy_name;
g_value_take_string (&return_vals[1].value, copy_name);
return return_vals;
}
@ -1191,9 +1187,7 @@ gradient_is_editable_invoker (ProcRecord *proc_record,
gchar *name;
gboolean editable = FALSE;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1209,7 +1203,7 @@ gradient_is_editable_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = editable;
g_value_set_boolean (&return_vals[1].value, editable);
return return_vals;
}
@ -1242,13 +1236,8 @@ gradient_rename_invoker (ProcRecord *proc_record,
gchar *new_name;
gchar *actual_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
new_name = (gchar *) args[1].value.pdb_pointer;
if (new_name == NULL || !g_utf8_validate (new_name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
new_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -1267,7 +1256,7 @@ gradient_rename_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = actual_name;
g_value_take_string (&return_vals[1].value, actual_name);
return return_vals;
}
@ -1297,9 +1286,7 @@ gradient_delete_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -1357,15 +1344,9 @@ gradient_get_uniform_samples_invoker (ProcRecord *proc_record,
gint32 num_color_samples = 0;
gdouble *color_samples = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
num_samples = args[1].value.pdb_int;
if (num_samples < 2)
success = FALSE;
reverse = args[2].value.pdb_int ? TRUE : FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
num_samples = g_value_get_int (&args[1].value);
reverse = g_value_get_boolean (&args[2].value);
if (success)
{
@ -1405,8 +1386,8 @@ gradient_get_uniform_samples_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_color_samples;
return_vals[2].value.pdb_pointer = color_samples;
g_value_set_int (&return_vals[1].value, num_color_samples);
g_value_set_pointer (&return_vals[2].value, color_samples);
}
return return_vals;
@ -1443,17 +1424,10 @@ gradient_get_custom_samples_invoker (ProcRecord *proc_record,
gint32 num_color_samples = 0;
gdouble *color_samples = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
num_samples = args[1].value.pdb_int;
if (num_samples < 1)
success = FALSE;
positions = (gdouble *) args[2].value.pdb_pointer;
reverse = args[3].value.pdb_int ? TRUE : FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
num_samples = g_value_get_int (&args[1].value);
positions = g_value_get_pointer (&args[2].value);
reverse = g_value_get_boolean (&args[3].value);
if (success)
{
@ -1492,8 +1466,8 @@ gradient_get_custom_samples_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_color_samples;
return_vals[2].value.pdb_pointer = color_samples;
g_value_set_int (&return_vals[1].value, num_color_samples);
g_value_set_pointer (&return_vals[2].value, color_samples);
}
return return_vals;
@ -1528,13 +1502,8 @@ gradient_segment_get_left_color_invoker (ProcRecord *proc_record,
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
gdouble opacity = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
if (success)
{
@ -1556,8 +1525,8 @@ gradient_segment_get_left_color_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_color = color;
return_vals[2].value.pdb_float = opacity;
gimp_value_set_rgb (&return_vals[1].value, &color);
g_value_set_double (&return_vals[2].value, opacity);
}
return return_vals;
@ -1591,19 +1560,10 @@ gradient_segment_set_left_color_invoker (ProcRecord *proc_record,
GimpRGB color;
gdouble opacity;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
color = args[2].value.pdb_color;
opacity = args[3].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
gimp_value_get_rgb (&args[2].value, &color);
opacity = g_value_get_double (&args[3].value);
if (success)
{
@ -1653,13 +1613,8 @@ gradient_segment_get_right_color_invoker (ProcRecord *proc_record,
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
gdouble opacity = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
if (success)
{
@ -1681,8 +1636,8 @@ gradient_segment_get_right_color_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_color = color;
return_vals[2].value.pdb_float = opacity;
gimp_value_set_rgb (&return_vals[1].value, &color);
g_value_set_double (&return_vals[2].value, opacity);
}
return return_vals;
@ -1716,19 +1671,10 @@ gradient_segment_set_right_color_invoker (ProcRecord *proc_record,
GimpRGB color;
gdouble opacity;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
color = args[2].value.pdb_color;
opacity = args[3].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
gimp_value_get_rgb (&args[2].value, &color);
opacity = g_value_get_double (&args[3].value);
if (success)
{
@ -1777,13 +1723,8 @@ gradient_segment_get_left_pos_invoker (ProcRecord *proc_record,
gint32 segment;
gdouble pos = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
if (success)
{
@ -1803,7 +1744,7 @@ gradient_segment_get_left_pos_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = pos;
g_value_set_double (&return_vals[1].value, pos);
return return_vals;
}
@ -1837,17 +1778,9 @@ gradient_segment_set_left_pos_invoker (ProcRecord *proc_record,
gdouble pos;
gdouble final_pos = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
pos = args[2].value.pdb_float;
if (pos < 0.0 || pos > 1.0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
pos = g_value_get_double (&args[2].value);
if (success)
{
@ -1867,7 +1800,7 @@ gradient_segment_set_left_pos_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = final_pos;
g_value_set_double (&return_vals[1].value, final_pos);
return return_vals;
}
@ -1900,13 +1833,8 @@ gradient_segment_get_middle_pos_invoker (ProcRecord *proc_record,
gint32 segment;
gdouble pos = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
if (success)
{
@ -1926,7 +1854,7 @@ gradient_segment_get_middle_pos_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = pos;
g_value_set_double (&return_vals[1].value, pos);
return return_vals;
}
@ -1960,17 +1888,9 @@ gradient_segment_set_middle_pos_invoker (ProcRecord *proc_record,
gdouble pos;
gdouble final_pos = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
pos = args[2].value.pdb_float;
if (pos < 0.0 || pos > 1.0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
pos = g_value_get_double (&args[2].value);
if (success)
{
@ -1991,7 +1911,7 @@ gradient_segment_set_middle_pos_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = final_pos;
g_value_set_double (&return_vals[1].value, final_pos);
return return_vals;
}
@ -2024,13 +1944,8 @@ gradient_segment_get_right_pos_invoker (ProcRecord *proc_record,
gint32 segment;
gdouble pos = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
if (success)
{
@ -2050,7 +1965,7 @@ gradient_segment_get_right_pos_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = pos;
g_value_set_double (&return_vals[1].value, pos);
return return_vals;
}
@ -2084,17 +1999,9 @@ gradient_segment_set_right_pos_invoker (ProcRecord *proc_record,
gdouble pos;
gdouble final_pos = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
pos = args[2].value.pdb_float;
if (pos < 0.0 || pos > 1.0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
pos = g_value_get_double (&args[2].value);
if (success)
{
@ -2115,7 +2022,7 @@ gradient_segment_set_right_pos_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = final_pos;
g_value_set_double (&return_vals[1].value, final_pos);
return return_vals;
}
@ -2148,13 +2055,8 @@ gradient_segment_get_blending_function_invoker (ProcRecord *proc_record,
gint32 segment;
gint32 blend_func = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
if (success)
{
@ -2174,7 +2076,7 @@ gradient_segment_get_blending_function_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = blend_func;
g_value_set_enum (&return_vals[1].value, blend_func);
return return_vals;
}
@ -2207,13 +2109,8 @@ gradient_segment_get_coloring_type_invoker (ProcRecord *proc_record,
gint32 segment;
gint32 coloring_type = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
segment = g_value_get_int (&args[1].value);
if (success)
{
@ -2233,7 +2130,7 @@ gradient_segment_get_coloring_type_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = coloring_type;
g_value_set_enum (&return_vals[1].value, coloring_type);
return return_vals;
}
@ -2266,19 +2163,10 @@ gradient_segment_range_set_blending_function_invoker (ProcRecord *proc_record,
gint32 end_segment;
gint32 blending_function;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
blending_function = args[3].value.pdb_int;
if (blending_function < GIMP_GRADIENT_SEGMENT_LINEAR || blending_function > GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
blending_function = g_value_get_enum (&args[3].value);
if (success)
{
@ -2330,19 +2218,10 @@ gradient_segment_range_set_coloring_type_invoker (ProcRecord *proc_record,
gint32 end_segment;
gint32 coloring_type;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
coloring_type = args[3].value.pdb_int;
if (coloring_type < GIMP_GRADIENT_SEGMENT_RGB || coloring_type > GIMP_GRADIENT_SEGMENT_HSV_CW)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
coloring_type = g_value_get_enum (&args[3].value);
if (success)
{
@ -2393,15 +2272,9 @@ gradient_segment_range_flip_invoker (ProcRecord *proc_record,
gint32 start_segment;
gint32 end_segment;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
if (success)
{
@ -2453,19 +2326,10 @@ gradient_segment_range_replicate_invoker (ProcRecord *proc_record,
gint32 end_segment;
gint32 replicate_times;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
replicate_times = args[3].value.pdb_int;
if (replicate_times < 2 || replicate_times > 20)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
replicate_times = g_value_get_int (&args[3].value);
if (success)
{
@ -2517,15 +2381,9 @@ gradient_segment_range_split_midpoint_invoker (ProcRecord *proc_record,
gint32 start_segment;
gint32 end_segment;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
if (success)
{
@ -2577,19 +2435,10 @@ gradient_segment_range_split_uniform_invoker (ProcRecord *proc_record,
gint32 end_segment;
gint32 split_parts;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
split_parts = args[3].value.pdb_int;
if (split_parts < 2 || split_parts > 20)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
split_parts = g_value_get_int (&args[3].value);
if (success)
{
@ -2641,15 +2490,9 @@ gradient_segment_range_delete_invoker (ProcRecord *proc_record,
gint32 start_segment;
gint32 end_segment;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
if (success)
{
@ -2700,15 +2543,9 @@ gradient_segment_range_redistribute_handles_invoker (ProcRecord *proc_record,
gint32 start_segment;
gint32 end_segment;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
if (success)
{
@ -2758,15 +2595,9 @@ gradient_segment_range_blend_colors_invoker (ProcRecord *proc_record,
gint32 start_segment;
gint32 end_segment;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
if (success)
{
@ -2819,15 +2650,9 @@ gradient_segment_range_blend_opacity_invoker (ProcRecord *proc_record,
gint32 start_segment;
gint32 end_segment;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
if (success)
{
@ -2884,21 +2709,11 @@ gradient_segment_range_move_invoker (ProcRecord *proc_record,
gboolean control_compress;
gdouble final_delta = 0.0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
delta = args[3].value.pdb_float;
if (delta < -1.0 || delta > 1.0)
success = FALSE;
control_compress = args[4].value.pdb_int ? TRUE : FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
start_segment = g_value_get_int (&args[1].value);
end_segment = g_value_get_int (&args[2].value);
delta = g_value_get_double (&args[3].value);
control_compress = g_value_get_boolean (&args[4].value);
if (success)
{
@ -2923,7 +2738,7 @@ gradient_segment_range_move_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = final_delta;
g_value_set_double (&return_vals[1].value, final_delta);
return return_vals;
}

View File

@ -128,19 +128,10 @@ gradients_popup_invoker (ProcRecord *proc_record,
gchar *initial_gradient;
gint32 sample_size;
gradient_callback = (gchar *) args[0].value.pdb_pointer;
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
success = FALSE;
popup_title = (gchar *) args[1].value.pdb_pointer;
if (popup_title == NULL || !g_utf8_validate (popup_title, -1, NULL))
success = FALSE;
initial_gradient = (gchar *) args[2].value.pdb_pointer;
if (initial_gradient && !g_utf8_validate (initial_gradient, -1, NULL))
success = FALSE;
sample_size = args[3].value.pdb_int;
gradient_callback = (gchar *) g_value_get_string (&args[0].value);
popup_title = (gchar *) g_value_get_string (&args[1].value);
initial_gradient = (gchar *) g_value_get_string (&args[2].value);
sample_size = g_value_get_int (&args[3].value);
if (success)
{
@ -184,9 +175,7 @@ gradients_close_popup_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *gradient_callback;
gradient_callback = (gchar *) args[0].value.pdb_pointer;
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
success = FALSE;
gradient_callback = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -226,13 +215,8 @@ gradients_set_popup_invoker (ProcRecord *proc_record,
gchar *gradient_callback;
gchar *gradient_name;
gradient_callback = (gchar *) args[0].value.pdb_pointer;
if (gradient_callback == NULL || !g_utf8_validate (gradient_callback, -1, NULL))
success = FALSE;
gradient_name = (gchar *) args[1].value.pdb_pointer;
if (gradient_name == NULL || !g_utf8_validate (gradient_name, -1, NULL))
success = FALSE;
gradient_callback = (gchar *) g_value_get_string (&args[0].value);
gradient_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{

View File

@ -241,9 +241,7 @@ gradients_get_list_invoker (ProcRecord *proc_record,
gint32 num_gradients = 0;
gchar **gradient_list = NULL;
filter = (gchar *) args[0].value.pdb_pointer;
if (filter && !g_utf8_validate (filter, -1, NULL))
success = FALSE;
filter = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -255,8 +253,8 @@ gradients_get_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_gradients;
return_vals[2].value.pdb_pointer = gradient_list;
g_value_set_int (&return_vals[1].value, num_gradients);
g_value_set_pointer (&return_vals[2].value, gradient_list);
}
return return_vals;
@ -291,11 +289,8 @@ gradients_sample_uniform_invoker (ProcRecord *proc_record,
gint32 array_length = 0;
gdouble *color_samples = NULL;
num_samples = args[0].value.pdb_int;
if (num_samples < 2)
success = FALSE;
reverse = args[1].value.pdb_int ? TRUE : FALSE;
num_samples = g_value_get_int (&args[0].value);
reverse = g_value_get_boolean (&args[1].value);
if (success)
{
@ -331,8 +326,8 @@ gradients_sample_uniform_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = array_length;
return_vals[2].value.pdb_pointer = color_samples;
g_value_set_int (&return_vals[1].value, array_length);
g_value_set_pointer (&return_vals[2].value, color_samples);
}
return return_vals;
@ -368,13 +363,9 @@ gradients_sample_custom_invoker (ProcRecord *proc_record,
gint32 array_length = 0;
gdouble *color_samples = NULL;
num_samples = args[0].value.pdb_int;
if (num_samples <= 0)
success = FALSE;
positions = (gdouble *) args[1].value.pdb_pointer;
reverse = args[2].value.pdb_int ? TRUE : FALSE;
num_samples = g_value_get_int (&args[0].value);
positions = g_value_get_pointer (&args[1].value);
reverse = g_value_get_boolean (&args[2].value);
if (success)
{
@ -407,8 +398,8 @@ gradients_sample_custom_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = array_length;
return_vals[2].value.pdb_pointer = color_samples;
g_value_set_int (&return_vals[1].value, array_length);
g_value_set_pointer (&return_vals[2].value, color_samples);
}
return return_vals;
@ -445,13 +436,9 @@ gradients_get_gradient_data_invoker (ProcRecord *proc_record,
gint32 width = 0;
gdouble *grad_data = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
success = FALSE;
sample_size = args[1].value.pdb_int;
reverse = args[2].value.pdb_int ? TRUE : FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
sample_size = g_value_get_int (&args[1].value);
reverse = g_value_get_boolean (&args[2].value);
if (success)
{
@ -507,9 +494,9 @@ gradients_get_gradient_data_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_pointer = actual_name;
return_vals[2].value.pdb_int = width;
return_vals[3].value.pdb_pointer = grad_data;
g_value_take_string (&return_vals[1].value, actual_name);
g_value_set_int (&return_vals[2].value, width);
g_value_set_pointer (&return_vals[3].value, grad_data);
}
return return_vals;

View File

@ -295,9 +295,7 @@ image_grid_get_spacing_invoker (ProcRecord *proc_record,
gdouble xspacing = 0.0;
gdouble yspacing = 0.0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -316,8 +314,8 @@ image_grid_get_spacing_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_float = xspacing;
return_vals[2].value.pdb_float = yspacing;
g_value_set_double (&return_vals[1].value, xspacing);
g_value_set_double (&return_vals[2].value, yspacing);
}
return return_vals;
@ -350,13 +348,9 @@ image_grid_set_spacing_invoker (ProcRecord *proc_record,
gdouble xspacing;
gdouble yspacing;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
xspacing = args[1].value.pdb_float;
yspacing = args[2].value.pdb_float;
image = gimp_value_get_image (&args[0].value, gimp);
xspacing = g_value_get_double (&args[1].value);
yspacing = g_value_get_double (&args[2].value);
if (success)
{
@ -402,9 +396,7 @@ image_grid_get_offset_invoker (ProcRecord *proc_record,
gdouble xoffset = 0.0;
gdouble yoffset = 0.0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -423,8 +415,8 @@ image_grid_get_offset_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_float = xoffset;
return_vals[2].value.pdb_float = yoffset;
g_value_set_double (&return_vals[1].value, xoffset);
g_value_set_double (&return_vals[2].value, yoffset);
}
return return_vals;
@ -457,13 +449,9 @@ image_grid_set_offset_invoker (ProcRecord *proc_record,
gdouble xoffset;
gdouble yoffset;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
xoffset = args[1].value.pdb_float;
yoffset = args[2].value.pdb_float;
image = gimp_value_get_image (&args[0].value, gimp);
xoffset = g_value_get_double (&args[1].value);
yoffset = g_value_get_double (&args[2].value);
if (success)
{
@ -508,9 +496,7 @@ image_grid_get_foreground_color_invoker (ProcRecord *proc_record,
GimpImage *image;
GimpRGB fgcolor = { 0.0, 0.0, 0.0, 1.0 };
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -525,7 +511,7 @@ image_grid_get_foreground_color_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_color = fgcolor;
gimp_value_set_rgb (&return_vals[1].value, &fgcolor);
return return_vals;
}
@ -556,11 +542,8 @@ image_grid_set_foreground_color_invoker (ProcRecord *proc_record,
GimpImage *image;
GimpRGB fgcolor;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
fgcolor = args[1].value.pdb_color;
image = gimp_value_get_image (&args[0].value, gimp);
gimp_value_get_rgb (&args[1].value, &fgcolor);
if (success)
{
@ -602,9 +585,7 @@ image_grid_get_background_color_invoker (ProcRecord *proc_record,
GimpImage *image;
GimpRGB bgcolor = { 0.0, 0.0, 0.0, 1.0 };
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -619,7 +600,7 @@ image_grid_get_background_color_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_color = bgcolor;
gimp_value_set_rgb (&return_vals[1].value, &bgcolor);
return return_vals;
}
@ -650,11 +631,8 @@ image_grid_set_background_color_invoker (ProcRecord *proc_record,
GimpImage *image;
GimpRGB bgcolor;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
bgcolor = args[1].value.pdb_color;
image = gimp_value_get_image (&args[0].value, gimp);
gimp_value_get_rgb (&args[1].value, &bgcolor);
if (success)
{
@ -696,9 +674,7 @@ image_grid_get_style_invoker (ProcRecord *proc_record,
GimpImage *image;
gint32 style = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -713,7 +689,7 @@ image_grid_get_style_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = style;
g_value_set_enum (&return_vals[1].value, style);
return return_vals;
}
@ -744,13 +720,8 @@ image_grid_set_style_invoker (ProcRecord *proc_record,
GimpImage *image;
gint32 style;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
style = args[1].value.pdb_int;
if (style < GIMP_GRID_DOTS || style > GIMP_GRID_SOLID)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
style = g_value_get_enum (&args[1].value);
if (success)
{

View File

@ -164,12 +164,14 @@ register_guides_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("orientation",
"orientation",
"The guide's orientation: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("orientation",
"orientation",
"The guide's orientation: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0].pspec),
GIMP_ORIENTATION_UNKNOWN);
procedural_db_register (gimp, procedure);
/*
@ -214,13 +216,8 @@ image_add_hguide_invoker (ProcRecord *proc_record,
gint32 yposition;
gint32 guide = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
yposition = args[1].value.pdb_int;
if (yposition < 0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
yposition = g_value_get_int (&args[1].value);
if (success)
{
@ -238,7 +235,7 @@ image_add_hguide_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = guide;
g_value_set_uint (&return_vals[1].value, guide);
return return_vals;
}
@ -271,13 +268,8 @@ image_add_vguide_invoker (ProcRecord *proc_record,
gint32 xposition;
gint32 guide = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
xposition = args[1].value.pdb_int;
if (xposition < 0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
xposition = g_value_get_int (&args[1].value);
if (success)
{
@ -295,7 +287,7 @@ image_add_vguide_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = guide;
g_value_set_uint (&return_vals[1].value, guide);
return return_vals;
}
@ -326,11 +318,8 @@ image_delete_guide_invoker (ProcRecord *proc_record,
GimpImage *image;
gint32 guide;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
guide = args[1].value.pdb_int;
image = gimp_value_get_image (&args[0].value, gimp);
guide = g_value_get_uint (&args[1].value);
if (success)
{
@ -373,11 +362,8 @@ image_find_next_guide_invoker (ProcRecord *proc_record,
gint32 guide;
gint32 next_guide = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
guide = args[1].value.pdb_int;
image = gimp_value_get_image (&args[0].value, gimp);
guide = g_value_get_uint (&args[1].value);
if (success)
{
@ -390,7 +376,7 @@ image_find_next_guide_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = next_guide;
g_value_set_uint (&return_vals[1].value, next_guide);
return return_vals;
}
@ -423,11 +409,8 @@ image_get_guide_orientation_invoker (ProcRecord *proc_record,
gint32 guide;
gint32 orientation = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
guide = args[1].value.pdb_int;
image = gimp_value_get_image (&args[0].value, gimp);
guide = g_value_get_uint (&args[1].value);
if (success)
{
@ -442,7 +425,7 @@ image_get_guide_orientation_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = orientation;
g_value_set_enum (&return_vals[1].value, orientation);
return return_vals;
}
@ -475,11 +458,8 @@ image_get_guide_position_invoker (ProcRecord *proc_record,
gint32 guide;
gint32 position = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
guide = args[1].value.pdb_int;
image = gimp_value_get_image (&args[0].value, gimp);
guide = g_value_get_uint (&args[1].value);
if (success)
{
@ -494,7 +474,7 @@ image_get_guide_position_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = position;
g_value_set_int (&return_vals[1].value, position);
return return_vals;
}

View File

@ -73,13 +73,8 @@ help_invoker (ProcRecord *proc_record,
gchar *help_domain;
gchar *help_id;
help_domain = (gchar *) args[0].value.pdb_pointer;
if (help_domain && !g_utf8_validate (help_domain, -1, NULL))
success = FALSE;
help_id = (gchar *) args[1].value.pdb_pointer;
if (help_id == NULL || !g_utf8_validate (help_id, -1, NULL))
success = FALSE;
help_domain = (gchar *) g_value_get_string (&args[0].value);
help_id = (gchar *) g_value_get_string (&args[1].value);
if (success)
{

File diff suppressed because it is too large Load Diff

View File

@ -768,33 +768,13 @@ layer_new_invoker (ProcRecord *proc_record,
gint32 mode;
GimpLayer *layer = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
width = args[1].value.pdb_int;
if (width < 1)
success = FALSE;
height = args[2].value.pdb_int;
if (height < 1)
success = FALSE;
type = args[3].value.pdb_int;
if (type < GIMP_RGB_IMAGE || type > GIMP_INDEXEDA_IMAGE)
success = FALSE;
name = (gchar *) args[4].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
success = FALSE;
opacity = args[5].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
mode = args[6].value.pdb_int;
if (mode < GIMP_NORMAL_MODE || mode > GIMP_COLOR_ERASE_MODE)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
width = g_value_get_int (&args[1].value);
height = g_value_get_int (&args[2].value);
type = g_value_get_enum (&args[3].value);
name = (gchar *) g_value_get_string (&args[4].value);
opacity = g_value_get_double (&args[5].value);
mode = g_value_get_enum (&args[6].value);
if (success)
{
@ -808,7 +788,7 @@ layer_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = layer ? gimp_item_get_ID (GIMP_ITEM (layer)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (layer));
return return_vals;
}
@ -841,13 +821,8 @@ layer_new_from_drawable_invoker (ProcRecord *proc_record,
GimpImage *dest_image;
GimpLayer *layer_copy = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
dest_image = gimp_image_get_by_ID (gimp, args[1].value.pdb_int);
if (! GIMP_IS_IMAGE (dest_image))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
dest_image = gimp_value_get_image (&args[1].value, gimp);
if (success)
{
@ -873,7 +848,7 @@ layer_new_from_drawable_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = layer_copy ? gimp_item_get_ID (GIMP_ITEM (layer_copy)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (layer_copy));
return return_vals;
}
@ -906,11 +881,8 @@ layer_copy_invoker (ProcRecord *proc_record,
gboolean add_alpha;
GimpLayer *layer_copy = NULL;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
add_alpha = args[1].value.pdb_int ? TRUE : FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
add_alpha = g_value_get_boolean (&args[1].value);
if (success)
{
@ -924,7 +896,7 @@ layer_copy_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = layer_copy ? gimp_item_get_ID (GIMP_ITEM (layer_copy)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (layer_copy));
return return_vals;
}
@ -954,9 +926,7 @@ layer_add_alpha_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpLayer *layer;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -994,19 +964,10 @@ layer_scale_invoker (ProcRecord *proc_record,
gint32 new_height;
gboolean local_origin;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
new_width = args[1].value.pdb_int;
if (new_width < 1)
success = FALSE;
new_height = args[2].value.pdb_int;
if (new_height < 1)
success = FALSE;
local_origin = args[3].value.pdb_int ? TRUE : FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
new_width = g_value_get_int (&args[1].value);
new_height = g_value_get_int (&args[2].value);
local_origin = g_value_get_boolean (&args[3].value);
if (success)
{
@ -1050,21 +1011,11 @@ layer_resize_invoker (ProcRecord *proc_record,
gint32 offx;
gint32 offy;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
new_width = args[1].value.pdb_int;
if (new_width < 1)
success = FALSE;
new_height = args[2].value.pdb_int;
if (new_height < 1)
success = FALSE;
offx = args[3].value.pdb_int;
offy = args[4].value.pdb_int;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
new_width = g_value_get_int (&args[1].value);
new_height = g_value_get_int (&args[2].value);
offx = g_value_get_int (&args[3].value);
offy = g_value_get_int (&args[4].value);
if (success)
{
@ -1103,9 +1054,7 @@ layer_resize_to_image_size_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpLayer *layer;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1145,13 +1094,9 @@ layer_translate_invoker (ProcRecord *proc_record,
gint32 offx;
gint32 offy;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
offx = args[1].value.pdb_int;
offy = args[2].value.pdb_int;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
offx = g_value_get_int (&args[1].value);
offy = g_value_get_int (&args[2].value);
if (success)
{
@ -1198,13 +1143,9 @@ layer_set_offsets_invoker (ProcRecord *proc_record,
gint32 offx;
gint32 offy;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
offx = args[1].value.pdb_int;
offy = args[2].value.pdb_int;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
offx = g_value_get_int (&args[1].value);
offy = g_value_get_int (&args[2].value);
if (success)
{
@ -1255,13 +1196,8 @@ layer_create_mask_invoker (ProcRecord *proc_record,
gint32 mask_type;
GimpLayerMask *mask = NULL;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
mask_type = args[1].value.pdb_int;
if (mask_type < GIMP_ADD_WHITE_MASK || mask_type > GIMP_ADD_COPY_MASK)
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
mask_type = g_value_get_enum (&args[1].value);
if (success)
{
@ -1274,7 +1210,7 @@ layer_create_mask_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = mask ? gimp_item_get_ID (GIMP_ITEM (mask)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (mask));
return return_vals;
}
@ -1306,9 +1242,7 @@ layer_get_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
GimpLayerMask *mask = NULL;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1318,7 +1252,7 @@ layer_get_mask_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = mask ? gimp_item_get_ID (GIMP_ITEM (mask)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (mask));
return return_vals;
}
@ -1350,9 +1284,7 @@ layer_from_mask_invoker (ProcRecord *proc_record,
GimpLayerMask *mask;
GimpLayer *layer = NULL;
mask = (GimpLayerMask *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER_MASK (mask) && ! gimp_item_is_removed (GIMP_ITEM (mask))))
success = FALSE;
mask = (GimpLayerMask *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER_MASK);
if (success)
{
@ -1362,7 +1294,7 @@ layer_from_mask_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = layer ? gimp_item_get_ID (GIMP_ITEM (layer)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (layer));
return return_vals;
}
@ -1393,13 +1325,8 @@ layer_add_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
GimpLayerMask *mask;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
mask = (GimpLayerMask *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);
if (! (GIMP_IS_LAYER_MASK (mask) && ! gimp_item_is_removed (GIMP_ITEM (mask))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
mask = (GimpLayerMask *) gimp_value_get_item (&args[1].value, gimp, GIMP_TYPE_LAYER_MASK);
if (success)
{
@ -1438,13 +1365,8 @@ layer_remove_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gint32 mode;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
mode = args[1].value.pdb_int;
if (mode < GIMP_MASK_APPLY || mode > GIMP_MASK_DISCARD)
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
mode = g_value_get_enum (&args[1].value);
if (success)
{
@ -1484,9 +1406,7 @@ layer_is_floating_sel_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean is_floating_sel = FALSE;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1496,7 +1416,7 @@ layer_is_floating_sel_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = is_floating_sel;
g_value_set_boolean (&return_vals[1].value, is_floating_sel);
return return_vals;
}
@ -1528,9 +1448,7 @@ layer_get_lock_alpha_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean lock_alpha = FALSE;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1540,7 +1458,7 @@ layer_get_lock_alpha_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = lock_alpha;
g_value_set_boolean (&return_vals[1].value, lock_alpha);
return return_vals;
}
@ -1571,11 +1489,8 @@ layer_set_lock_alpha_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean lock_alpha;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
lock_alpha = args[1].value.pdb_int ? TRUE : FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
lock_alpha = g_value_get_boolean (&args[1].value);
if (success)
{
@ -1612,9 +1527,7 @@ layer_get_apply_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean apply_mask = FALSE;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1627,7 +1540,7 @@ layer_get_apply_mask_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = apply_mask;
g_value_set_boolean (&return_vals[1].value, apply_mask);
return return_vals;
}
@ -1658,11 +1571,8 @@ layer_set_apply_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean apply_mask;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
apply_mask = args[1].value.pdb_int ? TRUE : FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
apply_mask = g_value_get_boolean (&args[1].value);
if (success)
{
@ -1702,9 +1612,7 @@ layer_get_show_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean show_mask = FALSE;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1717,7 +1625,7 @@ layer_get_show_mask_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = show_mask;
g_value_set_boolean (&return_vals[1].value, show_mask);
return return_vals;
}
@ -1748,11 +1656,8 @@ layer_set_show_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean show_mask;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
show_mask = args[1].value.pdb_int ? TRUE : FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
show_mask = g_value_get_boolean (&args[1].value);
if (success)
{
@ -1792,9 +1697,7 @@ layer_get_edit_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean edit_mask = FALSE;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1807,7 +1710,7 @@ layer_get_edit_mask_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = edit_mask;
g_value_set_boolean (&return_vals[1].value, edit_mask);
return return_vals;
}
@ -1838,11 +1741,8 @@ layer_set_edit_mask_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gboolean edit_mask;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
edit_mask = args[1].value.pdb_int ? TRUE : FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
edit_mask = g_value_get_boolean (&args[1].value);
if (success)
{
@ -1882,9 +1782,7 @@ layer_get_opacity_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gdouble opacity = 0.0;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1894,7 +1792,7 @@ layer_get_opacity_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = opacity;
g_value_set_double (&return_vals[1].value, opacity);
return return_vals;
}
@ -1925,13 +1823,8 @@ layer_set_opacity_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gdouble opacity;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
opacity = args[1].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
opacity = g_value_get_double (&args[1].value);
if (success)
{
@ -1968,9 +1861,7 @@ layer_get_mode_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gint32 mode = 0;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1980,7 +1871,7 @@ layer_get_mode_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = mode;
g_value_set_enum (&return_vals[1].value, mode);
return return_vals;
}
@ -2011,13 +1902,8 @@ layer_set_mode_invoker (ProcRecord *proc_record,
GimpLayer *layer;
gint32 mode;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
mode = args[1].value.pdb_int;
if (mode < GIMP_NORMAL_MODE || mode > GIMP_COLOR_ERASE_MODE)
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
mode = g_value_get_enum (&args[1].value);
if (success)
{

View File

@ -96,9 +96,7 @@ message_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *message;
message = (gchar *) args[0].value.pdb_pointer;
if (message == NULL || !g_utf8_validate (message, -1, NULL))
success = FALSE;
message = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -139,7 +137,7 @@ message_get_handler_invoker (ProcRecord *proc_record,
handler = gimp->message_handler;
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_int = handler;
g_value_set_enum (&return_vals[1].value, handler);
return return_vals;
}
@ -169,9 +167,7 @@ message_set_handler_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gint32 handler;
handler = args[0].value.pdb_int;
if (handler < GIMP_MESSAGE_BOX || handler > GIMP_ERROR_CONSOLE)
success = FALSE;
handler = g_value_get_enum (&args[0].value);
if (success)
{

View File

@ -107,7 +107,7 @@ version_invoker (ProcRecord *proc_record,
version = g_strdup (GIMP_VERSION);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_pointer = version;
g_value_take_string (&return_vals[1].value, version);
return return_vals;
}
@ -140,7 +140,7 @@ getpid_invoker (ProcRecord *proc_record,
pid = getpid ();
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_int = pid;
g_value_set_int (&return_vals[1].value, pid);
return return_vals;
}
@ -167,13 +167,17 @@ quit_invoker (ProcRecord *proc_record,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
gboolean force;
force = args[0].value.pdb_int ? TRUE : FALSE;
force = g_value_get_boolean (&args[0].value);
gimp_exit (gimp, force);
if (success)
{
gimp_exit (gimp, force);
}
return procedural_db_return_values (proc_record, TRUE);
return procedural_db_return_values (proc_record, success);
}
static ProcRecord quit_proc =

View File

@ -644,19 +644,10 @@ airbrush_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
pressure = args[1].value.pdb_float;
if (pressure < 0.0 || pressure > 100.0)
success = FALSE;
num_strokes = args[2].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[3].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
pressure = g_value_get_double (&args[1].value);
num_strokes = g_value_get_int (&args[2].value);
strokes = g_value_get_pointer (&args[3].value);
if (success)
{
@ -708,15 +699,9 @@ airbrush_default_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
if (success)
{
@ -768,27 +753,13 @@ clone_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
src_drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (src_drawable) && ! gimp_item_is_removed (GIMP_ITEM (src_drawable))))
success = FALSE;
clone_type = args[2].value.pdb_int;
if (clone_type < GIMP_IMAGE_CLONE || clone_type > GIMP_PATTERN_CLONE)
success = FALSE;
src_x = args[3].value.pdb_float;
src_y = args[4].value.pdb_float;
num_strokes = args[5].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[6].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
src_drawable = (GimpDrawable *) gimp_value_get_item (&args[1].value, gimp, GIMP_TYPE_DRAWABLE);
clone_type = g_value_get_enum (&args[2].value);
src_x = g_value_get_double (&args[3].value);
src_y = g_value_get_double (&args[4].value);
num_strokes = g_value_get_int (&args[5].value);
strokes = g_value_get_pointer (&args[6].value);
if (success)
{
@ -851,15 +822,9 @@ clone_default_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
if (success)
{
@ -909,23 +874,11 @@ convolve_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
pressure = args[1].value.pdb_float;
if (pressure < 0.0 || pressure > 100.0)
success = FALSE;
convolve_type = args[2].value.pdb_int;
if (convolve_type < GIMP_BLUR_CONVOLVE || convolve_type > GIMP_SHARPEN_CONVOLVE)
success = FALSE;
num_strokes = args[3].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[4].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
pressure = g_value_get_double (&args[1].value);
convolve_type = g_value_get_enum (&args[2].value);
num_strokes = g_value_get_int (&args[3].value);
strokes = g_value_get_pointer (&args[4].value);
if (success)
{
@ -978,15 +931,9 @@ convolve_default_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
if (success)
{
@ -1037,27 +984,12 @@ dodgeburn_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
exposure = args[1].value.pdb_float;
if (exposure < 0.0 || exposure > 100.0)
success = FALSE;
dodgeburn_type = args[2].value.pdb_int;
if (dodgeburn_type < GIMP_DODGE || dodgeburn_type > GIMP_BURN)
success = FALSE;
dodgeburn_mode = args[3].value.pdb_int;
if (dodgeburn_mode < GIMP_SHADOWS || dodgeburn_mode > GIMP_HIGHLIGHTS)
success = FALSE;
num_strokes = args[4].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[5].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
exposure = g_value_get_double (&args[1].value);
dodgeburn_type = g_value_get_enum (&args[2].value);
dodgeburn_mode = g_value_get_enum (&args[3].value);
num_strokes = g_value_get_int (&args[4].value);
strokes = g_value_get_pointer (&args[5].value);
if (success)
{
@ -1111,15 +1043,9 @@ dodgeburn_default_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
if (success)
{
@ -1169,23 +1095,11 @@ eraser_invoker (ProcRecord *proc_record,
gint32 hardness;
gint32 method;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
hardness = args[3].value.pdb_int;
if (hardness < GIMP_BRUSH_HARD || hardness > GIMP_BRUSH_SOFT)
success = FALSE;
method = args[4].value.pdb_int;
if (method < GIMP_PAINT_CONSTANT || method > GIMP_PAINT_INCREMENTAL)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
hardness = g_value_get_enum (&args[3].value);
method = g_value_get_enum (&args[4].value);
if (success)
{
@ -1238,15 +1152,9 @@ eraser_default_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
if (success)
{
@ -1297,27 +1205,12 @@ paintbrush_invoker (ProcRecord *proc_record,
gint32 method;
gdouble gradient_length;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
fade_out = args[1].value.pdb_float;
if (fade_out < 0.0)
success = FALSE;
num_strokes = args[2].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[3].value.pdb_pointer;
method = args[4].value.pdb_int;
if (method < GIMP_PAINT_CONSTANT || method > GIMP_PAINT_INCREMENTAL)
success = FALSE;
gradient_length = args[5].value.pdb_float;
if (gradient_length < 0.0)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
fade_out = g_value_get_double (&args[1].value);
num_strokes = g_value_get_int (&args[2].value);
strokes = g_value_get_pointer (&args[3].value);
method = g_value_get_enum (&args[4].value);
gradient_length = g_value_get_double (&args[5].value);
if (success)
{
@ -1373,15 +1266,9 @@ paintbrush_default_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
if (success)
{
@ -1429,15 +1316,9 @@ pencil_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
if (success)
{
@ -1486,19 +1367,10 @@ smudge_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
pressure = args[1].value.pdb_float;
if (pressure < 0.0 || pressure > 100.0)
success = FALSE;
num_strokes = args[2].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[3].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
pressure = g_value_get_double (&args[1].value);
num_strokes = g_value_get_int (&args[2].value);
strokes = g_value_get_pointer (&args[3].value);
if (success)
{
@ -1550,15 +1422,9 @@ smudge_default_invoker (ProcRecord *proc_record,
gint32 num_strokes;
gdouble *strokes;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
num_strokes = args[1].value.pdb_int;
if (num_strokes < 2)
success = FALSE;
strokes = (gdouble *) args[2].value.pdb_pointer;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
num_strokes = g_value_get_int (&args[1].value);
strokes = g_value_get_pointer (&args[2].value);
if (success)
{

View File

@ -413,9 +413,7 @@ palette_new_invoker (ProcRecord *proc_record,
gchar *name;
gchar *actual_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -435,7 +433,7 @@ palette_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = actual_name;
g_value_take_string (&return_vals[1].value, actual_name);
return return_vals;
}
@ -467,9 +465,7 @@ palette_duplicate_invoker (ProcRecord *proc_record,
gchar *name;
gchar *copy_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -494,7 +490,7 @@ palette_duplicate_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = copy_name;
g_value_take_string (&return_vals[1].value, copy_name);
return return_vals;
}
@ -527,13 +523,8 @@ palette_rename_invoker (ProcRecord *proc_record,
gchar *new_name;
gchar *actual_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
new_name = (gchar *) args[1].value.pdb_pointer;
if (new_name == NULL || !g_utf8_validate (new_name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
new_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -552,7 +543,7 @@ palette_rename_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = actual_name;
g_value_take_string (&return_vals[1].value, actual_name);
return return_vals;
}
@ -582,9 +573,7 @@ palette_delete_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -639,9 +628,7 @@ palette_is_editable_invoker (ProcRecord *proc_record,
gchar *name;
gboolean editable = FALSE;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -657,7 +644,7 @@ palette_is_editable_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = editable;
g_value_set_boolean (&return_vals[1].value, editable);
return return_vals;
}
@ -689,9 +676,7 @@ palette_get_info_invoker (ProcRecord *proc_record,
gchar *name;
gint32 num_colors = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -707,7 +692,7 @@ palette_get_info_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = num_colors;
g_value_set_int (&return_vals[1].value, num_colors);
return return_vals;
}
@ -739,9 +724,7 @@ palette_get_columns_invoker (ProcRecord *proc_record,
gchar *name;
gint32 num_columns = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -757,7 +740,7 @@ palette_get_columns_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = num_columns;
g_value_set_int (&return_vals[1].value, num_columns);
return return_vals;
}
@ -788,13 +771,8 @@ palette_set_columns_invoker (ProcRecord *proc_record,
gchar *name;
gint32 columns;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
columns = args[1].value.pdb_int;
if (columns < 0 || columns > 64)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
columns = g_value_get_int (&args[1].value);
if (success)
{
@ -839,15 +817,9 @@ palette_add_entry_invoker (ProcRecord *proc_record,
GimpRGB color;
gint32 entry_num = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_name = (gchar *) args[1].value.pdb_pointer;
if (entry_name && !g_utf8_validate (entry_name, -1, NULL))
success = FALSE;
color = args[2].value.pdb_color;
name = (gchar *) g_value_get_string (&args[0].value);
entry_name = (gchar *) g_value_get_string (&args[1].value);
gimp_value_get_rgb (&args[2].value, &color);
if (success)
{
@ -868,7 +840,7 @@ palette_add_entry_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = entry_num;
g_value_set_int (&return_vals[1].value, entry_num);
return return_vals;
}
@ -899,11 +871,8 @@ palette_delete_entry_invoker (ProcRecord *proc_record,
gchar *name;
gint32 entry_num;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
entry_num = g_value_get_int (&args[1].value);
if (success)
{
@ -956,11 +925,8 @@ palette_entry_get_color_invoker (ProcRecord *proc_record,
gint32 entry_num;
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
entry_num = g_value_get_int (&args[1].value);
if (success)
{
@ -985,7 +951,7 @@ palette_entry_get_color_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_color = color;
gimp_value_set_rgb (&return_vals[1].value, &color);
return return_vals;
}
@ -1017,13 +983,9 @@ palette_entry_set_color_invoker (ProcRecord *proc_record,
gint32 entry_num;
GimpRGB color;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
color = args[2].value.pdb_color;
name = (gchar *) g_value_get_string (&args[0].value);
entry_num = g_value_get_int (&args[1].value);
gimp_value_get_rgb (&args[2].value, &color);
if (success)
{
@ -1078,11 +1040,8 @@ palette_entry_get_name_invoker (ProcRecord *proc_record,
gint32 entry_num;
gchar *entry_name = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
entry_num = g_value_get_int (&args[1].value);
if (success)
{
@ -1107,7 +1066,7 @@ palette_entry_get_name_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = entry_name;
g_value_take_string (&return_vals[1].value, entry_name);
return return_vals;
}
@ -1139,15 +1098,9 @@ palette_entry_set_name_invoker (ProcRecord *proc_record,
gint32 entry_num;
gchar *entry_name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
entry_name = (gchar *) args[2].value.pdb_pointer;
if (entry_name && !g_utf8_validate (entry_name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
entry_num = g_value_get_int (&args[1].value);
entry_name = (gchar *) g_value_get_string (&args[2].value);
if (success)
{

View File

@ -119,17 +119,9 @@ palettes_popup_invoker (ProcRecord *proc_record,
gchar *popup_title;
gchar *initial_palette;
palette_callback = (gchar *) args[0].value.pdb_pointer;
if (palette_callback == NULL || !g_utf8_validate (palette_callback, -1, NULL))
success = FALSE;
popup_title = (gchar *) args[1].value.pdb_pointer;
if (popup_title == NULL || !g_utf8_validate (popup_title, -1, NULL))
success = FALSE;
initial_palette = (gchar *) args[2].value.pdb_pointer;
if (initial_palette && !g_utf8_validate (initial_palette, -1, NULL))
success = FALSE;
palette_callback = (gchar *) g_value_get_string (&args[0].value);
popup_title = (gchar *) g_value_get_string (&args[1].value);
initial_palette = (gchar *) g_value_get_string (&args[2].value);
if (success)
{
@ -169,9 +161,7 @@ palettes_close_popup_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *palette_callback;
palette_callback = (gchar *) args[0].value.pdb_pointer;
if (palette_callback == NULL || !g_utf8_validate (palette_callback, -1, NULL))
success = FALSE;
palette_callback = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -211,13 +201,8 @@ palettes_set_popup_invoker (ProcRecord *proc_record,
gchar *palette_callback;
gchar *palette_name;
palette_callback = (gchar *) args[0].value.pdb_pointer;
if (palette_callback == NULL || !g_utf8_validate (palette_callback, -1, NULL))
success = FALSE;
palette_name = (gchar *) args[1].value.pdb_pointer;
if (palette_name == NULL || !g_utf8_validate (palette_name, -1, NULL))
success = FALSE;
palette_callback = (gchar *) g_value_get_string (&args[0].value);
palette_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{

View File

@ -185,9 +185,7 @@ palettes_get_list_invoker (ProcRecord *proc_record,
gint32 num_palettes = 0;
gchar **palette_list = NULL;
filter = (gchar *) args[0].value.pdb_pointer;
if (filter && !g_utf8_validate (filter, -1, NULL))
success = FALSE;
filter = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -199,8 +197,8 @@ palettes_get_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_palettes;
return_vals[2].value.pdb_pointer = palette_list;
g_value_set_int (&return_vals[1].value, num_palettes);
g_value_set_pointer (&return_vals[2].value, palette_list);
}
return return_vals;
@ -247,8 +245,8 @@ palettes_get_palette_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_pointer = name;
return_vals[2].value.pdb_int = num_colors;
g_value_take_string (&return_vals[1].value, name);
g_value_set_int (&return_vals[2].value, num_colors);
}
return return_vals;
@ -284,11 +282,8 @@ palettes_get_palette_entry_invoker (ProcRecord *proc_record,
gint32 num_colors = 0;
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
name = (gchar *) g_value_get_string (&args[0].value);
entry_num = g_value_get_int (&args[1].value);
if (success)
{
@ -326,9 +321,9 @@ palettes_get_palette_entry_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_pointer = actual_name;
return_vals[2].value.pdb_int = num_colors;
return_vals[3].value.pdb_color = color;
g_value_take_string (&return_vals[1].value, actual_name);
g_value_set_int (&return_vals[2].value, num_colors);
gimp_value_set_rgb (&return_vals[3].value, &color);
}
return return_vals;

View File

@ -422,9 +422,7 @@ parasite_find_invoker (ProcRecord *proc_record,
gchar *name;
GimpParasite *parasite = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -437,7 +435,7 @@ parasite_find_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = parasite;
g_value_take_boxed (&return_vals[1].value, parasite);
return return_vals;
}
@ -467,9 +465,7 @@ parasite_attach_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpParasite *parasite;
parasite = (GimpParasite *) args[0].value.pdb_pointer;
if (parasite == NULL || parasite->name == NULL || !g_utf8_validate (parasite->name, -1, NULL))
success = FALSE;
parasite = g_value_get_boxed (&args[0].value);
if (success)
{
@ -504,9 +500,7 @@ parasite_detach_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *name;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -546,8 +540,8 @@ parasite_list_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_int = num_parasites;
return_vals[2].value.pdb_pointer = parasites;
g_value_set_int (&return_vals[1].value, num_parasites);
g_value_set_pointer (&return_vals[2].value, parasites);
return return_vals;
}
@ -580,13 +574,8 @@ image_parasite_find_invoker (ProcRecord *proc_record,
gchar *name;
GimpParasite *parasite = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -599,7 +588,7 @@ image_parasite_find_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = parasite;
g_value_take_boxed (&return_vals[1].value, parasite);
return return_vals;
}
@ -630,13 +619,8 @@ image_parasite_attach_invoker (ProcRecord *proc_record,
GimpImage *image;
GimpParasite *parasite;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
parasite = (GimpParasite *) args[1].value.pdb_pointer;
if (parasite == NULL || parasite->name == NULL || !g_utf8_validate (parasite->name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
parasite = g_value_get_boxed (&args[1].value);
if (success)
{
@ -672,13 +656,8 @@ image_parasite_detach_invoker (ProcRecord *proc_record,
GimpImage *image;
gchar *name;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -716,9 +695,7 @@ image_parasite_list_invoker (ProcRecord *proc_record,
gint32 num_parasites = 0;
gchar **parasites = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -729,8 +706,8 @@ image_parasite_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_parasites;
return_vals[2].value.pdb_pointer = parasites;
g_value_set_int (&return_vals[1].value, num_parasites);
g_value_set_pointer (&return_vals[2].value, parasites);
}
return return_vals;
@ -764,13 +741,8 @@ drawable_parasite_find_invoker (ProcRecord *proc_record,
gchar *name;
GimpParasite *parasite = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -784,7 +756,7 @@ drawable_parasite_find_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = parasite;
g_value_take_boxed (&return_vals[1].value, parasite);
return return_vals;
}
@ -815,13 +787,8 @@ drawable_parasite_attach_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
GimpParasite *parasite;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
parasite = (GimpParasite *) args[1].value.pdb_pointer;
if (parasite == NULL || parasite->name == NULL || !g_utf8_validate (parasite->name, -1, NULL))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
parasite = g_value_get_boxed (&args[1].value);
if (success)
{
@ -857,13 +824,8 @@ drawable_parasite_detach_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gchar *name;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -901,9 +863,7 @@ drawable_parasite_list_invoker (ProcRecord *proc_record,
gint32 num_parasites = 0;
gchar **parasites = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
if (success)
{
@ -914,8 +874,8 @@ drawable_parasite_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_parasites;
return_vals[2].value.pdb_pointer = parasites;
g_value_set_int (&return_vals[1].value, num_parasites);
g_value_set_pointer (&return_vals[2].value, parasites);
}
return return_vals;
@ -949,13 +909,8 @@ vectors_parasite_find_invoker (ProcRecord *proc_record,
gchar *name;
GimpParasite *parasite = NULL;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -969,7 +924,7 @@ vectors_parasite_find_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = parasite;
g_value_take_boxed (&return_vals[1].value, parasite);
return return_vals;
}
@ -1000,13 +955,8 @@ vectors_parasite_attach_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
GimpParasite *parasite;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
parasite = (GimpParasite *) args[1].value.pdb_pointer;
if (parasite == NULL || parasite->name == NULL || !g_utf8_validate (parasite->name, -1, NULL))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
parasite = g_value_get_boxed (&args[1].value);
if (success)
{
@ -1042,13 +992,8 @@ vectors_parasite_detach_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gchar *name;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -1086,9 +1031,7 @@ vectors_parasite_list_invoker (ProcRecord *proc_record,
gint32 num_parasites = 0;
gchar **parasites = NULL;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
if (success)
{
@ -1099,8 +1042,8 @@ vectors_parasite_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_parasites;
return_vals[2].value.pdb_pointer = parasites;
g_value_set_int (&return_vals[1].value, num_parasites);
g_value_set_pointer (&return_vals[2].value, parasites);
}
return return_vals;

View File

@ -583,9 +583,7 @@ path_list_invoker (ProcRecord *proc_record,
gint32 num_paths = 0;
gchar **path_list = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -596,8 +594,8 @@ path_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_paths;
return_vals[2].value.pdb_pointer = path_list;
g_value_set_int (&return_vals[1].value, num_paths);
g_value_set_pointer (&return_vals[2].value, path_list);
}
return return_vals;
@ -630,9 +628,7 @@ path_get_current_invoker (ProcRecord *proc_record,
GimpImage *image;
gchar *name = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -647,7 +643,7 @@ path_get_current_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -678,13 +674,8 @@ path_set_current_invoker (ProcRecord *proc_record,
GimpImage *image;
gchar *name;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -725,13 +716,8 @@ path_delete_invoker (ProcRecord *proc_record,
GimpImage *image;
gchar *name;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -777,13 +763,8 @@ path_get_points_invoker (ProcRecord *proc_record,
gint32 num_path_point_details = 0;
gdouble *points_pairs = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -830,10 +811,10 @@ path_get_points_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = path_type;
return_vals[2].value.pdb_int = path_closed;
return_vals[3].value.pdb_int = num_path_point_details;
return_vals[4].value.pdb_pointer = points_pairs;
g_value_set_int (&return_vals[1].value, path_type);
g_value_set_int (&return_vals[2].value, path_closed);
g_value_set_int (&return_vals[3].value, num_path_point_details);
g_value_set_pointer (&return_vals[4].value, points_pairs);
}
return return_vals;
@ -868,21 +849,11 @@ path_set_points_invoker (ProcRecord *proc_record,
gint32 num_path_points;
gdouble *points_pairs;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
ptype = args[2].value.pdb_int;
num_path_points = args[3].value.pdb_int;
if (num_path_points <= 0)
success = FALSE;
points_pairs = (gdouble *) args[4].value.pdb_pointer;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
ptype = g_value_get_int (&args[2].value);
num_path_points = g_value_get_int (&args[3].value);
points_pairs = g_value_get_pointer (&args[4].value);
if (success)
{
@ -954,9 +925,7 @@ path_stroke_current_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -1011,11 +980,8 @@ path_get_point_at_dist_invoker (ProcRecord *proc_record,
gint32 y_point = 0;
gdouble slope = 0.0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
distance = args[1].value.pdb_float;
image = gimp_value_get_image (&args[0].value, gimp);
distance = g_value_get_double (&args[1].value);
if (success)
{
@ -1074,9 +1040,9 @@ path_get_point_at_dist_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = x_point;
return_vals[2].value.pdb_int = y_point;
return_vals[3].value.pdb_float = slope;
g_value_set_int (&return_vals[1].value, x_point);
g_value_set_int (&return_vals[2].value, y_point);
g_value_set_double (&return_vals[3].value, slope);
}
return return_vals;
@ -1110,13 +1076,8 @@ path_get_tattoo_invoker (ProcRecord *proc_record,
gchar *name;
gint32 tattoo = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -1131,7 +1092,7 @@ path_get_tattoo_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = tattoo;
g_value_set_int (&return_vals[1].value, tattoo);
return return_vals;
}
@ -1163,15 +1124,9 @@ path_set_tattoo_invoker (ProcRecord *proc_record,
gchar *name;
gint32 tattovalue;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
tattovalue = args[2].value.pdb_int;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
tattovalue = g_value_get_int (&args[2].value);
if (success)
{
@ -1214,11 +1169,8 @@ get_path_by_tattoo_invoker (ProcRecord *proc_record,
gint32 tattoo;
gchar *name = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
tattoo = args[1].value.pdb_int;
image = gimp_value_get_image (&args[0].value, gimp);
tattoo = g_value_get_int (&args[1].value);
if (success)
{
@ -1233,7 +1185,7 @@ get_path_by_tattoo_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -1266,13 +1218,8 @@ path_get_locked_invoker (ProcRecord *proc_record,
gchar *name;
gboolean locked = FALSE;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -1287,7 +1234,7 @@ path_get_locked_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = locked;
g_value_set_boolean (&return_vals[1].value, locked);
return return_vals;
}
@ -1319,15 +1266,9 @@ path_set_locked_invoker (ProcRecord *proc_record,
gchar *name;
gboolean locked;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
locked = args[2].value.pdb_int ? TRUE : FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
locked = g_value_get_boolean (&args[2].value);
if (success)
{
@ -1373,25 +1314,13 @@ path_to_selection_invoker (ProcRecord *proc_record,
gdouble feather_radius_x;
gdouble feather_radius_y;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
op = args[2].value.pdb_int;
if (op < GIMP_CHANNEL_OP_ADD || op > GIMP_CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[3].value.pdb_int ? TRUE : FALSE;
feather = args[4].value.pdb_int ? TRUE : FALSE;
feather_radius_x = args[5].value.pdb_float;
feather_radius_y = args[6].value.pdb_float;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
op = g_value_get_enum (&args[2].value);
antialias = g_value_get_boolean (&args[3].value);
feather = g_value_get_boolean (&args[4].value);
feather_radius_x = g_value_get_double (&args[5].value);
feather_radius_y = g_value_get_double (&args[6].value);
if (success)
{
@ -1441,17 +1370,10 @@ path_import_invoker (ProcRecord *proc_record,
gboolean merge;
gboolean scale;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
filename = (gchar *) args[1].value.pdb_pointer;
if (filename == NULL)
success = FALSE;
merge = args[2].value.pdb_int ? TRUE : FALSE;
scale = args[3].value.pdb_int ? TRUE : FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
filename = (gchar *) g_value_get_string (&args[1].value);
merge = g_value_get_boolean (&args[2].value);
scale = g_value_get_boolean (&args[3].value);
if (success)
{
@ -1490,19 +1412,11 @@ path_import_string_invoker (ProcRecord *proc_record,
gboolean merge;
gboolean scale;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
string = (gchar *) args[1].value.pdb_pointer;
if (string == NULL)
success = FALSE;
length = args[2].value.pdb_int;
merge = args[3].value.pdb_int ? TRUE : FALSE;
scale = args[4].value.pdb_int ? TRUE : FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
string = (gchar *) g_value_get_string (&args[1].value);
length = g_value_get_int (&args[2].value);
merge = g_value_get_boolean (&args[3].value);
scale = g_value_get_boolean (&args[4].value);
if (success)
{

View File

@ -142,9 +142,7 @@ pattern_get_info_invoker (ProcRecord *proc_record,
gint32 height = 0;
gint32 bpp = 0;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -165,9 +163,9 @@ pattern_get_info_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = width;
return_vals[2].value.pdb_int = height;
return_vals[3].value.pdb_int = bpp;
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, bpp);
}
return return_vals;
@ -204,9 +202,7 @@ pattern_get_pixels_invoker (ProcRecord *proc_record,
gint32 num_color_bytes = 0;
guint8 *color_bytes = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -231,11 +227,11 @@ pattern_get_pixels_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = width;
return_vals[2].value.pdb_int = height;
return_vals[3].value.pdb_int = bpp;
return_vals[4].value.pdb_int = num_color_bytes;
return_vals[5].value.pdb_pointer = color_bytes;
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, bpp);
g_value_set_int (&return_vals[4].value, num_color_bytes);
g_value_set_pointer (&return_vals[5].value, color_bytes);
}
return return_vals;

View File

@ -119,17 +119,9 @@ patterns_popup_invoker (ProcRecord *proc_record,
gchar *popup_title;
gchar *initial_pattern;
pattern_callback = (gchar *) args[0].value.pdb_pointer;
if (pattern_callback == NULL || !g_utf8_validate (pattern_callback, -1, NULL))
success = FALSE;
popup_title = (gchar *) args[1].value.pdb_pointer;
if (popup_title == NULL || !g_utf8_validate (popup_title, -1, NULL))
success = FALSE;
initial_pattern = (gchar *) args[2].value.pdb_pointer;
if (initial_pattern && !g_utf8_validate (initial_pattern, -1, NULL))
success = FALSE;
pattern_callback = (gchar *) g_value_get_string (&args[0].value);
popup_title = (gchar *) g_value_get_string (&args[1].value);
initial_pattern = (gchar *) g_value_get_string (&args[2].value);
if (success)
{
@ -169,9 +161,7 @@ patterns_close_popup_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *pattern_callback;
pattern_callback = (gchar *) args[0].value.pdb_pointer;
if (pattern_callback == NULL || !g_utf8_validate (pattern_callback, -1, NULL))
success = FALSE;
pattern_callback = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -211,13 +201,8 @@ patterns_set_popup_invoker (ProcRecord *proc_record,
gchar *pattern_callback;
gchar *pattern_name;
pattern_callback = (gchar *) args[0].value.pdb_pointer;
if (pattern_callback == NULL || !g_utf8_validate (pattern_callback, -1, NULL))
success = FALSE;
pattern_name = (gchar *) args[1].value.pdb_pointer;
if (pattern_name == NULL || !g_utf8_validate (pattern_name, -1, NULL))
success = FALSE;
pattern_callback = (gchar *) g_value_get_string (&args[0].value);
pattern_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{

View File

@ -204,9 +204,7 @@ patterns_get_list_invoker (ProcRecord *proc_record,
gint32 num_patterns = 0;
gchar **pattern_list = NULL;
filter = (gchar *) args[0].value.pdb_pointer;
if (filter && !g_utf8_validate (filter, -1, NULL))
success = FALSE;
filter = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -218,8 +216,8 @@ patterns_get_list_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_patterns;
return_vals[2].value.pdb_pointer = pattern_list;
g_value_set_int (&return_vals[1].value, num_patterns);
g_value_set_pointer (&return_vals[2].value, pattern_list);
}
return return_vals;
@ -268,9 +266,9 @@ patterns_get_pattern_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_pointer = name;
return_vals[2].value.pdb_int = width;
return_vals[3].value.pdb_int = height;
g_value_take_string (&return_vals[1].value, name);
g_value_set_int (&return_vals[2].value, width);
g_value_set_int (&return_vals[3].value, height);
}
return return_vals;
@ -308,9 +306,7 @@ patterns_get_pattern_data_invoker (ProcRecord *proc_record,
gint32 length = 0;
guint8 *mask_data = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -345,12 +341,12 @@ patterns_get_pattern_data_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_pointer = actual_name;
return_vals[2].value.pdb_int = width;
return_vals[3].value.pdb_int = height;
return_vals[4].value.pdb_int = mask_bpp;
return_vals[5].value.pdb_int = length;
return_vals[6].value.pdb_pointer = mask_data;
g_value_take_string (&return_vals[1].value, actual_name);
g_value_set_int (&return_vals[2].value, width);
g_value_set_int (&return_vals[3].value, height);
g_value_set_int (&return_vals[4].value, mask_bpp);
g_value_set_int (&return_vals[5].value, length);
g_value_set_pointer (&return_vals[6].value, mask_data);
}
return return_vals;

View File

@ -286,7 +286,7 @@ plugins_query_invoker (ProcRecord *proc_record,
gint32 *plugin_install_time = NULL;
gchar **plugin_real_name = NULL;
search_string = (gchar *) args[0].value.pdb_pointer;
search_string = (gchar *) g_value_get_string (&args[0].value);
num_plugins = plug_ins_query (gimp, search_string,
&menu_path,
@ -298,18 +298,18 @@ plugins_query_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_int = num_plugins;
return_vals[2].value.pdb_pointer = menu_path;
return_vals[3].value.pdb_int = num_plugins;
return_vals[4].value.pdb_pointer = plugin_accelerator;
return_vals[5].value.pdb_int = num_plugins;
return_vals[6].value.pdb_pointer = plugin_location;
return_vals[7].value.pdb_int = num_plugins;
return_vals[8].value.pdb_pointer = plugin_image_type;
return_vals[9].value.pdb_int = num_plugins;
return_vals[10].value.pdb_pointer = plugin_install_time;
return_vals[11].value.pdb_int = num_plugins;
return_vals[12].value.pdb_pointer = plugin_real_name;
g_value_set_int (&return_vals[1].value, num_plugins);
g_value_set_pointer (&return_vals[2].value, menu_path);
g_value_set_int (&return_vals[3].value, num_plugins);
g_value_set_pointer (&return_vals[4].value, plugin_accelerator);
g_value_set_int (&return_vals[5].value, num_plugins);
g_value_set_pointer (&return_vals[6].value, plugin_location);
g_value_set_int (&return_vals[7].value, num_plugins);
g_value_set_pointer (&return_vals[8].value, plugin_image_type);
g_value_set_int (&return_vals[9].value, num_plugins);
g_value_set_pointer (&return_vals[10].value, plugin_install_time);
g_value_set_int (&return_vals[11].value, num_plugins);
g_value_set_pointer (&return_vals[12].value, plugin_real_name);
return return_vals;
}
@ -340,11 +340,8 @@ plugin_domain_register_invoker (ProcRecord *proc_record,
gchar *domain_name;
gchar *domain_path;
domain_name = (gchar *) args[0].value.pdb_pointer;
if (domain_name == NULL || !g_utf8_validate (domain_name, -1, NULL))
success = FALSE;
domain_path = (gchar *) args[1].value.pdb_pointer;
domain_name = (gchar *) g_value_get_string (&args[0].value);
domain_path = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -388,13 +385,8 @@ plugin_help_register_invoker (ProcRecord *proc_record,
gchar *domain_name;
gchar *domain_uri;
domain_name = (gchar *) args[0].value.pdb_pointer;
if (domain_name == NULL || !g_utf8_validate (domain_name, -1, NULL))
success = FALSE;
domain_uri = (gchar *) args[1].value.pdb_pointer;
if (domain_uri == NULL || !g_utf8_validate (domain_uri, -1, NULL))
success = FALSE;
domain_name = (gchar *) g_value_get_string (&args[0].value);
domain_uri = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -438,13 +430,8 @@ plugin_menu_register_invoker (ProcRecord *proc_record,
gchar *procedure_name;
gchar *menu_path;
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
menu_path = (gchar *) args[1].value.pdb_pointer;
if (menu_path == NULL || !g_utf8_validate (menu_path, -1, NULL))
success = FALSE;
procedure_name = (gchar *) g_value_get_string (&args[0].value);
menu_path = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -491,13 +478,8 @@ plugin_menu_branch_register_invoker (ProcRecord *proc_record,
gchar *menu_path;
gchar *menu_name;
menu_path = (gchar *) args[0].value.pdb_pointer;
if (menu_path == NULL || !g_utf8_validate (menu_path, -1, NULL))
success = FALSE;
menu_name = (gchar *) args[1].value.pdb_pointer;
if (menu_name == NULL || !g_utf8_validate (menu_name, -1, NULL))
success = FALSE;
menu_path = (gchar *) g_value_get_string (&args[0].value);
menu_name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -549,19 +531,10 @@ plugin_icon_register_invoker (ProcRecord *proc_record,
gint32 icon_data_length;
guint8 *icon_data;
procedure_name = (gchar *) args[0].value.pdb_pointer;
if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL))
success = FALSE;
icon_type = args[1].value.pdb_int;
if (icon_type < GIMP_ICON_TYPE_STOCK_ID || icon_type > GIMP_ICON_TYPE_IMAGE_FILE)
success = FALSE;
icon_data_length = args[2].value.pdb_int;
if (icon_data_length < 1)
success = FALSE;
icon_data = (guint8 *) args[3].value.pdb_pointer;
procedure_name = (gchar *) g_value_get_string (&args[0].value);
icon_type = g_value_get_enum (&args[1].value);
icon_data_length = g_value_get_int (&args[2].value);
icon_data = g_value_get_pointer (&args[3].value);
if (success)
{

View File

@ -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 *gimp,
{
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);
return return_args;
*n_return_vals = 1;
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;
return_vals = procedural_db_execute_proc (gimp, context, progress,
procedure,
args, n_args,
n_return_vals);
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_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 *gimp,
}
}
return return_args;
return return_vals;
}
Argument *
@ -362,7 +407,7 @@ procedural_db_run_proc (Gimp *gimp,
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 *gimp,
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 *gimp,
{
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;
gchar *expected = procedural_db_type_name (proc->args[i].arg_type);
gchar *got = procedural_db_type_name (arg_type);
expected = procedural_db_type_name (proc->args[i].arg_type);
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,20 +464,62 @@ procedural_db_run_proc (Gimp *gimp,
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 = &params[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:
g_value_set_uint (value, va_arg (args, guint));
break;
case GIMP_PDB_FLOAT:
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:
g_value_set_pointer (value, va_arg (args, gpointer));
break;
case GIMP_PDB_COLOR:
{
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:
@ -443,30 +527,16 @@ procedural_db_run_proc (Gimp *gimp,
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_int (value, va_arg (args, gint));
break;
case GIMP_PDB_FLOAT:
params[i].value.pdb_float = (gdouble) va_arg (args, gdouble);
break;
case GIMP_PDB_STRING:
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_static_boxed (value, va_arg (args, gpointer));
break;
case GIMP_PDB_COLOR:
params[i].value.pdb_color = va_arg (args, GimpRGB);
break;
case GIMP_PDB_STATUS:
g_value_set_enum (value, va_arg (args, gint));
case GIMP_PDB_REGION:
case GIMP_PDB_BOUNDARY:
case GIMP_PDB_END:
break;
}
@ -474,17 +544,17 @@ procedural_db_run_proc (Gimp *gimp,
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 *procedure)
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 *args,
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 *args,
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 (ProcRecord *procedure,
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,
@ -822,6 +909,73 @@ procedural_db_add_compat_value (ProcRecord *procedure,
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 */
gchar *

View File

@ -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);
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,
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);
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_values);
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_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_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__ */

View File

@ -248,12 +248,14 @@ register_procedural_db_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("arg-type",
"arg type",
"The type of argument: { GIMP_PDB_INT32 (0), GIMP_PDB_INT16 (1), GIMP_PDB_INT8 (2), GIMP_PDB_FLOAT (3), GIMP_PDB_STRING (4), GIMP_PDB_INT32ARRAY (5), GIMP_PDB_INT16ARRAY (6), GIMP_PDB_INT8ARRAY (7), GIMP_PDB_FLOATARRAY (8), GIMP_PDB_STRINGARRAY (9), GIMP_PDB_COLOR (10), GIMP_PDB_REGION (11), GIMP_PDB_DISPLAY (12), GIMP_PDB_IMAGE (13), GIMP_PDB_LAYER (14), GIMP_PDB_CHANNEL (15), GIMP_PDB_DRAWABLE (16), GIMP_PDB_SELECTION (17), GIMP_PDB_BOUNDARY (18), GIMP_PDB_VECTORS (19), GIMP_PDB_PARASITE (20), GIMP_PDB_STATUS (21), GIMP_PDB_PATH (GIMP_PDB_VECTORS) }",
GIMP_TYPE_PDB_ARG_TYPE,
GIMP_PDB_INT32,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("arg-type",
"arg type",
"The type of argument: { GIMP_PDB_INT32 (0), GIMP_PDB_INT16 (1), GIMP_PDB_INT8 (2), GIMP_PDB_FLOAT (3), GIMP_PDB_STRING (4), GIMP_PDB_INT32ARRAY (5), GIMP_PDB_INT16ARRAY (6), GIMP_PDB_INT8ARRAY (7), GIMP_PDB_FLOATARRAY (8), GIMP_PDB_STRINGARRAY (9), GIMP_PDB_COLOR (10), GIMP_PDB_REGION (11), GIMP_PDB_DISPLAY (12), GIMP_PDB_IMAGE (13), GIMP_PDB_LAYER (14), GIMP_PDB_CHANNEL (15), GIMP_PDB_DRAWABLE (16), GIMP_PDB_SELECTION (17), GIMP_PDB_BOUNDARY (18), GIMP_PDB_VECTORS (19), GIMP_PDB_PARASITE (20), GIMP_PDB_STATUS (21), GIMP_PDB_PATH (GIMP_PDB_VECTORS) }",
GIMP_TYPE_PDB_ARG_TYPE,
GIMP_PDB_INT32,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0].pspec),
GIMP_PDB_END);
procedural_db_add_return_value (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("arg-name",
@ -293,12 +295,14 @@ register_procedural_db_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("val-type",
"val type",
"The type of return value: { GIMP_PDB_INT32 (0), GIMP_PDB_INT16 (1), GIMP_PDB_INT8 (2), GIMP_PDB_FLOAT (3), GIMP_PDB_STRING (4), GIMP_PDB_INT32ARRAY (5), GIMP_PDB_INT16ARRAY (6), GIMP_PDB_INT8ARRAY (7), GIMP_PDB_FLOATARRAY (8), GIMP_PDB_STRINGARRAY (9), GIMP_PDB_COLOR (10), GIMP_PDB_REGION (11), GIMP_PDB_DISPLAY (12), GIMP_PDB_IMAGE (13), GIMP_PDB_LAYER (14), GIMP_PDB_CHANNEL (15), GIMP_PDB_DRAWABLE (16), GIMP_PDB_SELECTION (17), GIMP_PDB_BOUNDARY (18), GIMP_PDB_VECTORS (19), GIMP_PDB_PARASITE (20), GIMP_PDB_STATUS (21), GIMP_PDB_PATH (GIMP_PDB_VECTORS) }",
GIMP_TYPE_PDB_ARG_TYPE,
GIMP_PDB_INT32,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("val-type",
"val type",
"The type of return value: { GIMP_PDB_INT32 (0), GIMP_PDB_INT16 (1), GIMP_PDB_INT8 (2), GIMP_PDB_FLOAT (3), GIMP_PDB_STRING (4), GIMP_PDB_INT32ARRAY (5), GIMP_PDB_INT16ARRAY (6), GIMP_PDB_INT8ARRAY (7), GIMP_PDB_FLOATARRAY (8), GIMP_PDB_STRINGARRAY (9), GIMP_PDB_COLOR (10), GIMP_PDB_REGION (11), GIMP_PDB_DISPLAY (12), GIMP_PDB_IMAGE (13), GIMP_PDB_LAYER (14), GIMP_PDB_CHANNEL (15), GIMP_PDB_DRAWABLE (16), GIMP_PDB_SELECTION (17), GIMP_PDB_BOUNDARY (18), GIMP_PDB_VECTORS (19), GIMP_PDB_PARASITE (20), GIMP_PDB_STATUS (21), GIMP_PDB_PATH (GIMP_PDB_VECTORS) }",
GIMP_TYPE_PDB_ARG_TYPE,
GIMP_PDB_INT32,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0].pspec),
GIMP_PDB_END);
procedural_db_add_return_value (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("val-name",
@ -409,7 +413,7 @@ procedural_db_temp_name_invoker (ProcRecord *proc_record,
temp_name = g_strdup_printf ("temp-procedure-number-%d", proc_number++);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_pointer = temp_name;
g_value_take_string (&return_vals[1].value, temp_name);
return return_vals;
}
@ -439,9 +443,7 @@ procedural_db_dump_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *filename;
filename = (gchar *) args[0].value.pdb_pointer;
if (filename == NULL)
success = FALSE;
filename = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -485,33 +487,13 @@ procedural_db_query_invoker (ProcRecord *proc_record,
gint32 num_matches = 0;
gchar **procedure_names = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
success = FALSE;
blurb = (gchar *) args[1].value.pdb_pointer;
if (blurb == NULL)
success = FALSE;
help = (gchar *) args[2].value.pdb_pointer;
if (help == NULL)
success = FALSE;
author = (gchar *) args[3].value.pdb_pointer;
if (author == NULL)
success = FALSE;
copyright = (gchar *) args[4].value.pdb_pointer;
if (copyright == NULL)
success = FALSE;
date = (gchar *) args[5].value.pdb_pointer;
if (date == NULL)
success = FALSE;
proc_type = (gchar *) args[6].value.pdb_pointer;
if (proc_type == NULL)
success = FALSE;
name = (gchar *) g_value_get_string (&args[0].value);
blurb = (gchar *) g_value_get_string (&args[1].value);
help = (gchar *) g_value_get_string (&args[2].value);
author = (gchar *) g_value_get_string (&args[3].value);
copyright = (gchar *) g_value_get_string (&args[4].value);
date = (gchar *) g_value_get_string (&args[5].value);
proc_type = (gchar *) g_value_get_string (&args[6].value);
if (success)
{
@ -525,8 +507,8 @@ procedural_db_query_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_matches;
return_vals[2].value.pdb_pointer = procedure_names;
g_value_set_int (&return_vals[1].value, num_matches);
g_value_set_pointer (&return_vals[2].value, procedure_names);
}
return return_vals;
@ -566,9 +548,7 @@ procedural_db_proc_info_invoker (ProcRecord *proc_record,
gint32 num_args = 0;
gint32 num_values = 0;
procedure = (gchar *) args[0].value.pdb_pointer;
if (procedure == NULL || !g_utf8_validate (procedure, -1, NULL))
success = FALSE;
procedure = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -590,14 +570,14 @@ procedural_db_proc_info_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_pointer = blurb;
return_vals[2].value.pdb_pointer = help;
return_vals[3].value.pdb_pointer = author;
return_vals[4].value.pdb_pointer = copyright;
return_vals[5].value.pdb_pointer = date;
return_vals[6].value.pdb_int = proc_type;
return_vals[7].value.pdb_int = num_args;
return_vals[8].value.pdb_int = num_values;
g_value_take_string (&return_vals[1].value, blurb);
g_value_take_string (&return_vals[2].value, help);
g_value_take_string (&return_vals[3].value, author);
g_value_take_string (&return_vals[4].value, copyright);
g_value_take_string (&return_vals[5].value, date);
g_value_set_enum (&return_vals[6].value, proc_type);
g_value_set_int (&return_vals[7].value, num_args);
g_value_set_int (&return_vals[8].value, num_values);
}
return return_vals;
@ -633,11 +613,8 @@ procedural_db_proc_arg_invoker (ProcRecord *proc_record,
gchar *arg_name = NULL;
gchar *arg_desc = NULL;
procedure = (gchar *) args[0].value.pdb_pointer;
if (procedure == NULL || !g_utf8_validate (procedure, -1, NULL))
success = FALSE;
arg_num = args[1].value.pdb_int;
procedure = (gchar *) g_value_get_string (&args[0].value);
arg_num = g_value_get_int (&args[1].value);
if (success)
{
@ -676,9 +653,9 @@ procedural_db_proc_arg_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = arg_type;
return_vals[2].value.pdb_pointer = arg_name;
return_vals[3].value.pdb_pointer = arg_desc;
g_value_set_enum (&return_vals[1].value, arg_type);
g_value_take_string (&return_vals[2].value, arg_name);
g_value_take_string (&return_vals[3].value, arg_desc);
}
return return_vals;
@ -714,11 +691,8 @@ procedural_db_proc_val_invoker (ProcRecord *proc_record,
gchar *val_name = NULL;
gchar *val_desc = NULL;
procedure = (gchar *) args[0].value.pdb_pointer;
if (procedure == NULL || !g_utf8_validate (procedure, -1, NULL))
success = FALSE;
val_num = args[1].value.pdb_int;
procedure = (gchar *) g_value_get_string (&args[0].value);
val_num = g_value_get_int (&args[1].value);
if (success)
{
@ -757,9 +731,9 @@ procedural_db_proc_val_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = val_type;
return_vals[2].value.pdb_pointer = val_name;
return_vals[3].value.pdb_pointer = val_desc;
g_value_set_enum (&return_vals[1].value, val_type);
g_value_take_string (&return_vals[2].value, val_name);
g_value_take_string (&return_vals[3].value, val_desc);
}
return return_vals;
@ -793,9 +767,7 @@ procedural_db_get_data_invoker (ProcRecord *proc_record,
gint32 bytes = 0;
guint8 *data = NULL;
identifier = (gchar *) args[0].value.pdb_pointer;
if (identifier == NULL || !g_utf8_validate (identifier, -1, NULL))
success = FALSE;
identifier = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -818,8 +790,8 @@ procedural_db_get_data_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = bytes;
return_vals[2].value.pdb_pointer = data;
g_value_set_int (&return_vals[1].value, bytes);
g_value_set_pointer (&return_vals[2].value, data);
}
return return_vals;
@ -852,9 +824,7 @@ procedural_db_get_data_size_invoker (ProcRecord *proc_record,
gchar *identifier;
gint32 bytes = 0;
identifier = (gchar *) args[0].value.pdb_pointer;
if (identifier == NULL || !g_utf8_validate (identifier, -1, NULL))
success = FALSE;
identifier = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -875,7 +845,7 @@ procedural_db_get_data_size_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = bytes;
g_value_set_int (&return_vals[1].value, bytes);
return return_vals;
}
@ -907,15 +877,9 @@ procedural_db_set_data_invoker (ProcRecord *proc_record,
gint32 bytes;
guint8 *data;
identifier = (gchar *) args[0].value.pdb_pointer;
if (identifier == NULL || !g_utf8_validate (identifier, -1, NULL))
success = FALSE;
bytes = args[1].value.pdb_int;
if (bytes < 1)
success = FALSE;
data = (guint8 *) args[2].value.pdb_pointer;
identifier = (gchar *) g_value_get_string (&args[0].value);
bytes = g_value_get_int (&args[1].value);
data = g_value_get_pointer (&args[2].value);
if (success)
{

View File

@ -167,11 +167,8 @@ progress_init_invoker (ProcRecord *proc_record,
gchar *message;
GimpObject *gdisplay;
message = (gchar *) args[0].value.pdb_pointer;
if (message && !g_utf8_validate (message, -1, NULL))
success = FALSE;
gdisplay = gimp_get_display_by_ID (gimp, args[1].value.pdb_int);
message = (gchar *) g_value_get_string (&args[0].value);
gdisplay = gimp_value_get_display (&args[1].value, gimp);
if (success)
{
@ -212,15 +209,18 @@ progress_update_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gdouble percentage;
percentage = args[0].value.pdb_float;
percentage = g_value_get_double (&args[0].value);
if (gimp->current_plug_in && gimp->current_plug_in->open)
if (success)
{
if (! gimp->no_interface)
plug_in_progress_set_value (gimp->current_plug_in, percentage);
if (gimp->current_plug_in && gimp->current_plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_set_value (gimp->current_plug_in, percentage);
}
else
success = FALSE;
}
else
success = FALSE;
return procedural_db_return_values (proc_record, success);
}
@ -283,9 +283,7 @@ progress_set_text_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *message;
message = (gchar *) args[0].value.pdb_pointer;
if (message && !g_utf8_validate (message, -1, NULL))
success = FALSE;
message = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -338,7 +336,7 @@ progress_get_window_handle_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = window;
g_value_set_int (&return_vals[1].value, window);
return return_vals;
}
@ -368,9 +366,7 @@ progress_install_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *progress_callback;
progress_callback = (gchar *) args[0].value.pdb_pointer;
if (progress_callback == NULL || !g_utf8_validate (progress_callback, -1, NULL))
success = FALSE;
progress_callback = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -409,9 +405,7 @@ progress_uninstall_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *progress_callback;
progress_callback = (gchar *) args[0].value.pdb_pointer;
if (progress_callback == NULL || !g_utf8_validate (progress_callback, -1, NULL))
success = FALSE;
progress_callback = (gchar *) g_value_get_string (&args[0].value);
if (success)
{
@ -450,9 +444,7 @@ progress_cancel_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
gchar *progress_callback;
progress_callback = (gchar *) args[0].value.pdb_pointer;
if (progress_callback == NULL || !g_utf8_validate (progress_callback, -1, NULL))
success = FALSE;
progress_callback = (gchar *) g_value_get_string (&args[0].value);
if (success)
{

View File

@ -445,9 +445,7 @@ selection_bounds_invoker (ProcRecord *proc_record,
gint32 x2 = 0;
gint32 y2 = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -459,11 +457,11 @@ selection_bounds_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = non_empty;
return_vals[2].value.pdb_int = x1;
return_vals[3].value.pdb_int = y1;
return_vals[4].value.pdb_int = x2;
return_vals[5].value.pdb_int = y2;
g_value_set_boolean (&return_vals[1].value, non_empty);
g_value_set_int (&return_vals[2].value, x1);
g_value_set_int (&return_vals[3].value, y1);
g_value_set_int (&return_vals[4].value, x2);
g_value_set_int (&return_vals[5].value, y2);
}
return return_vals;
@ -498,13 +496,9 @@ selection_value_invoker (ProcRecord *proc_record,
gint32 y;
gint32 value = 0;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
x = args[1].value.pdb_int;
y = args[2].value.pdb_int;
image = gimp_value_get_image (&args[0].value, gimp);
x = g_value_get_int (&args[1].value);
y = g_value_get_int (&args[2].value);
if (success)
{
@ -514,7 +508,7 @@ selection_value_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = value;
g_value_set_int (&return_vals[1].value, value);
return return_vals;
}
@ -546,9 +540,7 @@ selection_is_empty_invoker (ProcRecord *proc_record,
GimpImage *image;
gboolean is_empty = FALSE;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -558,7 +550,7 @@ selection_is_empty_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = is_empty;
g_value_set_boolean (&return_vals[1].value, is_empty);
return return_vals;
}
@ -590,13 +582,9 @@ selection_translate_invoker (ProcRecord *proc_record,
gint32 offx;
gint32 offy;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
offx = args[1].value.pdb_int;
offy = args[2].value.pdb_int;
image = gimp_value_get_image (&args[0].value, gimp);
offx = g_value_get_int (&args[1].value);
offy = g_value_get_int (&args[2].value);
if (success)
{
@ -636,13 +624,9 @@ selection_float_invoker (ProcRecord *proc_record,
gint32 offy;
GimpLayer *layer = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
offx = args[1].value.pdb_int;
offy = args[2].value.pdb_int;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
offx = g_value_get_int (&args[1].value);
offy = g_value_get_int (&args[2].value);
if (success)
{
@ -662,7 +646,7 @@ selection_float_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = layer ? gimp_item_get_ID (GIMP_ITEM (layer)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (layer));
return return_vals;
}
@ -692,9 +676,7 @@ selection_invert_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -729,9 +711,7 @@ selection_sharpen_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -766,9 +746,7 @@ selection_all_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -803,9 +781,7 @@ selection_none_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -841,13 +817,8 @@ selection_feather_invoker (ProcRecord *proc_record,
GimpImage *image;
gdouble radius;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
radius = args[1].value.pdb_float;
if (radius < 0.0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
radius = g_value_get_double (&args[1].value);
if (success)
{
@ -884,13 +855,8 @@ selection_border_invoker (ProcRecord *proc_record,
GimpImage *image;
gint32 radius;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
radius = args[1].value.pdb_int;
if (radius < 0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
radius = g_value_get_int (&args[1].value);
if (success)
{
@ -927,13 +893,8 @@ selection_grow_invoker (ProcRecord *proc_record,
GimpImage *image;
gint32 steps;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
steps = args[1].value.pdb_int;
if (steps < 0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
steps = g_value_get_int (&args[1].value);
if (success)
{
@ -970,13 +931,8 @@ selection_shrink_invoker (ProcRecord *proc_record,
GimpImage *image;
gint32 steps;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
steps = args[1].value.pdb_int;
if (steps < 0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
steps = g_value_get_int (&args[1].value);
if (success)
{
@ -1012,9 +968,7 @@ selection_layer_alpha_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpLayer *layer;
layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
success = FALSE;
layer = (GimpLayer *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_LAYER);
if (success)
{
@ -1053,9 +1007,7 @@ selection_load_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpChannel *channel;
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
if (success)
{
@ -1103,9 +1055,7 @@ selection_save_invoker (ProcRecord *proc_record,
GimpImage *image;
GimpChannel *channel = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -1118,7 +1068,7 @@ selection_save_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = channel ? gimp_item_get_ID (GIMP_ITEM (channel)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (channel));
return return_vals;
}
@ -1149,13 +1099,8 @@ selection_combine_invoker (ProcRecord *proc_record,
GimpChannel *channel;
gint32 operation;
channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
success = FALSE;
operation = args[1].value.pdb_int;
if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
success = FALSE;
channel = (GimpChannel *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_CHANNEL);
operation = g_value_get_enum (&args[1].value);
if (success)
{

View File

@ -387,29 +387,14 @@ by_color_select_invoker (ProcRecord *proc_record,
gdouble feather_radius;
gboolean sample_merged;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
color = args[1].value.pdb_color;
threshold = args[2].value.pdb_int;
if (threshold < 0 || threshold > 255)
success = FALSE;
operation = args[3].value.pdb_int;
if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[4].value.pdb_int ? TRUE : FALSE;
feather = args[5].value.pdb_int ? TRUE : FALSE;
feather_radius = args[6].value.pdb_float;
if (feather_radius < 0.0)
success = FALSE;
sample_merged = args[7].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
gimp_value_get_rgb (&args[1].value, &color);
threshold = g_value_get_int (&args[2].value);
operation = g_value_get_enum (&args[3].value);
antialias = g_value_get_boolean (&args[4].value);
feather = g_value_get_boolean (&args[5].value);
feather_radius = g_value_get_double (&args[6].value);
sample_merged = g_value_get_boolean (&args[7].value);
if (success)
{
@ -463,33 +448,15 @@ ellipse_select_invoker (ProcRecord *proc_record,
gboolean feather;
gdouble feather_radius;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
width = args[3].value.pdb_float;
if (width <= 0.0)
success = FALSE;
height = args[4].value.pdb_float;
if (height <= 0.0)
success = FALSE;
operation = args[5].value.pdb_int;
if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[6].value.pdb_int ? TRUE : FALSE;
feather = args[7].value.pdb_int ? TRUE : FALSE;
feather_radius = args[8].value.pdb_float;
if (feather_radius < 0.0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
x = g_value_get_double (&args[1].value);
y = g_value_get_double (&args[2].value);
width = g_value_get_double (&args[3].value);
height = g_value_get_double (&args[4].value);
operation = g_value_get_enum (&args[5].value);
antialias = g_value_get_boolean (&args[6].value);
feather = g_value_get_boolean (&args[7].value);
feather_radius = g_value_get_double (&args[8].value);
if (success)
{
@ -537,27 +504,13 @@ free_select_invoker (ProcRecord *proc_record,
gboolean feather;
gdouble feather_radius;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
num_segs = args[1].value.pdb_int;
if (num_segs < 2)
success = FALSE;
segs = (gdouble *) args[2].value.pdb_pointer;
operation = args[3].value.pdb_int;
if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[4].value.pdb_int ? TRUE : FALSE;
feather = args[5].value.pdb_int ? TRUE : FALSE;
feather_radius = args[6].value.pdb_float;
if (feather_radius < 0.0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
num_segs = g_value_get_int (&args[1].value);
segs = g_value_get_pointer (&args[2].value);
operation = g_value_get_enum (&args[3].value);
antialias = g_value_get_boolean (&args[4].value);
feather = g_value_get_boolean (&args[5].value);
feather_radius = g_value_get_double (&args[6].value);
if (success)
{
@ -608,31 +561,15 @@ fuzzy_select_invoker (ProcRecord *proc_record,
gdouble feather_radius;
gboolean sample_merged;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
threshold = args[3].value.pdb_int;
if (threshold < 0 || threshold > 255)
success = FALSE;
operation = args[4].value.pdb_int;
if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
success = FALSE;
antialias = args[5].value.pdb_int ? TRUE : FALSE;
feather = args[6].value.pdb_int ? TRUE : FALSE;
feather_radius = args[7].value.pdb_float;
if (feather_radius < 0.0)
success = FALSE;
sample_merged = args[8].value.pdb_int ? TRUE : FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
x = g_value_get_double (&args[1].value);
y = g_value_get_double (&args[2].value);
threshold = g_value_get_int (&args[3].value);
operation = g_value_get_enum (&args[4].value);
antialias = g_value_get_boolean (&args[5].value);
feather = g_value_get_boolean (&args[6].value);
feather_radius = g_value_get_double (&args[7].value);
sample_merged = g_value_get_boolean (&args[8].value);
if (success)
{
@ -687,31 +624,14 @@ rect_select_invoker (ProcRecord *proc_record,
gboolean feather;
gdouble feather_radius;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
x = args[1].value.pdb_float;
y = args[2].value.pdb_float;
width = args[3].value.pdb_float;
if (width <= 0.0)
success = FALSE;
height = args[4].value.pdb_float;
if (height <= 0.0)
success = FALSE;
operation = args[5].value.pdb_int;
if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
success = FALSE;
feather = args[6].value.pdb_int ? TRUE : FALSE;
feather_radius = args[7].value.pdb_float;
if (feather_radius < 0.0)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
x = g_value_get_double (&args[1].value);
y = g_value_get_double (&args[2].value);
width = g_value_get_double (&args[3].value);
height = g_value_get_double (&args[4].value);
operation = g_value_get_enum (&args[5].value);
feather = g_value_get_boolean (&args[6].value);
feather_radius = g_value_get_double (&args[7].value);
if (success)
{

View File

@ -485,37 +485,16 @@ text_fontname_invoker (ProcRecord *proc_record,
gchar *fontname;
GimpLayer *text_layer = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);
x = args[2].value.pdb_float;
y = args[3].value.pdb_float;
text = (gchar *) args[4].value.pdb_pointer;
if (text == NULL || !g_utf8_validate (text, -1, NULL))
success = FALSE;
border = args[5].value.pdb_int;
if (border < -1)
success = FALSE;
antialias = args[6].value.pdb_int ? TRUE : FALSE;
size = args[7].value.pdb_float;
if (size <= 0.0)
success = FALSE;
size_type = args[8].value.pdb_int;
if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
success = FALSE;
fontname = (gchar *) args[9].value.pdb_pointer;
if (fontname == NULL || !g_utf8_validate (fontname, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
drawable = (GimpDrawable *) gimp_value_get_item (&args[1].value, gimp, GIMP_TYPE_DRAWABLE);
x = g_value_get_double (&args[2].value);
y = g_value_get_double (&args[3].value);
text = (gchar *) g_value_get_string (&args[4].value);
border = g_value_get_int (&args[5].value);
antialias = g_value_get_boolean (&args[6].value);
size = g_value_get_double (&args[7].value);
size_type = g_value_get_enum (&args[8].value);
fontname = (gchar *) g_value_get_string (&args[9].value);
if (success)
{
@ -537,7 +516,7 @@ text_fontname_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = text_layer ? gimp_item_get_ID (GIMP_ITEM (text_layer)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (text_layer));
return return_vals;
}
@ -575,21 +554,10 @@ text_get_extents_fontname_invoker (ProcRecord *proc_record,
gint32 ascent = 0;
gint32 descent = 0;
text = (gchar *) args[0].value.pdb_pointer;
if (text == NULL || !g_utf8_validate (text, -1, NULL))
success = FALSE;
size = args[1].value.pdb_float;
if (size <= 0.0)
success = FALSE;
size_type = args[2].value.pdb_int;
if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
success = FALSE;
fontname = (gchar *) args[3].value.pdb_pointer;
if (fontname == NULL || !g_utf8_validate (fontname, -1, NULL))
success = FALSE;
text = (gchar *) g_value_get_string (&args[0].value);
size = g_value_get_double (&args[1].value);
size_type = g_value_get_enum (&args[2].value);
fontname = (gchar *) g_value_get_string (&args[3].value);
if (success)
{
@ -606,10 +574,10 @@ text_get_extents_fontname_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = width;
return_vals[2].value.pdb_int = height;
return_vals[3].value.pdb_int = ascent;
return_vals[4].value.pdb_int = descent;
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, ascent);
g_value_set_int (&return_vals[4].value, descent);
}
return return_vals;
@ -658,65 +626,23 @@ text_invoker (ProcRecord *proc_record,
gchar *encoding;
GimpLayer *text_layer = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[1].value.pdb_int);
x = args[2].value.pdb_float;
y = args[3].value.pdb_float;
text = (gchar *) args[4].value.pdb_pointer;
if (text == NULL || !g_utf8_validate (text, -1, NULL))
success = FALSE;
border = args[5].value.pdb_int;
if (border < -1)
success = FALSE;
antialias = args[6].value.pdb_int ? TRUE : FALSE;
size = args[7].value.pdb_float;
if (size <= 0.0)
success = FALSE;
size_type = args[8].value.pdb_int;
if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
success = FALSE;
foundry = (gchar *) args[9].value.pdb_pointer;
if (foundry == NULL)
success = FALSE;
family = (gchar *) args[10].value.pdb_pointer;
if (family == NULL)
success = FALSE;
weight = (gchar *) args[11].value.pdb_pointer;
if (weight == NULL)
success = FALSE;
slant = (gchar *) args[12].value.pdb_pointer;
if (slant == NULL)
success = FALSE;
set_width = (gchar *) args[13].value.pdb_pointer;
if (set_width == NULL)
success = FALSE;
spacing = (gchar *) args[14].value.pdb_pointer;
if (spacing == NULL)
success = FALSE;
registry = (gchar *) args[15].value.pdb_pointer;
if (registry == NULL)
success = FALSE;
encoding = (gchar *) args[16].value.pdb_pointer;
if (encoding == NULL)
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
drawable = (GimpDrawable *) gimp_value_get_item (&args[1].value, gimp, GIMP_TYPE_DRAWABLE);
x = g_value_get_double (&args[2].value);
y = g_value_get_double (&args[3].value);
text = (gchar *) g_value_get_string (&args[4].value);
border = g_value_get_int (&args[5].value);
antialias = g_value_get_boolean (&args[6].value);
size = g_value_get_double (&args[7].value);
size_type = g_value_get_enum (&args[8].value);
foundry = (gchar *) g_value_get_string (&args[9].value);
family = (gchar *) g_value_get_string (&args[10].value);
weight = (gchar *) g_value_get_string (&args[11].value);
slant = (gchar *) g_value_get_string (&args[12].value);
set_width = (gchar *) g_value_get_string (&args[13].value);
spacing = (gchar *) g_value_get_string (&args[14].value);
registry = (gchar *) g_value_get_string (&args[15].value);
encoding = (gchar *) g_value_get_string (&args[16].value);
if (success)
{
@ -738,7 +664,7 @@ text_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = text_layer ? gimp_item_get_ID (GIMP_ITEM (text_layer)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (text_layer));
return return_vals;
}
@ -783,49 +709,17 @@ text_get_extents_invoker (ProcRecord *proc_record,
gint32 ascent = 0;
gint32 descent = 0;
text = (gchar *) args[0].value.pdb_pointer;
if (text == NULL || !g_utf8_validate (text, -1, NULL))
success = FALSE;
size = args[1].value.pdb_float;
if (size <= 0.0)
success = FALSE;
size_type = args[2].value.pdb_int;
if (size_type < GIMP_PIXELS || size_type > GIMP_POINTS)
success = FALSE;
foundry = (gchar *) args[3].value.pdb_pointer;
if (foundry == NULL)
success = FALSE;
family = (gchar *) args[4].value.pdb_pointer;
if (family == NULL)
success = FALSE;
weight = (gchar *) args[5].value.pdb_pointer;
if (weight == NULL)
success = FALSE;
slant = (gchar *) args[6].value.pdb_pointer;
if (slant == NULL)
success = FALSE;
set_width = (gchar *) args[7].value.pdb_pointer;
if (set_width == NULL)
success = FALSE;
spacing = (gchar *) args[8].value.pdb_pointer;
if (spacing == NULL)
success = FALSE;
registry = (gchar *) args[9].value.pdb_pointer;
if (registry == NULL)
success = FALSE;
encoding = (gchar *) args[10].value.pdb_pointer;
if (encoding == NULL)
success = FALSE;
text = (gchar *) g_value_get_string (&args[0].value);
size = g_value_get_double (&args[1].value);
size_type = g_value_get_enum (&args[2].value);
foundry = (gchar *) g_value_get_string (&args[3].value);
family = (gchar *) g_value_get_string (&args[4].value);
weight = (gchar *) g_value_get_string (&args[5].value);
slant = (gchar *) g_value_get_string (&args[6].value);
set_width = (gchar *) g_value_get_string (&args[7].value);
spacing = (gchar *) g_value_get_string (&args[8].value);
registry = (gchar *) g_value_get_string (&args[9].value);
encoding = (gchar *) g_value_get_string (&args[10].value);
if (success)
{
@ -842,10 +736,10 @@ text_get_extents_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = width;
return_vals[2].value.pdb_int = height;
return_vals[3].value.pdb_int = ascent;
return_vals[4].value.pdb_int = descent;
g_value_set_int (&return_vals[1].value, width);
g_value_set_int (&return_vals[2].value, height);
g_value_set_int (&return_vals[3].value, ascent);
g_value_set_int (&return_vals[4].value, descent);
}
return return_vals;

View File

@ -64,12 +64,14 @@ register_transform_tools_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("flip-type",
"flip type",
"Type of flip: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("flip-type",
"flip type",
"Type of flip: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1].pspec),
GIMP_ORIENTATION_UNKNOWN);
procedural_db_add_return_value (procedure,
GIMP_PDB_DRAWABLE,
gimp_param_spec_item_id ("drawable",
@ -279,12 +281,14 @@ register_transform_tools_procs (Gimp *gimp)
GIMP_PARAM_READWRITE));
procedural_db_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("shear-type",
"shear type",
"Type of shear: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum ("shear-type",
"shear type",
"Type of shear: { GIMP_ORIENTATION_HORIZONTAL (0), GIMP_ORIENTATION_VERTICAL (1) }",
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_HORIZONTAL,
GIMP_PARAM_READWRITE));
gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[2].pspec),
GIMP_ORIENTATION_UNKNOWN);
procedural_db_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("magnitude",
@ -394,13 +398,8 @@ flip_invoker (ProcRecord *proc_record,
GimpDrawable *drawable;
gint32 flip_type;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
flip_type = args[1].value.pdb_int;
if (flip_type < GIMP_ORIENTATION_HORIZONTAL || flip_type > GIMP_ORIENTATION_VERTICAL)
success = FALSE;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
flip_type = g_value_get_enum (&args[1].value);
if (success)
{
@ -419,7 +418,7 @@ flip_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -459,27 +458,16 @@ perspective_invoker (ProcRecord *proc_record,
gdouble x3;
gdouble y3;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
x0 = args[2].value.pdb_float;
y0 = args[3].value.pdb_float;
x1 = args[4].value.pdb_float;
y1 = args[5].value.pdb_float;
x2 = args[6].value.pdb_float;
y2 = args[7].value.pdb_float;
x3 = args[8].value.pdb_float;
y3 = args[9].value.pdb_float;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
interpolation = g_value_get_boolean (&args[1].value);
x0 = g_value_get_double (&args[2].value);
y0 = g_value_get_double (&args[3].value);
x1 = g_value_get_double (&args[4].value);
y1 = g_value_get_double (&args[5].value);
x2 = g_value_get_double (&args[6].value);
y2 = g_value_get_double (&args[7].value);
x3 = g_value_get_double (&args[8].value);
y3 = g_value_get_double (&args[9].value);
if (success)
{
@ -523,7 +511,7 @@ perspective_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -556,13 +544,9 @@ rotate_invoker (ProcRecord *proc_record,
gboolean interpolation;
gdouble angle;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
angle = args[2].value.pdb_float;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
interpolation = g_value_get_boolean (&args[1].value);
angle = g_value_get_double (&args[2].value);
if (success)
{
@ -602,7 +586,7 @@ rotate_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -638,19 +622,12 @@ scale_invoker (ProcRecord *proc_record,
gdouble x1;
gdouble y1;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
x0 = args[2].value.pdb_float;
y0 = args[3].value.pdb_float;
x1 = args[4].value.pdb_float;
y1 = args[5].value.pdb_float;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
interpolation = g_value_get_boolean (&args[1].value);
x0 = g_value_get_double (&args[2].value);
y0 = g_value_get_double (&args[3].value);
x1 = g_value_get_double (&args[4].value);
y1 = g_value_get_double (&args[5].value);
if (success)
{
@ -694,7 +671,7 @@ scale_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -728,17 +705,10 @@ shear_invoker (ProcRecord *proc_record,
gint32 shear_type;
gdouble magnitude;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
shear_type = args[2].value.pdb_int;
if (shear_type < GIMP_ORIENTATION_HORIZONTAL || shear_type > GIMP_ORIENTATION_VERTICAL)
success = FALSE;
magnitude = args[3].value.pdb_float;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
interpolation = g_value_get_boolean (&args[1].value);
shear_type = g_value_get_enum (&args[2].value);
magnitude = g_value_get_double (&args[3].value);
if (success)
{
@ -779,7 +749,7 @@ shear_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}
@ -818,25 +788,15 @@ transform_2d_invoker (ProcRecord *proc_record,
gdouble dest_x;
gdouble dest_y;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
source_x = args[2].value.pdb_float;
source_y = args[3].value.pdb_float;
scale_x = args[4].value.pdb_float;
scale_y = args[5].value.pdb_float;
angle = args[6].value.pdb_float;
dest_x = args[7].value.pdb_float;
dest_y = args[8].value.pdb_float;
drawable = (GimpDrawable *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_DRAWABLE);
interpolation = g_value_get_boolean (&args[1].value);
source_x = g_value_get_double (&args[2].value);
source_y = g_value_get_double (&args[3].value);
scale_x = g_value_get_double (&args[4].value);
scale_y = g_value_get_double (&args[5].value);
angle = g_value_get_double (&args[6].value);
dest_x = g_value_get_double (&args[7].value);
dest_y = g_value_get_double (&args[8].value);
if (success)
{
@ -877,7 +837,7 @@ transform_2d_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = drawable ? gimp_item_get_ID (GIMP_ITEM (drawable)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (drawable));
return return_vals;
}

View File

@ -183,9 +183,7 @@ image_undo_group_start_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -228,9 +226,7 @@ image_undo_group_end_invoker (ProcRecord *proc_record,
gboolean success = TRUE;
GimpImage *image;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -267,9 +263,7 @@ image_undo_is_enabled_invoker (ProcRecord *proc_record,
GimpImage *image;
gboolean enabled = FALSE;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -279,7 +273,7 @@ image_undo_is_enabled_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = enabled;
g_value_set_boolean (&return_vals[1].value, enabled);
return return_vals;
}
@ -311,9 +305,7 @@ image_undo_disable_invoker (ProcRecord *proc_record,
GimpImage *image;
gboolean disabled = FALSE;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -323,7 +315,7 @@ image_undo_disable_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = disabled;
g_value_set_boolean (&return_vals[1].value, disabled);
return return_vals;
}
@ -355,9 +347,7 @@ image_undo_enable_invoker (ProcRecord *proc_record,
GimpImage *image;
gboolean enabled = FALSE;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -367,7 +357,7 @@ image_undo_enable_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = enabled;
g_value_set_boolean (&return_vals[1].value, enabled);
return return_vals;
}
@ -399,9 +389,7 @@ image_undo_freeze_invoker (ProcRecord *proc_record,
GimpImage *image;
gboolean frozen = FALSE;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -411,7 +399,7 @@ image_undo_freeze_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = frozen;
g_value_set_boolean (&return_vals[1].value, frozen);
return return_vals;
}
@ -443,9 +431,7 @@ image_undo_thaw_invoker (ProcRecord *proc_record,
GimpImage *image;
gboolean thawed = FALSE;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
@ -455,7 +441,7 @@ image_undo_thaw_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = thawed;
g_value_set_boolean (&return_vals[1].value, thawed);
return return_vals;
}

View File

@ -362,7 +362,7 @@ unit_get_number_of_units_invoker (ProcRecord *proc_record,
num_units = _gimp_unit_get_number_of_units (gimp);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_int = num_units;
g_value_set_int (&return_vals[1].value, num_units);
return return_vals;
}
@ -395,7 +395,7 @@ unit_get_number_of_built_in_units_invoker (ProcRecord *proc_record,
num_units = _gimp_unit_get_number_of_built_in_units (gimp);
return_vals = procedural_db_return_values (proc_record, TRUE);
return_vals[1].value.pdb_int = num_units;
g_value_set_int (&return_vals[1].value, num_units);
return return_vals;
}
@ -433,29 +433,13 @@ unit_new_invoker (ProcRecord *proc_record,
gchar *plural;
GimpUnit unit_id = 0;
identifier = (gchar *) args[0].value.pdb_pointer;
if (identifier == NULL || !g_utf8_validate (identifier, -1, NULL))
success = FALSE;
factor = args[1].value.pdb_float;
digits = args[2].value.pdb_int;
symbol = (gchar *) args[3].value.pdb_pointer;
if (symbol == NULL || !g_utf8_validate (symbol, -1, NULL))
success = FALSE;
abbreviation = (gchar *) args[4].value.pdb_pointer;
if (abbreviation == NULL || !g_utf8_validate (abbreviation, -1, NULL))
success = FALSE;
singular = (gchar *) args[5].value.pdb_pointer;
if (singular == NULL || !g_utf8_validate (singular, -1, NULL))
success = FALSE;
plural = (gchar *) args[6].value.pdb_pointer;
if (plural == NULL || !g_utf8_validate (plural, -1, NULL))
success = FALSE;
identifier = (gchar *) g_value_get_string (&args[0].value);
factor = g_value_get_double (&args[1].value);
digits = g_value_get_int (&args[2].value);
symbol = (gchar *) g_value_get_string (&args[3].value);
abbreviation = (gchar *) g_value_get_string (&args[4].value);
singular = (gchar *) g_value_get_string (&args[5].value);
plural = (gchar *) g_value_get_string (&args[6].value);
if (success)
{
@ -466,7 +450,7 @@ unit_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = unit_id;
g_value_set_int (&return_vals[1].value, unit_id);
return return_vals;
}
@ -498,9 +482,7 @@ unit_get_deletion_flag_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gboolean deletion_flag = FALSE;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
unit_id = g_value_get_int (&args[0].value);
if (success)
{
@ -510,7 +492,7 @@ unit_get_deletion_flag_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = deletion_flag;
g_value_set_boolean (&return_vals[1].value, deletion_flag);
return return_vals;
}
@ -541,11 +523,8 @@ unit_set_deletion_flag_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gboolean deletion_flag;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
deletion_flag = args[1].value.pdb_int ? TRUE : FALSE;
unit_id = g_value_get_int (&args[0].value);
deletion_flag = g_value_get_boolean (&args[1].value);
if (success)
{
@ -582,9 +561,7 @@ unit_get_identifier_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gchar *identifier = NULL;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
unit_id = g_value_get_int (&args[0].value);
if (success)
{
@ -594,7 +571,7 @@ unit_get_identifier_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = identifier;
g_value_take_string (&return_vals[1].value, identifier);
return return_vals;
}
@ -626,9 +603,7 @@ unit_get_factor_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gdouble factor = 0.0;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
unit_id = g_value_get_int (&args[0].value);
if (success)
{
@ -638,7 +613,7 @@ unit_get_factor_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = factor;
g_value_set_double (&return_vals[1].value, factor);
return return_vals;
}
@ -670,9 +645,7 @@ unit_get_digits_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gint32 digits = 0;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
unit_id = g_value_get_int (&args[0].value);
if (success)
{
@ -682,7 +655,7 @@ unit_get_digits_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = digits;
g_value_set_int (&return_vals[1].value, digits);
return return_vals;
}
@ -714,9 +687,7 @@ unit_get_symbol_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gchar *symbol = NULL;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
unit_id = g_value_get_int (&args[0].value);
if (success)
{
@ -726,7 +697,7 @@ unit_get_symbol_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = symbol;
g_value_take_string (&return_vals[1].value, symbol);
return return_vals;
}
@ -758,9 +729,7 @@ unit_get_abbreviation_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gchar *abbreviation = NULL;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
unit_id = g_value_get_int (&args[0].value);
if (success)
{
@ -770,7 +739,7 @@ unit_get_abbreviation_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = abbreviation;
g_value_take_string (&return_vals[1].value, abbreviation);
return return_vals;
}
@ -802,9 +771,7 @@ unit_get_singular_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gchar *singular = NULL;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
unit_id = g_value_get_int (&args[0].value);
if (success)
{
@ -814,7 +781,7 @@ unit_get_singular_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = singular;
g_value_take_string (&return_vals[1].value, singular);
return return_vals;
}
@ -846,9 +813,7 @@ unit_get_plural_invoker (ProcRecord *proc_record,
GimpUnit unit_id;
gchar *plural = NULL;
unit_id = args[0].value.pdb_int;
if (unit_id < GIMP_UNIT_PIXEL || unit_id >= _gimp_unit_get_number_of_units (gimp))
success = FALSE;
unit_id = g_value_get_int (&args[0].value);
if (success)
{
@ -858,7 +823,7 @@ unit_get_plural_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = plural;
g_value_take_string (&return_vals[1].value, plural);
return return_vals;
}

View File

@ -823,13 +823,8 @@ vectors_new_invoker (ProcRecord *proc_record,
gchar *name;
GimpVectors *vectors = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -839,7 +834,7 @@ vectors_new_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = vectors ? gimp_item_get_ID (GIMP_ITEM (vectors)) : -1;
gimp_value_set_item (&return_vals[1].value, GIMP_ITEM (vectors));
return return_vals;
}
@ -871,9 +866,7 @@ vectors_get_image_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
GimpImage *image = NULL;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
if (success)
{
@ -883,7 +876,7 @@ vectors_get_image_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = image ? gimp_image_get_ID (image) : -1;
gimp_value_set_image (&return_vals[1].value, image);
return return_vals;
}
@ -915,9 +908,7 @@ vectors_get_name_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gchar *name = NULL;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
if (success)
{
@ -927,7 +918,7 @@ vectors_get_name_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_pointer = name;
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
@ -958,13 +949,8 @@ vectors_set_name_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gchar *name;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
name = (gchar *) args[1].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
@ -1001,9 +987,7 @@ vectors_get_visible_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gboolean visible = FALSE;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
if (success)
{
@ -1013,7 +997,7 @@ vectors_get_visible_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = visible;
g_value_set_boolean (&return_vals[1].value, visible);
return return_vals;
}
@ -1044,11 +1028,8 @@ vectors_set_visible_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gboolean visible;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
visible = args[1].value.pdb_int ? TRUE : FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
visible = g_value_get_boolean (&args[1].value);
if (success)
{
@ -1085,9 +1066,7 @@ vectors_get_linked_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gboolean linked = FALSE;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
if (success)
{
@ -1097,7 +1076,7 @@ vectors_get_linked_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = linked;
g_value_set_boolean (&return_vals[1].value, linked);
return return_vals;
}
@ -1128,11 +1107,8 @@ vectors_set_linked_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gboolean linked;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
linked = args[1].value.pdb_int ? TRUE : FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
linked = g_value_get_boolean (&args[1].value);
if (success)
{
@ -1169,9 +1145,7 @@ vectors_get_tattoo_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gint32 tattoo = 0;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
if (success)
{
@ -1181,7 +1155,7 @@ vectors_get_tattoo_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = tattoo;
g_value_set_int (&return_vals[1].value, tattoo);
return return_vals;
}
@ -1212,11 +1186,8 @@ vectors_set_tattoo_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gint32 tattoo;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
tattoo = args[1].value.pdb_int;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
tattoo = g_value_get_int (&args[1].value);
if (success)
{
@ -1254,9 +1225,7 @@ vectors_get_strokes_invoker (ProcRecord *proc_record,
gint32 num_strokes = 0;
gint32 *stroke_ids = NULL;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
if (success)
{
@ -1283,8 +1252,8 @@ vectors_get_strokes_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = num_strokes;
return_vals[2].value.pdb_pointer = stroke_ids;
g_value_set_int (&return_vals[1].value, num_strokes);
g_value_set_pointer (&return_vals[2].value, stroke_ids);
}
return return_vals;
@ -1319,13 +1288,9 @@ vectors_stroke_get_length_invoker (ProcRecord *proc_record,
gdouble prescision;
gdouble length = 0.0;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
prescision = args[2].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
prescision = g_value_get_double (&args[2].value);
if (success)
{
@ -1340,7 +1305,7 @@ vectors_stroke_get_length_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_float = length;
g_value_set_double (&return_vals[1].value, length);
return return_vals;
}
@ -1378,15 +1343,10 @@ vectors_stroke_get_point_at_dist_invoker (ProcRecord *proc_record,
gdouble slope = 0.0;
gboolean valid = FALSE;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
dist = args[2].value.pdb_float;
prescision = args[3].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
dist = g_value_get_double (&args[2].value);
prescision = g_value_get_double (&args[3].value);
if (success)
{
@ -1409,10 +1369,10 @@ vectors_stroke_get_point_at_dist_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_float = x_point;
return_vals[2].value.pdb_float = y_point;
return_vals[3].value.pdb_float = slope;
return_vals[4].value.pdb_int = valid;
g_value_set_double (&return_vals[1].value, x_point);
g_value_set_double (&return_vals[2].value, y_point);
g_value_set_double (&return_vals[3].value, slope);
g_value_set_boolean (&return_vals[4].value, valid);
}
return return_vals;
@ -1444,11 +1404,8 @@ vectors_stroke_remove_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gint32 stroke_id;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
if (success)
{
@ -1489,11 +1446,8 @@ vectors_stroke_close_invoker (ProcRecord *proc_record,
GimpVectors *vectors;
gint32 stroke_id;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
if (success)
{
@ -1536,15 +1490,10 @@ vectors_stroke_translate_invoker (ProcRecord *proc_record,
gint32 off_x;
gint32 off_y;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
off_x = args[2].value.pdb_int;
off_y = args[3].value.pdb_int;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
off_x = g_value_get_int (&args[2].value);
off_y = g_value_get_int (&args[3].value);
if (success)
{
@ -1587,15 +1536,10 @@ vectors_stroke_scale_invoker (ProcRecord *proc_record,
gdouble scale_x;
gdouble scale_y;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
scale_x = args[2].value.pdb_float;
scale_y = args[3].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
scale_x = g_value_get_double (&args[2].value);
scale_y = g_value_get_double (&args[3].value);
if (success)
{
@ -1641,13 +1585,9 @@ vectors_stroke_interpolate_invoker (ProcRecord *proc_record,
gint32 num_coords = 0;
gdouble *coords = NULL;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
prescision = args[2].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
prescision = g_value_get_double (&args[2].value);
if (success)
{
@ -1684,9 +1624,9 @@ vectors_stroke_interpolate_invoker (ProcRecord *proc_record,
if (success)
{
return_vals[1].value.pdb_int = closed;
return_vals[2].value.pdb_int = num_coords;
return_vals[3].value.pdb_pointer = coords;
g_value_set_boolean (&return_vals[1].value, closed);
g_value_set_int (&return_vals[2].value, num_coords);
g_value_set_pointer (&return_vals[3].value, coords);
}
return return_vals;
@ -1721,13 +1661,9 @@ vectors_bezier_stroke_new_moveto_invoker (ProcRecord *proc_record,
gdouble y0;
gint32 stroke_id = 0;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
x0 = args[1].value.pdb_float;
y0 = args[2].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
x0 = g_value_get_double (&args[1].value);
y0 = g_value_get_double (&args[2].value);
if (success)
{
@ -1745,7 +1681,7 @@ vectors_bezier_stroke_new_moveto_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = stroke_id;
g_value_set_int (&return_vals[1].value, stroke_id);
return return_vals;
}
@ -1778,15 +1714,10 @@ vectors_bezier_stroke_lineto_invoker (ProcRecord *proc_record,
gdouble x0;
gdouble y0;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
x0 = args[2].value.pdb_float;
y0 = args[3].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
x0 = g_value_get_double (&args[2].value);
y0 = g_value_get_double (&args[3].value);
if (success)
{
@ -1838,19 +1769,12 @@ vectors_bezier_stroke_conicto_invoker (ProcRecord *proc_record,
gdouble x1;
gdouble y1;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
x0 = args[2].value.pdb_float;
y0 = args[3].value.pdb_float;
x1 = args[4].value.pdb_float;
y1 = args[5].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
x0 = g_value_get_double (&args[2].value);
y0 = g_value_get_double (&args[3].value);
x1 = g_value_get_double (&args[4].value);
y1 = g_value_get_double (&args[5].value);
if (success)
{
@ -1908,23 +1832,14 @@ vectors_bezier_stroke_cubicto_invoker (ProcRecord *proc_record,
gdouble x2;
gdouble y2;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
stroke_id = args[1].value.pdb_int;
x0 = args[2].value.pdb_float;
y0 = args[3].value.pdb_float;
x1 = args[4].value.pdb_float;
y1 = args[5].value.pdb_float;
x2 = args[6].value.pdb_float;
y2 = args[7].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
stroke_id = g_value_get_int (&args[1].value);
x0 = g_value_get_double (&args[2].value);
y0 = g_value_get_double (&args[3].value);
x1 = g_value_get_double (&args[4].value);
y1 = g_value_get_double (&args[5].value);
x2 = g_value_get_double (&args[6].value);
y2 = g_value_get_double (&args[7].value);
if (success)
{
@ -1986,19 +1901,12 @@ vectors_bezier_stroke_new_ellipse_invoker (ProcRecord *proc_record,
gdouble angle;
gint32 stroke_id = 0;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
success = FALSE;
x0 = args[1].value.pdb_float;
y0 = args[2].value.pdb_float;
radius_x = args[3].value.pdb_float;
radius_y = args[4].value.pdb_float;
angle = args[5].value.pdb_float;
vectors = (GimpVectors *) gimp_value_get_item (&args[0].value, gimp, GIMP_TYPE_VECTORS);
x0 = g_value_get_double (&args[1].value);
y0 = g_value_get_double (&args[2].value);
radius_x = g_value_get_double (&args[3].value);
radius_y = g_value_get_double (&args[4].value);
angle = g_value_get_double (&args[5].value);
if (success)
{
@ -2016,7 +1924,7 @@ vectors_bezier_stroke_new_ellipse_invoker (ProcRecord *proc_record,
return_vals = procedural_db_return_values (proc_record, success);
if (success)
return_vals[1].value.pdb_int = stroke_id;
g_value_set_int (&return_vals[1].value, stroke_id);
return return_vals;
}

View File

@ -348,10 +348,12 @@ plug_in_handle_proc_run (PlugIn *plug_in,
{
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_in,
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_in,
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_in,
* 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_in,
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 *plug_in,
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;

View File

@ -307,11 +307,10 @@ plug_in_progress_cancel_callback (GimpProgress *progress,
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 (GimpProgress *progress,
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);
}
}

View File

@ -57,7 +57,8 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
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 *plug_in,
/* 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

View File

@ -29,7 +29,7 @@ Argument * plug_in_run (Gimp *gimp,
GimpProgress *progress,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gint n_args,
gboolean synchronous,
gboolean destroy_return_vals,
gint display_ID);

View File

@ -57,7 +57,8 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
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 *plug_in,
/* 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

View File

@ -29,7 +29,7 @@ Argument * plug_in_run (Gimp *gimp,
GimpProgress *progress,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gint n_args,
gboolean synchronous,
gboolean destroy_return_vals,
gint display_ID);

View File

@ -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);
}
}
}

View File

@ -348,10 +348,12 @@ plug_in_handle_proc_run (PlugIn *plug_in,
{
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_in,
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_in,
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_in,
* 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_in,
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 *plug_in,
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;

View File

@ -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;
if (! (params && nparams))
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)
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;
for (j = 0; j < args[i-1].value.pdb_int; j++)
stringarray[j] = g_strdup (params[i].data.d_stringarray[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 < 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, &params[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, &params[i].data.d_parasite);
else
args[i].value.pdb_pointer = (gpointer) &(params[i].data.d_parasite);
g_value_set_static_boxed (value, &params[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;
if (! (args && nargs))
g_return_val_if_fail ((args != NULL && n_args > 0) ||
(args == NULL && n_args == 0), NULL);
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;
for (j = 0; j < params[i-1].data.d_int32; j++)
params[i].data.d_stringarray[j] = g_strdup (stringarray[j]);
count = g_value_get_int (&args[i - 1].value);
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, &params[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;
break;
case GIMP_PDB_IMAGE:
params[i].data.d_image = args[i].value.pdb_int;
break;
case GIMP_PDB_LAYER:
params[i].data.d_layer = args[i].value.pdb_int;
break;
case GIMP_PDB_CHANNEL:
params[i].data.d_channel = args[i].value.pdb_int;
break;
case GIMP_PDB_DRAWABLE:
params[i].data.d_drawable = args[i].value.pdb_int;
break;
case GIMP_PDB_SELECTION:
params[i].data.d_selection = args[i].value.pdb_int;
break;
case GIMP_PDB_BOUNDARY:
params[i].data.d_boundary = args[i].value.pdb_int;
break;
case GIMP_PDB_VECTORS:
params[i].data.d_vectors = args[i].value.pdb_int;
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 (&params[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 (&params[i].data.d_parasite,
(GimpParasite *) (args[i].value.pdb_pointer),
sizeof (GimpParasite));
}
case GIMP_PDB_DISPLAY:
params[i].data.d_display = g_value_get_int (value);
break;
case GIMP_PDB_IMAGE:
params[i].data.d_image = g_value_get_int (value);
break;
case GIMP_PDB_LAYER:
params[i].data.d_layer = g_value_get_int (value);
break;
case GIMP_PDB_CHANNEL:
params[i].data.d_channel = g_value_get_int (value);
break;
case GIMP_PDB_DRAWABLE:
params[i].data.d_drawable = g_value_get_int (value);
break;
case GIMP_PDB_SELECTION:
params[i].data.d_selection = g_value_get_int (value);
break;
case GIMP_PDB_BOUNDARY:
g_message ("the \"boundary\" arg type is not currently supported");
break;
case GIMP_PDB_VECTORS:
params[i].data.d_vectors = g_value_get_int (value);
break;
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,

View File

@ -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,
@ -30,9 +32,6 @@ GPParam * plug_in_args_to_params (Argument *args,
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,
const gchar *plug_in_prog,

View File

@ -307,11 +307,10 @@ plug_in_progress_cancel_callback (GimpProgress *progress,
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 (GimpProgress *progress,
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);
}
}

View File

@ -57,7 +57,8 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
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 *plug_in,
/* 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

View File

@ -29,7 +29,7 @@ Argument * plug_in_run (Gimp *gimp,
GimpProgress *progress,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gint n_args,
gboolean synchronous,
gboolean destroy_return_vals,
gint display_ID);

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -315,7 +315,7 @@ gimp_pdb_dialog_run_callback (GimpPdbDialog *dialog,
&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 (GimpPdbDialog *dialog,
}
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;

View File

@ -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 *procedure,
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 *procedure,
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 *procedure,
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");

View File

@ -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 .= <<CODE;
switch ($var)
{
$okvals
break;
$failvals
break;
}
CODE
}
}
elsif (defined $typeinfo[0] || defined $typeinfo[2]) {
my $code = ""; my $tests = 0; my $extra = "";
if ($pdbtype eq 'enum') {
my $symbols = $enums{shift @typeinfo}->{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 = <<CODE;
my ($foo, $bar, @remove) = &arg_parse($arg->{type});
foreach (@remove) {
$postproc .= 'gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM ($pspec),';
$postproc .= "\n $_);\n";
}
if ($postproc eq '') {
$pspec = <<CODE;
g_param_spec_enum ("$name",
"$nick",
"$blurb",
@ -574,6 +403,17 @@ g_param_spec_enum ("$name",
$default,
$flags)
CODE
}
else {
$pspec = <<CODE;
gimp_param_spec_enum ("$name",
"$nick",
"$blurb",
$enum_type,
$default,
$flags)
CODE
}
}
elsif ($pdbtype eq 'unit') {
$typeinfo[0] = 'GIMP_UNIT_PIXEL' unless defined $typeinfo[0];
@ -628,13 +468,14 @@ CODE
$pspec = "GIMP_PDB_$arg_types{$pdbtype}->{name},\n" . $pspec;
$pspec =~ s/\s$//;
$pspec;
return ($pspec, $postproc);
}
sub generate {
my @procs = @{(shift)};
my %out;
my $total = 0.0;
my $argc;
foreach $name (@procs) {
my $proc = $main::pdb{$name};
@ -656,8 +497,10 @@ sub generate {
procedure = procedural_db_init_proc (\&${name}_proc, @{[scalar @inargs]}, @{[scalar @outargs]});
CODE
foreach $arg (@inargs) {
my $pspec = &generate_pspec($arg);
$argc = 0;
foreach $arg (@inargs) {
my ($pspec, $postproc) = &generate_pspec($arg);
$pspec =~ s/^/' ' x length(" procedural_db_add_argument (")/meg;
@ -665,10 +508,21 @@ CODE
procedural_db_add_argument (procedure,
${pspec});
CODE
if (! ($postproc eq '')) {
$pspec = "procedure->args[$argc].pspec";
$postproc =~ s/^/' '/meg;
$out->{register} .= eval qq/"$postproc"/;
}
$argc++;
}
$argc = 0;
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 +530,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} .= <<CODE;

View File

@ -59,7 +59,7 @@ sub generate {
my ($type, $name) = &arg_parse($arg->{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 = "";

View File

@ -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' },
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' },
string => { name => 'STRING', type => 'gchar *', init_value => 'NULL' },
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' },
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' },
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 ',
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") ] },
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
);
@ -156,24 +223,4 @@ sub arg_parse {
}
}
# 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;

View File

@ -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_transform (&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_transform (&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;
}