summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-03-08 16:14:15 +0800
committerJohn Hodge <tpg@mutabah.net>2015-03-08 16:14:15 +0800
commit0ab6d527125669ca7a36e5b27ff429c0f402ba77 (patch)
tree1c7e14e452d563ebbe95acf39f2a7364a3c2d48b /src/include
parentfcec09900f158aa939eb1c96607aaabf4c8171ef (diff)
downloadmrust-0ab6d527125669ca7a36e5b27ff429c0f402ba77.tar.gz
Macro parsing, saving, and evaluating
Diffstat (limited to 'src/include')
-rw-r--r--src/include/debug.hpp24
-rw-r--r--src/include/serialise.hpp1
2 files changed, 25 insertions, 0 deletions
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