diff options
author | Karl Berry <karl@freefriends.org> | 2010-06-08 13:46:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-06-08 13:46:05 +0000 |
commit | a960e44eb527236f39aec81babc0474911a86078 (patch) | |
tree | 9950eca71791d90820a80a521a7cc252c0955db5 /Build/source/utils/asymptote/findsym.pl | |
parent | 6443467452320c296faa1f43f0606a9457bd4463 (diff) |
asy 1.96
git-svn-id: svn://tug.org/texlive/trunk@18817 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/findsym.pl')
-rw-r--r-- | Build/source/utils/asymptote/findsym.pl | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/findsym.pl b/Build/source/utils/asymptote/findsym.pl new file mode 100644 index 00000000000..38c3865a7af --- /dev/null +++ b/Build/source/utils/asymptote/findsym.pl @@ -0,0 +1,57 @@ +#!/usr/bin/env perl +##### +# findsym.pl +# Andy Hammerlindl 2010/06/01 +# +# Extract static symbols used in builtin.cc and write code so that they are +# translated only once when creating the symbol table. +##### + +$outname = shift(@ARGV); +if (not $outname) { + print STDERR "usage ./findsym.pl out_symbols.h file1.cc file2.cc ...\n"; + exit(1); +} + +open(header, ">$outname") || + die("Couldn't open $outname for writing"); + +print header <<END; +/***** + * This file is automatically generated by findsym.pl + * Changes will be overwritten. + *****/ + +// If the ADDSYMBOL macro is not already defined, define it with the default +// purpose of referring to an external pre-translated symbol, such that +// SYM(name) also refers to that symbol. +#ifndef ADDSYMBOL + #define ADDSYMBOL(name) extern symbol *PRETRANSLATED_SYMBOL_##name + #ifdef PRESYM + #define SYM(name) PRETRANSLATED_SYMBOL_##name + #else + #define SYM(name) symbol::trans(#name) + #endif +#endif + +END + +sub add { + print header "ADDSYMBOL(".$_[0].");\n"; +} + +my %symbols = (); + +foreach my $inname (@ARGV) { + open(infile, $inname) || + die("Couldn't open $inname"); + while (<infile>) { + while (m/SYM\(([_A-Za-z][_A-Za-z0-9]*)\)/gx) { + $symbols{ $1 } = 1; + } + } +} + +foreach my $s (sort keys %symbols) { + add($s); +} |