]> www.ginac.de Git - ginac.git/blobdiff - ginac/function.pl
function_options::nparams is now always correctly initialized, even if no
[ginac.git] / ginac / function.pl
index 312640fe7c31d8b89b95fb47bb763148273acc8e..318e46c19bda4143f4f77908f19928de6cbdf203 100755 (executable)
@@ -60,6 +60,7 @@ $declare_function_macro = generate(
        <<'END_OF_DECLARE_FUNCTION_MACRO','typename T${N}','const T${N} & p${N}','GiNaC::ex(p${N})');
 #define DECLARE_FUNCTION_${N}P(NAME) \\
 class NAME##_SERIAL { public: static unsigned serial; }; \\
+const unsigned NAME##_NPARAMS = ${N}; \\
 template<${SEQ1}> const GiNaC::function NAME(${SEQ2}) { \\
        return GiNaC::function(NAME##_SERIAL::serial, ${SEQ3}); \\
 }
@@ -260,7 +261,7 @@ $declare_function_macro
 
 #define REGISTER_FUNCTION(NAME,OPT) \\
 unsigned NAME##_SERIAL::serial = \\
-       GiNaC::function::register_new(GiNaC::function_options(#NAME).OPT);
+       GiNaC::function::register_new(GiNaC::function_options(#NAME, NAME##_NPARAMS).OPT);
 
 namespace GiNaC {
 
@@ -300,6 +301,7 @@ class function_options
 public:
        function_options();
        function_options(std::string const & n, std::string const & tn=std::string());
+       function_options(std::string const & n, unsigned np);
        ~function_options();
        void initialize();
 
@@ -537,6 +539,13 @@ function_options::function_options(std::string const & n, std::string const & tn
        set_name(n, tn);
 }
 
+function_options::function_options(std::string const & n, unsigned np)
+{
+       initialize();
+       set_name(n, std::string());
+       nparams = np;
+}
+
 function_options::~function_options()
 {
        // nothing to clean up at the moment
@@ -557,6 +566,7 @@ void function_options::initialize()
        print_use_exvector_args = false;
        use_remember = false;
        functions_with_same_name = 1;
+       symtree = 0;
 }
 
 function_options & function_options::set_name(std::string const & n,