]> www.ginac.de Git - ginac.git/blobdiff - ginac/structure.pl
- Changed behaviour of .evalf() to not evalf any exponents.
[ginac.git] / ginac / structure.pl
index b6137d0b41f57c2ddec32b254b9d07d621215377..41989148a52c57e731ea77112a32cbee6be3543d 100755 (executable)
@@ -32,7 +32,7 @@ while ($decl =~ /^ ?(\w+) ([\w \,]+)\; ?((\/\*.*?\*\/)?)(.*)$/) {
         }
         $member=$2;
     }
-    if ($member !~ /^\w$/) {
+    if ($member !~ /^\w+$/) {
         die "illegal struct, must match 'struct name { type var; /*comment*/ ...};': $input_structure";
     }
     push @TYPES,$type;
@@ -71,7 +71,7 @@ sub generate {
 
 $number_of_members=$#MEMBERS+1;
 $constructor_arglist=generate('ex tmp_${MEMBER}',', ');
-$member_access_functions=generate('    ex const & ${MEMBER}(void) { return m_${MEMBER}; }',"\n");
+$member_access_functions=generate('    const ex & ${MEMBER}(void) { return m_${MEMBER}; }',"\n");
 $op_access_indices_decl=generate('    static unsigned op_${MEMBER};',"\n");
 $op_access_indices_def=generate('unsigned ${STRUCTURE}::op_${MEMBER}=${N}-1;',"\n");
 $members=generate('    ex m_${MEMBER}; ${COMMENT}',"\n");
@@ -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 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2000 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
@@ -148,9 +148,11 @@ ${input_structure}
 #ifndef __GINAC_${STRUCTURE_UC}_H__
 #define __GINAC_${STRUCTURE_UC}_H__
 
-#include <ginac/structure.h>
+#include "structure.h"
 
+#ifndef NO_NAMESPACE_GINAC
 namespace GiNaC {
+#endif // ndef NO_NAMESPACE_GINAC
 
 class ${STRUCTURE} : public structure
 {
@@ -177,17 +179,17 @@ public:
     void print(ostream & os, unsigned upper_precedence=0) const;
     void printtree(ostream & os, unsigned indent) const;
     int nops() const;
-    ex & let_op(int const i);
+    ex & let_op(int i);
     ex expand(unsigned options=0) const;
-    bool has(ex const & other) const;
+    bool has(const ex & other) const;
     ex eval(int level=0) const;
     ex evalf(int level=0) const;
     ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
-    ex diff(symbol const & s) const;
-    ex subs(lst const & ls, lst const & lr) const;
+    ex diff(const symbol & s) const;
+    ex subs(const lst & ls, const lst & lr) const;
 protected:
-    int compare_same_type(basic const & other) const;
-    bool is_equal_same_type(basic const & other) const;
+    int compare_same_type(const basic & other) const;
+    bool is_equal_same_type(const basic & other) const;
     unsigned return_type(void) const;
 
     // new virtual functions which can be overridden by derived classes
@@ -208,14 +210,16 @@ ${op_access_indices_decl}
 // global constants
 
 extern const ${STRUCTURE} some_${STRUCTURE};
-extern type_info const & typeid_${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_
 
@@ -230,7 +234,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 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2000 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
@@ -254,7 +258,9 @@ ${input_structure}
 
 #include "${STRUCTURE}.h"
 
+#ifndef NO_NAMESPACE_GINAC
 namespace GiNaC {
+#endif // ndef NO_NAMESPACE_GINAC
 
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
@@ -352,10 +358,10 @@ int ${STRUCTURE}::nops() const
     return ${number_of_members};
 }
 
-ex & ${STRUCTURE}::let_op(int const i)
+ex & ${STRUCTURE}::let_op(int i)
 {
-    ASSERT(i>=0);
-    ASSERT(i<nops());
+    GINAC_ASSERT(i>=0);
+    GINAC_ASSERT(i<nops());
 
     switch (i) {
 ${let_op_statements}
@@ -376,9 +382,9 @@ ${expand_statements}
 
 // a ${STRUCTURE} 'has' an expression if it is this expression itself or a child 'has' it
 
-bool ${STRUCTURE}::has(ex const & other) const
+bool ${STRUCTURE}::has(const ex & other) const
 {
-    ASSERT(other.bp!=0);
+    GINAC_ASSERT(other.bp!=0);
     if (is_equal(*other.bp)) return true;
 ${has_statements}
     return false;
@@ -430,13 +436,13 @@ ${normal_statements}
 /** ${STRUCTURE}::diff() differentiates the children.
     there is no need to check for triavially equal, since diff usually
     does not return itself unevaluated. */
-ex ${STRUCTURE}::diff(symbol const & s) const
+ex ${STRUCTURE}::diff(const symbol & s) const
 {
 ${diff_statements}
     return ${STRUCTURE}(${temporary_arglist});
 }
 
-ex ${STRUCTURE}::subs(lst const & ls, lst const & lr) const
+ex ${STRUCTURE}::subs(const lst & ls, const lst & lr) const
 {
     bool all_are_trivially_equal=true;
 ${subs_statements}
@@ -448,9 +454,9 @@ ${subs_statements}
 
 // protected
 
-int ${STRUCTURE}::compare_same_type(basic const & other) const
+int ${STRUCTURE}::compare_same_type(const basic & other) const
 {
-    ASSERT(is_of_type(other,${STRUCTURE}));
+    GINAC_ASSERT(is_of_type(other,${STRUCTURE}));
     ${STRUCTURE} const & o=static_cast<${STRUCTURE} const &>
                                     (const_cast<basic &>(other));
     int cmpval;
@@ -458,9 +464,9 @@ ${compare_statements}
     return 0;
 }
 
-bool ${STRUCTURE}::is_equal_same_type(basic const & other) const
+bool ${STRUCTURE}::is_equal_same_type(const basic & other) const
 {
-    ASSERT(is_of_type(other,${STRUCTURE}));
+    GINAC_ASSERT(is_of_type(other,${STRUCTURE}));
     ${STRUCTURE} const & o=static_cast<${STRUCTURE} const &>
                                     (const_cast<basic &>(other));
 ${is_equal_statements}
@@ -505,10 +511,12 @@ ${op_access_indices_def}
 //////////
 
 const ${STRUCTURE} some_${STRUCTURE};
-type_info const & typeid_${STRUCTURE}=typeid(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