mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
pdb: add gimp_procedural_db_proc_argument() and _return_value()
Which return proper GParamSpecs. Incuding some useless testing code in gimp_procedural_db_proc_info(), to make sure things work, will go away again soon.
This commit is contained in:
parent
aa505b43dc
commit
c8f38810d1
9 changed files with 475 additions and 40 deletions
|
@ -28,7 +28,7 @@
|
||||||
#include "internal-procs.h"
|
#include "internal-procs.h"
|
||||||
|
|
||||||
|
|
||||||
/* 743 procedures registered total */
|
/* 745 procedures registered total */
|
||||||
|
|
||||||
void
|
void
|
||||||
internal_procs_init (GimpPDB *pdb)
|
internal_procs_init (GimpPDB *pdb)
|
||||||
|
|
|
@ -370,6 +370,116 @@ procedural_db_proc_val_invoker (GimpProcedure *procedure,
|
||||||
return return_vals;
|
return return_vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GimpValueArray *
|
||||||
|
procedural_db_proc_argument_invoker (GimpProcedure *procedure,
|
||||||
|
Gimp *gimp,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpProgress *progress,
|
||||||
|
const GimpValueArray *args,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean success = TRUE;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
const gchar *procedure_name;
|
||||||
|
gint32 arg_num;
|
||||||
|
GParamSpec *param_spec = NULL;
|
||||||
|
|
||||||
|
procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
|
||||||
|
arg_num = g_value_get_int (gimp_value_array_index (args, 1));
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
GimpProcedure *proc;
|
||||||
|
gchar *canonical;
|
||||||
|
|
||||||
|
canonical = gimp_canonicalize_identifier (procedure_name);
|
||||||
|
|
||||||
|
proc = gimp_pdb_lookup_procedure (gimp->pdb, canonical);
|
||||||
|
|
||||||
|
if (! proc)
|
||||||
|
{
|
||||||
|
const gchar *compat_name;
|
||||||
|
|
||||||
|
compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb, canonical);
|
||||||
|
|
||||||
|
if (compat_name)
|
||||||
|
proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (canonical);
|
||||||
|
|
||||||
|
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
|
||||||
|
{
|
||||||
|
param_spec = g_param_spec_ref (proc->args[arg_num]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
success = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||||
|
error ? *error : NULL);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
g_value_take_param (gimp_value_array_index (return_vals, 1), param_spec);
|
||||||
|
|
||||||
|
return return_vals;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GimpValueArray *
|
||||||
|
procedural_db_proc_return_value_invoker (GimpProcedure *procedure,
|
||||||
|
Gimp *gimp,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpProgress *progress,
|
||||||
|
const GimpValueArray *args,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean success = TRUE;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
const gchar *procedure_name;
|
||||||
|
gint32 val_num;
|
||||||
|
GParamSpec *param_spec = NULL;
|
||||||
|
|
||||||
|
procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
|
||||||
|
val_num = g_value_get_int (gimp_value_array_index (args, 1));
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
GimpProcedure *proc;
|
||||||
|
gchar *canonical;
|
||||||
|
|
||||||
|
canonical = gimp_canonicalize_identifier (procedure_name);
|
||||||
|
|
||||||
|
proc = gimp_pdb_lookup_procedure (gimp->pdb, canonical);
|
||||||
|
|
||||||
|
if (! proc)
|
||||||
|
{
|
||||||
|
const gchar *compat_name;
|
||||||
|
|
||||||
|
compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb, canonical);
|
||||||
|
|
||||||
|
if (compat_name)
|
||||||
|
proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (canonical);
|
||||||
|
|
||||||
|
if (proc && (val_num >= 0 && val_num < proc->num_values))
|
||||||
|
{
|
||||||
|
param_spec = g_param_spec_ref (proc->values[val_num]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
success = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||||
|
error ? *error : NULL);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
g_value_take_param (gimp_value_array_index (return_vals, 1), param_spec);
|
||||||
|
|
||||||
|
return return_vals;
|
||||||
|
}
|
||||||
|
|
||||||
static GimpValueArray *
|
static GimpValueArray *
|
||||||
procedural_db_get_data_invoker (GimpProcedure *procedure,
|
procedural_db_get_data_invoker (GimpProcedure *procedure,
|
||||||
Gimp *gimp,
|
Gimp *gimp,
|
||||||
|
@ -824,6 +934,78 @@ register_procedural_db_procs (GimpPDB *pdb)
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
g_object_unref (procedure);
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gimp-procedural-db-proc-argument
|
||||||
|
*/
|
||||||
|
procedure = gimp_procedure_new (procedural_db_proc_argument_invoker);
|
||||||
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||||
|
"gimp-procedural-db-proc-argument");
|
||||||
|
gimp_procedure_set_static_strings (procedure,
|
||||||
|
"gimp-procedural-db-proc-argument",
|
||||||
|
"Queries the procedural database for information on the specified procedure's argument.",
|
||||||
|
"This procedure returns the #GParamSpec of procedure_name's argument.",
|
||||||
|
"Michael Natterer <mitch@gimp.org>",
|
||||||
|
"Michael Natterer",
|
||||||
|
"2019",
|
||||||
|
NULL);
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_string ("procedure-name",
|
||||||
|
"procedure name",
|
||||||
|
"The procedure name",
|
||||||
|
FALSE, FALSE, TRUE,
|
||||||
|
NULL,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_int32 ("arg-num",
|
||||||
|
"arg num",
|
||||||
|
"The argument number",
|
||||||
|
G_MININT32, G_MAXINT32, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_return_value (procedure,
|
||||||
|
g_param_spec_param ("param-spec",
|
||||||
|
"param spec",
|
||||||
|
"The GParamSpec of the argument",
|
||||||
|
G_TYPE_PARAM,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gimp-procedural-db-proc-return-value
|
||||||
|
*/
|
||||||
|
procedure = gimp_procedure_new (procedural_db_proc_return_value_invoker);
|
||||||
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||||
|
"gimp-procedural-db-proc-return-value");
|
||||||
|
gimp_procedure_set_static_strings (procedure,
|
||||||
|
"gimp-procedural-db-proc-return-value",
|
||||||
|
"Queries the procedural database for information on the specified procedure's return value.",
|
||||||
|
"This procedure returns the #GParamSpec of procedure_name's return value.",
|
||||||
|
"Michael Natterer <mitch@gimp.org>",
|
||||||
|
"Michael Natterer",
|
||||||
|
"2019",
|
||||||
|
NULL);
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_string ("procedure-name",
|
||||||
|
"procedure name",
|
||||||
|
"The procedure name",
|
||||||
|
FALSE, FALSE, TRUE,
|
||||||
|
NULL,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_int32 ("val-num",
|
||||||
|
"val num",
|
||||||
|
"The return value number",
|
||||||
|
G_MININT32, G_MAXINT32, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_return_value (procedure,
|
||||||
|
g_param_spec_param ("param-spec",
|
||||||
|
"param spec",
|
||||||
|
"The GParamSpec of the return value",
|
||||||
|
G_TYPE_PARAM,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
|
g_object_unref (procedure);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gimp-procedural-db-get-data
|
* gimp-procedural-db-get-data
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -82,6 +82,8 @@ gimp_procedural_db_proc_info (const gchar *procedure,
|
||||||
|
|
||||||
for (i = 0; i < *num_args; i++)
|
for (i = 0; i < *num_args; i++)
|
||||||
{
|
{
|
||||||
|
GParamSpec *pspec;
|
||||||
|
|
||||||
if (! gimp_procedural_db_proc_arg (procedure,
|
if (! gimp_procedural_db_proc_arg (procedure,
|
||||||
i,
|
i,
|
||||||
&(*args)[i].type,
|
&(*args)[i].type,
|
||||||
|
@ -93,10 +95,21 @@ gimp_procedural_db_proc_info (const gchar *procedure,
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pspec = gimp_procedural_db_proc_argument (procedure, i);
|
||||||
|
|
||||||
|
if (pspec)
|
||||||
|
{
|
||||||
|
g_printerr ("Arg %i of %s: %s\n", i, procedure,
|
||||||
|
G_PARAM_SPEC_TYPE_NAME (pspec));
|
||||||
|
g_param_spec_unref (pspec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < *num_values; i++)
|
for (i = 0; i < *num_values; i++)
|
||||||
{
|
{
|
||||||
|
GParamSpec *pspec;
|
||||||
|
|
||||||
if (! gimp_procedural_db_proc_val (procedure,
|
if (! gimp_procedural_db_proc_val (procedure,
|
||||||
i,
|
i,
|
||||||
&(*return_vals)[i].type,
|
&(*return_vals)[i].type,
|
||||||
|
@ -108,6 +121,15 @@ gimp_procedural_db_proc_info (const gchar *procedure,
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pspec = gimp_procedural_db_proc_return_value (procedure, i);
|
||||||
|
|
||||||
|
if (pspec)
|
||||||
|
{
|
||||||
|
g_printerr ("Value %i of %s: %s\n", i, procedure,
|
||||||
|
G_PARAM_SPEC_TYPE_NAME (pspec));
|
||||||
|
g_param_spec_unref (pspec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -404,6 +404,89 @@ gimp_procedural_db_proc_val (const gchar *procedure_name,
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_procedural_db_proc_argument:
|
||||||
|
* @procedure_name: The procedure name.
|
||||||
|
* @arg_num: The argument number.
|
||||||
|
*
|
||||||
|
* Queries the procedural database for information on the specified
|
||||||
|
* procedure's argument.
|
||||||
|
*
|
||||||
|
* This procedure returns the #GParamSpec of procedure_name's argument.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): The GParamSpec of the argument.
|
||||||
|
* The returned value must be freed with g_param_spec_unref().
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
**/
|
||||||
|
GParamSpec *
|
||||||
|
gimp_procedural_db_proc_argument (const gchar *procedure_name,
|
||||||
|
gint arg_num)
|
||||||
|
{
|
||||||
|
GimpValueArray *args;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
GParamSpec *param_spec = NULL;
|
||||||
|
|
||||||
|
args = gimp_value_array_new_from_types (G_TYPE_STRING,
|
||||||
|
GIMP_TYPE_INT32,
|
||||||
|
G_TYPE_NONE);
|
||||||
|
g_value_set_string (gimp_value_array_index (args, 0), procedure_name);
|
||||||
|
g_value_set_int (gimp_value_array_index (args, 1), arg_num);
|
||||||
|
|
||||||
|
return_vals = gimp_run_procedure_with_array ("gimp-procedural-db-proc-argument",
|
||||||
|
args);
|
||||||
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
|
||||||
|
param_spec = g_value_dup_param (gimp_value_array_index (return_vals, 1));
|
||||||
|
|
||||||
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
|
return param_spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_procedural_db_proc_return_value:
|
||||||
|
* @procedure_name: The procedure name.
|
||||||
|
* @val_num: The return value number.
|
||||||
|
*
|
||||||
|
* Queries the procedural database for information on the specified
|
||||||
|
* procedure's return value.
|
||||||
|
*
|
||||||
|
* This procedure returns the #GParamSpec of procedure_name's return
|
||||||
|
* value.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): The GParamSpec of the return value.
|
||||||
|
* The returned value must be freed with g_param_spec_unref().
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
**/
|
||||||
|
GParamSpec *
|
||||||
|
gimp_procedural_db_proc_return_value (const gchar *procedure_name,
|
||||||
|
gint val_num)
|
||||||
|
{
|
||||||
|
GimpValueArray *args;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
GParamSpec *param_spec = NULL;
|
||||||
|
|
||||||
|
args = gimp_value_array_new_from_types (G_TYPE_STRING,
|
||||||
|
GIMP_TYPE_INT32,
|
||||||
|
G_TYPE_NONE);
|
||||||
|
g_value_set_string (gimp_value_array_index (args, 0), procedure_name);
|
||||||
|
g_value_set_int (gimp_value_array_index (args, 1), val_num);
|
||||||
|
|
||||||
|
return_vals = gimp_run_procedure_with_array ("gimp-procedural-db-proc-return-value",
|
||||||
|
args);
|
||||||
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
|
||||||
|
param_spec = g_value_dup_param (gimp_value_array_index (return_vals, 1));
|
||||||
|
|
||||||
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
|
return param_spec;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _gimp_procedural_db_get_data:
|
* _gimp_procedural_db_get_data:
|
||||||
* @identifier: The identifier associated with data.
|
* @identifier: The identifier associated with data.
|
||||||
|
|
|
@ -32,44 +32,48 @@ G_BEGIN_DECLS
|
||||||
/* For information look into the C source or the html documentation */
|
/* For information look into the C source or the html documentation */
|
||||||
|
|
||||||
|
|
||||||
gchar* gimp_procedural_db_temp_name (void);
|
gchar* gimp_procedural_db_temp_name (void);
|
||||||
gboolean gimp_procedural_db_dump (const gchar *filename);
|
gboolean gimp_procedural_db_dump (const gchar *filename);
|
||||||
gboolean gimp_procedural_db_query (const gchar *name,
|
gboolean gimp_procedural_db_query (const gchar *name,
|
||||||
const gchar *blurb,
|
const gchar *blurb,
|
||||||
const gchar *help,
|
const gchar *help,
|
||||||
const gchar *author,
|
const gchar *author,
|
||||||
const gchar *copyright,
|
const gchar *copyright,
|
||||||
const gchar *date,
|
const gchar *date,
|
||||||
const gchar *proc_type,
|
const gchar *proc_type,
|
||||||
gint *num_matches,
|
gint *num_matches,
|
||||||
gchar ***procedure_names);
|
gchar ***procedure_names);
|
||||||
gboolean gimp_procedural_db_proc_exists (const gchar *procedure_name);
|
gboolean gimp_procedural_db_proc_exists (const gchar *procedure_name);
|
||||||
G_GNUC_INTERNAL gboolean _gimp_procedural_db_proc_info (const gchar *procedure_name,
|
G_GNUC_INTERNAL gboolean _gimp_procedural_db_proc_info (const gchar *procedure_name,
|
||||||
gchar **blurb,
|
gchar **blurb,
|
||||||
gchar **help,
|
gchar **help,
|
||||||
gchar **author,
|
gchar **author,
|
||||||
gchar **copyright,
|
gchar **copyright,
|
||||||
gchar **date,
|
gchar **date,
|
||||||
GimpPDBProcType *proc_type,
|
GimpPDBProcType *proc_type,
|
||||||
gint *num_args,
|
gint *num_args,
|
||||||
gint *num_values);
|
gint *num_values);
|
||||||
gboolean gimp_procedural_db_proc_arg (const gchar *procedure_name,
|
gboolean gimp_procedural_db_proc_arg (const gchar *procedure_name,
|
||||||
gint arg_num,
|
gint arg_num,
|
||||||
GimpPDBArgType *arg_type,
|
GimpPDBArgType *arg_type,
|
||||||
gchar **arg_name,
|
gchar **arg_name,
|
||||||
gchar **arg_desc);
|
gchar **arg_desc);
|
||||||
gboolean gimp_procedural_db_proc_val (const gchar *procedure_name,
|
gboolean gimp_procedural_db_proc_val (const gchar *procedure_name,
|
||||||
gint val_num,
|
gint val_num,
|
||||||
GimpPDBArgType *val_type,
|
GimpPDBArgType *val_type,
|
||||||
gchar **val_name,
|
gchar **val_name,
|
||||||
gchar **val_desc);
|
gchar **val_desc);
|
||||||
G_GNUC_INTERNAL gboolean _gimp_procedural_db_get_data (const gchar *identifier,
|
GParamSpec* gimp_procedural_db_proc_argument (const gchar *procedure_name,
|
||||||
gint *bytes,
|
gint arg_num);
|
||||||
guint8 **data);
|
GParamSpec* gimp_procedural_db_proc_return_value (const gchar *procedure_name,
|
||||||
gint gimp_procedural_db_get_data_size (const gchar *identifier);
|
gint val_num);
|
||||||
G_GNUC_INTERNAL gboolean _gimp_procedural_db_set_data (const gchar *identifier,
|
G_GNUC_INTERNAL gboolean _gimp_procedural_db_get_data (const gchar *identifier,
|
||||||
gint bytes,
|
gint *bytes,
|
||||||
const guint8 *data);
|
guint8 **data);
|
||||||
|
gint gimp_procedural_db_get_data_size (const gchar *identifier);
|
||||||
|
G_GNUC_INTERNAL gboolean _gimp_procedural_db_set_data (const gchar *identifier,
|
||||||
|
gint bytes,
|
||||||
|
const guint8 *data);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -508,6 +508,15 @@ gimp_param_spec_parasite ("$name",
|
||||||
"$nick",
|
"$nick",
|
||||||
"$blurb",
|
"$blurb",
|
||||||
$flags)
|
$flags)
|
||||||
|
CODE
|
||||||
|
}
|
||||||
|
elsif ($pdbtype eq 'param') {
|
||||||
|
$pspec = <<CODE;
|
||||||
|
g_param_spec_param ("$name",
|
||||||
|
"$nick",
|
||||||
|
"$blurb",
|
||||||
|
G_TYPE_PARAM,
|
||||||
|
$flags)
|
||||||
CODE
|
CODE
|
||||||
}
|
}
|
||||||
elsif ($pdbtype eq 'int32array') {
|
elsif ($pdbtype eq 'int32array') {
|
||||||
|
|
|
@ -244,6 +244,124 @@ CODE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub procedural_db_proc_argument {
|
||||||
|
$blurb = <<BLURB;
|
||||||
|
Queries the procedural database for information on the specified procedure's
|
||||||
|
argument.
|
||||||
|
BLURB
|
||||||
|
|
||||||
|
$help = <<HELP;
|
||||||
|
This procedure returns the #GParamSpec of procedure_name's argument.
|
||||||
|
HELP
|
||||||
|
|
||||||
|
&mitch_pdb_misc;
|
||||||
|
$date = '2019';
|
||||||
|
$since = '3.0';
|
||||||
|
|
||||||
|
@inargs = (
|
||||||
|
{ name => 'procedure_name', type => 'string', non_empty => 1,
|
||||||
|
desc => 'The procedure name' },
|
||||||
|
{ name => 'arg_num', type => 'int32',
|
||||||
|
desc => 'The argument number' }
|
||||||
|
);
|
||||||
|
|
||||||
|
@outargs = (
|
||||||
|
{ name => 'param_spec', type => 'param',
|
||||||
|
desc => "The GParamSpec of the argument" }
|
||||||
|
);
|
||||||
|
|
||||||
|
%invoke = (
|
||||||
|
code => <<CODE
|
||||||
|
{
|
||||||
|
GimpProcedure *proc;
|
||||||
|
gchar *canonical;
|
||||||
|
|
||||||
|
canonical = gimp_canonicalize_identifier (procedure_name);
|
||||||
|
|
||||||
|
proc = gimp_pdb_lookup_procedure (gimp->pdb, canonical);
|
||||||
|
|
||||||
|
if (! proc)
|
||||||
|
{
|
||||||
|
const gchar *compat_name;
|
||||||
|
|
||||||
|
compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb, canonical);
|
||||||
|
|
||||||
|
if (compat_name)
|
||||||
|
proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (canonical);
|
||||||
|
|
||||||
|
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
|
||||||
|
{
|
||||||
|
param_spec = g_param_spec_ref (proc->args[arg_num]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
success = FALSE;
|
||||||
|
}
|
||||||
|
CODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub procedural_db_proc_return_value {
|
||||||
|
$blurb = <<BLURB;
|
||||||
|
Queries the procedural database for information on the specified procedure's
|
||||||
|
return value.
|
||||||
|
BLURB
|
||||||
|
|
||||||
|
$help = <<HELP;
|
||||||
|
This procedure returns the #GParamSpec of procedure_name's return value.
|
||||||
|
HELP
|
||||||
|
|
||||||
|
&mitch_pdb_misc;
|
||||||
|
$date = '2019';
|
||||||
|
$since = '3.0';
|
||||||
|
|
||||||
|
@inargs = (
|
||||||
|
{ name => 'procedure_name', type => 'string', non_empty => 1,
|
||||||
|
desc => 'The procedure name' },
|
||||||
|
{ name => 'val_num', type => 'int32',
|
||||||
|
desc => 'The return value number' }
|
||||||
|
);
|
||||||
|
|
||||||
|
@outargs = (
|
||||||
|
{ name => 'param_spec', type => 'param',
|
||||||
|
desc => "The GParamSpec of the return value" }
|
||||||
|
);
|
||||||
|
|
||||||
|
%invoke = (
|
||||||
|
code => <<CODE
|
||||||
|
{
|
||||||
|
GimpProcedure *proc;
|
||||||
|
gchar *canonical;
|
||||||
|
|
||||||
|
canonical = gimp_canonicalize_identifier (procedure_name);
|
||||||
|
|
||||||
|
proc = gimp_pdb_lookup_procedure (gimp->pdb, canonical);
|
||||||
|
|
||||||
|
if (! proc)
|
||||||
|
{
|
||||||
|
const gchar *compat_name;
|
||||||
|
|
||||||
|
compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb, canonical);
|
||||||
|
|
||||||
|
if (compat_name)
|
||||||
|
proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (canonical);
|
||||||
|
|
||||||
|
if (proc && (val_num >= 0 && val_num < proc->num_values))
|
||||||
|
{
|
||||||
|
param_spec = g_param_spec_ref (proc->values[val_num]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
success = FALSE;
|
||||||
|
}
|
||||||
|
CODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
sub procedural_db_proc_arg {
|
sub procedural_db_proc_arg {
|
||||||
$blurb = <<BLURB;
|
$blurb = <<BLURB;
|
||||||
Queries the procedural database for information on the specified procedure's
|
Queries the procedural database for information on the specified procedure's
|
||||||
|
@ -507,7 +625,10 @@ CODE
|
||||||
procedural_db_query
|
procedural_db_query
|
||||||
procedural_db_proc_exists
|
procedural_db_proc_exists
|
||||||
procedural_db_proc_info
|
procedural_db_proc_info
|
||||||
procedural_db_proc_arg procedural_db_proc_val
|
procedural_db_proc_arg
|
||||||
|
procedural_db_proc_val
|
||||||
|
procedural_db_proc_argument
|
||||||
|
procedural_db_proc_return_value
|
||||||
procedural_db_get_data procedural_db_get_data_size
|
procedural_db_get_data procedural_db_get_data_size
|
||||||
procedural_db_set_data);
|
procedural_db_set_data);
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,9 @@ sub generate {
|
||||||
elsif ($retarg->{type} eq 'stringarray') {
|
elsif ($retarg->{type} eq 'stringarray') {
|
||||||
$retdesc .= "\n * The returned value must be freed with g_strfreev().";
|
$retdesc .= "\n * The returned value must be freed with g_strfreev().";
|
||||||
}
|
}
|
||||||
|
elsif ($retarg->{type} eq 'param') {
|
||||||
|
$retdesc .= "\n * The returned value must be freed with g_param_spec_unref().";
|
||||||
|
}
|
||||||
elsif (exists $argtype->{array}) {
|
elsif (exists $argtype->{array}) {
|
||||||
$retdesc .= "\n * The returned value must be freed with g_free().";
|
$retdesc .= "\n * The returned value must be freed with g_free().";
|
||||||
}
|
}
|
||||||
|
|
11
pdb/pdb.pl
11
pdb/pdb.pl
|
@ -277,6 +277,17 @@ package Gimp::CodeGen::pdb;
|
||||||
take_value_func => 'g_value_take_boxed ($value, $var)',
|
take_value_func => 'g_value_take_boxed ($value, $var)',
|
||||||
headers => [ qw("libgimpbase/gimpbase.h") ] },
|
headers => [ qw("libgimpbase/gimpbase.h") ] },
|
||||||
|
|
||||||
|
param => { name => 'PARAM',
|
||||||
|
gtype => 'G_TYPE_PARAM_SPEC',
|
||||||
|
type => 'GParamSpec *',
|
||||||
|
const_type => 'GParamSpec *',
|
||||||
|
init_value => 'NULL',
|
||||||
|
out_annotate => '(transfer full)',
|
||||||
|
get_value_func => '$var = g_value_get_param ($value)',
|
||||||
|
dup_value_func => '$var = g_value_dup_param ($value)',
|
||||||
|
set_value_func => 'g_value_set_param ($value, $var)',
|
||||||
|
take_value_func => 'g_value_take_param ($value, $var)' },
|
||||||
|
|
||||||
# Special cases
|
# Special cases
|
||||||
enum => { name => 'INT32',
|
enum => { name => 'INT32',
|
||||||
gtype => 'G_TYPE_ENUM',
|
gtype => 'G_TYPE_ENUM',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue