X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fwildcard.cpp;h=fa4153f1b5bff0b5fc5009ad1afa5f48c74f597a;hp=10aa7e40ac8c9007e0916615e74118720c2650d2;hb=8dc09f48182574d792a2ed7c37b66831d9267a6c;hpb=3a63743e24046766b37c3d1bd38605542ee0a536 diff --git a/ginac/wildcard.cpp b/ginac/wildcard.cpp index 10aa7e40..fa4153f1 100644 --- a/ginac/wildcard.cpp +++ b/ginac/wildcard.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's wildcard objects. */ /* - * 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 @@ -23,47 +23,42 @@ #include #include "wildcard.h" -#include "print.h" #include "archive.h" #include "utils.h" namespace GiNaC { -GINAC_IMPLEMENT_REGISTERED_CLASS(wildcard, basic) +GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(wildcard, basic, + print_func(&wildcard::do_print). + print_func(&wildcard::do_print_tree). + print_func(&wildcard::do_print_python_repr)) ////////// -// default ctor, dtor, copy ctor, assignment operator and helpers +// default constructor ////////// -wildcard::wildcard() : label(0) +wildcard::wildcard() : inherited(TINFO_wildcard), label(0) { - tinfo_key = TINFO_wildcard; + setflag(status_flags::evaluated | status_flags::expanded); } -void wildcard::copy(const wildcard & other) -{ - inherited::copy(other); - label = other.label; -} - -DEFAULT_DESTROY(wildcard) - ////////// // other constructors ////////// -wildcard::wildcard(unsigned l) : label(l) +wildcard::wildcard(unsigned l) : inherited(TINFO_wildcard), label(l) { - tinfo_key = TINFO_wildcard; + setflag(status_flags::evaluated | status_flags::expanded); } ////////// // archiving ////////// -wildcard::wildcard(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) +wildcard::wildcard(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) { n.find_unsigned("label", label); + setflag(status_flags::evaluated | status_flags::expanded); } void wildcard::archive(archive_node &n) const @@ -89,19 +84,24 @@ int wildcard::compare_same_type(const basic & other) const return label < o.label ? -1 : 1; } -void wildcard::print(const print_context & c, unsigned level) const +void wildcard::do_print(const print_context & c, unsigned level) const +{ + c.s << "$" << label; +} + +void wildcard::do_print_tree(const print_tree & c, unsigned level) const +{ + c.s << std::string(level, ' ') << class_name() << "(" << label << ")" << " @" << this + << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec + << std::endl; +} + +void wildcard::do_print_python_repr(const print_python_repr & c, unsigned level) const { - if (is_a(c)) { - c.s << std::string(level, ' ') << class_name() << " (" << label << ")" - << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec - << std::endl; - } else if (is_a(c)) { - c.s << class_name() << '(' << label << ')'; - } else - c.s << "$" << label; + c.s << class_name() << '(' << label << ')'; } -unsigned wildcard::calchash(void) const +unsigned wildcard::calchash() const { // this is where the schoolbook method // (golden_ratio_hash(tinfo()) ^ label)