]> www.ginac.de Git - ginac.git/blobdiff - ginac/structure.pl
fixed a bug where quo() would call vector::reserve() with a negative argument
[ginac.git] / ginac / structure.pl
index 7521016a377e2013188261c485d0dd5ca74ac205..6c5760f865d9f589a3bace7199314e1ef0444fcb 100755 (executable)
@@ -125,7 +125,7 @@ $interface=<<END_OF_INTERFACE;
  *  This file was generated automatically by structure.pl.
  *  Please do not modify it directly, edit the perl script instead!
  *
- *  GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2001 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
@@ -150,15 +150,13 @@ ${input_structure}
 
 #include "structure.h"
 
-#ifndef NO_NAMESPACE_GINAC
 namespace GiNaC {
-#endif // ndef NO_NAMESPACE_GINAC
 
 class ${STRUCTURE} : public structure
 {
 // member functions
 
-       // default constructor, destructor, copy constructor assignment operator and helpers
+       // default ctor, dtor, copy ctor, assignment operator and helpers
 public:
        ${STRUCTURE}();
        ~${STRUCTURE}();
@@ -168,16 +166,14 @@ protected:
        void copy(${STRUCTURE} const & other);
        void destroy(bool call_parent);
 
-       // other constructors
+       // other ctors
 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;
@@ -213,13 +209,7 @@ 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))
-
-#ifndef NO_NAMESPACE_GINAC
 } // namespace GiNaC
-#endif // ndef NO_NAMESPACE_GINAC
 
 #endif // ndef _${STRUCTURE_UC}_H_
 
@@ -234,7 +224,7 @@ $implementation=<<END_OF_IMPLEMENTATION;
  *  This file was generated automatically by STRUCTURE.pl.
  *  Please do not modify it directly, edit the perl script instead!
  *
- *  GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2001 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
@@ -255,40 +245,36 @@ $implementation=<<END_OF_IMPLEMENTATION;
 ${input_structure}
 
 #include <iostream>
+#include <stdexcept>
 
 #include "${STRUCTURE}.h"
+#include "print.h"
 
-#ifndef NO_NAMESPACE_GINAC
 namespace GiNaC {
-#endif // ndef NO_NAMESPACE_GINAC
 
 //////////
-// default constructor, destructor, copy constructor assignment operator and helpers
+// default ctor, destructor, copy ctor assignment operator and helpers
 //////////
 
 // public
 
 ${STRUCTURE}::${STRUCTURE}()
 {
-       debugmsg("${STRUCTURE} default constructor",LOGLEVEL_CONSTRUCT);
        tinfo_key=tinfo_${STRUCTURE};
 }
 
 ${STRUCTURE}::~${STRUCTURE}()
 {
-       debugmsg("${STRUCTURE} destructor",LOGLEVEL_DESTRUCT);
        destroy(false);
 }
 
 ${STRUCTURE}::${STRUCTURE}(${STRUCTURE} const & other)
 {
-       debugmsg("${STRUCTURE} copy constructor",LOGLEVEL_CONSTRUCT);
        copy(other);
 }
 
 ${STRUCTURE} const & ${STRUCTURE}::operator=(${STRUCTURE} const & other)
 {
-       debugmsg("${STRUCTURE} operator=",LOGLEVEL_ASSIGNMENT);
        if (this != &other) {
                destroy(true);
                copy(other);
@@ -310,7 +296,7 @@ void ${STRUCTURE}::destroy(bool call_parent)
 }
 
 //////////
-// other constructors
+// other ctors
 //////////
 
 // public
@@ -318,38 +304,23 @@ void ${STRUCTURE}::destroy(bool call_parent)
 ${STRUCTURE}::${STRUCTURE}(${constructor_arglist}) 
        : ${constructor_statements}
 {
-       debugmsg("${STRUCTURE} constructor from children", LOGLEVEL_CONSTRUCT);
        tinfo_key=tinfo_${STRUCTURE};
 }
 
 //////////
-// functions overriding virtual functions from bases classes
+// functions overriding virtual functions from base classes
 //////////
 
 // public
 
 basic * ${STRUCTURE}::duplicate() const
 {
-       debugmsg("${STRUCTURE} duplicate",LOGLEVEL_DUPLICATE);
        return new ${STRUCTURE}(*this);
 }
 
-void ${STRUCTURE}::printraw(ostream & os) const
-{
-       debugmsg("${STRUCTURE} printraw",LOGLEVEL_PRINT);
-       os << "${STRUCTURE}()";
-}
-
-void ${STRUCTURE}::print(ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("${STRUCTURE} print",LOGLEVEL_PRINT);
-       os << "${STRUCTURE}()";
-}
-
-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}()";
+       c.s << class_name() << "()";
 }
 
 int ${STRUCTURE}::nops() const
@@ -365,8 +336,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
@@ -456,8 +426,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;
@@ -466,8 +435,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;
 }
@@ -513,9 +481,7 @@ const ${STRUCTURE} some_${STRUCTURE};
 const type_info & typeid_${STRUCTURE}=typeid(some_${STRUCTURE});
 const unsigned tinfo_${STRUCTURE}=structure::register_new("${STRUCTURE}");
 
-#ifndef NO_NAMESPACE_GINAC
 } // namespace GiNaC
-#endif // ndef NO_NAMESPACE_GINAC
 
 END_OF_IMPLEMENTATION