2006-12-09 13:33:38 -08:00
|
|
|
# GIMP - The GNU Image Manipulation Program
|
2003-07-02 17:47:26 -07:00
|
|
|
# Copyright (C) 1998-2003 Manish Singh <yosh@gimp.org>
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2009-01-17 14:28:01 -08:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
1998-10-23 22:19:30 -07:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1998-10-23 22:19:30 -07: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-11 14:27:07 -07:00
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1998-10-23 22:19:30 -07:00
|
|
|
|
|
|
|
|
package Gimp::CodeGen::lib;
|
|
|
|
|
|
|
|
|
|
# Generates all the libgimp C wrappers (used by plugins)
|
2011-11-06 08:33:20 -08:00
|
|
|
$destdir = "$main::destdir/libgimp";
|
|
|
|
|
$builddir = "$main::builddir/libgimp";
|
1998-10-23 22:19:30 -07:00
|
|
|
|
|
|
|
|
*arg_types = \%Gimp::CodeGen::pdb::arg_types;
|
|
|
|
|
*arg_parse = \&Gimp::CodeGen::pdb::arg_parse;
|
|
|
|
|
|
1999-07-28 16:00:08 -07:00
|
|
|
*enums = \%Gimp::CodeGen::enums::enums;
|
|
|
|
|
|
1998-10-23 22:19:30 -07:00
|
|
|
*write_file = \&Gimp::CodeGen::util::write_file;
|
1999-03-10 10:56:56 -08:00
|
|
|
*FILE_EXT = \$Gimp::CodeGen::util::FILE_EXT;
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2000-08-24 16:06:53 -07:00
|
|
|
use Text::Wrap qw(wrap);
|
|
|
|
|
|
|
|
|
|
sub desc_wrap {
|
|
|
|
|
my ($str) = @_;
|
|
|
|
|
my $leading = ' * ';
|
2013-10-04 23:48:39 -07:00
|
|
|
my $wrapped;
|
|
|
|
|
|
2019-07-31 03:16:38 -07:00
|
|
|
$str =~ s/\s+$//; # trim trailing whitespace
|
2003-02-06 10:51:44 -08:00
|
|
|
$str =~ s/&/&\;/g;
|
|
|
|
|
$str =~ s/\</<\;/g;
|
|
|
|
|
$str =~ s/\>/>\;/g;
|
2000-08-24 16:06:53 -07:00
|
|
|
$Text::Wrap::columns = 72;
|
2013-10-04 23:48:39 -07:00
|
|
|
$wrapped = wrap($leading, $leading, $str);
|
|
|
|
|
$wrapped =~ s/[ \t]+\n/\n/g;
|
|
|
|
|
return $wrapped;
|
2000-08-24 16:06:53 -07:00
|
|
|
}
|
|
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
sub generate_fun {
|
2019-09-03 04:31:27 -07:00
|
|
|
my ($proc, $out) = @_;
|
2019-08-12 05:44:07 -07:00
|
|
|
my @inargs = @{$proc->{inargs}} if (defined $proc->{inargs});
|
|
|
|
|
my @outargs = @{$proc->{outargs}} if (defined $proc->{outargs});
|
1998-10-23 22:19:30 -07:00
|
|
|
|
1999-03-10 10:56:56 -08:00
|
|
|
sub libtype {
|
2000-01-01 16:16:47 -08:00
|
|
|
my $arg = shift;
|
2006-04-02 09:03:32 -07:00
|
|
|
my $outarg = shift;
|
2000-01-01 16:16:47 -08:00
|
|
|
my ($type, $name) = &arg_parse($arg->{type});
|
|
|
|
|
my $argtype = $arg_types{$type};
|
2006-04-02 09:03:32 -07:00
|
|
|
my $rettype = '';
|
2019-08-12 05:44:07 -07:00
|
|
|
|
2000-01-01 16:16:47 -08:00
|
|
|
if ($type eq 'enum') {
|
|
|
|
|
return "$name ";
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-02 09:03:32 -07:00
|
|
|
if ($outarg) {
|
|
|
|
|
$rettype .= $argtype->{type};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (exists $argtype->{struct}) {
|
|
|
|
|
$rettype .= 'const ';
|
|
|
|
|
}
|
|
|
|
|
$rettype .= $argtype->{const_type};
|
|
|
|
|
}
|
2019-08-12 05:44:07 -07:00
|
|
|
|
2000-01-01 16:16:47 -08:00
|
|
|
$rettype =~ s/int32/int/ unless exists $arg->{keep_size};
|
2001-01-25 06:38:10 -08:00
|
|
|
$rettype .= '*' if exists $argtype->{struct};
|
2000-01-01 16:16:47 -08:00
|
|
|
return $rettype;
|
1999-03-10 10:56:56 -08:00
|
|
|
}
|
|
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
my $funcname = "gimp_$name";
|
|
|
|
|
my $wrapped = "";
|
2019-08-12 09:00:44 -07:00
|
|
|
my $new_funcname = $funcname;
|
2019-08-12 05:44:07 -07:00
|
|
|
my %usednames;
|
|
|
|
|
my $retdesc = " * Returns:";
|
|
|
|
|
my $func_annotations = "";
|
2012-05-02 16:12:25 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if ($proc->{lib_private}) {
|
|
|
|
|
$wrapped = '_';
|
|
|
|
|
}
|
1999-03-10 10:56:56 -08:00
|
|
|
|
2022-06-27 04:40:27 -07:00
|
|
|
$skip_gi = '';
|
|
|
|
|
if ($proc->{skip_gi}) {
|
|
|
|
|
$skip_gi = ' (skip)';
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
if ($proc->{deprecated}) {
|
2019-08-12 05:44:07 -07:00
|
|
|
if ($proc->{deprecated} eq 'NONE') {
|
|
|
|
|
push @{$out->{protos}}, "GIMP_DEPRECATED\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
my $underscores = $proc->{deprecated};
|
|
|
|
|
$underscores =~ s/-/_/g;
|
|
|
|
|
|
|
|
|
|
push @{$out->{protos}}, "GIMP_DEPRECATED_FOR($underscores)\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-08-24 16:06:53 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
# Find the return argument (defaults to the first arg if not
|
|
|
|
|
# explicitly set
|
|
|
|
|
my $retarg = undef;
|
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 00:48:14 -07:00
|
|
|
my $retarg_len = undef;
|
2019-08-12 05:44:07 -07:00
|
|
|
$retvoid = 0;
|
|
|
|
|
foreach (@outargs) {
|
|
|
|
|
$retarg = $_, last if exists $_->{retval};
|
|
|
|
|
}
|
2019-07-31 03:54:51 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
unless ($retarg) {
|
|
|
|
|
if (scalar @outargs) {
|
|
|
|
|
if (exists $outargs[0]->{void_ret}) {
|
|
|
|
|
$retvoid = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$retarg = exists $outargs[0]->{num} ? $outargs[1]
|
|
|
|
|
: $outargs[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-04 13:09:04 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
my $rettype;
|
|
|
|
|
if ($retarg) {
|
|
|
|
|
my ($type) = &arg_parse($retarg->{type});
|
|
|
|
|
my $argtype = $arg_types{$type};
|
|
|
|
|
my $annotate = "";
|
2019-09-03 04:31:27 -07:00
|
|
|
$rettype = &libtype($retarg, 1);
|
2019-08-12 05:44:07 -07:00
|
|
|
chop $rettype unless $rettype =~ /\*$/;
|
2012-12-04 12:01:13 -08:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$retarg->{retval} = 1;
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if (exists $argtype->{array}) {
|
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 00:48:14 -07:00
|
|
|
$retarg_len = $retarg->{array}->{name};
|
|
|
|
|
$annotate = " (array length=$retarg_len)";
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
2025-06-12 03:52:19 -07:00
|
|
|
|
2025-06-12 04:16:07 -07:00
|
|
|
if (exists $retarg->{none_ok} && $type ne 'sample_point' && $type ne 'guide') {
|
2019-08-24 14:02:35 -07:00
|
|
|
$annotate .= " (nullable)";
|
|
|
|
|
}
|
2019-07-30 01:51:16 -07:00
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
if (exists $argtype->{out_annotate}) {
|
2019-08-12 05:44:07 -07:00
|
|
|
$annotate .= " $argtype->{out_annotate}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($annotate eq "") {
|
|
|
|
|
$retdesc .= " $retarg->{desc}";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (exists $retarg->{desc}) {
|
|
|
|
|
if ((length ($annotate) +
|
|
|
|
|
length ($retarg->{desc})) > 65) {
|
|
|
|
|
$retdesc .= $annotate . ":\n * " . $retarg->{desc};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$retdesc .= $annotate . ": " . $retarg->{desc};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unless ($retdesc =~ /[\.\!\?]$/) { $retdesc .= '.' }
|
|
|
|
|
|
2024-10-23 13:50:45 -07:00
|
|
|
my $array_test = $retarg->{type};
|
|
|
|
|
$array_test =~ s/array$//g;
|
|
|
|
|
if ($retarg->{type} eq 'colorarray') {
|
|
|
|
|
$retdesc .= "\n * The returned value must be freed with gimp_color_array_free().";
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
2020-12-23 12:15:43 -08:00
|
|
|
elsif ($retarg->{type} eq 'strv') {
|
2019-08-12 05:44:07 -07:00
|
|
|
$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().";
|
|
|
|
|
}
|
2024-10-23 13:50:45 -07:00
|
|
|
elsif ($retarg->{type} eq 'string' || $retarg->{type} ne $array_test) {
|
2019-08-12 05:44:07 -07:00
|
|
|
$retdesc .= "\n * The returned value must be freed with g_free().";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
# No return values
|
|
|
|
|
$rettype = 'void';
|
|
|
|
|
}
|
2019-08-08 04:01:50 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
# The parameters to the function
|
|
|
|
|
my $arglist = "";
|
|
|
|
|
my $argdesc = "";
|
|
|
|
|
my $sincedesc = "";
|
2024-10-25 07:56:48 -07:00
|
|
|
my $inargs_testing = "";
|
2019-08-12 05:44:07 -07:00
|
|
|
my $value_array = "";
|
|
|
|
|
my $arg_array = "";
|
|
|
|
|
my $argc = 0;
|
|
|
|
|
foreach (@inargs) {
|
|
|
|
|
my ($type, @typeinfo) = &arg_parse($_->{type});
|
|
|
|
|
my $arg = $arg_types{$type};
|
|
|
|
|
my $var = $_->{name};
|
|
|
|
|
my $desc = exists $_->{desc} ? $_->{desc} : "";
|
|
|
|
|
my $var_len;
|
|
|
|
|
my $value;
|
2025-06-12 03:52:19 -07:00
|
|
|
my $n_annotations = 0;
|
2019-08-12 05:44:07 -07:00
|
|
|
|
2024-10-24 16:31:30 -07:00
|
|
|
if (exists $_->{nopdb}) {
|
|
|
|
|
$argc--;
|
2024-10-25 07:56:48 -07:00
|
|
|
|
|
|
|
|
if (defined $typeinfo[0]) {
|
|
|
|
|
$min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
|
|
|
|
|
# gsize is positive, no need to test for >= 0.
|
|
|
|
|
if ($min > 0) {
|
|
|
|
|
if ($rettype eq 'void') {
|
|
|
|
|
# void rettype is in fact boolean.
|
|
|
|
|
$inargs_testing .= "\n" . ' ' x 2 . "g_return_val_if_fail ($_->{name} >= $min, FALSE);";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
# TODO: I should in fact test the exact return
|
|
|
|
|
# type. E.g. it could be int or float. But since
|
|
|
|
|
# we have no such case (while also generating in
|
|
|
|
|
# argument testing) so far, I took the easy way
|
|
|
|
|
# out. To be completed if needed.
|
|
|
|
|
$inargs_testing .= "\n" . ' ' x 2 . "g_return_val_if_fail ($_->{name} >= $min, NULL);";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (defined $typeinfo[2]) {
|
|
|
|
|
$max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
|
|
|
|
|
if ($rettype eq 'void') {
|
|
|
|
|
$inargs_testing .= "\n" . ' ' x 2 . "g_return_val_if_fail ($_->{name} <= $max, FALSE);";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$inargs_testing .= "\n" . ' ' x 2 . "g_return_val_if_fail ($_->{name} <= $max, NULL);";
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
|
|
|
|
else {
|
2024-10-24 16:31:30 -07:00
|
|
|
# This gets passed to gimp_value_array_new_with_types()
|
|
|
|
|
if ($type 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/;
|
|
|
|
|
$enum_type =~ s/^GEGL/GEGL_TYPE/;
|
|
|
|
|
|
|
|
|
|
$value_array .= "$enum_type, ";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$value_array .= "$arg->{gtype}, ";
|
|
|
|
|
}
|
2019-08-12 05:44:07 -07:00
|
|
|
|
2024-10-24 16:31:30 -07:00
|
|
|
if (exists $_->{array}) {
|
|
|
|
|
$value_array .= "NULL";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$value_array .= "$var";
|
|
|
|
|
}
|
2019-08-12 05:44:07 -07:00
|
|
|
|
2024-10-24 16:31:30 -07:00
|
|
|
$value_array .= ",\n" . " " x 42;
|
|
|
|
|
}
|
2019-08-12 05:44:07 -07:00
|
|
|
|
|
|
|
|
if (exists $_->{array}) {
|
|
|
|
|
my $arrayarg = $_->{array};
|
|
|
|
|
|
|
|
|
|
$value = "gimp_value_array_index (args, $argc)";
|
|
|
|
|
|
|
|
|
|
if (exists $arrayarg->{name}) {
|
|
|
|
|
$var_len = $arrayarg->{name};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$var_len = 'num_' . $_->{name};
|
|
|
|
|
}
|
2019-07-30 01:51:16 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
# This is the list of g_value_set_foo_array
|
|
|
|
|
$arg_array .= eval qq/" $arg->{set_value_func};\n"/;
|
|
|
|
|
}
|
2019-07-30 01:51:16 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$usednames{$_->{name}}++;
|
2019-08-08 04:01:50 -07:00
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
$arglist .= &libtype($_, 0);
|
2019-08-12 05:44:07 -07:00
|
|
|
$arglist .= $_->{name};
|
|
|
|
|
$arglist .= ', ';
|
2019-07-30 01:51:16 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$argdesc .= " * \@$_->{name}";
|
|
|
|
|
$argdesc .= ":";
|
2019-07-30 01:51:16 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if (exists $arg->{array}) {
|
2024-10-24 16:31:30 -07:00
|
|
|
$argdesc .= " (array length=$var_len)";
|
2025-06-12 03:52:19 -07:00
|
|
|
$n_annotations++;
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
2000-06-22 13:06:02 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if (exists $arg->{in_annotate}) {
|
|
|
|
|
$argdesc .= " $arg->{in_annotate}";
|
2025-06-12 03:52:19 -07:00
|
|
|
$n_annotations++;
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
2025-06-12 03:52:19 -07:00
|
|
|
|
2025-06-12 04:16:07 -07:00
|
|
|
if (exists $_->{none_ok} && $type ne 'sample_point' && $type ne 'guide') {
|
2019-08-24 14:02:35 -07:00
|
|
|
$argdesc .= " (nullable)";
|
2025-06-12 03:52:19 -07:00
|
|
|
$n_annotations++;
|
2019-08-24 14:02:35 -07:00
|
|
|
}
|
2006-03-26 10:15:58 -08:00
|
|
|
|
2025-06-12 03:52:19 -07:00
|
|
|
if ($n_annotations > 0) {
|
2019-08-12 05:44:07 -07:00
|
|
|
$argdesc .= ":";
|
|
|
|
|
}
|
2019-07-31 09:58:52 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$argdesc .= " $desc";
|
2019-07-31 10:08:01 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
unless ($argdesc =~ /[\.\!\?]$/) { $argdesc .= '.' }
|
|
|
|
|
$argdesc .= "\n";
|
2019-07-31 09:58:52 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$argc++;
|
|
|
|
|
}
|
2019-07-31 13:51:35 -07:00
|
|
|
|
2024-10-25 07:56:48 -07:00
|
|
|
if ($inargs_testing ne "") {
|
|
|
|
|
$inargs_testing .= "\n";
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
# This marshals the return value(s)
|
|
|
|
|
my $return_args = "";
|
|
|
|
|
my $return_marshal = "gimp_value_array_unref (return_vals);";
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
# return success/failure boolean if we don't have anything else
|
|
|
|
|
if ($rettype eq 'void') {
|
|
|
|
|
$return_args .= "\n" . ' ' x 2 . "gboolean success = TRUE;";
|
|
|
|
|
$retdesc .= " TRUE on success.";
|
|
|
|
|
}
|
2019-07-31 09:58:52 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
# We only need to bother with this if we have to return a value
|
|
|
|
|
if ($rettype ne 'void' || $retvoid) {
|
|
|
|
|
my $once = 0;
|
|
|
|
|
my $firstvar;
|
|
|
|
|
my @initnums;
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
foreach (@outargs) {
|
|
|
|
|
my ($type) = &arg_parse($_->{type});
|
|
|
|
|
my $arg = $arg_types{$type};
|
|
|
|
|
my $var;
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$return_marshal = "" unless $once++;
|
2000-08-22 18:44:59 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$_->{libname} = exists $usednames{$_->{name}} ? "ret_$_->{name}"
|
|
|
|
|
: $_->{name};
|
1999-03-10 10:56:56 -08:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if (exists $_->{num}) {
|
|
|
|
|
if (!exists $_->{no_lib}) {
|
|
|
|
|
push @initnums, $_;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elsif (exists $_->{retval}) {
|
|
|
|
|
$return_args .= "\n" . ' ' x 2;
|
2019-09-03 04:31:27 -07:00
|
|
|
$return_args .= &libtype($_, 1);
|
2019-08-12 05:44:07 -07:00
|
|
|
|
|
|
|
|
# The return value variable
|
|
|
|
|
$var = $_->{libname};
|
|
|
|
|
$return_args .= $var;
|
|
|
|
|
|
|
|
|
|
# Save the first var to "return" it
|
|
|
|
|
$firstvar = $var unless defined $firstvar;
|
|
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
if ($_->{libdef}) {
|
2019-08-12 05:44:07 -07:00
|
|
|
$return_args .= " = $_->{libdef}";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return_args .= " = $arg->{init_value}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return_args .= ";";
|
|
|
|
|
|
|
|
|
|
if (exists $_->{array} && exists $_->{array}->{no_lib}) {
|
|
|
|
|
$return_args .= "\n" . ' ' x 2 . "gint num_$var;";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elsif ($retvoid) {
|
|
|
|
|
push @initnums, $_ unless exists $arg->{struct};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scalar(@initnums)) {
|
|
|
|
|
foreach (@initnums) {
|
|
|
|
|
$return_marshal .= "\*$_->{libname} = ";
|
|
|
|
|
my ($type) = &arg_parse($_->{type});
|
|
|
|
|
for ($arg_types{$type}->{type}) {
|
|
|
|
|
/\*$/ && do { $return_marshal .= "NULL"; last };
|
|
|
|
|
/boolean/ && do { $return_marshal .= "FALSE"; last };
|
|
|
|
|
/double/ && do { $return_marshal .= "0.0"; last };
|
|
|
|
|
$return_marshal .= "0";
|
|
|
|
|
}
|
|
|
|
|
$return_marshal .= ";\n ";
|
|
|
|
|
}
|
|
|
|
|
$return_marshal =~ s/\n $/\n\n /s;
|
|
|
|
|
}
|
1999-03-10 10:56:56 -08:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if ($rettype eq 'void') {
|
|
|
|
|
$return_marshal .= <<CODE;
|
2019-09-03 16:49:35 -07:00
|
|
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
2000-08-22 18:44:59 -07:00
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
CODE
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return_marshal .= <<CODE;
|
2019-09-03 16:49:35 -07:00
|
|
|
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
1998-10-23 22:19:30 -07:00
|
|
|
CODE
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return_marshal .= ' ' x 4 . "{\n" if $#outargs;
|
|
|
|
|
|
|
|
|
|
my $argc = 1; my ($numpos, $numtype);
|
|
|
|
|
foreach (@outargs) {
|
|
|
|
|
my ($type) = &arg_parse($_->{type});
|
|
|
|
|
my $desc = exists $_->{desc} ? $_->{desc} : "";
|
|
|
|
|
my $arg = $arg_types{$type};
|
|
|
|
|
my $var;
|
|
|
|
|
|
|
|
|
|
# The return value variable
|
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 00:48:14 -07:00
|
|
|
$var = "";
|
|
|
|
|
$var_len = $retarg_len;
|
2019-08-12 05:44:07 -07:00
|
|
|
|
|
|
|
|
unless (exists $_->{retval}) {
|
|
|
|
|
$var .= '*';
|
|
|
|
|
$arglist .= &libtype($_, 1);
|
|
|
|
|
$arglist .= '*' unless exists $arg->{struct};
|
|
|
|
|
$arglist .= "$_->{libname}";
|
|
|
|
|
$arglist .= ', ';
|
|
|
|
|
|
|
|
|
|
$argdesc .= " * \@$_->{libname}";
|
|
|
|
|
|
|
|
|
|
if ($arg->{name} eq 'COLOR') {
|
|
|
|
|
$argdesc .= ": (out caller-allocates)";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$argdesc .= ": (out)";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exists $arg->{array}) {
|
2024-10-24 16:31:30 -07:00
|
|
|
my $arrayarg = $_->{array};
|
|
|
|
|
if (exists $arrayarg->{name}) {
|
|
|
|
|
$var_len = $arrayarg->{name};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$var_len = 'num_' . $_->{libname};
|
|
|
|
|
}
|
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 00:48:14 -07:00
|
|
|
$argdesc .= " (array length=$var_len)";
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
|
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
if (exists $arg->{out_annotate}) {
|
2019-08-12 05:44:07 -07:00
|
|
|
$argdesc .= " $arg->{out_annotate}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$argdesc .= ": $desc";
|
|
|
|
|
}
|
1999-12-25 23:54:39 -08:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$var = exists $_->{retval} ? "" : '*';
|
|
|
|
|
$var .= $_->{libname};
|
1999-03-10 10:56:56 -08:00
|
|
|
|
2024-10-24 16:31:30 -07:00
|
|
|
if (exists $_->{nopdb}) {
|
|
|
|
|
$argc--;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 17:49:33 -07:00
|
|
|
$value = "return_vals, $argc";
|
2019-07-30 01:51:16 -07:00
|
|
|
|
2024-10-24 16:31:30 -07:00
|
|
|
if (! exists $_->{nopdb}) {
|
|
|
|
|
$return_marshal .= ' ' x 2 if $#outargs;
|
|
|
|
|
$return_marshal .= eval qq/" $arg->{dup_value_func};\n"/;
|
|
|
|
|
}
|
1999-03-10 10:56:56 -08:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if ($argdesc) {
|
|
|
|
|
unless ($argdesc =~ /[\.\!\?]$/) { $argdesc .= '.' }
|
|
|
|
|
unless ($argdesc =~ /\n$/) { $argdesc .= "\n" }
|
|
|
|
|
}
|
2019-07-31 10:19:06 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$argc++;
|
|
|
|
|
}
|
1999-03-10 10:56:56 -08:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$return_marshal .= ' ' x 4 . "}\n" if $#outargs;
|
1999-03-10 10:56:56 -08:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$return_marshal .= <<'CODE';
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2019-07-30 01:51:16 -07:00
|
|
|
gimp_value_array_unref (return_vals);
|
1998-10-23 22:19:30 -07:00
|
|
|
|
|
|
|
|
CODE
|
2019-08-12 05:44:07 -07:00
|
|
|
unless ($retvoid) {
|
|
|
|
|
$return_marshal .= ' ' x 2 . "return $firstvar;";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return_marshal .= ' ' x 2 . "return success;";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return_marshal = <<CODE;
|
2019-09-03 16:49:35 -07:00
|
|
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
2000-08-22 18:44:59 -07:00
|
|
|
|
|
|
|
|
$return_marshal
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
CODE
|
2000-08-24 16:06:53 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
chop $return_marshal;
|
|
|
|
|
}
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if ($arglist) {
|
|
|
|
|
my @arglist = split(/, /, $arglist);
|
|
|
|
|
my $longest = 0; my $seen = 0;
|
|
|
|
|
foreach (@arglist) {
|
|
|
|
|
/(const \w+) \S+/ || /(\w+) \S+/;
|
|
|
|
|
my $len = length($1);
|
|
|
|
|
my $num = scalar @{[ /\*/g ]};
|
|
|
|
|
$seen = $num if $seen < $num;
|
|
|
|
|
$longest = $len if $longest < $len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$longest += $seen;
|
|
|
|
|
|
|
|
|
|
my $once = 0; $arglist = "";
|
|
|
|
|
foreach (@arglist) {
|
|
|
|
|
my $space = rindex($_, ' ');
|
|
|
|
|
my $len = $longest - $space + 1;
|
|
|
|
|
$len -= scalar @{[ /\*/g ]};
|
|
|
|
|
substr($_, $space, 1) = ' ' x $len if $space != -1 && $len > 1;
|
|
|
|
|
$arglist .= "\t" if $once;
|
|
|
|
|
$arglist .= $_;
|
|
|
|
|
$arglist .= ",\n";
|
|
|
|
|
$once++;
|
|
|
|
|
}
|
|
|
|
|
$arglist =~ s/,\n$//;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$arglist = "void";
|
|
|
|
|
}
|
1999-04-22 23:55:37 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
$rettype = 'gboolean' if $rettype eq 'void';
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
# Our function prototype for the headers
|
|
|
|
|
(my $hrettype = $rettype) =~ s/ //g;
|
1999-04-22 23:55:37 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
my $proto = "$hrettype $wrapped$funcname ($arglist);\n";
|
|
|
|
|
$proto =~ s/ +/ /g;
|
2004-10-05 18:37:54 -07:00
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
push @{$out->{protos}}, $proto;
|
1999-04-22 23:55:37 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
my $clist = $arglist;
|
|
|
|
|
my $padlen = length($wrapped) + length($funcname) + 2;
|
|
|
|
|
my $padding = ' ' x $padlen;
|
|
|
|
|
$clist =~ s/\t/$padding/eg;
|
2000-08-22 18:44:59 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if ($proc->{since}) {
|
|
|
|
|
$sincedesc = "\n *\n * Since: $proc->{since}";
|
|
|
|
|
}
|
2004-05-13 12:59:11 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
my $procdesc = '';
|
2005-08-02 15:52:23 -07:00
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
if ($proc->{deprecated}) {
|
2026-02-01 17:12:10 -08:00
|
|
|
if (! $proc->{deprecated_since}) {
|
|
|
|
|
die "ERROR: missing 'deprecated_since' variable on $name.\n";
|
|
|
|
|
}
|
2026-02-01 13:33:49 -08:00
|
|
|
$deprecated_since = $proc->{deprecated_since};
|
2019-08-12 05:44:07 -07:00
|
|
|
if ($proc->{deprecated} eq 'NONE') {
|
|
|
|
|
if ($proc->{blurb}) {
|
|
|
|
|
$procdesc = &desc_wrap($proc->{blurb}) . "\n *\n";
|
|
|
|
|
}
|
|
|
|
|
if ($proc->{help}) {
|
|
|
|
|
$procdesc .= &desc_wrap($proc->{help}) . "\n *\n";
|
|
|
|
|
}
|
2026-02-01 13:33:49 -08:00
|
|
|
$procdesc .= &desc_wrap("Deprecated: $deprecated_since: There is no replacement " .
|
2019-08-12 05:44:07 -07:00
|
|
|
"for this procedure.");
|
|
|
|
|
}
|
|
|
|
|
else {
|
2026-02-01 10:19:55 -08:00
|
|
|
my $replacement = $proc->{deprecated};
|
|
|
|
|
chomp $replacement;
|
|
|
|
|
if ($replacement =~ / /) {
|
|
|
|
|
# Use the deprecated string as-is.
|
|
|
|
|
#$replacement =~ s/"/\\"/g;
|
|
|
|
|
}
|
|
|
|
|
elsif ($replacement =~ /:/) {
|
|
|
|
|
# Replacement is a GEGL operation.
|
|
|
|
|
$replacement = "filter \"$replacement\"";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
# Replacement is another function.
|
|
|
|
|
$replacement =~ s/-/_/g;
|
|
|
|
|
$replacement .= '()';
|
|
|
|
|
}
|
2019-08-12 05:44:07 -07:00
|
|
|
|
|
|
|
|
if ($proc->{blurb}) {
|
|
|
|
|
$procdesc = &desc_wrap($proc->{blurb}) . "\n *\n";
|
|
|
|
|
}
|
|
|
|
|
if ($proc->{help}) {
|
|
|
|
|
$procdesc .= &desc_wrap($proc->{help}) . "\n *\n";
|
|
|
|
|
}
|
2026-02-01 13:33:49 -08:00
|
|
|
$procdesc .= &desc_wrap("Deprecated: $deprecated_since: " .
|
2026-02-01 10:19:55 -08:00
|
|
|
"Use $replacement instead.");
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$procdesc = &desc_wrap($proc->{blurb}) . "\n *\n" .
|
|
|
|
|
&desc_wrap($proc->{help});
|
|
|
|
|
}
|
|
|
|
|
return <<CODE;
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2000-08-24 16:06:53 -07:00
|
|
|
/**
|
2022-06-27 04:40:27 -07:00
|
|
|
* $wrapped$funcname:$func_annotations$skip_gi
|
2000-08-24 16:06:53 -07:00
|
|
|
$argdesc *
|
2004-10-06 11:44:48 -07:00
|
|
|
$procdesc
|
2000-08-24 16:06:53 -07:00
|
|
|
*
|
2012-12-04 19:16:25 -08:00
|
|
|
$retdesc$sincedesc
|
2010-09-15 13:07:36 -07:00
|
|
|
**/
|
1998-10-23 22:19:30 -07:00
|
|
|
$rettype
|
2000-06-21 20:21:20 -07:00
|
|
|
$wrapped$funcname ($clist)
|
1998-10-23 22:19:30 -07:00
|
|
|
{
|
2019-07-30 01:51:16 -07:00
|
|
|
GimpValueArray *args;
|
|
|
|
|
GimpValueArray *return_vals;$return_args
|
2024-10-25 07:56:48 -07:00
|
|
|
$inargs_testing
|
2019-08-08 04:01:50 -07:00
|
|
|
args = gimp_value_array_new_from_types (NULL,
|
|
|
|
|
${value_array}G_TYPE_NONE);
|
2019-07-30 01:51:16 -07:00
|
|
|
$arg_array
|
2023-10-16 13:07:55 -07:00
|
|
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
|
|
|
"gimp-$proc->{canonical_name}",
|
|
|
|
|
args);
|
2019-07-30 01:51:16 -07:00
|
|
|
gimp_value_array_unref (args);
|
1998-10-23 22:19:30 -07:00
|
|
|
|
|
|
|
|
$return_marshal
|
|
|
|
|
}
|
|
|
|
|
CODE
|
2019-08-12 05:44:07 -07:00
|
|
|
}
|
|
|
|
|
|
2019-08-12 09:00:44 -07:00
|
|
|
sub generate_hbody {
|
2019-09-03 04:31:27 -07:00
|
|
|
my ($out, $extra) = @_;
|
2019-08-12 09:00:44 -07:00
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
if (exists $extra->{protos}) {
|
2019-08-12 09:00:44 -07:00
|
|
|
my $proto = "";
|
2019-09-03 04:31:27 -07:00
|
|
|
foreach (split(/\n/, $extra->{protos})) {
|
2019-08-12 09:00:44 -07:00
|
|
|
next if /^\s*$/;
|
|
|
|
|
|
|
|
|
|
if (/^\t/ && length($proto)) {
|
|
|
|
|
s/\s+/ /g; s/ $//; s/^ /\t/;
|
|
|
|
|
$proto .= $_ . "\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
2019-09-03 04:31:27 -07:00
|
|
|
push @{$out->{protos}}, $proto if length($proto);
|
2019-08-12 09:00:44 -07:00
|
|
|
|
|
|
|
|
s/\s+/ /g; s/^ //; s/ $//;
|
|
|
|
|
$proto = $_ . "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my @longest = (0, 0, 0); my @arglist = (); my $seen = 0;
|
2019-09-03 04:31:27 -07:00
|
|
|
foreach (@{$out->{protos}}) {
|
2019-08-12 09:00:44 -07:00
|
|
|
my $arglist;
|
|
|
|
|
|
|
|
|
|
if (!/^GIMP_DEPRECATED/) {
|
|
|
|
|
my $len;
|
|
|
|
|
|
|
|
|
|
$arglist = [ split(' ', $_, 3) ];
|
|
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
if ($arglist->[1] =~ /^_/) {
|
2019-08-12 09:00:44 -07:00
|
|
|
$arglist->[0] = "G_GNUC_INTERNAL ".$arglist->[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (0..1) {
|
|
|
|
|
$len = length($arglist->[$_]);
|
|
|
|
|
$longest[$_] = $len if $longest[$_] < $len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (split(/,/, $arglist->[2])) {
|
|
|
|
|
next unless /(const \w+) \S+/ || /(\w+) \S+/;
|
|
|
|
|
$len = length($1) + 1;
|
|
|
|
|
my $num = scalar @{[ /\*/g ]};
|
|
|
|
|
$seen = $num if $seen < $num;
|
|
|
|
|
$longest[2] = $len if $longest[2] < $len;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$arglist = $_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
push @arglist, $arglist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$longest[2] += $seen;
|
|
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
@{$out->{protos}} = ();
|
2019-08-12 09:00:44 -07:00
|
|
|
foreach (@arglist) {
|
|
|
|
|
my $arg;
|
|
|
|
|
|
|
|
|
|
if (ref) {
|
|
|
|
|
my ($type, $func, $arglist) = @$_;
|
|
|
|
|
|
|
|
|
|
my @args = split(/,/, $arglist); $arglist = "";
|
|
|
|
|
|
|
|
|
|
foreach (@args) {
|
|
|
|
|
$space = rindex($_, ' ');
|
|
|
|
|
if ($space > 0 && substr($_, $space - 1, 1) eq ')') {
|
|
|
|
|
$space = rindex($_, ' ', $space - 1)
|
|
|
|
|
}
|
|
|
|
|
my $len = $longest[2] - $space + 1;
|
|
|
|
|
|
|
|
|
|
$len -= scalar @{[ /\*/g ]};
|
|
|
|
|
$len++ if /\t/;
|
|
|
|
|
|
|
|
|
|
if ($space != -1 && $len > 1) {
|
|
|
|
|
substr($_, $space, 1) = ' ' x $len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$arglist .= $_;
|
|
|
|
|
$arglist .= "," if !/;\n$/;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$arg = $type;
|
|
|
|
|
$arg .= ' ' x ($longest[0] - length($type) + 1) . $func;
|
|
|
|
|
$arg .= ' ' x ($longest[1] - length($func) + 1) . $arglist;
|
|
|
|
|
$arg =~ s/\t/' ' x ($longest[0] + $longest[1] + 3)/eg;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$arg = $_;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
push @{$out->{protos}}, $arg;
|
2019-08-12 09:00:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my $body = '';
|
|
|
|
|
$body = $extra->{decls} if exists $extra->{decls};
|
2019-09-03 04:31:27 -07:00
|
|
|
foreach (@{$out->{protos}}) { $body .= $_ }
|
2019-08-12 09:00:44 -07:00
|
|
|
if ($out->{deprecated}) {
|
|
|
|
|
$body .= "#endif /* GIMP_DISABLE_DEPRECATED */\n";
|
|
|
|
|
}
|
|
|
|
|
chomp $body;
|
|
|
|
|
|
|
|
|
|
return $body;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-08-12 05:44:07 -07:00
|
|
|
sub generate {
|
|
|
|
|
my @procs = @{(shift)};
|
|
|
|
|
my %out;
|
|
|
|
|
|
|
|
|
|
foreach $name (@procs) {
|
|
|
|
|
my $proc = $main::pdb{$name};
|
|
|
|
|
my $out = \%{$out{$proc->{group}}};
|
|
|
|
|
|
|
|
|
|
my @inargs = @{$proc->{inargs}} if (defined $proc->{inargs});
|
|
|
|
|
my @outargs = @{$proc->{outargs}} if (defined $proc->{outargs});
|
|
|
|
|
|
2019-09-03 04:31:27 -07:00
|
|
|
$out->{code} .= generate_fun($proc, $out);
|
1998-10-23 22:19:30 -07:00
|
|
|
}
|
|
|
|
|
|
2000-05-31 14:16:11 -07:00
|
|
|
my $lgpl_top = <<'LGPL';
|
2000-05-31 06:24:14 -07:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2003-07-02 17:47:26 -07:00
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
1998-10-23 22:19:30 -07:00
|
|
|
*
|
2000-05-31 14:16:11 -07:00
|
|
|
LGPL
|
|
|
|
|
|
|
|
|
|
my $lgpl_bottom = <<'LGPL';
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
1999-12-25 23:54:39 -08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-10-23 22:19:30 -07:00
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-17 14:28:01 -08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2000-05-31 06:24:14 -07:00
|
|
|
*
|
|
|
|
|
* This library 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
|
1999-12-25 23:54:39 -08:00
|
|
|
* Lesser General Public License for more details.
|
1998-10-23 22:19:30 -07:00
|
|
|
*
|
1999-12-25 23:54:39 -08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-17 14:28:01 -08:00
|
|
|
* License along with this library. If not, see
|
2018-07-11 14:27:07 -07:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2000-05-31 14:16:11 -07:00
|
|
|
*/
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2007-01-09 02:52:47 -08:00
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl */
|
1999-03-10 15:34:26 -08:00
|
|
|
|
1998-10-23 22:19:30 -07:00
|
|
|
LGPL
|
|
|
|
|
|
2000-05-31 06:24:14 -07:00
|
|
|
# We generate two files, a _pdb.h file with prototypes for all
|
|
|
|
|
# the functions we make, and a _pdb.c file for the actual implementation
|
1998-10-23 22:19:30 -07:00
|
|
|
while (my($group, $out) = each %out) {
|
2011-03-08 04:58:56 -08:00
|
|
|
my $hname = "${group}pdb.h";
|
|
|
|
|
my $cname = "${group}pdb.c";
|
|
|
|
|
if ($group ne 'gimp') {
|
|
|
|
|
$hname = "gimp${hname}";
|
|
|
|
|
$cname = "gimp${cname}";
|
|
|
|
|
}
|
2000-05-31 14:16:11 -07:00
|
|
|
$hname =~ s/_//g; $hname =~ s/pdb\./_pdb./;
|
|
|
|
|
$cname =~ s/_//g; $cname =~ s/pdb\./_pdb./;
|
2011-11-06 08:33:20 -08:00
|
|
|
my $hfile = "$builddir/$hname$FILE_EXT";
|
|
|
|
|
my $cfile = "$builddir/$cname$FILE_EXT";
|
2019-08-12 09:00:44 -07:00
|
|
|
my $body;
|
1999-12-25 23:54:39 -08:00
|
|
|
|
1999-04-03 21:59:08 -08:00
|
|
|
my $extra = {};
|
|
|
|
|
if (exists $main::grp{$group}->{extra}->{lib}) {
|
|
|
|
|
$extra = $main::grp{$group}->{extra}->{lib}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-12 09:00:44 -07:00
|
|
|
$body = generate_hbody($out, $extra, "protos");
|
1998-10-23 22:19:30 -07:00
|
|
|
|
1999-12-25 23:54:39 -08:00
|
|
|
open HFILE, "> $hfile" or die "Can't open $hfile: $!\n";
|
2000-05-31 14:16:11 -07:00
|
|
|
print HFILE $lgpl_top;
|
|
|
|
|
print HFILE " * $hname\n";
|
|
|
|
|
print HFILE $lgpl_bottom;
|
2025-08-13 15:31:46 -07:00
|
|
|
my $guard = "__GIMP_\U$group\E_PDB_H__";
|
1998-10-23 22:19:30 -07:00
|
|
|
print HFILE <<HEADER;
|
2011-04-28 10:59:52 -07:00
|
|
|
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
|
|
|
|
|
#error "Only <libgimp/gimp.h> can be included directly."
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-08-13 15:31:46 -07:00
|
|
|
#ifndef $guard
|
|
|
|
|
#define $guard
|
|
|
|
|
|
2001-11-22 15:46:13 -08:00
|
|
|
G_BEGIN_DECLS
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2000-05-31 14:16:11 -07:00
|
|
|
/* For information look into the C source or the html documentation */
|
|
|
|
|
|
1998-10-23 22:19:30 -07:00
|
|
|
|
1999-04-03 21:59:08 -08:00
|
|
|
$body
|
1998-10-23 22:19:30 -07:00
|
|
|
|
2025-08-13 15:31:46 -07:00
|
|
|
|
2001-11-22 15:46:13 -08:00
|
|
|
G_END_DECLS
|
2025-08-13 15:31:46 -07:00
|
|
|
|
|
|
|
|
#endif /* $guard */
|
1998-10-23 22:19:30 -07:00
|
|
|
HEADER
|
|
|
|
|
close HFILE;
|
2011-11-06 08:33:20 -08:00
|
|
|
&write_file($hfile, $destdir);
|
1998-10-23 22:19:30 -07:00
|
|
|
|
|
|
|
|
open CFILE, "> $cfile" or die "Can't open $cfile: $!\n";
|
2000-05-31 14:16:11 -07:00
|
|
|
print CFILE $lgpl_top;
|
|
|
|
|
print CFILE " * $cname\n";
|
|
|
|
|
print CFILE $lgpl_bottom;
|
2002-05-13 16:30:23 -07:00
|
|
|
print CFILE qq/#include "config.h"\n\n/;
|
2022-03-28 06:13:17 -07:00
|
|
|
print CFILE qq/#include "stamp-pdbgen.h"\n\n/;
|
2001-03-18 04:51:37 -08:00
|
|
|
print CFILE $out->{headers}, "\n" if exists $out->{headers};
|
2000-05-31 14:16:11 -07:00
|
|
|
print CFILE qq/#include "gimp.h"\n/;
|
2019-08-01 07:06:54 -07:00
|
|
|
|
2019-08-07 09:43:21 -07:00
|
|
|
if (exists $main::grp{$group}->{lib_private}) {
|
|
|
|
|
print CFILE qq/#include "$hname"\n/;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-01 07:06:54 -07:00
|
|
|
if (exists $main::grp{$group}->{doc_title}) {
|
|
|
|
|
$long_desc = &desc_wrap($main::grp{$group}->{doc_long_desc});
|
|
|
|
|
print CFILE <<SECTION_DOCS;
|
2010-07-07 02:43:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-31 01:04:43 -07:00
|
|
|
* SECTION: $main::grp{$group}->{doc_title}
|
2010-07-07 02:43:10 -07:00
|
|
|
* \@title: $main::grp{$group}->{doc_title}
|
|
|
|
|
* \@short_description: $main::grp{$group}->{doc_short_desc}
|
|
|
|
|
*
|
|
|
|
|
${long_desc}
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
SECTION_DOCS
|
2019-08-01 07:06:54 -07:00
|
|
|
}
|
|
|
|
|
|
1999-04-03 21:59:08 -08:00
|
|
|
print CFILE "\n", $extra->{code} if exists $extra->{code};
|
1998-10-23 22:19:30 -07:00
|
|
|
print CFILE $out->{code};
|
|
|
|
|
close CFILE;
|
2011-11-06 08:33:20 -08:00
|
|
|
&write_file($cfile, $destdir);
|
1998-10-23 22:19:30 -07:00
|
|
|
}
|
2002-03-13 10:41:07 -08:00
|
|
|
|
|
|
|
|
if (! $ENV{PDBGEN_GROUPS}) {
|
2011-11-06 08:33:20 -08:00
|
|
|
my $gimp_pdb_headers = "$builddir/gimp_pdb_headers.h$FILE_EXT";
|
2011-03-08 04:42:05 -08:00
|
|
|
open PFILE, "> $gimp_pdb_headers" or die "Can't open $gimp_pdb_headers: $!\n";
|
2002-03-13 10:41:07 -08:00
|
|
|
print PFILE $lgpl_top;
|
2011-03-08 04:42:05 -08:00
|
|
|
print PFILE " * gimp_pdb_headers.h\n";
|
2002-03-13 10:41:07 -08:00
|
|
|
print PFILE $lgpl_bottom;
|
2025-08-13 15:21:42 -07:00
|
|
|
my $guard = "__GIMP_PDB_HEADERS_H__";
|
2002-03-13 10:41:07 -08:00
|
|
|
print PFILE <<HEADER;
|
2011-04-28 10:59:52 -07:00
|
|
|
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
|
|
|
|
|
#error "Only <libgimp/gimp.h> can be included directly."
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-08-13 15:21:42 -07:00
|
|
|
#ifndef $guard
|
|
|
|
|
#define $guard
|
|
|
|
|
|
2002-03-13 10:41:07 -08:00
|
|
|
HEADER
|
|
|
|
|
my @groups;
|
|
|
|
|
foreach $group (keys %out) {
|
2011-03-08 04:58:56 -08:00
|
|
|
my $hname = "${group}pdb.h";
|
|
|
|
|
if ($group ne 'gimp') {
|
|
|
|
|
$hname = "gimp${hname}";
|
|
|
|
|
}
|
2002-03-13 10:41:07 -08:00
|
|
|
$hname =~ s/_//g; $hname =~ s/pdb\./_pdb./;
|
2019-08-07 09:43:21 -07:00
|
|
|
if (! exists $main::grp{$group}->{lib_private}) {
|
|
|
|
|
push @groups, $hname;
|
|
|
|
|
}
|
2002-03-13 10:41:07 -08:00
|
|
|
}
|
|
|
|
|
foreach $group (sort @groups) {
|
|
|
|
|
print PFILE "#include <libgimp/$group>\n";
|
|
|
|
|
}
|
|
|
|
|
print PFILE <<HEADER;
|
|
|
|
|
|
2025-08-13 15:21:42 -07:00
|
|
|
#endif /* $guard */
|
2002-03-13 10:41:07 -08:00
|
|
|
HEADER
|
|
|
|
|
close PFILE;
|
2011-11-06 08:33:20 -08:00
|
|
|
&write_file($gimp_pdb_headers, $destdir);
|
2002-03-13 10:41:07 -08:00
|
|
|
}
|
1998-10-23 22:19:30 -07:00
|
|
|
}
|