gimp/tools/pdbgen/app.pl

669 lines
17 KiB
Perl
Raw Normal View History

# The GIMP -- an image manipulation program
1999-03-10 18:56:56 +00:00
# Copyright (C) 1998-1999 Manish Singh <yosh@gimp.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (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
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package Gimp::CodeGen::app;
$destdir = "$main::destdir/app";
*arg_types = \%Gimp::CodeGen::pdb::arg_types;
*arg_parse = \&Gimp::CodeGen::pdb::arg_parse;
*arg_ptype = \&Gimp::CodeGen::pdb::arg_ptype;
*arg_vname = \&Gimp::CodeGen::pdb::arg_vname;
1999-03-17 23:08:08 +00:00
*enums = \%Gimp::CodeGen::enums::enums;
*write_file = \&Gimp::CodeGen::util::write_file;
1999-03-10 18:56:56 +00:00
*FILE_EXT = \$Gimp::CodeGen::util::FILE_EXT;
1999-03-19 23:04:16 +00:00
use Text::Wrap qw(wrap);
sub quotewrap {
my ($str, $indent) = @_;
my $leading = ' ' x $indent . '"';
$Text::Wrap::columns = 1000;
$str = wrap($leading, $leading, $str);
$str =~ s/^\s*//s;
$str =~ s/(.)$/$1"/mg;
$str;
}
1999-03-21 02:14:08 +00: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 =~ s/^ {8}/\t/mg;
$code .= "\n";
$code;
}
1999-04-04 05:59:08 +00:00
sub make_arg_test {
my ($arg, $reverse, $test) = @_;
my $result = "";
my $yes = exists $arg->{on_success};
my $no = !exists $arg->{no_success} || exists $arg->{on_fail};
if ($yes || $no) {
&$reverse(\$test) if $yes;
$result = ' ' x 2 . "if ($test)\n";
$result .= &format_code_frag($arg->{on_success}, 1) if $yes;
if ($no) {
$result .= ' ' x 2 . "else\n" if $yes;
if (!exists $arg->{no_success}) {
$success = 1;
$result .= ' ' x 4 . "success = FALSE;\n";
}
if (exists $arg->{on_fail}) {
$result .= &format_code_frag($_->{on_fail}, 1);
}
}
}
$result;
}
sub declare_args {
my $proc = shift;
my $out = shift;
1999-03-10 18:56:56 +00:00
1999-03-17 23:08:08 +00:00
local $result = "";
1999-03-10 18:56:56 +00:00
foreach (@_) {
my @args = @{$proc->{$_}} if exists $proc->{$_};
1999-03-10 18:56:56 +00:00
foreach (@args) {
my $arg = $arg_types{(&arg_parse($_->{type}))[0]};
1999-03-10 18:56:56 +00:00
1999-03-21 02:14:08 +00:00
if ($arg->{array} && !exists $_->{array}) {
1999-03-10 18:56:56 +00:00
warn "Array without number of elements param in $proc->{name}";
}
unless (exists $_->{no_declare}) {
1999-03-17 23:08:08 +00:00
$result .= ' ' x 2 . $arg->{type} . &arg_vname($_);
if (!exists $_->{no_init} && exists $_->{init}) {
1999-03-28 06:36:11 +00:00
$result .= $arg->{type} =~ /\*$/ ? ' = NULL' : ' = 0'
1999-03-17 23:08:08 +00:00
}
1999-03-10 23:34:26 +00:00
$result .= ";\n";
1999-03-10 18:56:56 +00:00
1999-03-21 02:14:08 +00:00
if (exists $arg->{headers}) {
foreach (@{$arg->{headers}}) {
$out->{headers}->{$_}++;
}
}
}
}
}
1999-03-10 18:56:56 +00:00
$result;
1999-04-10 04:52:07 +00:00
}
sub declare_vars {
my $proc = shift;
my $code = "";
if (exists $proc->{invoke}->{vars}) {
foreach (@{$proc->{invoke}->{vars}}) {
$code .= ' ' x 2 . $_ . ";\n";
}
}
$code;
}
1999-03-21 02:14:08 +00:00
sub make_arg_recs {
my $proc = shift;
1999-03-10 18:56:56 +00:00
my $result = "";
my $once;
1999-03-10 18:56:56 +00:00
foreach (@_) {
my @args = @{$proc->{$_}} if exists $proc->{$_};
1999-03-10 18:56:56 +00:00
if (scalar @args) {
$result .= "\nstatic ProcArg $proc->{name}_${_}\[] =\n{\n";
1999-03-10 18:56:56 +00:00
1999-03-17 23:08:08 +00:00
foreach $arg (@{$proc->{$_}}) {
my ($type, $name, @remove) = &arg_parse($arg->{type});
my $desc = $arg->{desc};
my $info = $arg->{type};
for ($type) {
/array/ && do { last };
/boolean/ && do { $info = 'TRUE or FALSE'; last };
/int|float/ && do { $info =~ s/$type/$arg->{name}/e; last };
1999-04-04 05:59:08 +00:00
/enum/ && do { my $enum = $enums{$name};
$info = $enum->{info};
1999-03-17 23:08:08 +00:00
foreach (@remove) {
1999-04-04 05:59:08 +00:00
if (exists $enum->{nicks}->{$_}) {
$nick = $enum->{nicks}->{$_};
}
else {
$nick = $_;
}
$info =~ s/$nick \(.*?\)(, )?//
}
$info =~ s/, $//; last };
1999-03-17 23:08:08 +00:00
}
$desc =~ s/%%desc%%/$info/eg;
1999-03-10 18:56:56 +00:00
$result .= <<CODE;
{
PDB_$arg_types{$type}->{name},
"$arg->{name}",
1999-03-19 23:04:16 +00:00
@{[ &quotewrap($desc, 4) ]}
1999-03-10 18:56:56 +00:00
},
CODE
}
1999-03-10 18:56:56 +00:00
1999-03-21 02:14:08 +00:00
$result =~ s/,\n$/\n/s;
$result .= "};\n";
}
}
1999-03-10 18:56:56 +00:00
$result;
}
sub marshal_inargs {
1999-03-21 02:14:08 +00:00
my ($proc, $argc) = @_;
1999-03-10 18:56:56 +00:00
my $result = "";
my %decls;
1999-03-10 18:56:56 +00:00
my @inargs = @{$proc->{inargs}} if exists $proc->{inargs};
1999-03-10 18:56:56 +00:00
foreach (@inargs) {
my($pdbtype, @typeinfo) = &arg_parse($_->{type});
my $arg = $arg_types{$pdbtype};
my $type = &arg_ptype($arg);
my $var = &arg_vname($_);
1999-03-17 23:08:08 +00:00
if (exists $arg->{id_func}) {
1999-03-10 23:34:26 +00:00
$result .= <<CODE;
1999-03-21 02:14:08 +00:00
$var = $arg->{id_func} (args[$argc].value.pdb_$type);
1999-03-10 18:56:56 +00:00
CODE
1999-04-04 05:59:08 +00:00
$result .= &make_arg_test($_, sub { ${$_[0]} =~ s/==/!=/ },
"$var == NULL");
}
else {
1999-04-04 05:59:08 +00:00
$result .= ' ' x 2 . "$var =";
1999-03-17 23:08:08 +00:00
my $cast = "";
if ($type eq 'pointer' || $arg->{type} =~ /int(16|8)$/) {
$cast = " ($arg->{type})";
}
1999-04-04 05:59:08 +00:00
$result .= "$cast args[$argc].value.pdb_$type";
$result .= ' ? TRUE : FALSE' if $pdbtype eq 'boolean';
$result .= ";\n";
1999-03-17 23:08:08 +00:00
1999-04-10 04:52:07 +00:00
if ($pdbtype eq 'string' || $pdbtype eq 'parasite') {
1999-04-04 05:59:08 +00:00
$result .= &make_arg_test($_, sub { ${$_[0]} =~ s/==/!=/ },
"$var == NULL");
}
elsif ($pdbtype eq 'unit') {
$result .= &make_arg_test($_, sub { ${$_[0]} = "!(${$_[0]})" },
'unit < UNIT_PIXEL || unit >= ' .
'gimp_unit_get_number_of_units ()');
}
elsif ($pdbtype eq 'enum' && !$enums{$typeinfo[0]}->{contig}) {
if (!exists $_->{no_success} || exists $_->{on_success} ||
exists $_->{on_fail}) {
1999-03-19 23:04:16 +00:00
my %vals; my $symbols = $enums{pop @typeinfo}->{symbols};
@vals{@$symbols}++; delete @vals{@typeinfo};
1999-03-10 18:56:56 +00:00
1999-04-04 05:59:08 +00:00
my $okvals = ""; my $failvals = "";
my $once = 0;
1999-03-19 23:04:16 +00:00
foreach (@$symbols) {
1999-04-04 05:59:08 +00:00
if (exists $vals{$_}) {
$okvals .= ' ' x 4 if $once++;
$okvals .= "case $_:\n";
}
1999-03-19 23:04:16 +00:00
}
1999-03-10 18:56:56 +00:00
1999-04-04 05:59:08 +00:00
sub format_switch_frag {
my ($arg, $key) = @_;
my $frag = "";
if (exists $arg->{$key}) {
$frag = &format_code_frag($arg->{$key}, 1);
$frag =~ s/\t/' ' x 8/eg;
$frag =~ s/^/' ' x 2/meg;
$frag =~ s/^ {8}/\t/mg;
}
$frag;
}
$okvals .= &format_switch_frag($_, 'on_success');
$failvals .= "default:\n";
if (!exists $_->{no_success}) {
$success = 1;
$failvals .= ' ' x 6 . "success = FALSE\n"
}
$failvals .= &format_switch_frag($_, 'on_fail');
$result .= <<CODE;
switch ($var)
{
$okvals
1999-03-19 23:04:16 +00:00
break;
1999-03-10 18:56:56 +00:00
1999-04-04 05:59:08 +00:00
$failvals
1999-03-19 23:04:16 +00:00
break;
}
CODE
1999-03-10 18:56:56 +00:00
}
1999-04-04 05:59:08 +00:00
}
elsif (defined $typeinfo[0] || defined $typeinfo[2]) {
my $code = ""; my $tests = 0; my $extra = "";
1999-03-19 23:04:16 +00:00
1999-04-04 05:59:08 +00:00
if ($pdbtype eq 'enum') {
my $symbols = $enums{shift @typeinfo}->{symbols};
1999-03-19 23:04:16 +00:00
1999-04-10 04:52:07 +00:00
my ($start, $end) = (0, $#$symbols);
my $syms = "@$symbols "; my $test = $syms;
foreach (@typeinfo) { $test =~ s/$_ // }
1999-03-10 18:56:56 +00:00
1999-04-10 04:52:07 +00:00
if ($syms =~ /$test/g) {
if (pos $syms == length $syms) {
$start = @typeinfo;
}
else {
$end -= @typeinfo;
}
}
else {
foreach (@typeinfo) {
$extra .= " || $var == $_";
}
}
$typeinfo[0] = $symbols->[$start];
if ($start != $end) {
$typeinfo[1] = '<';
$typeinfo[2] = $symbols->[$end];
$typeinfo[3] = '>';
}
else {
$typeinfo[1] = '!=';
undef @typeinf[2..3];
}
1999-03-19 23:04:16 +00:00
}
1999-04-04 05:59:08 +00:00
elsif ($pdbtype eq 'float') {
foreach (@typeinfo[0, 2]) {
$_ .= '.0' if defined $_ && !/\./
1999-03-21 02:14:08 +00:00
}
1999-04-04 05:59:08 +00:00
}
1999-03-17 23:08:08 +00:00
1999-04-04 05:59:08 +00:00
if (defined $typeinfo[0]) {
$code .= "$var $typeinfo[1] $typeinfo[0]";
$code .= '.0' if $pdbtype eq 'float' && $typeinfo[0] !~ /\./;
$tests++;
}
1999-03-21 02:14:08 +00:00
1999-04-04 05:59:08 +00:00
if (defined $typeinfo[2]) {
$code .= ' || ' if $tests;
$code .= "$var $typeinfo[3] $typeinfo[2]";
}
1999-03-21 02:14:08 +00:00
1999-04-04 05:59:08 +00:00
$code .= $extra;
1999-03-21 02:14:08 +00:00
1999-04-04 05:59:08 +00:00
$result .= &make_arg_test($_, sub { ${$_[0]} = "!(${$_[0]})" },
$code);
}
}
1999-03-10 18:56:56 +00:00
$argc++; $result .= "\n";
}
1999-03-10 18:56:56 +00:00
$result = "\n" . $result if $result;
$result;
}
sub marshal_outargs {
my $proc = shift;
1999-03-10 18:56:56 +00:00
my $result = <<CODE;
return_args = procedural_db_return_args (\&$proc->{name}_proc, success);
CODE
1999-03-10 18:56:56 +00:00
my $argc = 0;
my @outargs = @{$proc->{outargs}} if exists $proc->{outargs};
1999-03-10 18:56:56 +00:00
if (scalar @outargs) {
my $outargs = "";
1999-03-10 18:56:56 +00:00
foreach (@{$proc->{outargs}}) {
my ($pdbtype) = &arg_parse($_->{type});
my $arg = $arg_types{$pdbtype};
my $type = &arg_ptype($arg);
my $var = &arg_vname($_);
1999-03-10 18:56:56 +00:00
$argc++; $outargs .= ' ' x 2;
1999-03-10 18:56:56 +00:00
if (exists $arg->{id_ret_func}) {
1999-03-10 18:56:56 +00:00
$var = eval qq/"$arg->{id_ret_func}"/;
}
1999-03-10 18:56:56 +00:00
$outargs .= "return_args[$argc].value.pdb_$type = $var;\n";
}
1999-03-10 18:56:56 +00:00
$outargs =~ s/^/' ' x 2/meg if $success;
$outargs =~ s/^/' ' x 2/meg if $success && $argc > 1;
1999-03-10 18:56:56 +00: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;
$result .= "\n" . ' ' x 2 . "return return_args;\n";
}
else {
$result =~ s/_args =//;
}
1999-03-10 18:56:56 +00:00
$result =~ s/, success\);$/, TRUE);/m unless $success;
$result;
}
sub generate {
my @procs = @{(shift)};
my %out;
my $total = 0.0;
1999-03-17 23:08:08 +00:00
foreach $name (@procs) {
my $proc = $main::pdb{$name};
my $out = \%{$out{$proc->{group}}};
my @inargs = @{$proc->{inargs}} if exists $proc->{inargs};
my @outargs = @{$proc->{outargs}} if exists $proc->{outargs};
local $success = 0;
$out->{pcount}++; $total++;
$out->{procs} .= "static ProcRecord ${name}_proc;\n";
$out->{register} .= <<CODE;
procedural_db_register (\&${name}_proc);
CODE
if (exists $proc->{invoke}->{headers}) {
1999-03-17 23:08:08 +00:00
foreach $header (@{$proc->{invoke}->{headers}}) {
$out->{headers}->{$header}++;
}
}
$out->{code} .= "\nstatic Argument *\n";
$out->{code} .= "${name}_invoker (Argument *args)\n{\n";
1999-03-21 02:14:08 +00:00
my $code = "";
if (exists $proc->{invoke}->{pass_through}) {
my $invoke = $proc->{invoke};
1999-03-21 02:14:08 +00:00
my $argc = 0;
$argc += @{$invoke->{pass_args}} if exists $invoke->{pass_args};
$argc += @{$invoke->{make_args}} if exists $invoke->{make_args};
my %pass; my @passgroup;
my $before = 0; my $contig = 0; my $pos = -1;
if (exists $invoke->{pass_args}) {
foreach (@{$invoke->{pass_args}}) {
$pass{$_}++;
$_ - 1 == $before ? $contig = 1 : $pos++;
push @{$passgroup[$pos]}, $_;
$before = $_;
}
}
$code .= ' ' x 2 . "int i;\n" if $contig;
$code .= ' ' x 2 . "Argument argv[$argc];\n";
my $tempproc; $pos = 0;
foreach (@{$proc->{inargs}}) {
$_->{argpos} = $pos++;
push @{$tempproc->{inargs}}, $_ if !exists $pass{$_->{argpos}};
}
1999-03-21 02:14:08 +00:00
$code .= &declare_args($tempproc, $out, qw(inargs)) . "\n";
1999-04-10 04:52:07 +00:00
$code .= &declare_vars($proc);
1999-03-21 02:14:08 +00:00
my $marshal = "";
foreach (@{$tempproc->{inargs}}) {
my $argproc; $argproc->{inargs} = [ $_ ];
$marshal .= &marshal_inargs($argproc, $_->{argpos});
1999-04-10 04:52:07 +00:00
chop $marshal;
1999-03-21 02:14:08 +00:00
}
1999-04-10 04:52:07 +00:00
$marshal .= "\n" if $marshal;
1999-03-21 02:14:08 +00:00
if ($success) {
$marshal .= <<CODE;
if (!success)
return procedural_db_return_args (\&${name}_proc, FALSE);
1999-03-21 02:14:08 +00:00
CODE
}
$marshal = substr($marshal, 1) if $marshal;
$code .= $marshal;
foreach (@passgroup) {
$code .= ($#$_ ? <<LOOP : <<CODE) . "\n";
for (i = $_->[0]; i < @{[ $_->[$#$_] + 1 ]}; i++)
argv[i] = args[i];
LOOP
argv[$_->[0]] = args[$_->[0]];
CODE
}
if (exists $invoke->{make_args}) {
$pos = 0;
foreach (@{$invoke->{make_args}}) {
while (exists $pass{$pos}) { $pos++ }
my $arg = $arg_types{(&arg_parse($_->{type}))[0]};
my $type = &arg_ptype($arg);
$code .= <<CODE;
argv[$pos].arg_type = PDB_$arg->{name};
CODE
1999-03-10 18:56:56 +00:00
1999-03-21 02:14:08 +00:00
my $frag = $_->{code};
$frag =~ s/%%arg%%/"argv[$pos].value.pdb_$type"/e;
$code .= &format_code_frag($frag, 0);
1999-03-10 18:56:56 +00:00
1999-03-21 02:14:08 +00:00
$pos++;
}
$code .= "\n";
}
$code .= <<CODE;
return $invoke->{pass_through}_invoker (argv);
}
CODE
}
else {
1999-03-21 02:14:08 +00:00
my $invoker = "";
$invoker .= ' ' x 2 . "Argument *return_args;\n" if scalar @outargs;
$invoker .= &declare_args($proc, $out, qw(inargs outargs));
1999-04-10 04:52:07 +00:00
$invoker .= &declare_vars($proc);
1999-03-21 02:14:08 +00:00
$invoker .= &marshal_inargs($proc, 0);
$invoker .= "\n" if $invoker && $invoker !~ /\n\n/s;
1999-03-28 06:36:11 +00:00
my $frag = "";
1999-03-21 02:14:08 +00:00
1999-03-28 06:36:11 +00: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 02:14:08 +00:00
1999-03-28 06:36:11 +00:00
chomp $invoker if !$frag;
1999-03-21 02:14:08 +00:00
$code .= $invoker . $frag;
$code .= "\n" if $frag =~ /\n\n/s || $invoker;
$code .= &marshal_outargs($proc) . "}\n";
}
1999-03-10 18:56:56 +00:00
if ($success) {
1999-04-04 05:59:08 +00:00
$out->{code} .= ' ' x 2 . "gboolean success";
unless ($proc->{invoke}->{success} eq 'NONE') {
$out->{code} .= " = $proc->{invoke}->{success}";
}
$out->{code} .= ";\n";
1999-03-10 18:56:56 +00:00
}
1999-03-21 02:14:08 +00:00
$out->{code} .= $code;
1999-03-21 02:14:08 +00:00
$out->{code} .= &make_arg_recs($proc, qw(inargs outargs));
$out->{code} .= <<CODE;
static ProcRecord ${name}_proc =
{
"gimp_$name",
1999-03-19 23:04:16 +00:00
@{[ &quotewrap($proc->{blurb}, 2) ]},
@{[ &quotewrap($proc->{help}, 2) ]},
"$proc->{author}",
"$proc->{copyright}",
"$proc->{date}",
PDB_INTERNAL,
1999-04-04 05:59:08 +00:00
@{[scalar @inargs]},
@{[scalar @inargs ? "${name}_inargs" : 'NULL']},
1999-04-04 05:59:08 +00:00
@{[scalar @outargs]},
@{[scalar @outargs ? "${name}_outargs" : 'NULL']},
{ { ${name}_invoker } }
};
CODE
}
my $gpl = <<'GPL';
/* The GIMP -- an image manipulation program
1999-03-10 23:34:26 +00:00
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
1999-03-10 23:34:26 +00:00
/* NOTE: This file is autogenerated by pdbgen.pl. */
GPL
1999-03-10 18:56:56 +00:00
my $internal = "$destdir/internal_procs.h$FILE_EXT";
open INTERNAL, "> $internal" or die "Can't open $cmdfile: $!\n";
print INTERNAL $gpl;
my $guard = "__INTERNAL_PROCS_H__";
print INTERNAL <<HEADER;
#ifndef $guard
#define $guard
void internal_procs_init (void);
#endif /* $guard */
HEADER
close INTERNAL;
&write_file($internal);
my $group_procs = ""; my $longest = 0;
my $once = 0; my $pcount = 0.0;
foreach $group (@main::groups) {
my $out = $out{$group};
1999-04-04 05:59:08 +00:00
foreach (@{$main::grp{$group}->{headers}}) { $out->{headers}->{$_}++ }
delete $out->{headers}->{q/"procedural_db.h"/};
my $headers = "";
foreach (sort keys %{$out->{headers}}) { $headers .= "#include $_\n" }
my $extra = {};
if (exists $main::grp{$group}->{extra}->{app}) {
$extra = $main::grp{$group}->{extra}->{app}
}
1999-03-10 18:56:56 +00:00
my $cfile = "$destdir/${group}_cmds.c$FILE_EXT";
open CFILE, "> $cfile" or die "Can't open $cmdfile: $!\n";
print CFILE $gpl;
1999-03-28 06:36:11 +00:00
print CFILE qq/#include "procedural_db.h"\n\n/;
1999-04-04 05:59:08 +00:00
print CFILE $headers, "\n";
print CFILE $extra->{decls}, "\n" if exists $extra->{decls};
print CFILE $out->{procs};
print CFILE "\nvoid\nregister_${group}_procs (void)\n";
print CFILE "{\n$out->{register}}\n";
1999-04-04 05:59:08 +00:00
print CFILE "\n", $extra->{code} if exists $extra->{code};
print CFILE $out->{code};
close CFILE;
&write_file($cfile);
my $decl = "register_${group}_procs";
push @group_decls, $decl;
$longest = length $decl if $longest < length $decl;
$group_procs .= ' ' x 2 . "app_init_update_status (";
1999-04-04 05:59:08 +00:00
$group_procs .= q/_("Internal Procedures")/ unless $once;
$group_procs .= 'NULL' if $once++;
1999-04-04 05:59:08 +00:00
$group_procs .= qq/, _("$main::grp{$group}->{desc}"), /;
($group_procs .= sprintf "%.3f", $pcount / $total) =~ s/\.?0*$//s;
$group_procs .= ($group_procs !~ /\.\d+$/s ? ".0" : "") . ");\n";
$group_procs .= ' ' x 2 . "register_${group}_procs ();\n\n";
$pcount += $out->{pcount};
}
1999-03-10 18:56:56 +00:00
$internal = "$destdir/internal_procs.c$FILE_EXT";
open INTERNAL, "> $internal" or die "Can't open $cmdfile: $!\n";
print INTERNAL $gpl;
1999-04-04 05:59:08 +00:00
print INTERNAL qq@#include "app_procs.h"\n\n@;
print INTERNAL qq@#include "libgimp/gimpintl.h"\n\n@;
print INTERNAL "/* Forward declarations for registering PDB procs */\n\n";
foreach (@group_decls) {
print INTERNAL "void $_" . ' ' x ($longest - length $_) . " (void);\n";
}
chop $group_procs;
print INTERNAL "\n/* $total total procedures registered total */\n\n";
print INTERNAL "void\ninternal_procs_init (void)\n{\n$group_procs}\n";
close INTERNAL;
&write_file($internal);
}
1;