From: Alexander Frink Date: Fri, 28 Jan 2000 18:26:41 +0000 (+0000) Subject: genheader.pl: create a header file 'cint_workaround.h' to fix the broken X-Git-Tag: release_0-5-0~25 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=1a21a1a5d97950126a8df787302286b6cc1a902c;hp=c66c8e73568eeac73afb5be4881698901462fefc;ds=sidebyside genheader.pl: create a header file 'cint_workaround.h' to fix the broken cint overloading for C math library functions --- diff --git a/cint/configure b/cint/configure index 0b3941f0..ec988b42 100755 --- a/cint/configure +++ b/cint/configure @@ -29,7 +29,8 @@ echo "ok, cint seems to be in \$PATH" makecint -mk Makefile -o ginaccint -m \ -D OBSCURE_CINT_HACK -D NO_GINAC_NAMESPACE \ -I .. -I $CINTSYSDIR \ - -m -H ../ginac/ginac.h -C++ dummy_ginsh.cpp -C++ ginaccint.cpp \ + -m -H ../ginac/ginac.h -H cint_workaround.h \ + -C++ dummy_ginsh.cpp -C++ ginaccint.cpp \ -l ../ginac/.libs/libginac.a -lcln \ -cint -M0x10 echo "ok, makecint has created the Makefile" diff --git a/cint/genheader.pl b/cint/genheader.pl new file mode 100755 index 00000000..7c4a98fb --- /dev/null +++ b/cint/genheader.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl -w + +# Generate a header file which is additionally included in cint +# to work around the broken overloading resolution of cint for +# C library functions +# e.g. if a function declared as ex sin(ex const & x) and called +# with sin(y) where y is a symbol, cint favours a conversion from +# symbol to void * to double over symbol to ex and thus calls the +# C math library function double sin(double x) (sigh!) + +$header='cint_workaround.h'; + +# types which need help to be converted to ex +@types=('symbol','function','constant','idx','lorentzidx','coloridx'); +@moretypes=('numeric','int','double'); +@extype=('ex'); + +# functions with one parameter +@functions1p=('sin','cos','tan','asin','acos','atan','exp','log','sqrt', + 'sinh','cosh','tanh','abs'); + +# functions with two parameters +@functions2p=('pow','atan2'); + +open OUT,">$header"; + +foreach $f (@functions1p) { + print OUT "// fixes for $f(x)\n"; + foreach $t (@types) { + print OUT "inline ex $f($t const & x) { return $f(ex(x)); }\n"; + } + print OUT "\n"; +} + +sub inlines2 { + my ($types1ref,$types2ref)=@_; + foreach $t1 (@$types1ref) { + foreach $t2 (@$types2ref) { + print OUT "inline ex $f($t1 const & x,$t2 const & y) {\n"; + print OUT " return $f(ex(x),ex(y));\n"; + print OUT "}\n"; + } + } +} + +foreach $f (@functions2p) { + print OUT "// fixes for $f(x,y)\n"; + inlines2(\@types,\@types); + inlines2(\@types,\@moretypes); + inlines2(\@moretypes,\@types); + inlines2(\@extype,\@moretypes); + inlines2(\@moretypes,\@extype); + print OUT "\n"; +} + +close OUT; + +