2006-12-10 05:33:38 +08:00
|
|
|
# GIMP - The GNU Image Manipulation Program
|
2003-07-03 08:47:26 +08:00
|
|
|
# Copyright (C) 1998-2003 Manish Singh <yosh@gimp.org>
|
1998-10-24 13:19:30 +08:00
|
|
|
|
2009-01-18 06:28:01 +08:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
1998-10-24 13:19:30 +08:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1998-10-24 13:19:30 +08:00
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1998-10-24 13:19:30 +08:00
|
|
|
|
|
|
|
package Gimp::CodeGen::app;
|
|
|
|
|
2011-11-07 00:33:20 +08:00
|
|
|
$destdir = "$main::destdir/app/pdb";
|
|
|
|
$builddir = "$main::builddir/app/pdb";
|
1998-10-24 13:19:30 +08:00
|
|
|
|
|
|
|
*arg_types = \%Gimp::CodeGen::pdb::arg_types;
|
|
|
|
*arg_parse = \&Gimp::CodeGen::pdb::arg_parse;
|
|
|
|
|
1999-03-18 07:08:08 +08:00
|
|
|
*enums = \%Gimp::CodeGen::enums::enums;
|
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
*write_file = \&Gimp::CodeGen::util::write_file;
|
1999-03-11 02:56:56 +08:00
|
|
|
*FILE_EXT = \$Gimp::CodeGen::util::FILE_EXT;
|
|
|
|
|
1999-03-20 07:04:16 +08:00
|
|
|
use Text::Wrap qw(wrap);
|
|
|
|
|
|
|
|
sub quotewrap {
|
2013-09-14 09:12:26 +08:00
|
|
|
my ($str, $indent, $subsequent_indent) = @_;
|
1999-03-20 07:04:16 +08:00
|
|
|
my $leading = ' ' x $indent . '"';
|
2013-09-14 09:12:26 +08:00
|
|
|
my $subsequent_leading = ' ' x $subsequent_indent . '"';
|
1999-03-20 07:04:16 +08:00
|
|
|
$Text::Wrap::columns = 1000;
|
2013-09-14 09:12:26 +08:00
|
|
|
$Text::Wrap::unexpand = 0;
|
|
|
|
$str = wrap($leading, $subsequent_leading, $str);
|
1999-03-20 07:04:16 +08:00
|
|
|
$str =~ s/^\s*//s;
|
2013-09-14 09:12:26 +08:00
|
|
|
$str =~ s/(.)\n(.)/$1\\n"\n$2/g;
|
|
|
|
$str =~ s/(.)$/$1"/s;
|
1999-03-20 07:04:16 +08:00
|
|
|
$str;
|
|
|
|
}
|
|
|
|
|
1999-03-21 10:14:08 +08:00
|
|
|
sub format_code_frag {
|
|
|
|
my ($code, $indent) = @_;
|
|
|
|
|
|
|
|
chomp $code;
|
|
|
|
$code =~ s/\t/' ' x 8/eg;
|
|
|
|
|
|
|
|
if (!$indent && $code =~ /^\s*{\s*\n.*\n\s*}\s*$/s) {
|
|
|
|
$code =~ s/^\s*{\s*\n//s;
|
|
|
|
$code =~ s/\n\s*}\s*$//s;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$code =~ s/^/' ' x ($indent ? 4 : 2)/meg;
|
|
|
|
}
|
|
|
|
$code .= "\n";
|
|
|
|
|
2004-03-27 00:38:44 +08:00
|
|
|
$code =~ s/^\s+$//mg;
|
|
|
|
|
1999-03-21 10:14:08 +08:00
|
|
|
$code;
|
|
|
|
}
|
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
sub declare_args {
|
|
|
|
my $proc = shift;
|
|
|
|
my $out = shift;
|
2006-04-03 00:03:32 +08:00
|
|
|
my $outargs = shift;
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1999-03-18 07:08:08 +08:00
|
|
|
local $result = "";
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
foreach (@_) {
|
2013-09-26 20:09:08 +08:00
|
|
|
my @args = @{$proc->{$_}} if (defined $proc->{$_});
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
foreach (@args) {
|
1999-04-23 14:55:37 +08:00
|
|
|
my ($type, $name) = &arg_parse($_->{type});
|
|
|
|
my $arg = $arg_types{$type};
|
|
|
|
|
1999-03-21 10:14:08 +08:00
|
|
|
if ($arg->{array} && !exists $_->{array}) {
|
1999-03-11 02:56:56 +08:00
|
|
|
warn "Array without number of elements param in $proc->{name}";
|
|
|
|
}
|
|
|
|
|
2011-10-08 21:32:09 +08:00
|
|
|
unless (exists $_->{no_declare} || exists $_->{dead}) {
|
2006-04-03 00:03:32 +08:00
|
|
|
if ($outargs) {
|
2019-08-14 03:36:03 +08:00
|
|
|
if (exists $arg->{app_type}) {
|
|
|
|
$result .= " $arg->{app_type}$_->{name} = $arg->{init_value}";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$result .= " $arg->{type}$_->{name} = $arg->{init_value}";
|
|
|
|
}
|
2006-04-03 00:03:32 +08:00
|
|
|
}
|
|
|
|
else {
|
2019-08-14 03:36:03 +08:00
|
|
|
if (exists $arg->{app_const_type}) {
|
|
|
|
$result .= " $arg->{app_const_type}$_->{name}";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$result .= " $arg->{const_type}$_->{name}";
|
|
|
|
}
|
1999-03-18 07:08:08 +08:00
|
|
|
}
|
1999-03-11 07:34:26 +08:00
|
|
|
$result .= ";\n";
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1999-03-21 10:14:08 +08:00
|
|
|
if (exists $arg->{headers}) {
|
|
|
|
foreach (@{$arg->{headers}}) {
|
1998-10-24 13:19:30 +08:00
|
|
|
$out->{headers}->{$_}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
$result;
|
1999-04-10 12:52:07 +08:00
|
|
|
}
|
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
sub marshal_inargs {
|
1999-03-21 10:14:08 +08:00
|
|
|
my ($proc, $argc) = @_;
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
my $result = "";
|
|
|
|
my %decls;
|
1999-03-11 02:56:56 +08:00
|
|
|
|
2013-09-26 20:09:08 +08:00
|
|
|
my @inargs = @{$proc->{inargs}} if (defined $proc->{inargs});
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
foreach (@inargs) {
|
|
|
|
my($pdbtype, @typeinfo) = &arg_parse($_->{type});
|
|
|
|
my $arg = $arg_types{$pdbtype};
|
2006-03-30 07:56:07 +08:00
|
|
|
my $var = $_->{name};
|
|
|
|
my $value;
|
1999-04-27 12:33:41 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
$value = "gimp_value_array_index (args, $argc)";
|
2024-10-25 07:31:30 +08:00
|
|
|
if (exists $_->{nopdb}) {
|
|
|
|
$argc--;
|
|
|
|
}
|
|
|
|
elsif (!exists $_->{dead}) {
|
app, libgimp*, pdb, plug-ins: first step to make int32array PDB type aware of its length.
PDB code is now looking directly into the GimpArray length for
determining the data length.
Also adding a 'size' argument (number of elements, not bytes) to
gimp_value_(get|dup)_int32_array() to make it actually introspectable.
Until now, it was somehow introspected but was segfaulting on run.
I.e. that, e.g. in Python, calling Gimp.value_set_int32_array(v, [1, 2, 3])
followed by Gimp.value_get_int32_array(v) would actually make a
segmentation fault. Now the binding works flawlessly.
This will also make these functions much more usable in general.
2024-10-24 15:48:14 +08:00
|
|
|
my $var_len;
|
|
|
|
|
|
|
|
if (exists $_->{array}) {
|
|
|
|
my $arrayarg = $_->{array};
|
|
|
|
|
|
|
|
if (exists $arrayarg->{name}) {
|
|
|
|
$var_len = $arrayarg->{name};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$var_len = 'num_' . $_->{name};
|
|
|
|
}
|
|
|
|
}
|
2011-10-08 21:32:09 +08:00
|
|
|
$result .= eval qq/" $arg->{get_value_func};\n"/;
|
|
|
|
}
|
2002-08-30 01:21:21 +08:00
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
$argc++;
|
2004-03-28 22:20:57 +08:00
|
|
|
|
2007-04-27 03:10:23 +08:00
|
|
|
if (!exists $_->{no_validate}) {
|
2006-03-30 07:56:07 +08:00
|
|
|
$success = 1;
|
1998-10-24 13:19:30 +08:00
|
|
|
}
|
1999-03-20 07:04:16 +08:00
|
|
|
}
|
1999-04-10 12:52:07 +08:00
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
$result = "\n" . $result . "\n" if $result;
|
1998-10-24 13:19:30 +08:00
|
|
|
$result;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub marshal_outargs {
|
|
|
|
my $proc = shift;
|
2008-08-16 21:57:57 +08:00
|
|
|
my $result;
|
1998-10-24 13:19:30 +08:00
|
|
|
my $argc = 0;
|
2013-09-26 20:09:08 +08:00
|
|
|
my @outargs = @{$proc->{outargs}} if (defined $proc->{outargs});
|
1999-03-11 02:56:56 +08:00
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
if ($success) {
|
|
|
|
$result = <<CODE;
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
|
|
error ? *error : NULL);
|
|
|
|
CODE
|
|
|
|
} else {
|
|
|
|
$result = <<CODE;
|
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
if (scalar @outargs) {
|
|
|
|
my $outargs = "";
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
foreach (@{$proc->{outargs}}) {
|
|
|
|
my ($pdbtype) = &arg_parse($_->{type});
|
|
|
|
my $arg = $arg_types{$pdbtype};
|
2006-03-30 07:56:07 +08:00
|
|
|
my $var = $_->{name};
|
2006-04-01 09:33:28 +08:00
|
|
|
my $var_len;
|
2006-03-30 07:56:07 +08:00
|
|
|
my $value;
|
1999-03-11 02:56:56 +08:00
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
$argc++;
|
1999-03-11 02:56:56 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
if (exists $_->{nopdb}) {
|
|
|
|
$argc--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$value = "gimp_value_array_index (return_vals, $argc)";
|
1999-03-11 02:56:56 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
if (exists $_->{array}) {
|
|
|
|
my $arrayarg = $_->{array};
|
2006-04-01 09:33:28 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
if (exists $arrayarg->{name}) {
|
|
|
|
$var_len = $arrayarg->{name};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$var_len = 'num_' . $_->{name};
|
|
|
|
}
|
|
|
|
}
|
2006-04-01 09:33:28 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
$outargs .= eval qq/" $arg->{take_value_func};\n"/;
|
|
|
|
}
|
1998-10-24 13:19:30 +08:00
|
|
|
}
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
$outargs =~ s/^/' ' x 2/meg if $success;
|
|
|
|
$outargs =~ s/^/' ' x 2/meg if $success && $argc > 1;
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
$result .= "\n" if $success || $argc > 1;
|
|
|
|
$result .= ' ' x 2 . "if (success)\n" if $success;
|
|
|
|
$result .= ' ' x 4 . "{\n" if $success && $argc > 1;
|
|
|
|
$result .= $outargs;
|
|
|
|
$result .= ' ' x 4 . "}\n" if $success && $argc > 1;
|
2006-03-28 05:09:32 +08:00
|
|
|
$result .= "\n" . ' ' x 2 . "return return_vals;\n";
|
1998-10-24 13:19:30 +08:00
|
|
|
}
|
|
|
|
else {
|
2008-02-21 21:43:10 +08:00
|
|
|
if ($success) {
|
|
|
|
$result =~ s/return_vals =/return/;
|
2008-08-16 21:57:57 +08:00
|
|
|
$result =~ s/ error/error/;
|
2008-02-21 21:43:10 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$result =~ s/ return_vals =/\n return/;
|
2008-08-16 21:57:57 +08:00
|
|
|
$result =~ s/ error/error/;
|
2008-02-21 21:43:10 +08:00
|
|
|
}
|
1998-10-24 13:19:30 +08:00
|
|
|
}
|
1999-03-11 02:56:56 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
$result;
|
|
|
|
}
|
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
sub generate_pspec {
|
|
|
|
my $arg = shift;
|
2006-03-30 07:56:07 +08:00
|
|
|
my ($pdbtype, @typeinfo) = &arg_parse($arg->{type});
|
2006-03-29 03:58:00 +08:00
|
|
|
my $name = $arg->{canonical_name};
|
|
|
|
my $nick = $arg->{canonical_name};
|
2006-05-19 01:25:15 +08:00
|
|
|
my $blurb = exists $arg->{desc} ? $arg->{desc} : "";
|
2006-03-29 03:58:00 +08:00
|
|
|
my $min;
|
|
|
|
my $max;
|
|
|
|
my $default;
|
|
|
|
my $flags = 'GIMP_PARAM_READWRITE';
|
|
|
|
my $pspec = "";
|
2006-03-30 07:56:07 +08:00
|
|
|
my $postproc = "";
|
2006-03-29 03:58:00 +08:00
|
|
|
|
|
|
|
$nick =~ s/-/ /g;
|
|
|
|
|
2007-04-27 03:10:23 +08:00
|
|
|
if (exists $arg->{no_validate}) {
|
2006-03-29 03:58:00 +08:00
|
|
|
$flags .= ' | GIMP_PARAM_NO_VALIDATE';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($pdbtype eq 'image') {
|
2006-05-07 02:57:51 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_image ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2023-05-31 22:12:04 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'resource') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2024-07-27 20:18:54 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
2023-05-31 22:12:04 +08:00
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_resource ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
app, libgimp*, pdb: new GimpParamSpecObject abstract spec type.
This abstract spec type is basically a GParamSpecObject with a default
value. It will be used by various object spec with default values, such
as GimpParamSpecColor, GimpParamSpecUnit and all GimpParamSpecResource
subtypes. Also it has a duplicate() class method so that every spec type
can implement the proper way to duplicate itself.
This fixes the fact that in gimp_config_param_spec_duplicate(), all
unknown object spec types (because they are implemented in libgimp,
which is invisible to libgimpconfig) are just copied as
GParamSpecObject, hence losing default values and other parameters.
As a second enhancement, it also makes it easier to detect the object
spec types for which we have default value support in
gimp_config_reset_properties().
As a side fix, gimp_param_spec_color() now just always duplicates the
passed default color, making it hence much easier to avoid bugs when
reusing a GeglColor.
2024-09-03 05:38:13 +08:00
|
|
|
GIMP_TYPE_RESOURCE,
|
2023-05-31 22:12:04 +08:00
|
|
|
$none_ok,
|
2024-07-27 20:18:54 +08:00
|
|
|
$default,
|
2024-09-06 19:38:43 +08:00
|
|
|
FALSE,
|
2023-05-31 22:12:04 +08:00
|
|
|
$flags)
|
2022-09-06 07:28:35 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'brush') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2024-07-27 20:18:54 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
|
2022-09-06 07:28:35 +08:00
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_brush ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
2024-07-27 20:18:54 +08:00
|
|
|
$default,
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context,
|
2022-09-06 07:28:35 +08:00
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'font') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2024-07-27 20:18:54 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
|
2022-09-06 07:28:35 +08:00
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_font ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
2024-07-27 20:18:54 +08:00
|
|
|
$default,
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context,
|
2022-09-06 07:28:35 +08:00
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'gradient') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2024-07-27 20:18:54 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
|
2022-09-06 07:28:35 +08:00
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_gradient ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
2024-07-27 20:18:54 +08:00
|
|
|
$default,
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context,
|
2022-09-06 07:28:35 +08:00
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'palette') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2024-07-27 20:18:54 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
|
2022-09-06 07:28:35 +08:00
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_palette ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
2024-07-27 20:18:54 +08:00
|
|
|
$default,
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context,
|
2022-09-06 07:28:35 +08:00
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'pattern') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2024-07-27 20:18:54 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context = exists $arg->{default_to_context} ? 'TRUE' : 'FALSE';
|
2022-09-06 07:28:35 +08:00
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_pattern ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
2024-07-27 20:18:54 +08:00
|
|
|
$default,
|
2024-09-06 19:38:43 +08:00
|
|
|
$default_to_context,
|
2022-09-06 07:28:35 +08:00
|
|
|
$flags)
|
2010-07-09 15:34:44 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'item') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
|
|
|
$pspec = <<CODE;
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_item ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'drawable') {
|
2006-05-07 02:57:51 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_drawable ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
app, libgimp, pdb, plug-ins: new GimpGroupLayer class in libgimp.
Also:
- renaming gimp_layer_group_new() to gimp_group_layer_new() in order to keep the
same name as in core code (i.e. GimpGroupLayer, not GimpLayerGroup).
- renaming gimp_image_merge_layer_group() to gimp_group_layer_merge()
- new functions: gimp_procedure_add_group_layer_argument(),
gimp_procedure_add_group_layer_aux_argument() and
gimp_procedure_add_group_layer_return_value().
This can be tested, e.g. in Python with these calls:
```py
i = Gimp.get_images()[0]
g = Gimp.GroupLayer.new(i, "hello")
i.insert_layer(g, None, 1)
g2 = Gimp.GroupLayer.new(i, "world")
i.insert_layer(g2, g, 1)
g.merge()
```
This was work started long ago, stored in an old stash which I finally
finish now! :-)
2024-07-06 23:24:11 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'group_layer') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_group_layer ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2022-09-30 22:21:47 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'text_layer') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_text_layer ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'layer') {
|
2006-05-07 02:57:51 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_layer ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'channel') {
|
2006-05-07 02:57:51 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_channel ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'layer_mask') {
|
2006-05-07 02:57:51 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_layer_mask ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'selection') {
|
2006-05-07 02:57:51 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_selection ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
2024-07-12 14:16:25 +08:00
|
|
|
elsif ($pdbtype eq 'path') {
|
2006-05-07 02:57:51 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2024-07-12 14:16:25 +08:00
|
|
|
gimp_param_spec_path ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2024-11-25 03:38:39 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'filter') {
|
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_drawable_filter ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'display') {
|
2006-05-07 02:57:51 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_display ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$none_ok,
|
|
|
|
$flags)
|
2019-09-12 03:48:34 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'file') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
g_param_spec_object ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
G_TYPE_FILE,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'tattoo') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
g_param_spec_uint ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
1, G_MAXUINT32, 1,
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'guide') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
g_param_spec_uint ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
1, G_MAXUINT32, 1,
|
|
|
|
$flags)
|
2016-01-05 04:13:48 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'sample_point') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
g_param_spec_uint ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
1, G_MAXUINT32, 1,
|
|
|
|
$flags)
|
2024-05-07 02:38:12 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'export_options') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_export_options ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
elsif ($pdbtype eq 'double') {
|
2006-03-29 03:58:00 +08:00
|
|
|
$min = defined $typeinfo[0] ? $typeinfo[0] : -G_MAXDOUBLE;
|
|
|
|
$max = defined $typeinfo[2] ? $typeinfo[2] : G_MAXDOUBLE;
|
|
|
|
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0.0;
|
|
|
|
$pspec = <<CODE;
|
|
|
|
g_param_spec_double ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$min, $max, $default,
|
|
|
|
$flags)
|
2024-10-25 08:10:57 +08:00
|
|
|
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)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'int32') {
|
2010-06-06 01:26:06 +08:00
|
|
|
if (defined $typeinfo[0]) {
|
|
|
|
$min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$min = G_MININT32;
|
|
|
|
}
|
|
|
|
if (defined $typeinfo[2]) {
|
|
|
|
$max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$max = G_MAXINT32;
|
|
|
|
}
|
2006-03-29 03:58:00 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
|
|
|
|
$pspec = <<CODE;
|
2019-08-15 20:04:56 +08:00
|
|
|
g_param_spec_int ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$min, $max, $default,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'int16') {
|
2010-06-06 01:26:06 +08:00
|
|
|
if (defined $typeinfo[0]) {
|
|
|
|
$min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$min = G_MININT16;
|
|
|
|
}
|
|
|
|
if (defined $typeinfo[2]) {
|
|
|
|
$max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$max = G_MAXINT16;
|
|
|
|
}
|
2006-03-29 03:58:00 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
|
|
|
|
$pspec = <<CODE;
|
2019-08-15 20:17:17 +08:00
|
|
|
g_param_spec_int ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$min, $max, $default,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'boolean') {
|
|
|
|
$default = exists $arg->{default} ? $arg->{default} : FALSE;
|
|
|
|
$pspec = <<CODE;
|
|
|
|
g_param_spec_boolean ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$default,
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'string') {
|
2007-04-27 03:10:23 +08:00
|
|
|
$allow_non_utf8 = exists $arg->{allow_non_utf8} ? 'TRUE' : 'FALSE';
|
2025-01-21 03:11:14 +08:00
|
|
|
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
|
2007-04-25 22:23:05 +08:00
|
|
|
$non_empty = exists $arg->{non_empty} ? 'TRUE' : 'FALSE';
|
2006-03-29 03:58:00 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_string ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2025-01-21 03:11:14 +08:00
|
|
|
$allow_non_utf8, $none_ok, $non_empty,
|
2006-03-29 03:58:00 +08:00
|
|
|
$default,
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'enum') {
|
|
|
|
$enum_type = $typeinfo[0];
|
|
|
|
$enum_type =~ s/([a-z])([A-Z])/$1_$2/g;
|
|
|
|
$enum_type =~ s/([A-Z]+)([A-Z])/$1_$2/g;
|
|
|
|
$enum_type =~ tr/[a-z]/[A-Z]/;
|
|
|
|
$enum_type =~ s/^GIMP/GIMP_TYPE/;
|
2018-03-18 07:33:04 +08:00
|
|
|
$enum_type =~ s/^GEGL/GEGL_TYPE/;
|
2006-03-29 03:58:00 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : $enums{$typeinfo[0]}->{symbols}[0];
|
2006-03-30 07:56:07 +08:00
|
|
|
|
|
|
|
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;
|
2006-03-29 03:58:00 +08:00
|
|
|
g_param_spec_enum ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$enum_type,
|
|
|
|
$default,
|
|
|
|
$flags)
|
|
|
|
CODE
|
2006-03-30 07:56:07 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_enum ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$enum_type,
|
|
|
|
$default,
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
2006-03-29 03:58:00 +08:00
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'unit') {
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
$allow_pixel = exists $arg->{allow_pixel} ? TRUE : FALSE;
|
2006-03-29 03:58:00 +08:00
|
|
|
$allow_percent = exists $arg->{allow_percent} ? TRUE : FALSE;
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : 'gimp_unit_inch ()';
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_unit ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
$allow_pixel,
|
2006-03-29 03:58:00 +08:00
|
|
|
$allow_percent,
|
|
|
|
$default,
|
|
|
|
$flags)
|
2023-11-04 04:26:51 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'geglcolor') {
|
2024-04-20 05:02:29 +08:00
|
|
|
$has_alpha = exists $arg->{has_alpha} ? TRUE : FALSE;
|
2023-11-04 04:26:51 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
|
|
|
$pspec = <<CODE;
|
2024-04-20 05:02:29 +08:00
|
|
|
gimp_param_spec_color ("$name",
|
2023-11-04 04:26:51 +08:00
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2024-04-20 05:02:29 +08:00
|
|
|
$has_alpha,
|
2023-11-04 04:26:51 +08:00
|
|
|
$default,
|
|
|
|
$flags)
|
2024-09-21 03:55:21 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'format') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
g_param_spec_boxed ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_BABL_FORMAT,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'parasite') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_parasite ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
2019-08-05 16:46:55 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'param') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
g_param_spec_param ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
G_TYPE_PARAM,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
2006-04-04 04:54:55 +08:00
|
|
|
elsif ($pdbtype eq 'int32array') {
|
2006-03-29 03:58:00 +08:00
|
|
|
$pspec = <<CODE;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_int32_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
elsif ($pdbtype eq 'doublearray') {
|
2006-04-04 04:54:55 +08:00
|
|
|
$pspec = <<CODE;
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 21:03:37 +08:00
|
|
|
gimp_param_spec_double_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
2006-04-04 04:54:55 +08:00
|
|
|
CODE
|
|
|
|
}
|
2023-05-24 05:37:46 +08:00
|
|
|
elsif ($pdbtype eq 'bytes') {
|
2006-04-04 04:54:55 +08:00
|
|
|
$pspec = <<CODE;
|
2023-05-24 05:37:46 +08:00
|
|
|
g_param_spec_boxed ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
G_TYPE_BYTES,
|
|
|
|
$flags)
|
2006-04-01 09:33:28 +08:00
|
|
|
CODE
|
|
|
|
}
|
2020-12-24 04:15:43 +08:00
|
|
|
elsif ($pdbtype eq 'strv') {
|
2006-04-01 09:33:28 +08:00
|
|
|
$pspec = <<CODE;
|
2020-12-24 04:15:43 +08:00
|
|
|
g_param_spec_boxed ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
G_TYPE_STRV,
|
|
|
|
$flags)
|
2008-07-14 22:44:13 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'colorarray') {
|
|
|
|
$pspec = <<CODE;
|
2023-12-27 00:07:19 +08:00
|
|
|
g_param_spec_boxed ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_COLOR_ARRAY,
|
|
|
|
$flags)
|
2019-09-05 18:57:43 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'imagearray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 19:10:06 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_IMAGE,
|
|
|
|
$flags)
|
2019-09-05 18:57:43 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'itemarray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 05:57:10 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_ITEM,
|
|
|
|
$flags)
|
2024-10-22 03:59:26 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'drawablearray') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_DRAWABLE,
|
|
|
|
$flags)
|
2019-09-05 18:57:43 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'layerarray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 07:47:45 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_LAYER,
|
|
|
|
$flags)
|
2019-09-05 18:57:43 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'channelarray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 08:09:58 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_CHANNEL,
|
|
|
|
$flags)
|
2019-09-05 18:57:43 +08:00
|
|
|
CODE
|
|
|
|
}
|
2024-07-12 14:16:25 +08:00
|
|
|
elsif ($pdbtype eq 'patharray') {
|
2019-09-05 18:57:43 +08:00
|
|
|
$pspec = <<CODE;
|
2024-10-22 18:20:30 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_PATH,
|
|
|
|
$flags)
|
2024-11-25 03:38:39 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'filterarray') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_DRAWABLE_FILTER,
|
|
|
|
$flags)
|
2023-10-03 05:22:49 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'resourcearray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 18:28:57 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_RESOURCE,
|
|
|
|
$flags)
|
2023-10-03 05:22:49 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'brusharray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 18:28:57 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_BRUSH,
|
|
|
|
$flags)
|
2023-10-03 05:22:49 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'fontarray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 18:28:57 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_FONT,
|
|
|
|
$flags)
|
2023-10-03 05:22:49 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'gradientarray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 18:28:57 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_GRADIENT,
|
|
|
|
$flags)
|
2023-10-03 05:22:49 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'palettearray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 18:28:57 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_PALETTE,
|
|
|
|
$flags)
|
2023-10-03 05:22:49 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'patternarray') {
|
|
|
|
$pspec = <<CODE;
|
2024-10-22 18:28:57 +08:00
|
|
|
gimp_param_spec_core_object_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
GIMP_TYPE_PATTERN,
|
|
|
|
$flags)
|
2024-11-29 16:37:23 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'valuearray') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_value_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
NULL,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
warn "Unsupported PDB type: $arg->{name} ($arg->{type})";
|
|
|
|
exit -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$pspec =~ s/\s$//;
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
return ($pspec, $postproc);
|
2006-03-29 03:58:00 +08:00
|
|
|
}
|
|
|
|
|
2006-05-19 20:58:27 +08:00
|
|
|
sub canonicalize {
|
|
|
|
$_ = shift; s/_/-/g; return $_;
|
|
|
|
}
|
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
sub generate {
|
|
|
|
my @procs = @{(shift)};
|
|
|
|
my %out;
|
|
|
|
my $total = 0.0;
|
2006-03-30 07:56:07 +08:00
|
|
|
my $argc;
|
1998-10-24 13:19:30 +08:00
|
|
|
|
1999-03-18 07:08:08 +08:00
|
|
|
foreach $name (@procs) {
|
1998-10-24 13:19:30 +08:00
|
|
|
my $proc = $main::pdb{$name};
|
|
|
|
my $out = \%{$out{$proc->{group}}};
|
|
|
|
|
2013-09-26 20:09:08 +08:00
|
|
|
my @inargs = @{$proc->{inargs}} if (defined $proc->{inargs});
|
|
|
|
my @outargs = @{$proc->{outargs}} if (defined $proc->{outargs});
|
2006-05-19 20:58:27 +08:00
|
|
|
|
2018-04-15 22:06:00 +08:00
|
|
|
my $blurb = $proc->{blurb};
|
2006-05-19 20:58:27 +08:00
|
|
|
my $help = $proc->{help};
|
|
|
|
|
2012-04-01 03:57:47 +08:00
|
|
|
my $procedure_name;
|
2025-01-20 00:34:22 +08:00
|
|
|
my $procedure_is_private;
|
2012-04-01 03:57:47 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
local $success = 0;
|
|
|
|
|
2018-04-15 22:06:00 +08:00
|
|
|
if ($proc->{deprecated}) {
|
|
|
|
if ($proc->{deprecated} eq 'NONE') {
|
|
|
|
if (!$blurb) {
|
|
|
|
$blurb = "Deprecated: There is no replacement for this procedure.";
|
|
|
|
}
|
|
|
|
if ($help) {
|
|
|
|
$help .= "\n\n";
|
|
|
|
}
|
|
|
|
$help .= "Deprecated: There is no replacement for this procedure.";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!$blurb) {
|
|
|
|
$blurb = "Deprecated: Use '$proc->{deprecated}' instead.";
|
|
|
|
}
|
|
|
|
if ($help) {
|
|
|
|
$help .= "\n\n";
|
|
|
|
}
|
|
|
|
$help .= "Deprecated: Use '$proc->{deprecated}' instead.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-19 20:58:27 +08:00
|
|
|
$help =~ s/gimp(\w+)\(\s*\)/"'gimp".canonicalize($1)."'"/ge;
|
|
|
|
|
2012-04-01 03:57:47 +08:00
|
|
|
if ($proc->{group} eq "plug_in_compat") {
|
|
|
|
$procedure_name = "$proc->{canonical_name}";
|
|
|
|
} else {
|
|
|
|
$procedure_name = "gimp-$proc->{canonical_name}";
|
|
|
|
}
|
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
$out->{pcount}++; $total++;
|
|
|
|
|
2025-01-20 00:34:22 +08:00
|
|
|
if ($proc->{lib_private}) {
|
|
|
|
$procedure_is_private = "TRUE";
|
|
|
|
} else {
|
|
|
|
$procedure_is_private = "FALSE";
|
|
|
|
}
|
|
|
|
|
2006-03-30 04:27:46 +08:00
|
|
|
$out->{register} .= <<CODE;
|
2006-04-26 17:13:47 +08:00
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
/*
|
2006-04-05 05:11:45 +08:00
|
|
|
* gimp-$proc->{canonical_name}
|
2006-03-29 03:58:00 +08:00
|
|
|
*/
|
2025-01-20 00:34:22 +08:00
|
|
|
procedure = gimp_procedure_new (${name}_invoker, TRUE, $procedure_is_private);
|
2008-04-04 18:58:56 +08:00
|
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
2012-04-01 03:57:47 +08:00
|
|
|
"$procedure_name");
|
2019-09-09 05:40:34 +08:00
|
|
|
gimp_procedure_set_static_help (procedure,
|
2022-06-05 06:20:03 +08:00
|
|
|
@{[ "ewrap($blurb, 2, 34) ]},
|
|
|
|
@{[ "ewrap($help, 2, 34) ]},
|
2019-09-09 05:40:34 +08:00
|
|
|
NULL);
|
|
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
|
|
"$proc->{author}",
|
|
|
|
"$proc->{copyright}",
|
|
|
|
"$proc->{date}");
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
|
2019-09-09 05:23:32 +08:00
|
|
|
if ($proc->{deprecated}) {
|
|
|
|
$out->{register} .= <<CODE;
|
|
|
|
gimp_procedure_set_deprecated (procedure,
|
|
|
|
"\"$proc->{deprecated}\"");
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
|
|
|
|
$argc = 0;
|
2006-03-30 07:56:07 +08:00
|
|
|
|
|
|
|
foreach $arg (@inargs) {
|
|
|
|
my ($pspec, $postproc) = &generate_pspec($arg);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
if (exists $arg->{nopdb}) {
|
|
|
|
$argc--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$pspec =~ s/^/' ' x length(" gimp_procedure_add_argument (")/meg;
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
$out->{register} .= <<CODE;
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_argument (procedure,
|
2006-03-29 03:58:00 +08:00
|
|
|
${pspec});
|
|
|
|
CODE
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
if ($postproc ne '') {
|
|
|
|
$pspec = "procedure->args[$argc]";
|
|
|
|
$postproc =~ s/^/' '/meg;
|
|
|
|
$out->{register} .= eval qq/"$postproc"/;
|
|
|
|
}
|
|
|
|
}
|
2006-03-30 07:56:07 +08:00
|
|
|
|
|
|
|
$argc++;
|
2006-03-29 03:58:00 +08:00
|
|
|
}
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
$argc = 0;
|
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
foreach $arg (@outargs) {
|
2006-03-30 07:56:07 +08:00
|
|
|
my ($pspec, $postproc) = &generate_pspec($arg);
|
|
|
|
my $argc = 0;
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
if (exists $arg->{nopdb}) {
|
|
|
|
$argc--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$pspec =~ s/^/' ' x length(" gimp_procedure_add_return_value (")/meg;
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
$out->{register} .= <<CODE;
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2006-03-29 03:58:00 +08:00
|
|
|
${pspec});
|
|
|
|
CODE
|
2006-03-30 07:56:07 +08:00
|
|
|
|
2024-10-25 07:31:30 +08:00
|
|
|
if ($postproc ne '') {
|
|
|
|
$pspec = "procedure->values[$argc]";
|
|
|
|
$postproc =~ s/^/' '/meg;
|
|
|
|
$out->{register} .= eval qq/"$postproc"/;
|
|
|
|
}
|
|
|
|
}
|
2006-03-30 07:56:07 +08:00
|
|
|
|
|
|
|
$argc++;
|
2006-03-29 03:58:00 +08:00
|
|
|
}
|
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
$out->{register} .= <<CODE;
|
2006-04-26 17:13:47 +08:00
|
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
2006-04-07 16:16:26 +08:00
|
|
|
g_object_unref (procedure);
|
1998-10-24 13:19:30 +08:00
|
|
|
CODE
|
|
|
|
|
|
|
|
if (exists $proc->{invoke}->{headers}) {
|
1999-03-18 07:08:08 +08:00
|
|
|
foreach $header (@{$proc->{invoke}->{headers}}) {
|
1998-10-24 13:19:30 +08:00
|
|
|
$out->{headers}->{$header}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
$out->{code} .= "\nstatic GimpValueArray *\n";
|
2012-05-29 01:55:28 +08:00
|
|
|
$out->{code} .= "${name}_invoker (GimpProcedure *procedure,\n";
|
2012-05-04 06:50:23 +08:00
|
|
|
$out->{code} .= ' ' x length($name) . " Gimp *gimp,\n";
|
|
|
|
$out->{code} .= ' ' x length($name) . " GimpContext *context,\n";
|
|
|
|
$out->{code} .= ' ' x length($name) . " GimpProgress *progress,\n";
|
|
|
|
$out->{code} .= ' ' x length($name) . " const GimpValueArray *args,\n";
|
|
|
|
$out->{code} .= ' ' x length($name) . " GError **error)\n{\n";
|
1998-10-24 13:19:30 +08:00
|
|
|
|
1999-03-21 10:14:08 +08:00
|
|
|
my $code = "";
|
|
|
|
|
2006-03-28 03:32:19 +08:00
|
|
|
if (exists $proc->{invoke}->{no_marshalling}) {
|
|
|
|
$code .= &format_code_frag($proc->{invoke}->{code}, 0) . "}\n";
|
1999-05-01 05:11:27 +08:00
|
|
|
}
|
1998-10-24 13:19:30 +08:00
|
|
|
else {
|
1999-03-21 10:14:08 +08:00
|
|
|
my $invoker = "";
|
2022-09-06 07:28:35 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
$invoker .= ' ' x 2 . "GimpValueArray *return_vals;\n" if scalar @outargs;
|
2006-03-15 23:32:39 +08:00
|
|
|
$invoker .= &declare_args($proc, $out, 0, qw(inargs));
|
|
|
|
$invoker .= &declare_args($proc, $out, 1, qw(outargs));
|
1999-03-21 10:14:08 +08:00
|
|
|
|
|
|
|
$invoker .= &marshal_inargs($proc, 0);
|
|
|
|
$invoker .= "\n" if $invoker && $invoker !~ /\n\n/s;
|
1998-10-24 13:19:30 +08:00
|
|
|
|
1999-03-28 14:36:11 +08:00
|
|
|
my $frag = "";
|
1999-03-21 10:14:08 +08:00
|
|
|
|
1999-03-28 14:36:11 +08:00
|
|
|
if (exists $proc->{invoke}->{code}) {
|
|
|
|
$frag = &format_code_frag($proc->{invoke}->{code}, $success);
|
|
|
|
$frag = ' ' x 2 . "if (success)\n" . $frag if $success;
|
|
|
|
$success = ($frag =~ /success =/) unless $success;
|
|
|
|
}
|
1999-03-21 10:14:08 +08:00
|
|
|
|
1999-03-28 14:36:11 +08:00
|
|
|
chomp $invoker if !$frag;
|
1999-03-21 10:14:08 +08:00
|
|
|
$code .= $invoker . $frag;
|
|
|
|
$code .= "\n" if $frag =~ /\n\n/s || $invoker;
|
|
|
|
$code .= &marshal_outargs($proc) . "}\n";
|
|
|
|
}
|
1998-10-24 13:19:30 +08:00
|
|
|
|
1999-03-11 02:56:56 +08:00
|
|
|
if ($success) {
|
1999-04-04 13:59:08 +08:00
|
|
|
$out->{code} .= ' ' x 2 . "gboolean success";
|
|
|
|
unless ($proc->{invoke}->{success} eq 'NONE') {
|
|
|
|
$out->{code} .= " = $proc->{invoke}->{success}";
|
|
|
|
}
|
|
|
|
$out->{code} .= ";\n";
|
1999-03-11 02:56:56 +08:00
|
|
|
}
|
|
|
|
|
1999-03-21 10:14:08 +08:00
|
|
|
$out->{code} .= $code;
|
1998-10-24 13:19:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
my $gpl = <<'GPL';
|
2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-07-03 08:47:26 +08:00
|
|
|
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
|
1998-10-24 13:19:30 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-10-24 13:19:30 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1998-10-24 13:19:30 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1998-10-24 13:19:30 +08:00
|
|
|
*/
|
|
|
|
|
2007-01-09 18:52:47 +08:00
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl. */
|
1999-03-11 07:34:26 +08:00
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
GPL
|
|
|
|
|
2001-05-10 01:46:28 +08:00
|
|
|
my $group_procs = "";
|
|
|
|
my $longest = 0;
|
|
|
|
my $once = 0;
|
|
|
|
my $pcount = 0.0;
|
|
|
|
|
1998-10-24 13:19:30 +08:00
|
|
|
foreach $group (@main::groups) {
|
|
|
|
my $out = $out{$group};
|
|
|
|
|
1999-04-04 13:59:08 +08:00
|
|
|
foreach (@{$main::grp{$group}->{headers}}) { $out->{headers}->{$_}++ }
|
2001-05-10 01:46:28 +08:00
|
|
|
|
2008-02-08 01:08:54 +08:00
|
|
|
$out->{headers}->{"\"core/gimpparamspecs.h\""}++;
|
|
|
|
|
1999-05-01 05:11:27 +08:00
|
|
|
my @headers = sort {
|
|
|
|
my ($x, $y) = ($a, $b);
|
|
|
|
foreach ($x, $y) {
|
2004-05-07 07:26:45 +08:00
|
|
|
if (/^</) {
|
|
|
|
s/^</!/;
|
|
|
|
}
|
|
|
|
elsif (!/libgimp/) {
|
|
|
|
s/^/~/;
|
|
|
|
}
|
1999-05-01 05:11:27 +08:00
|
|
|
}
|
|
|
|
$x cmp $y;
|
|
|
|
} keys %{$out->{headers}};
|
2008-02-08 01:08:54 +08:00
|
|
|
|
|
|
|
my $headers = "";
|
|
|
|
my $lib = 0;
|
|
|
|
my $seen = 0;
|
|
|
|
my $sys = 0;
|
|
|
|
my $base = 0;
|
2008-04-03 04:50:16 +08:00
|
|
|
my $error = 0;
|
2008-02-08 01:08:54 +08:00
|
|
|
my $utils = 0;
|
2010-09-05 04:31:58 +08:00
|
|
|
my $context = 0;
|
2008-04-03 04:50:16 +08:00
|
|
|
my $intl = 0;
|
2008-02-08 01:08:54 +08:00
|
|
|
|
1999-05-01 05:11:27 +08:00
|
|
|
foreach (@headers) {
|
|
|
|
$seen++ if /^</;
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2004-05-07 07:26:45 +08:00
|
|
|
if ($sys == 0 && !/^</) {
|
|
|
|
$sys = 1;
|
2008-02-08 01:08:54 +08:00
|
|
|
$headers .= "\n" if $seen;
|
2008-10-10 04:24:04 +08:00
|
|
|
$headers .= "#include <gegl.h>\n\n";
|
2012-05-03 09:36:22 +08:00
|
|
|
$headers .= "#include <gdk-pixbuf/gdk-pixbuf.h>\n\n";
|
2004-05-07 07:26:45 +08:00
|
|
|
}
|
2001-05-10 01:46:28 +08:00
|
|
|
|
2004-05-07 07:26:45 +08:00
|
|
|
$seen = 0 if !/^</;
|
2001-05-10 01:46:28 +08:00
|
|
|
|
2004-05-07 07:26:45 +08:00
|
|
|
if (/libgimp/) {
|
|
|
|
$lib = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$headers .= "\n" if $lib;
|
|
|
|
$lib = 0;
|
2001-08-17 22:27:31 +08:00
|
|
|
|
2004-05-07 07:26:45 +08:00
|
|
|
if ($sys == 1 && $base == 0) {
|
|
|
|
$base = 1;
|
2012-05-04 06:50:23 +08:00
|
|
|
$headers .= "#include \"libgimpbase/gimpbase.h\"\n\n";
|
2008-02-08 01:08:54 +08:00
|
|
|
$headers .= "#include \"pdb-types.h\"\n\n";
|
2004-05-07 07:26:45 +08:00
|
|
|
}
|
|
|
|
}
|
1999-05-01 05:11:27 +08:00
|
|
|
|
2008-02-08 01:08:54 +08:00
|
|
|
if (/gimp-intl/) {
|
|
|
|
$intl = 1;
|
|
|
|
}
|
|
|
|
elsif (/gimppdb-utils/) {
|
|
|
|
$utils = 1;
|
|
|
|
}
|
2008-04-03 04:50:16 +08:00
|
|
|
elsif (/gimppdberror/) {
|
|
|
|
$error = 1;
|
|
|
|
}
|
2010-09-05 04:31:58 +08:00
|
|
|
elsif (/gimppdbcontext/) {
|
|
|
|
$context = 1;
|
|
|
|
}
|
2008-02-08 01:08:54 +08:00
|
|
|
else {
|
|
|
|
$headers .= "#include $_\n";
|
|
|
|
}
|
1999-04-23 14:55:37 +08:00
|
|
|
}
|
1999-04-04 13:59:08 +08:00
|
|
|
|
2008-02-08 01:08:54 +08:00
|
|
|
$headers .= "\n";
|
|
|
|
$headers .= "#include \"gimppdb.h\"\n";
|
2008-04-03 04:50:16 +08:00
|
|
|
$headers .= "#include \"gimppdberror.h\"\n" if $error;
|
2008-02-08 01:08:54 +08:00
|
|
|
$headers .= "#include \"gimppdb-utils.h\"\n" if $utils;
|
2010-09-05 04:31:58 +08:00
|
|
|
$headers .= "#include \"gimppdbcontext.h\"\n" if $context;
|
2008-02-08 01:08:54 +08:00
|
|
|
$headers .= "#include \"gimpprocedure.h\"\n";
|
2008-04-04 19:15:55 +08:00
|
|
|
$headers .= "#include \"internal-procs.h\"\n";
|
2008-02-08 01:08:54 +08:00
|
|
|
|
|
|
|
$headers .= "\n#include \"gimp-intl.h\"\n" if $intl;
|
2006-11-01 03:02:56 +08:00
|
|
|
|
1999-04-04 13:59:08 +08:00
|
|
|
my $extra = {};
|
|
|
|
if (exists $main::grp{$group}->{extra}->{app}) {
|
|
|
|
$extra = $main::grp{$group}->{extra}->{app}
|
|
|
|
}
|
|
|
|
|
2011-11-07 00:33:20 +08:00
|
|
|
my $cfile = "$builddir/".canonicalize(${group})."-cmds.c$FILE_EXT";
|
1999-07-09 01:22:22 +08:00
|
|
|
open CFILE, "> $cfile" or die "Can't open $cfile: $!\n";
|
1998-10-24 13:19:30 +08:00
|
|
|
print CFILE $gpl;
|
2000-12-29 23:22:01 +08:00
|
|
|
print CFILE qq/#include "config.h"\n\n/;
|
2022-03-28 21:13:17 +08:00
|
|
|
print CFILE qq/#include "stamp-pdbgen.h"\n\n/;
|
1999-04-04 13:59:08 +08:00
|
|
|
print CFILE $headers, "\n";
|
|
|
|
print CFILE $extra->{decls}, "\n" if exists $extra->{decls};
|
|
|
|
print CFILE "\n", $extra->{code} if exists $extra->{code};
|
1998-10-24 13:19:30 +08:00
|
|
|
print CFILE $out->{code};
|
2006-04-26 17:13:47 +08:00
|
|
|
print CFILE "\nvoid\nregister_${group}_procs (GimpPDB *pdb)\n";
|
|
|
|
print CFILE "{\n GimpProcedure *procedure;\n$out->{register}}\n";
|
1998-10-24 13:19:30 +08:00
|
|
|
close CFILE;
|
2011-11-07 00:33:20 +08:00
|
|
|
&write_file($cfile, $destdir);
|
1998-10-24 13:19:30 +08:00
|
|
|
|
|
|
|
my $decl = "register_${group}_procs";
|
|
|
|
push @group_decls, $decl;
|
|
|
|
$longest = length $decl if $longest < length $decl;
|
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
$group_procs .= ' ' x 2 . "register_${group}_procs (pdb);\n";
|
1998-10-24 13:19:30 +08:00
|
|
|
$pcount += $out->{pcount};
|
|
|
|
}
|
|
|
|
|
1999-04-28 15:03:35 +08:00
|
|
|
if (! $ENV{PDBGEN_GROUPS}) {
|
2011-11-07 00:33:20 +08:00
|
|
|
my $internal = "$builddir/internal-procs.h$FILE_EXT";
|
2002-03-14 02:41:07 +08:00
|
|
|
open IFILE, "> $internal" or die "Can't open $internal: $!\n";
|
1999-04-23 14:55:37 +08:00
|
|
|
print IFILE $gpl;
|
|
|
|
my $guard = "__INTERNAL_PROCS_H__";
|
|
|
|
print IFILE <<HEADER;
|
|
|
|
#ifndef $guard
|
|
|
|
#define $guard
|
|
|
|
|
2006-11-01 03:02:56 +08:00
|
|
|
HEADER
|
|
|
|
|
|
|
|
print IFILE "void internal_procs_init" . ' ' x ($longest - length "internal_procs_init") . " (GimpPDB *pdb);\n\n";
|
|
|
|
|
|
|
|
print IFILE "/* Forward declarations for registering PDB procs */\n\n";
|
|
|
|
foreach (@group_decls) {
|
|
|
|
print IFILE "void $_" . ' ' x ($longest - length $_) . " (GimpPDB *pdb);\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print IFILE <<HEADER;
|
1999-04-23 14:55:37 +08:00
|
|
|
|
|
|
|
#endif /* $guard */
|
|
|
|
HEADER
|
|
|
|
close IFILE;
|
2011-11-07 00:33:20 +08:00
|
|
|
&write_file($internal, $destdir);
|
1999-04-23 14:55:37 +08:00
|
|
|
|
2011-11-07 00:33:20 +08:00
|
|
|
$internal = "$builddir/internal-procs.c$FILE_EXT";
|
2002-03-14 02:41:07 +08:00
|
|
|
open IFILE, "> $internal" or die "Can't open $internal: $!\n";
|
1999-04-23 14:55:37 +08:00
|
|
|
print IFILE $gpl;
|
|
|
|
print IFILE qq@#include "config.h"\n\n@;
|
2022-03-28 21:13:17 +08:00
|
|
|
print IFILE qq/#include "stamp-pdbgen.h"\n\n/;
|
2001-08-17 22:27:31 +08:00
|
|
|
print IFILE qq@#include <glib-object.h>\n\n@;
|
|
|
|
print IFILE qq@#include "pdb-types.h"\n\n@;
|
2006-04-26 17:13:47 +08:00
|
|
|
print IFILE qq@#include "gimppdb.h"\n\n@;
|
2008-04-04 19:15:55 +08:00
|
|
|
print IFILE qq@#include "internal-procs.h"\n\n@;
|
1999-04-23 14:55:37 +08:00
|
|
|
chop $group_procs;
|
1999-04-27 12:33:41 +08:00
|
|
|
print IFILE "\n/* $total procedures registered total */\n\n";
|
2001-10-20 00:41:09 +08:00
|
|
|
print IFILE <<BODY;
|
|
|
|
void
|
2006-04-26 17:13:47 +08:00
|
|
|
internal_procs_init (GimpPDB *pdb)
|
2001-10-20 00:41:09 +08:00
|
|
|
{
|
2006-04-26 17:13:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PDB (pdb));
|
2004-03-27 00:38:44 +08:00
|
|
|
|
2001-10-20 00:41:09 +08:00
|
|
|
$group_procs
|
|
|
|
}
|
|
|
|
BODY
|
1999-04-23 14:55:37 +08:00
|
|
|
close IFILE;
|
2011-11-07 00:33:20 +08:00
|
|
|
&write_file($internal, $destdir);
|
1998-10-24 13:19:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|