app, libgimp, pdb: remove the internal PDB function _gimp_pdb_get_data_size().
We exchange GBytes structs which know their own data size already and is much safer.
This commit is contained in:
parent
7a03b3ea09
commit
2dcc8eea93
5 changed files with 1 additions and 154 deletions
|
|
@ -30,7 +30,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 780 procedures registered total */
|
||||
/* 779 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
|||
|
|
@ -1163,47 +1163,6 @@ pdb_get_data_invoker (GimpProcedure *procedure,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
pdb_get_data_size_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *identifier;
|
||||
gint bytes = 0;
|
||||
|
||||
identifier = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (gimp_is_canonical_identifier (identifier))
|
||||
{
|
||||
if (! gimp_plug_in_manager_get_data (gimp->plug_in_manager,
|
||||
identifier, &bytes))
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
||||
_("Data label '%s' is not a canonical identifier"),
|
||||
identifier);
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), bytes);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
pdb_set_data_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
|
@ -2226,36 +2185,6 @@ register_pdb_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-pdb-get-data-size
|
||||
*/
|
||||
procedure = gimp_procedure_new (pdb_get_data_size_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-pdb-get-data-size");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns size of data associated with the specified identifier.",
|
||||
"This procedure returns the size of any data which may have been associated with the specified identifier. If no data has been associated with the identifier, an error is returned.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Nick Lamb",
|
||||
"Nick Lamb",
|
||||
"1998");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("identifier",
|
||||
"identifier",
|
||||
"The identifier associated with data",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("bytes",
|
||||
"bytes",
|
||||
"The number of bytes in the data",
|
||||
1, G_MAXINT32, 1,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-pdb-set-data
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1215,42 +1215,6 @@ _gimp_pdb_get_data (const gchar *identifier,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gimp_pdb_get_data_size:
|
||||
* @identifier: The identifier associated with data.
|
||||
*
|
||||
* Returns size of data associated with the specified identifier.
|
||||
*
|
||||
* This procedure returns the size of any data which may have been
|
||||
* associated with the specified identifier. If no data has been
|
||||
* associated with the identifier, an error is returned.
|
||||
*
|
||||
* Returns: The number of bytes in the data.
|
||||
**/
|
||||
gint
|
||||
_gimp_pdb_get_data_size (const gchar *identifier)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
gint bytes = 0;
|
||||
|
||||
args = gimp_value_array_new_from_types (NULL,
|
||||
G_TYPE_STRING, identifier,
|
||||
G_TYPE_NONE);
|
||||
|
||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||
"gimp-pdb-get-data-size",
|
||||
args);
|
||||
gimp_value_array_unref (args);
|
||||
|
||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||
bytes = GIMP_VALUES_GET_INT (return_vals, 1);
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gimp_pdb_set_data:
|
||||
* @identifier: The identifier associated with data.
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ G_GNUC_INTERNAL gboolean _gimp_pdb_set_batch_interpreter (const gcha
|
|||
const gchar *interpreter_name);
|
||||
G_GNUC_INTERNAL gboolean _gimp_pdb_get_data (const gchar *identifier,
|
||||
GBytes **data);
|
||||
G_GNUC_INTERNAL gint _gimp_pdb_get_data_size (const gchar *identifier);
|
||||
G_GNUC_INTERNAL gboolean _gimp_pdb_set_data (const gchar *identifier,
|
||||
GBytes *data);
|
||||
|
||||
|
|
|
|||
|
|
@ -1246,50 +1246,6 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub pdb_get_data_size {
|
||||
$blurb = 'Returns size of data associated with the specified identifier.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure returns the size of any data which may have been associated with
|
||||
the specified identifier. If no data has been associated with the identifier,
|
||||
an error is returned.
|
||||
HELP
|
||||
|
||||
&nick_pdb_misc('1998');
|
||||
|
||||
$lib_private = 1;
|
||||
|
||||
@inargs = (
|
||||
{ name => 'identifier', type => 'string', non_empty => 1,
|
||||
desc => 'The identifier associated with data' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'bytes', type => '1 <= int32',
|
||||
desc => 'The number of bytes in the data' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (gimp_is_canonical_identifier (identifier))
|
||||
{
|
||||
if (! gimp_plug_in_manager_get_data (gimp->plug_in_manager,
|
||||
identifier, &bytes))
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
||||
_("Data label '%s' is not a canonical identifier"),
|
||||
identifier);
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub pdb_set_data {
|
||||
$blurb = 'Associates the specified identifier with the supplied data.';
|
||||
|
||||
|
|
@ -1398,7 +1354,6 @@ CODE
|
|||
pdb_set_file_proc_thumbnail_loader
|
||||
pdb_set_batch_interpreter
|
||||
pdb_get_data
|
||||
pdb_get_data_size
|
||||
pdb_set_data);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue