2014-05-18 19:40:22 -04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
@files = (
|
|
|
|
'piclib/built-in.scm',
|
|
|
|
'piclib/srfi/1.scm',
|
|
|
|
'piclib/srfi/26.scm',
|
|
|
|
'piclib/srfi/95.scm'
|
|
|
|
);
|
|
|
|
|
|
|
|
print <<EOL;
|
|
|
|
#include "picrin.h"
|
|
|
|
#include "picrin/error.h"
|
|
|
|
|
|
|
|
EOL
|
|
|
|
|
|
|
|
foreach my $file (@files) {
|
|
|
|
my $var = &escape_v($file);
|
|
|
|
print "const char *$var =\n";
|
|
|
|
|
|
|
|
open IN, $file;
|
|
|
|
while (<IN>) {
|
|
|
|
chomp;
|
|
|
|
s/\\/\\\\/g;
|
|
|
|
s/"/\\"/g;
|
2014-05-18 20:00:51 -04:00
|
|
|
print "\"$_\\n\"\n";
|
2014-05-18 19:40:22 -04:00
|
|
|
}
|
|
|
|
print ";\n\n";
|
|
|
|
}
|
|
|
|
close IN;
|
|
|
|
|
|
|
|
print <<EOL;
|
|
|
|
void
|
|
|
|
pic_load_piclib(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_try {
|
|
|
|
EOL
|
|
|
|
|
|
|
|
foreach my $file (@files) {
|
|
|
|
my $var = &escape_v($file);
|
|
|
|
print " pic_load_cstr(pic, $var);\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print <<EOL;
|
|
|
|
}
|
|
|
|
pic_catch {
|
|
|
|
/* error! */
|
|
|
|
fputs("fatal error: failure in loading built-in.scm\\n", stderr);
|
|
|
|
fputs(pic_errmsg(pic), stderr);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
puts("successfully loaded stdlib");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
EOL
|
|
|
|
|
|
|
|
sub escape_v {
|
2014-05-18 23:58:11 -04:00
|
|
|
($_) = @_;
|
2014-05-18 19:40:22 -04:00
|
|
|
s/\.scm$//g;
|
|
|
|
s/[\/-]/_/g;
|
|
|
|
$_;
|
|
|
|
}
|