]> www.ginac.de Git - ginac.git/blobdiff - ginac/function.pl
A better return_type_tinfo() mechanism.
[ginac.git] / ginac / function.pl
index b478023f50dc2d56852e3ebceac374af178aeaea..88be68d89e129308ce6a5ac18d53eb766f9f2ef6 100644 (file)
@@ -410,7 +410,7 @@ $print_func_interface
                return *this;
        }
 
                return *this;
        }
 
-       function_options & set_return_type(unsigned rt, tinfo_t rtt=NULL);
+       function_options & set_return_type(unsigned rt, const return_type_t* rtt = 0);
        function_options & do_not_evalf_params();
        function_options & remember(unsigned size, unsigned assoc_size=0,
                                    unsigned strategy=remember_strategies::delete_never);
        function_options & do_not_evalf_params();
        function_options & remember(unsigned size, unsigned assoc_size=0,
                                    unsigned strategy=remember_strategies::delete_never);
@@ -445,7 +445,7 @@ protected:
 
        bool use_return_type;
        unsigned return_type;
 
        bool use_return_type;
        unsigned return_type;
-       tinfo_t return_type_tinfo;
+       return_type_t return_type_tinfo;
 
        bool use_remember;
        unsigned remember_size;
 
        bool use_remember;
        unsigned remember_size;
@@ -520,7 +520,7 @@ protected:
        bool is_equal_same_type(const basic & other) const;
        bool match_same_type(const basic & other) const;
        unsigned return_type() const;
        bool is_equal_same_type(const basic & other) const;
        bool match_same_type(const basic & other) const;
        unsigned return_type() const;
-       tinfo_t return_type_tinfo() const;
+       return_type_t return_type_tinfo() const;
        
        // new virtual functions which can be overridden by derived classes
        // none
        
        // new virtual functions which can be overridden by derived classes
        // none
@@ -739,11 +739,14 @@ function_options& function_options::series_func(series_funcp_exvector s)
        return *this;
 }
 
        return *this;
 }
 
-function_options & function_options::set_return_type(unsigned rt, tinfo_t rtt)
+function_options & function_options::set_return_type(unsigned rt, const return_type_t* rtt)
 {
        use_return_type = true;
        return_type = rt;
 {
        use_return_type = true;
        return_type = rt;
-       return_type_tinfo = rtt;
+       if (rtt != 0)
+               return_type_tinfo = *rtt;
+       else
+               return_type_tinfo = make_return_type_t<function>();
        return *this;
 }
 
        return *this;
 }
 
@@ -1258,7 +1261,7 @@ unsigned function::return_type() const
        }
 }
 
        }
 }
 
-tinfo_t function::return_type_tinfo() const
+return_type_t function::return_type_tinfo() const
 {
        GINAC_ASSERT(serial<registered_functions().size());
        const function_options &opt = registered_functions()[serial];
 {
        GINAC_ASSERT(serial<registered_functions().size());
        const function_options &opt = registered_functions()[serial];
@@ -1270,7 +1273,7 @@ tinfo_t function::return_type_tinfo() const
                // Default behavior is to use the return type of the first
                // argument. Thus, exp() of a matrix behaves like a matrix, etc.
                if (seq.empty())
                // Default behavior is to use the return type of the first
                // argument. Thus, exp() of a matrix behaves like a matrix, etc.
                if (seq.empty())
-                       return this;
+                       return make_return_type_t<function>();
                else
                        return seq.begin()->return_type_tinfo();
        }
                else
                        return seq.begin()->return_type_tinfo();
        }