#!/usr/bin/perl -w
use PARI::822;
$class=$ARGV[0];
%secnumber=(
'operators' => 1 ,
'conversions' => 2 ,
'transcendental' => 3 ,
'number_theoretical' => 4 ,
'elliptic_curves' => 5 ,
'number_fields' => 6 ,
'polynomials' => 7 ,
'linear_algebra' => 8 ,
'sums' => 9 ,
'graphic' => 10 ,
'programming' => 11
);
print <<EOF;
/* This file is autogenerated from the database. */
/* See src/desc/gen_proto */
/* Do not edit*/
entree functions_${class}[]={
EOF
%spec_valence=(
"O" => 50,
"if" => 80,
"while" => 81,
"until" => 82,
"global" => 88
);
PARI::822::read(\%funcs,$ARGV[1]);
foreach my $name (sort keys %funcs)
{
my %func=%{$funcs{$name}};
next if ($func{'Class'} ne $class);
my $gpname=$func{'Function'};
defined($func{'Section'}) or die("No section for $name");
my $sec=$secnumber{$func{'Section'}};
defined($sec) or die("Unknown section $func{'Section'}");
my $proto=$func{'Prototype'};
my $cname=$func{'C-Name'};
my $help=$func{'Help'};
defined($help) or die("No help for function $name");
$help =~ s/\n/ /g;
$help =~ s/\\/\\\\/g;
$help =~ s/"/\\"/g;
$help = "\"$help\"";
if (defined($cname))
{
my $cutproto=$proto;
$cutproto =~ s/^[vl]//;
$valence = ($cutproto eq "" || $cutproto =~ /^(s\*)|[DpP]/)? 0: 1;
$proto =~ s/"/\\"/g;
$proto = "\"$proto\"";
$cname = "(void*)$cname";
}
else
{
$cname='NULL';
$proto='NULL';
$valence=defined($spec_valence{$gpname})?$spec_valence{$gpname}:1;
}
print "{\"$gpname\",$valence,$cname,$sec,$proto,$help},\n";
}
print <<'EOF';
{NULL,0,NULL,0,NULL,NULL} /* sentinel */
};
EOF
syntax highlighted by Code2HTML, v. 0.9.1