Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28488 views
License: GPL3
ubuntu2004
#!/usr/bin/perl -w
BEGIN { @INC=(".",@INC); }
use PARI::822;

$class=$ARGV[0];

$i = 2;
# update MAX_SECTION in gplib.c when changing this
%secnumber=(
  'operators'             => $i++,
  'conversions'           => $i++,
  'combinatorics'         => $i++,
  'number_theoretical'    => $i++,
  'polynomials'           => $i++,
  'linear_algebra'        => $i++,
  'transcendental'        => $i++,
  'sums'                  => $i++,
  'number_fields'         => $i++,
  'algebras'              => $i++,
  'elliptic_curves'       => $i++,
  'l_functions'           => $i++,
  'modular_forms'         => $i++,
  'modular_symbols'       => $i++,
  'graphic'               => $i++,
);
$i++;# skip next = PARI community
$secnumber{'symbolic_operators'} = $i++;
$secnumber{'member_functions'} = $i++;
$secnumber{'programming/internals'} = $i++;
$secnumber{'default'} = $i++;

# join
$secnumber{'programming/control'} = 1;
$secnumber{'programming/specific'} = 1;
$secnumber{'programming/parallel'} = 1;

print <<EOF;
/* This file is autogenerated from the database. */
/* See src/desc/gen_proto */
/* Do not edit*/
entree functions_${class}[]={
EOF
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'};
      $gpname =~ s/\\/\\\\/g;
      $gpname =~ s/^_def_//;
      defined($func{'Section'})
        or die("$name: mandatory field Section is missing");
      my $sec=$secnumber{$func{'Section'}};
      defined($sec)
        or die("$name: Section field has unknown value $func{'Section'}");
      my $proto=$func{'Prototype'};
      my $cname=$func{'C-Name'};
      my $help=$func{'Help'};
      defined($help) or die("$name: mandatory field Help is missing");
      $help =~ s/\n/ /g;
      $help =~ s/\\/\\\\/g;
      $help =~ s/"/\\"/g;
      $help = "\"$help\"";

      if (defined($cname))
      {
        $proto =~ s/"/\\"/g;
        print "{\"$gpname\",0,(void*)$cname,$sec,\"$proto\",$help},\n";
      }
      else
      {
        print "{\"$gpname\",0,NULL,$sec,NULL,$help},\n";
      }
}
print <<'EOF';
{NULL,0,NULL,0,NULL,NULL} /* sentinel */
};
EOF