X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fparser%2Fdefault_reader.tpl;h=006fb908c28402f2d61fa5cacdee904788a091b7;hp=2018e04a0660e66b9faf2fe15f1c59b6e09bbf37;hb=c0fcba137d26486085ed5d4104b34d2c44978693;hpb=a6e5a7a5974dc95afe71c077f6a5e66b322c9d2c;ds=sidebyside diff --git a/ginac/parser/default_reader.tpl b/ginac/parser/default_reader.tpl index 2018e04a..006fb908 100644 --- a/ginac/parser/default_reader.tpl +++ b/ginac/parser/default_reader.tpl @@ -22,6 +22,7 @@ COMMENT a part of GiNaC parser -- construct functions from a byte stream. #ifdef HAVE_CONFIG_H #include "config.h" #endif + #ifdef HAVE_STDINT_H #include // for uintptr_t #endif @@ -58,7 +59,7 @@ static reader_func encode_serial_as_reader_func(unsigned serial) { uintptr_t u = (uintptr_t)serial; u = (u << 1) | (uintptr_t)1; - reader_func ptr = reinterpret_cast((void *)u); + reader_func ptr = (reader_func)((void *)u); return ptr; } @@ -87,5 +88,58 @@ const prototype_table& get_default_reader() } return reader; } -} // namespace GiNaC +const prototype_table& get_builtin_reader() +{ + using std::make_pair; + static bool initialized = false; + static prototype_table reader; + if (!initialized) { + [+ FOR function +] + reader[make_pair("[+ (get "name") +]", [+ + (if (exist? "args") (get "args") "1") + +])] = [+ (get "name") +]_reader;[+ + ENDFOR +] + enum { + log, + exp, + sin, + cos, + tan, + asin, + acos, + atan, + sinh, + cosh, + tanh, + asinh, + acosh, + atanh, + atan2, + Li2, + Li3, + zetaderiv, + Li, + S, + H, + lgamma, + tgamma, + beta, + factorial, + binomial, + Order, + NFUNCTIONS + }; + std::vector::const_iterator it = + registered_functions_hack::get_registered_functions().begin(); + unsigned serial = 0; + for ( ; serialget_name(), it->get_nparams()); + reader[proto] = encode_serial_as_reader_func(serial); + } + initialized = true; + } + return reader; +} + +} // namespace GiNaC