app, libgimp, pdb, plug-ins: array size's type should be gsize.

This changes the signature of generated functions in libgimp with array
arguments.
This commit is contained in:
Jehan 2024-10-25 02:10:57 +02:00
parent 3a2cbb4162
commit ac2bef4410
26 changed files with 100 additions and 55 deletions

View File

@ -295,7 +295,7 @@ gimp_dash_pattern_from_double_array (gint n_dashes,
gdouble *
gimp_dash_pattern_to_double_array (GArray *pattern,
gint *n_dashes)
gsize *n_dashes)
{
if (pattern != NULL && pattern->len > 0)
{

View File

@ -44,7 +44,7 @@ GimpValueArray * gimp_dash_pattern_to_value_array (GArray *pattern);
GArray * gimp_dash_pattern_from_double_array (gint n_dashes,
const gdouble *dashes);
gdouble * gimp_dash_pattern_to_double_array (GArray *pattern,
gint *n_dashes);
gsize *n_dashes);
GArray * gimp_dash_pattern_copy (GArray *pattern);
void gimp_dash_pattern_free (GArray *pattern);

View File

@ -753,7 +753,7 @@ context_get_line_dash_pattern_invoker (GimpProcedure *procedure,
GError **error)
{
GimpValueArray *return_vals;
gint num_dashes = 0;
gsize num_dashes = 0;
gdouble *dashes = NULL;
GimpStrokeOptions *options =
@ -778,7 +778,7 @@ context_set_line_dash_pattern_invoker (GimpProcedure *procedure,
GError **error)
{
gboolean success = TRUE;
gint num_dashes;
gsize num_dashes;
const gdouble *dashes;
dashes = gimp_value_get_float_array (gimp_value_array_index (args, 0), (gsize *) &num_dashes);

View File

@ -160,7 +160,7 @@ gradient_get_uniform_samples_invoker (GimpProcedure *procedure,
GimpGradient *gradient;
gint num_samples;
gboolean reverse;
gint num_color_samples = 0;
gsize num_color_samples = 0;
gdouble *color_samples = NULL;
gradient = g_value_get_object (gimp_value_array_index (args, 0));
@ -228,7 +228,7 @@ gradient_get_custom_samples_invoker (GimpProcedure *procedure,
gint num_samples;
const gdouble *positions;
gboolean reverse;
gint num_color_samples = 0;
gsize num_color_samples = 0;
gdouble *color_samples = NULL;
gradient = g_value_get_object (gimp_value_array_index (args, 0));

View File

@ -170,7 +170,7 @@ path_get_strokes_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpPath *path;
gint num_strokes = 0;
gsize num_strokes = 0;
gint32 *stroke_ids = NULL;
path = g_value_get_object (gimp_value_array_index (args, 0));
@ -657,7 +657,7 @@ path_stroke_get_points_invoker (GimpProcedure *procedure,
GimpPath *path;
gint stroke_id;
gint type = 0;
gint num_points = 0;
gsize num_points = 0;
gdouble *controlpoints = NULL;
gboolean closed = FALSE;
@ -723,7 +723,7 @@ path_stroke_new_from_points_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpPath *path;
gint type;
gint num_points;
gsize num_points;
const gdouble *controlpoints;
gboolean closed;
gint stroke_id = 0;
@ -795,7 +795,7 @@ path_stroke_interpolate_invoker (GimpProcedure *procedure,
GimpPath *path;
gint stroke_id;
gdouble precision;
gint num_coords = 0;
gsize num_coords = 0;
gdouble *coords = NULL;
gboolean closed = FALSE;

View File

@ -62,7 +62,7 @@ plug_ins_query_invoker (GimpProcedure *procedure,
gchar **procedures = NULL;
gchar **accelerators = NULL;
gchar **locations = NULL;
gint num_install_times = 0;
gsize num_install_times = 0;
gint32 *install_times = NULL;
search_string = g_value_get_string (gimp_value_array_index (args, 0));

View File

@ -1126,12 +1126,12 @@ plug_in_convmatrix_invoker (GimpProcedure *procedure,
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint argc_matrix;
gsize argc_matrix;
const gdouble *matrix;
gboolean alpha_alg;
gdouble divisor;
gdouble offset;
gint argc_channels;
gsize argc_channels;
const gint32 *channels;
gint bmode;
@ -1149,7 +1149,10 @@ plug_in_convmatrix_invoker (GimpProcedure *procedure,
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Array 'matrix' has only %d members, must have 25"),
argc_matrix);
/* TODO: rather than converting the gsize, we should
* change the string, but we are in string freeze.
*/
(gint) argc_matrix);
success = FALSE;
}
@ -1157,7 +1160,10 @@ plug_in_convmatrix_invoker (GimpProcedure *procedure,
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Array 'channels' has only %d members, must have 5"),
argc_channels);
/* TODO: rather than converting the gsize, we should
* change the string, but we are in string freeze.
*/
(gint) argc_channels);
success = FALSE;
}

View File

@ -1137,7 +1137,7 @@ gimp_context_set_line_dash_offset (gdouble dash_offset)
* Since: 2.10
**/
gboolean
gimp_context_get_line_dash_pattern (gint *num_dashes,
gimp_context_get_line_dash_pattern (gsize *num_dashes,
gdouble **dashes)
{
GimpValueArray *args;
@ -1189,7 +1189,7 @@ gimp_context_get_line_dash_pattern (gint *num_dashes,
* Since: 2.10
**/
gboolean
gimp_context_set_line_dash_pattern (gint num_dashes,
gimp_context_set_line_dash_pattern (gsize num_dashes,
const gdouble *dashes)
{
GimpValueArray *args;

View File

@ -62,9 +62,9 @@ gdouble gimp_context_get_line_miter_limit (void)
gboolean gimp_context_set_line_miter_limit (gdouble miter_limit);
gdouble gimp_context_get_line_dash_offset (void);
gboolean gimp_context_set_line_dash_offset (gdouble dash_offset);
gboolean gimp_context_get_line_dash_pattern (gint *num_dashes,
gboolean gimp_context_get_line_dash_pattern (gsize *num_dashes,
gdouble **dashes);
gboolean gimp_context_set_line_dash_pattern (gint num_dashes,
gboolean gimp_context_set_line_dash_pattern (gsize num_dashes,
const gdouble *dashes);
GimpBrush* gimp_context_get_brush (void);
gboolean gimp_context_set_brush (GimpBrush *brush);

View File

@ -170,7 +170,7 @@ gboolean
gimp_gradient_get_uniform_samples (GimpGradient *gradient,
gint num_samples,
gboolean reverse,
gint *num_color_samples,
gsize *num_color_samples,
gdouble **color_samples)
{
GimpValueArray *args;
@ -228,7 +228,7 @@ gimp_gradient_get_custom_samples (GimpGradient *gradient,
gint num_samples,
const gdouble *positions,
gboolean reverse,
gint *num_color_samples,
gsize *num_color_samples,
gdouble **color_samples)
{
GimpValueArray *args;

View File

@ -38,13 +38,13 @@ gint gimp_gradient_get_number_of_segments (GimpGradient
gboolean gimp_gradient_get_uniform_samples (GimpGradient *gradient,
gint num_samples,
gboolean reverse,
gint *num_color_samples,
gsize *num_color_samples,
gdouble **color_samples);
gboolean gimp_gradient_get_custom_samples (GimpGradient *gradient,
gint num_samples,
const gdouble *positions,
gboolean reverse,
gint *num_color_samples,
gsize *num_color_samples,
gdouble **color_samples);
GeglColor* gimp_gradient_segment_get_left_color (GimpGradient *gradient,
gint segment);

View File

@ -49,7 +49,7 @@ typedef struct
gint allocation_width;
gdouble *data;
gint n_samples;
gsize n_samples;
} GimpGradientPreviewData;
struct _GimpGradientChooser
@ -213,12 +213,12 @@ gimp_gradient_chooser_new (const gchar *title,
static gboolean
get_gradient_data (GimpGradient *gradient,
gint allocation_width,
gint *sample_count,
gsize *sample_count,
gdouble **sample_array)
{
gboolean result;
gdouble *samples;
gint n_samples;
gsize n_samples;
result = gimp_gradient_get_uniform_samples (gradient,
allocation_width,
@ -399,7 +399,7 @@ static gboolean
local_grad_data_refresh (GimpGradientChooser *self, GimpGradient *gradient)
{
gdouble *src;
gint n_samples;
gsize n_samples;
/* Must not be called before widget is allocated. */
g_assert (self->local_grad_data->allocation_width != 0);

View File

@ -172,7 +172,7 @@ gimp_path_copy (GimpPath *path)
**/
gint *
gimp_path_get_strokes (GimpPath *path,
gint *num_strokes)
gsize *num_strokes)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@ -678,7 +678,7 @@ gimp_path_stroke_flip_free (GimpPath *path,
GimpPathStrokeType
gimp_path_stroke_get_points (GimpPath *path,
gint stroke_id,
gint *num_points,
gsize *num_points,
gdouble **controlpoints,
gboolean *closed)
{
@ -735,7 +735,7 @@ gimp_path_stroke_get_points (GimpPath *path,
gint
gimp_path_stroke_new_from_points (GimpPath *path,
GimpPathStrokeType type,
gint num_points,
gsize num_points,
const gdouble *controlpoints,
gboolean closed)
{
@ -786,7 +786,7 @@ gdouble *
gimp_path_stroke_interpolate (GimpPath *path,
gint stroke_id,
gdouble precision,
gint *num_coords,
gsize *num_coords,
gboolean *closed)
{
GimpValueArray *args;

View File

@ -38,7 +38,7 @@ GimpPath* gimp_path_new_from_text_layer (GimpImage *im
GimpLayer *layer);
GimpPath* gimp_path_copy (GimpPath *path);
gint* gimp_path_get_strokes (GimpPath *path,
gint *num_strokes);
gsize *num_strokes);
gdouble gimp_path_stroke_get_length (GimpPath *path,
gint stroke_id,
gdouble precision);
@ -81,18 +81,18 @@ gboolean gimp_path_stroke_flip_free (GimpPath *pa
gdouble y2);
GimpPathStrokeType gimp_path_stroke_get_points (GimpPath *path,
gint stroke_id,
gint *num_points,
gsize *num_points,
gdouble **controlpoints,
gboolean *closed);
gint gimp_path_stroke_new_from_points (GimpPath *path,
GimpPathStrokeType type,
gint num_points,
gsize num_points,
const gdouble *controlpoints,
gboolean closed);
gdouble* gimp_path_stroke_interpolate (GimpPath *path,
gint stroke_id,
gdouble precision,
gint *num_coords,
gsize *num_coords,
gboolean *closed);
gint gimp_path_bezier_stroke_new_moveto (GimpPath *path,
gdouble x0,

View File

@ -498,6 +498,28 @@ g_param_spec_double ("$name",
"$blurb",
$min, $max, $default,
$flags)
CODE
}
elsif ($pdbtype eq 'size') {
if (defined $typeinfo[0]) {
$min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
}
else {
$min = G_MINSIZE;
}
if (defined $typeinfo[2]) {
$max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
}
else {
$max = G_MAXSIZE;
}
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
$pspec = <<CODE;
g_param_spec_size ("$name",
"$nick",
"$blurb",
$min, $max, $default,
$flags)
CODE
}
elsif ($pdbtype eq 'int32') {

View File

@ -866,7 +866,10 @@ HELP
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Array 'matrix' has only %d members, must have 25"),
argc_matrix);
/* TODO: rather than converting the gsize, we should
* change the string, but we are in string freeze.
*/
(gint) argc_matrix);
success = FALSE;
}
@ -874,7 +877,10 @@ HELP
{
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
_("Array 'channels' has only %d members, must have 5"),
argc_channels);
/* TODO: rather than converting the gsize, we should
* change the string, but we are in string freeze.
*/
(gint) argc_channels);
success = FALSE;
}
@ -5590,4 +5596,4 @@ $doc_title = 'gimpplugincompat';
$doc_short_desc = 'Compatibility for removed plug-ins.';
$doc_long_desc = 'Functions that perform the operation of removed plug-ins using GEGL operations or other GIMP internal functions.';
1;
1;

View File

@ -17,6 +17,16 @@
package Gimp::CodeGen::pdb;
%arg_types = (
size => { name => 'SIZE',
gtype => 'G_TYPE_SIZE',
type => 'gsize ',
const_type => 'gsize ',
init_value => '0',
get_value_func => '$var = g_value_get_size ($value)',
dup_value_func => '$var = GIMP_VALUES_GET_INT ($value)',
set_value_func => 'g_value_set_size ($value, $var)',
take_value_func => 'g_value_set_size ($value, $var)' },
int32 => { name => 'INT32',
gtype => 'G_TYPE_INT',
type => 'gint ',

View File

@ -224,7 +224,7 @@ sub arrayexpand {
# We can't have negative lengths, but let them set a min number
unless (exists $arg->{type}) {
$arg->{type} = '0 <= int32';
$arg->{type} = '0 <= size';
}
elsif ($arg->{type} !~ /^\s*\d+\s*</) {
$arg->{type} = '0 <= ' . $arg->{type};

View File

@ -418,7 +418,7 @@ get_samples_gradient (GimpDrawable *drawable)
{
GimpGradient *gradient;
gint n_d_samples;
gsize n_d_samples;
gdouble *d_samples = NULL;
gradient = gimp_context_get_gradient ();

View File

@ -2409,7 +2409,7 @@ get_gradient (gint mode)
{
GimpGradient *gradient;
gint n_f_samples;
gsize n_f_samples;
gdouble *f_samples;
gdouble *f_samp; /* float samples */
gint lum;

View File

@ -1155,7 +1155,7 @@ save_paths (GOutputStream *output,
GList *paths;
GList *iter;
gint v;
gint num_strokes;
gsize num_strokes;
gint *strokes;
gint s;
@ -1228,7 +1228,7 @@ save_paths (GOutputStream *output,
{
GimpPathStrokeType type;
gdouble *points;
gint num_points;
gsize num_points;
gboolean closed;
gint p = 0;
@ -1240,7 +1240,7 @@ save_paths (GOutputStream *output,
num_points % 6)
{
g_printerr ("psd-export: unsupported stroke type: "
"%d (%d points)\n", type, num_points);
"%d (%" G_GSIZE_FORMAT " points)\n", type, num_points);
continue;
}

View File

@ -107,11 +107,12 @@ save_paths (TIFF *tif,
gint offset_x,
gint offset_y)
{
gint id = 2000; /* Photoshop paths have IDs >= 2000 */
GList *path;
GList *iter;
gint v;
gint num_strokes, *strokes, s;
gint id = 2000; /* Photoshop paths have IDs >= 2000 */
GList *path;
GList *iter;
gint v;
gsize num_strokes;
gint *strokes, s;
GString *ps_tag;
path = gimp_image_list_paths (image);
@ -185,7 +186,7 @@ save_paths (TIFF *tif,
{
GimpPathStrokeType type;
gdouble *points;
gint num_points;
gsize num_points;
gboolean closed;
gint p = 0;
@ -197,7 +198,7 @@ save_paths (TIFF *tif,
num_points % 6)
{
g_printerr ("tiff-export: unsupported stroke type: "
"%d (%d points)\n", type, num_points);
"%d (%" G_GSIZE_FORMAT " points)\n", type, num_points);
continue;
}

View File

@ -386,7 +386,7 @@ drawable_to_cmap (control_point *cp)
{
GimpGradient *gradient = gimp_context_get_gradient ();
gint num;
gsize num;
gdouble *g;
/* FIXME: "reverse" hardcoded to FALSE. */

View File

@ -36,7 +36,7 @@
#define ZOOM_UNDO_SIZE 100
static gint n_gradient_samples = 0;
static gsize n_gradient_samples = 0;
static gdouble *gradient_samples = NULL;
static GimpGradient *gradient = NULL;
static gboolean ready_now = FALSE;

View File

@ -5035,7 +5035,7 @@ gradient_get_values_real_external (const gchar *gradient_name,
gboolean reverse)
{
GimpGradient *gradient;
gint n_tmp_values;
gsize n_tmp_values;
gdouble *tmp_values;
gint i;
gint j;

View File

@ -891,7 +891,7 @@ get_gradient_samples (GimpDrawable *drawable,
{
GimpGradient *gradient;
gint n_d_samples;
gsize n_d_samples;
gdouble *d_samples = NULL;
gradient = gimp_context_get_gradient ();