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
|
2009-01-18 06:28:01 +08:00
|
|
|
# along with this program. If not, see <http://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) {
|
|
|
|
$result .= " $arg->{type}$_->{name} = $arg->{init_value}";
|
|
|
|
}
|
|
|
|
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)";
|
2011-10-08 21:32:09 +08:00
|
|
|
if (!exists $_->{dead}) {
|
|
|
|
$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
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
$value = "gimp_value_array_index (return_vals, $argc)";
|
1999-03-11 02:56:56 +08:00
|
|
|
|
2006-04-01 09:33:28 +08:00
|
|
|
if (exists $_->{array}) {
|
|
|
|
my $arrayarg = $_->{array};
|
|
|
|
|
|
|
|
if (exists $arrayarg->{name}) {
|
|
|
|
$var_len = $arrayarg->{name};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$var_len = 'num_' . $_->{name};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
$outargs .= eval qq/" $arg->{set_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;
|
|
|
|
gimp_param_spec_image_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-05-07 02:57:51 +08:00
|
|
|
pdb->gimp, $none_ok,
|
2007-05-06 05:53:17 +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;
|
|
|
|
gimp_param_spec_item_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
pdb->gimp, $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;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_drawable_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-05-07 02:57:51 +08:00
|
|
|
pdb->gimp, $none_ok,
|
2006-04-04 04:54:55 +08:00
|
|
|
$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;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_layer_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-05-07 02:57:51 +08:00
|
|
|
pdb->gimp, $none_ok,
|
2006-04-04 04:54:55 +08:00
|
|
|
$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;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_channel_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-05-07 02:57:51 +08:00
|
|
|
pdb->gimp, $none_ok,
|
2006-04-04 04:54:55 +08:00
|
|
|
$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;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_layer_mask_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-05-07 02:57:51 +08:00
|
|
|
pdb->gimp, $none_ok,
|
2006-04-04 04:54:55 +08:00
|
|
|
$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;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_selection_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-05-07 02:57:51 +08:00
|
|
|
pdb->gimp, $none_ok,
|
2006-04-04 04:54:55 +08:00
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'vectors') {
|
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;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_vectors_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-05-07 02:57:51 +08:00
|
|
|
pdb->gimp, $none_ok,
|
2006-04-04 04:54:55 +08:00
|
|
|
$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;
|
|
|
|
gimp_param_spec_display_id ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-05-07 02:57:51 +08:00
|
|
|
pdb->gimp, $none_ok,
|
2006-03-29 03:58:00 +08:00
|
|
|
$flags)
|
|
|
|
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)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'float') {
|
|
|
|
$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)
|
|
|
|
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;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_int32 ("$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;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_int16 ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$min, $max, $default,
|
|
|
|
$flags)
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'int8') {
|
2010-06-06 01:26:06 +08:00
|
|
|
if (defined $typeinfo[0]) {
|
|
|
|
$min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$min = 0;
|
|
|
|
}
|
|
|
|
if (defined $typeinfo[2]) {
|
|
|
|
$max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$max = G_MAXUINT8;
|
|
|
|
}
|
2006-03-29 03:58:00 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
|
|
|
|
$pspec = <<CODE;
|
2006-04-04 04:54:55 +08:00
|
|
|
gimp_param_spec_int8 ("$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';
|
2006-03-29 03:58:00 +08:00
|
|
|
$null_ok = exists $arg->{null_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",
|
2007-04-27 03:10:23 +08:00
|
|
|
$allow_non_utf8, $null_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') {
|
|
|
|
$typeinfo[0] = 'GIMP_UNIT_PIXEL' unless defined $typeinfo[0];
|
|
|
|
$allow_pixels = $typeinfo[0] eq 'GIMP_UNIT_PIXEL' ? TRUE : FALSE;
|
|
|
|
$allow_percent = exists $arg->{allow_percent} ? TRUE : FALSE;
|
|
|
|
$default = exists $arg->{default} ? $arg->{default} : $typeinfo[0];
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_unit ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$allow_pixels,
|
|
|
|
$allow_percent,
|
|
|
|
$default,
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'color') {
|
2006-04-27 23:19:59 +08:00
|
|
|
$has_alpha = exists $arg->{has_alpha} ? TRUE : FALSE;
|
2006-03-29 03:58:00 +08:00
|
|
|
$default = exists $arg->{default} ? $arg->{default} : NULL;
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_rgb ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
2006-04-27 23:19:59 +08:00
|
|
|
$has_alpha,
|
2006-03-29 03:58:00 +08:00
|
|
|
$default,
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'parasite') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_parasite ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
|
|
|
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
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'int16array') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_int16_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'int8array') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_int8_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'floatarray') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_float_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
2006-04-01 09:33:28 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'stringarray') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_string_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$flags)
|
2008-07-14 22:44:13 +08:00
|
|
|
CODE
|
|
|
|
}
|
|
|
|
elsif ($pdbtype eq 'colorarray') {
|
|
|
|
$pspec = <<CODE;
|
|
|
|
gimp_param_spec_color_array ("$name",
|
|
|
|
"$nick",
|
|
|
|
"$blurb",
|
|
|
|
$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;
|
|
|
|
|
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++;
|
|
|
|
|
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
|
|
|
*/
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure = gimp_procedure_new (${name}_invoker);
|
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");
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_set_static_strings (procedure,
|
2012-04-01 03:57:47 +08:00
|
|
|
"$procedure_name",
|
2018-04-15 22:06:00 +08:00
|
|
|
@{[ "ewrap($blurb, 2, 37) ]},
|
2013-09-14 09:12:26 +08:00
|
|
|
@{[ "ewrap($help, 2, 37) ]},
|
2006-04-05 05:11:45 +08:00
|
|
|
"$proc->{author}",
|
|
|
|
"$proc->{copyright}",
|
|
|
|
"$proc->{date}",
|
|
|
|
@{[$proc->{deprecated} ? "\"$proc->{deprecated}\"" : 'NULL']});
|
2006-03-29 03:58:00 +08:00
|
|
|
CODE
|
|
|
|
|
2006-03-30 07:56:07 +08:00
|
|
|
$argc = 0;
|
|
|
|
|
|
|
|
foreach $arg (@inargs) {
|
|
|
|
my ($pspec, $postproc) = &generate_pspec($arg);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
$pspec =~ s/^/' ' x length(" gimp_procedure_add_argument (")/meg;
|
2006-03-29 03:58:00 +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
|
|
|
|
2006-04-05 05:11:45 +08:00
|
|
|
if ($postproc ne '') {
|
2006-04-04 18:30:58 +08:00
|
|
|
$pspec = "procedure->args[$argc]";
|
2006-03-30 07:56:07 +08:00
|
|
|
$postproc =~ s/^/' '/meg;
|
|
|
|
$out->{register} .= eval qq/"$postproc"/;
|
|
|
|
}
|
|
|
|
|
|
|
|
$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
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
$pspec =~ s/^/' ' x length(" gimp_procedure_add_return_value (")/meg;
|
2006-03-29 03:58:00 +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
|
|
|
|
2006-04-05 05:11:45 +08:00
|
|
|
if ($postproc ne '') {
|
2006-04-04 18:30:58 +08:00
|
|
|
$pspec = "procedure->values[$argc]";
|
2006-03-30 07:56:07 +08:00
|
|
|
$postproc =~ s/^/' '/meg;
|
|
|
|
$out->{register} .= eval qq/"$postproc"/;
|
|
|
|
}
|
|
|
|
|
|
|
|
$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 = "";
|
|
|
|
|
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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://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/;
|
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@;
|
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;
|