]> www.ginac.de Git - ginac.git/blobdiff - ginac/container.pl
- exprseq and lst are commutative (they shouldn't appear in products anyway,
[ginac.git] / ginac / container.pl
index a0a4a7b10598e6bc49d3ff1e74e7e931d3d989fc..9b02154097836fb0f4718eb3b3f275018e8148bd 100755 (executable)
@@ -168,7 +168,6 @@ $constructors_implementation=generate(
        <<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}',', ','    seq.push_back(param${N});',"\n");
 ${CONTAINER}::${CONTAINER}(${SEQ1}) : basic(TINFO_${CONTAINER})
 {
-       debugmsg(\"${CONTAINER} ctor from ${N}*ex\",LOGLEVEL_CONSTRUCT);
        RESERVE(seq,${N});
 ${SEQ2}
 }
@@ -192,7 +191,7 @@ $interface=<<END_OF_INTERFACE;
  *                        \$close_bracket=${close_bracket}
  *                        \$maxargs=${maxargs}
  *
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -245,7 +244,6 @@ public:
        ex subs(const lst & ls, const lst & lr, bool no_pattern = false) const;
 protected:
        bool is_equal_same_type(const basic & other) const;
-       unsigned return_type(void) const;
 
        // new virtual functions which can be overridden by derived classes
 public:
@@ -271,24 +269,12 @@ protected:
 
 // utility functions
 
-/** Return the ${CONTAINER} object handled by an ex.  Deprecated: use ex_to<${CONTAINER}>().
- *  This is unsafe: you need to check the type first. */
-inline const ${CONTAINER} &ex_to_${CONTAINER}(const ex &e)
-{
-       return static_cast<const ${CONTAINER} &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<${CONTAINER}>(obj) for ${CONTAINER} objects. */
 template<> inline bool is_exactly_a<${CONTAINER}>(const basic & obj)
 {
        return obj.tinfo()==TINFO_${CONTAINER};
 }
 
-inline ${CONTAINER} &ex_to_nonconst_${CONTAINER}(const ex &e)
-{
-       return static_cast<${CONTAINER} &>(*e.bp);
-}
-
 } // namespace GiNaC
 
 #endif // ndef __GINAC_${CONTAINER_UC}_H__
@@ -312,7 +298,7 @@ $implementation=<<END_OF_IMPLEMENTATION;
  *                        \$close_bracket=${close_bracket}
  *                        \$maxargs=${maxargs}
  *
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -336,7 +322,6 @@ $implementation=<<END_OF_IMPLEMENTATION;
 #include "ex.h"
 #include "print.h"
 #include "archive.h"
-#include "debugmsg.h"
 
 namespace GiNaC {
 
@@ -345,15 +330,12 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(${CONTAINER}, basic)
 ${RESERVE_IMPLEMENTATION}
 
 //////////
-// default ctor, dtor, copy ctor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
 //////////
 
 // public
 
-${CONTAINER}::${CONTAINER}() : basic(TINFO_${CONTAINER})
-{
-       debugmsg("${CONTAINER} default ctor",LOGLEVEL_CONSTRUCT);
-}
+${CONTAINER}::${CONTAINER}() : basic(TINFO_${CONTAINER}) {}
 
 // protected
 
@@ -377,7 +359,6 @@ void ${CONTAINER}::destroy(bool call_parent)
 
 ${CONTAINER}::${CONTAINER}(${STLT} const & s, bool discardable) :  basic(TINFO_${CONTAINER})
 {
-       debugmsg("${CONTAINER} ctor from ${STLT}", LOGLEVEL_CONSTRUCT);
        if (discardable) {
                seq.swap(const_cast<${STLT} &>(s));
        } else {
@@ -387,7 +368,6 @@ ${CONTAINER}::${CONTAINER}(${STLT} const & s, bool discardable) :  basic(TINFO_$
 
 ${CONTAINER}::${CONTAINER}(${STLT} * vp) : basic(TINFO_${CONTAINER})
 {
-       debugmsg("${CONTAINER} ctor from ${STLT} *",LOGLEVEL_CONSTRUCT);
        GINAC_ASSERT(vp!=0);
        seq.swap(*vp);
        delete vp;
@@ -402,7 +382,6 @@ ${constructors_implementation}
 /** Construct object from archive_node. */
 ${CONTAINER}::${CONTAINER}(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
-       debugmsg("${CONTAINER} ctor from archive_node", LOGLEVEL_CONSTRUCT);
        for (unsigned int i=0; true; i++) {
                ex e;
                if (n.find_ex("seq", e, sym_lst, i))
@@ -430,15 +409,13 @@ void ${CONTAINER}::archive(archive_node &n) const
 }
 
 //////////
-// functions overriding virtual functions from bases classes
+// functions overriding virtual functions from base classes
 //////////
 
 // public
 
 void ${CONTAINER}::print(const print_context & c, unsigned level) const
 {
-       debugmsg("${CONTAINER} print", LOGLEVEL_PRINT);
-
        if (is_a<print_tree>(c)) {
 
                c.s << std::string(level, ' ') << class_name()
@@ -452,7 +429,11 @@ void ${CONTAINER}::print(const print_context & c, unsigned level) const
                        ++i;
                }
                c.s << std::string(level + delta_indent,' ') << "=====" << std::endl;
-
+       } else if (is_a<print_python>(c)) {
+               printseq(c, '[', ',', ']', precedence(), precedence()+1);
+       } else if (is_a<print_python_repr>(c)) {
+               c.s << class_name ();
+               printseq(c, '(', ',', ')', precedence(), precedence()+1);
        } else {
                // always print brackets around seq, ignore upper_precedence
                printseq(c, '${open_bracket}', ',', '${close_bracket}', precedence(), precedence()+1);
@@ -495,7 +476,7 @@ ex ${CONTAINER}::subs(const lst & ls, const lst & lr, bool no_pattern) const
 {
        ${STLT} *vp = subschildren(ls, lr, no_pattern);
        if (vp)
-               return this${CONTAINER}(vp).bp->basic::subs(ls, lr, no_pattern);
+               return ex_to<basic>(this${CONTAINER}(vp)).basic::subs(ls, lr, no_pattern);
        else
                return basic::subs(ls, lr, no_pattern);
 }
@@ -540,11 +521,6 @@ bool ${CONTAINER}::is_equal_same_type(const basic & other) const
        return true;
 }
 
-unsigned ${CONTAINER}::return_type(void) const
-{
-       return return_types::noncommutative_composite;
-}
-
 //////////
 // new virtual functions which can be overridden by derived classes
 //////////