]> www.ginac.de Git - ginac.git/blobdiff - ginac/structure.pl
- eta(x,y) was broken all along since ages: eta(I,I) for instance ought
[ginac.git] / ginac / structure.pl
index 9a734c907acd0dac808457d4c4a3842c231cef49..f6b8a4898855e71f1d13e4645f8822778aded59b 100755 (executable)
@@ -170,12 +170,10 @@ protected:
 public:
        ${STRUCTURE}(${constructor_arglist});
 
-       // functions overriding virtual functions from bases classes
+       // functions overriding virtual functions from base classes
 public:
        basic * duplicate() const;
-       void printraw(ostream & os) const;
-       void print(ostream & os, unsigned upper_precedence=0) const;
-       void printtree(ostream & os, unsigned indent) const;
+       void print(const print_context & c, unsigned level = 0) const;
        int nops() const;
        ex & let_op(int i);
        ex expand(unsigned options=0) const;
@@ -211,10 +209,6 @@ extern const ${STRUCTURE} some_${STRUCTURE};
 extern const type_info & typeid_${STRUCTURE};
 extern const unsigned tinfo_${STRUCTURE};
 
-// macros
-
-#define ex_to_${STRUCTURE}(X) (static_cast<${STRUCTURE} const &>(*(X).bp))
-
 } // namespace GiNaC
 
 #endif // ndef _${STRUCTURE_UC}_H_
@@ -251,8 +245,10 @@ $implementation=<<END_OF_IMPLEMENTATION;
 ${input_structure}
 
 #include <iostream>
+#include <stdexcept>
 
 #include "${STRUCTURE}.h"
+#include "print.h"
 
 namespace GiNaC {
 
@@ -317,7 +313,7 @@ ${STRUCTURE}::${STRUCTURE}(${constructor_arglist})
 }
 
 //////////
-// functions overriding virtual functions from bases classes
+// functions overriding virtual functions from base classes
 //////////
 
 // public
@@ -328,22 +324,10 @@ basic * ${STRUCTURE}::duplicate() const
        return new ${STRUCTURE}(*this);
 }
 
-void ${STRUCTURE}::printraw(ostream & os) const
-{
-       debugmsg("${STRUCTURE} printraw",LOGLEVEL_PRINT);
-       os << class_name() << "()";
-}
-
-void ${STRUCTURE}::print(ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("${STRUCTURE} print",LOGLEVEL_PRINT);
-       os << class_name() << "()";
-}
-
-void ${STRUCTURE}::printtree(ostream & os, unsigned indent) const
+void ${STRUCTURE}::print(const print_context & c, unsigned level) const
 {
-       debugmsg("${STRUCTURE} printtree",LOGLEVEL_PRINT);
-       os << "${STRUCTURE}()";
+       debugmsg("${STRUCTURE} print", LOGLEVEL_PRINT);
+       c.s << class_name() << "()";
 }
 
 int ${STRUCTURE}::nops() const
@@ -359,8 +343,7 @@ ex & ${STRUCTURE}::let_op(int i)
        switch (i) {
 ${let_op_statements}
        }
-       errormsg("${STRUCTURE}::let_op(): should not reach this point");
-       return *new ex(fail());
+       throw(std::runtime_error("${STRUCTURE}::let_op(): should not have reached this point"));
 }
 
 ex ${STRUCTURE}::expand(unsigned options) const
@@ -450,8 +433,7 @@ ${subs_statements}
 int ${STRUCTURE}::compare_same_type(const basic & other) const
 {
        GINAC_ASSERT(is_of_type(other,${STRUCTURE}));
-       ${STRUCTURE} const & o=static_cast<${STRUCTURE} const &>
-                                                                       (const_cast<basic &>(other));
+       ${STRUCTURE} const &o = static_cast<const ${STRUCTURE} &>(other);
        int cmpval;
 ${compare_statements}
        return 0;
@@ -460,8 +442,7 @@ ${compare_statements}
 bool ${STRUCTURE}::is_equal_same_type(const basic & other) const
 {
        GINAC_ASSERT(is_of_type(other,${STRUCTURE}));
-       ${STRUCTURE} const & o=static_cast<${STRUCTURE} const &>
-                                                                       (const_cast<basic &>(other));
+       ${STRUCTURE} const &o = static_cast<const ${STRUCTURE} &>(other);
 ${is_equal_statements}
        return true;
 }