From def26469ff96228c66e877bb5594e7d9a24b638f Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Fri, 17 Oct 2008 13:41:01 +0400 Subject: [PATCH] Wipe out remnants of custom RTTI. Custom RTTI considered harmful, final part. --- doc/examples/mystring.cpp | 6 +++--- ginac/add.cpp | 6 ------ ginac/basic.cpp | 6 ++---- ginac/basic.h | 9 +-------- ginac/clifford.cpp | 5 ----- ginac/clifford.h | 4 ---- ginac/color.cpp | 5 ----- ginac/constant.cpp | 6 +++--- ginac/container.h | 41 +++++++++++++++++++-------------------- ginac/expairseq.cpp | 12 ++++++------ ginac/exprseq.h | 3 --- ginac/fderivative.cpp | 4 ---- ginac/function.pl | 6 ------ ginac/idx.cpp | 8 ++------ ginac/indexed.cpp | 14 ------------- ginac/integral.cpp | 4 ++-- ginac/lst.h | 3 --- ginac/matrix.cpp | 9 ++++----- ginac/mul.cpp | 7 ------- ginac/ncmul.cpp | 8 -------- ginac/numeric.cpp | 18 ++++++++--------- ginac/power.cpp | 2 +- ginac/power.h | 4 ++-- ginac/pseries.cpp | 4 ++-- ginac/registrar.h | 14 +++---------- ginac/relational.cpp | 5 +++-- ginac/structure.h | 5 ++--- ginac/symbol.cpp | 24 ++++++++++++++--------- ginac/symmetry.cpp | 6 +++--- ginac/tensor.cpp | 7 +------ ginac/tensor.h | 4 ---- ginac/utils.h | 2 +- ginac/wildcard.cpp | 4 ++-- 33 files changed, 87 insertions(+), 178 deletions(-) diff --git a/doc/examples/mystring.cpp b/doc/examples/mystring.cpp index e9d12591..eb0e452c 100644 --- a/doc/examples/mystring.cpp +++ b/doc/examples/mystring.cpp @@ -29,9 +29,9 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(mystring, basic, print_func(&mystring::do_print)) // ctors -mystring::mystring() : inherited(&mystring::tinfo_static) { } -mystring::mystring(const string &s) : inherited(&mystring::tinfo_static), str(s) { } -mystring::mystring(const char *s) : inherited(&mystring::tinfo_static), str(s) { } +mystring::mystring() { } +mystring::mystring(const string &s) : str(s) { } +mystring::mystring(const char *s) : str(s) { } // comparison int mystring::compare_same_type(const basic &other) const diff --git a/ginac/add.cpp b/ginac/add.cpp index 547bee32..7f721544 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -49,7 +49,6 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(add, expairseq, add::add() { - tinfo_key = &add::tinfo_static; } ////////// @@ -60,7 +59,6 @@ add::add() add::add(const ex & lh, const ex & rh) { - tinfo_key = &add::tinfo_static; overall_coeff = _ex0; construct_from_2_ex(lh,rh); GINAC_ASSERT(is_canonical()); @@ -68,7 +66,6 @@ add::add(const ex & lh, const ex & rh) add::add(const exvector & v) { - tinfo_key = &add::tinfo_static; overall_coeff = _ex0; construct_from_exvector(v); GINAC_ASSERT(is_canonical()); @@ -76,7 +73,6 @@ add::add(const exvector & v) add::add(const epvector & v) { - tinfo_key = &add::tinfo_static; overall_coeff = _ex0; construct_from_epvector(v); GINAC_ASSERT(is_canonical()); @@ -84,7 +80,6 @@ add::add(const epvector & v) add::add(const epvector & v, const ex & oc) { - tinfo_key = &add::tinfo_static; overall_coeff = oc; construct_from_epvector(v); GINAC_ASSERT(is_canonical()); @@ -92,7 +87,6 @@ add::add(const epvector & v, const ex & oc) add::add(std::auto_ptr vp, const ex & oc) { - tinfo_key = &add::tinfo_static; GINAC_ASSERT(vp.get()!=0); overall_coeff = oc; construct_from_epvector(*vp); diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 567760c9..237c63df 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -55,7 +55,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(basic, void, /** basic copy constructor: implicitly assumes that the other class is of * the exact same type (as it's used by duplicate()), so it can copy the * tinfo_key and the hash value. */ -basic::basic(const basic & other) : tinfo_key(other.tinfo_key), flags(other.flags & ~status_flags::dynallocated), hashvalue(other.hashvalue) +basic::basic(const basic & other) : flags(other.flags & ~status_flags::dynallocated), hashvalue(other.hashvalue) { } @@ -96,9 +96,7 @@ basic::basic(const archive_node &n, lst &sym_lst) : flags(0) { // Reconstruct tinfo_key from class name std::string class_name; - if (n.find_string("class", class_name)) - tinfo_key = find_tinfo_key(class_name); - else + if (!n.find_string("class", class_name)) throw (std::runtime_error("archive node contains no class name")); } diff --git a/ginac/basic.h b/ginac/basic.h index 3685fb53..534a5915 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -109,7 +109,7 @@ class basic : public refcounted // default constructor, destructor, copy constructor and assignment operator protected: - basic() : tinfo_key(&tinfo_static), flags(0) {} + basic() : flags(0) {} public: /** basic destructor, virtual because class ex will delete objects of @@ -122,10 +122,6 @@ public: const basic & operator=(const basic & other); protected: - /** Constructor with specified tinfo_key (used by derived classes instead - * of the default constructor to avoid assigning tinfo_key twice). */ - basic(tinfo_t ti) : tinfo_key(ti), flags(0) {} - // new virtual functions which can be overridden by derived classes public: // only const functions please (may break reference counting) @@ -266,8 +262,6 @@ public: } } - tinfo_t tinfo() const {return tinfo_key;} - /** Set some status_flags. */ const basic & setflag(unsigned f) const {flags |= f; return *this;} @@ -283,7 +277,6 @@ protected: // member variables protected: - tinfo_t tinfo_key; ///< type info mutable unsigned flags; ///< of type status_flags mutable unsigned hashvalue; ///< hash value }; diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index e6600372..d3667aac 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -76,7 +76,6 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(diracgammaR, tensor, clifford::clifford() : representation_label(0), metric(0), commutator_sign(-1) { - tinfo_key = &clifford::tinfo_static; } DEFAULT_CTOR(diracone) @@ -95,7 +94,6 @@ DEFAULT_CTOR(diracgammaR) * @see dirac_ONE */ clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representation_label(rl), metric(0), commutator_sign(-1) { - tinfo_key = &clifford::tinfo_static; } /** Construct object with one Lorentz index. This constructor is for internal @@ -105,17 +103,14 @@ clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representatio clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl, int comm_sign) : inherited(b, mu), representation_label(rl), metric(metr), commutator_sign(comm_sign) { GINAC_ASSERT(is_a(mu)); - tinfo_key = &clifford::tinfo_static; } clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), commutator_sign(comm_sign) { - tinfo_key = &clifford::tinfo_static; } clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, std::auto_ptr vp) : inherited(not_symmetric(), vp), representation_label(rl), metric(metr), commutator_sign(comm_sign) { - tinfo_key = &clifford::tinfo_static; } return_type_t clifford::return_type_tinfo() const diff --git a/ginac/clifford.h b/ginac/clifford.h index 59b49d0f..6b74a468 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -101,10 +101,6 @@ class cliffordunit : public tensor { GINAC_DECLARE_REGISTERED_CLASS(cliffordunit, tensor) - // other constructors -protected: - cliffordunit(tinfo_t ti) : inherited(ti) {} - // functions overriding virtual functions from base classes public: bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; diff --git a/ginac/color.cpp b/ginac/color.cpp index 43768633..30c38d9f 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -61,7 +61,6 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3d, tensor, color::color() : representation_label(0) { - tinfo_key = &color::tinfo_static; } DEFAULT_CTOR(su3one) @@ -78,7 +77,6 @@ DEFAULT_CTOR(su3d) * @see color_ONE */ color::color(const ex & b, unsigned char rl) : inherited(b), representation_label(rl) { - tinfo_key = &color::tinfo_static; } /** Construct object with one color index. This constructor is for internal @@ -86,17 +84,14 @@ color::color(const ex & b, unsigned char rl) : inherited(b), representation_labe * @see color_T */ color::color(const ex & b, const ex & i1, unsigned char rl) : inherited(b, i1), representation_label(rl) { - tinfo_key = &color::tinfo_static; } color::color(unsigned char rl, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl) { - tinfo_key = &color::tinfo_static; } color::color(unsigned char rl, std::auto_ptr vp) : inherited(not_symmetric(), vp), representation_label(rl) { - tinfo_key = &color::tinfo_static; } return_type_t color::return_type_tinfo() const diff --git a/ginac/constant.cpp b/ginac/constant.cpp index b63427fc..9247ac20 100644 --- a/ginac/constant.cpp +++ b/ginac/constant.cpp @@ -45,7 +45,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(constant, basic, // public -constant::constant() : basic(&constant::tinfo_static), ef(0), serial(next_serial++), domain(domain::complex) +constant::constant() : ef(0), serial(next_serial++), domain(domain::complex) { setflag(status_flags::evaluated | status_flags::expanded); } @@ -57,7 +57,7 @@ constant::constant() : basic(&constant::tinfo_static), ef(0), serial(next_serial // public constant::constant(const std::string & initname, evalffunctype efun, const std::string & texname, unsigned dm) - : basic(&constant::tinfo_static), name(initname), ef(efun), serial(next_serial++), domain(dm) + : name(initname), ef(efun), serial(next_serial++), domain(dm) { if (texname.empty()) TeX_name = "\\mbox{" + name + "}"; @@ -67,7 +67,7 @@ constant::constant(const std::string & initname, evalffunctype efun, const std:: } constant::constant(const std::string & initname, const numeric & initnumber, const std::string & texname, unsigned dm) - : basic(&constant::tinfo_static), name(initname), ef(0), number(initnumber), serial(next_serial++), domain(dm) + : name(initname), ef(0), number(initnumber), serial(next_serial++), domain(dm) { if (texname.empty()) TeX_name = "\\mbox{" + name + "}"; diff --git a/ginac/container.h b/ginac/container.h index bd21eb91..7092e3b0 100644 --- a/ginac/container.h +++ b/ginac/container.h @@ -138,14 +138,13 @@ public: protected: // helpers - static tinfo_t get_tinfo() { return NULL; } static unsigned get_default_flags() { return 0; } static char get_open_delim() { return '('; } static char get_close_delim() { return ')'; } // constructors public: - container(STLT const & s, bool discardable = false) : inherited(get_tinfo()) + container(STLT const & s, bool discardable = false) { setflag(get_default_flags()); @@ -155,32 +154,32 @@ public: this->seq = s; } - explicit container(std::auto_ptr vp) : inherited(get_tinfo()) + explicit container(std::auto_ptr vp) { setflag(get_default_flags()); this->seq.swap(*vp); } container(exvector::const_iterator b, exvector::const_iterator e) - : inherited(get_tinfo()), container_storage(b, e) + : container_storage(b, e) { setflag(get_default_flags()); } explicit container(const ex & p1) - : inherited(get_tinfo()), container_storage(1, p1) + : container_storage(1, p1) { setflag(get_default_flags()); } - container(const ex & p1, const ex & p2) : inherited(get_tinfo()) + container(const ex & p1, const ex & p2) { setflag(get_default_flags()); reserve(this->seq, 2); this->seq.push_back(p1); this->seq.push_back(p2); } - container(const ex & p1, const ex & p2, const ex & p3) : inherited(get_tinfo()) + container(const ex & p1, const ex & p2, const ex & p3) { setflag(get_default_flags()); reserve(this->seq, 3); @@ -188,7 +187,7 @@ public: } container(const ex & p1, const ex & p2, const ex & p3, - const ex & p4) : inherited(get_tinfo()) + const ex & p4) { setflag(get_default_flags()); reserve(this->seq, 4); @@ -197,7 +196,7 @@ public: } container(const ex & p1, const ex & p2, const ex & p3, - const ex & p4, const ex & p5) : inherited(get_tinfo()) + const ex & p4, const ex & p5) { setflag(get_default_flags()); reserve(this->seq, 5); @@ -206,7 +205,7 @@ public: } container(const ex & p1, const ex & p2, const ex & p3, - const ex & p4, const ex & p5, const ex & p6) : inherited(get_tinfo()) + const ex & p4, const ex & p5, const ex & p6) { setflag(get_default_flags()); reserve(this->seq, 6); @@ -216,7 +215,7 @@ public: container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, - const ex & p7) : inherited(get_tinfo()) + const ex & p7) { setflag(get_default_flags()); reserve(this->seq, 7); @@ -227,7 +226,7 @@ public: container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, - const ex & p7, const ex & p8) : inherited(get_tinfo()) + const ex & p7, const ex & p8) { setflag(get_default_flags()); reserve(this->seq, 8); @@ -238,7 +237,7 @@ public: container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, - const ex & p7, const ex & p8, const ex & p9) : inherited(get_tinfo()) + const ex & p7, const ex & p8, const ex & p9) { setflag(get_default_flags()); reserve(this->seq, 9); @@ -250,7 +249,7 @@ public: container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8, const ex & p9, - const ex & p10) : inherited(get_tinfo()) + const ex & p10) { setflag(get_default_flags()); reserve(this->seq, 10); @@ -263,7 +262,7 @@ public: container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8, const ex & p9, - const ex & p10, const ex & p11) : inherited(get_tinfo()) + const ex & p10, const ex & p11) { setflag(get_default_flags()); reserve(this->seq, 11); @@ -276,7 +275,7 @@ public: container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8, const ex & p9, - const ex & p10, const ex & p11, const ex & p12) : inherited(get_tinfo()) + const ex & p10, const ex & p11, const ex & p12) { setflag(get_default_flags()); reserve(this->seq, 12); @@ -290,7 +289,7 @@ public: const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8, const ex & p9, const ex & p10, const ex & p11, const ex & p12, - const ex & p13) : inherited(get_tinfo()) + const ex & p13) { setflag(get_default_flags()); reserve(this->seq, 13); @@ -305,7 +304,7 @@ public: const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8, const ex & p9, const ex & p10, const ex & p11, const ex & p12, - const ex & p13, const ex & p14) : inherited(get_tinfo()) + const ex & p13, const ex & p14) { setflag(get_default_flags()); reserve(this->seq, 14); @@ -320,7 +319,7 @@ public: const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8, const ex & p9, const ex & p10, const ex & p11, const ex & p12, - const ex & p13, const ex & p14, const ex & p15) : inherited(get_tinfo()) + const ex & p13, const ex & p14, const ex & p15) { setflag(get_default_flags()); reserve(this->seq, 15); @@ -336,7 +335,7 @@ public: const ex & p7, const ex & p8, const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14, const ex & p15, - const ex & p16) : inherited(get_tinfo()) + const ex & p16) { setflag(get_default_flags()); reserve(this->seq, 16); @@ -476,7 +475,7 @@ protected: /** Default constructor */ template