+
+// Helper macros for class implementations (mostly useful for trivial classes)
+
+#define DEFAULT_COPY(classname) \
+void classname::copy(const classname & other) \
+{ \
+ inherited::copy(other); \
+}
+
+#define DEFAULT_DESTROY(classname) \
+void classname::destroy(bool call_parent) \
+{ \
+ if (call_parent) \
+ inherited::destroy(call_parent); \
+}
+
+#define DEFAULT_CTORS(classname) \
+classname::classname() : inherited(TINFO_##classname) \
+{ \
+ debugmsg(#classname " default constructor", LOGLEVEL_CONSTRUCT); \
+} \
+DEFAULT_COPY(classname) \
+DEFAULT_DESTROY(classname)
+
+#define DEFAULT_UNARCHIVE(classname) \
+ex classname::unarchive(const archive_node &n, const lst &sym_lst) \
+{ \
+ return (new classname(n, sym_lst))->setflag(status_flags::dynallocated); \
+}
+
+#define DEFAULT_ARCHIVING(classname) \
+classname::classname(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) \
+{ \
+ debugmsg(#classname " constructor from archive_node", LOGLEVEL_CONSTRUCT); \
+} \
+DEFAULT_UNARCHIVE(classname) \
+void classname::archive(archive_node &n) const \
+{ \
+ inherited::archive(n); \
+}
+
+#define DEFAULT_COMPARE(classname) \
+int classname::compare_same_type(const basic & other) const \
+{ \
+ /* by default, the objects are always identical */ \
+ return 0; \
+}
+
+#define DEFAULT_PRINT(classname, text) \
+void classname::print(const print_context & c, unsigned level) const \
+{ \
+ debugmsg(#classname " print", LOGLEVEL_PRINT); \
+ if (is_a<print_tree>(c)) \
+ inherited::print(c, level); \
+ else \
+ c.s << text; \
+}
+
+#define DEFAULT_PRINT_LATEX(classname, text, latex) \
+void classname::print(const print_context & c, unsigned level) const \
+{ \
+ debugmsg(#classname " print", LOGLEVEL_PRINT); \
+ if (is_a<print_tree>(c)) \
+ inherited::print(c, level); \
+ else if (is_a<print_latex>(c)) \
+ c.s << latex; \
+ else \
+ c.s << text; \
+}
+
+// Obsolete convenience macros. TO BE PHASED OUT SOON!
+// Use the inlined template functions in basic.h instead. (FIXME: remove them)
+
+#define is_of_type(OBJ,TYPE) \
+ (dynamic_cast<const TYPE *>(&OBJ)!=0)
+
+#define is_exactly_of_type(OBJ,TYPE) \
+ ((OBJ).tinfo()==GiNaC::TINFO_##TYPE)
+
+#define is_ex_of_type(OBJ,TYPE) \
+ (dynamic_cast<const TYPE *>((OBJ).bp)!=0)
+
+#define is_ex_exactly_of_type(OBJ,TYPE) \
+ ((*(OBJ).bp).tinfo()==GiNaC::TINFO_##TYPE)
+