From 0ab6d527125669ca7a36e5b27ff429c0f402ba77 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 8 Mar 2015 16:14:15 +0800 Subject: Macro parsing, saving, and evaluating --- src/include/debug.hpp | 24 ++++++++++++++++++++++++ src/include/serialise.hpp | 1 + 2 files changed, 25 insertions(+) (limited to 'src/include') diff --git a/src/include/debug.hpp b/src/include/debug.hpp index 012ef1bb..4da63192 100644 --- a/src/include/debug.hpp +++ b/src/include/debug.hpp @@ -24,3 +24,27 @@ struct RepeatLitStr } }; +class TraceLog +{ + static unsigned int depth; + const char* m_tag; +public: + TraceLog(const char* tag): m_tag(tag) { indent(); ::std::cout << ">> " << m_tag << ::std::endl; } + ~TraceLog() { outdent(); ::std::cout << "<< " << m_tag << ::std::endl; } +private: + void indent() + { + for(unsigned int i = 0; i < depth; i ++) + ::std::cout << " "; + depth ++; + } + void outdent() + { + depth --; + for(unsigned int i = 0; i < depth; i ++) + ::std::cout << " "; + } +}; +#define TRACE_FUNCTION TraceLog _tf_(__func__) + + diff --git a/src/include/serialise.hpp b/src/include/serialise.hpp index 3949c8ae..1c2b882e 100644 --- a/src/include/serialise.hpp +++ b/src/include/serialise.hpp @@ -20,6 +20,7 @@ class Deserialiser; const char* method_prefix serialise_tag() const { return tag_str; } \ void method_prefix serialise(::Serialiser& s) const { body } \ void method_prefix deserialise(::Deserialiser& s) { des_body } +#define SERIALISE_TYPE_A(method_prefix, tag_str, body) SERIALISE_TYPE(method_prefix, tag_str, body, body) #define SERIALISE_TYPE_S(class_, body) SERIALISE_TYPE(class_::, #class_, body, body) class Serialisable -- cgit v1.2.3