From dd97c34fe124f520bab84b5c274349dacd2cbd43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 23 Nov 2010 12:29:46 +0000 Subject: [PATCH] Cleanup generated log code. --- base.py | 33 ++++++++++++++++----------------- log.cpp | 16 ++++++++-------- log.hpp | 16 ++++++++-------- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/base.py b/base.py index 615549a..3a801c1 100644 --- a/base.py +++ b/base.py @@ -193,16 +193,16 @@ class Concrete(Type): print ' Dump%s(%s);' % (self.id, instance) -class Literal(Concrete): +class Literal(Type): def __init__(self, expr, format, base=10): - Concrete.__init__(self, expr) + Type.__init__(self, expr) self.format = format def visit(self, visitor, *args, **kwargs): return visitor.visit_literal(self, *args, **kwargs) - def _dump(self, instance): + def dump(self, instance): print ' Log::Literal%s(%s);' % (self.format, instance) @@ -237,7 +237,7 @@ class Pointer(Type): def dump(self, instance): print ' if(%s) {' % instance - print ' Log::BeginPointer("%s", (const void *)%s);' % (self.type, instance) + print ' Log::BeginPointer((const void *)%s);' % (instance,) self.type.dump("*" + instance) print ' Log::EndPointer();' print ' }' @@ -292,7 +292,7 @@ class Bitmask(Concrete): def _dump(self, instance): print ' %s l_Value = %s;' % (self.type, instance) - print ' Log::BeginBitmask("%s");' % (self.type,) + print ' Log::BeginBitmask();' for value in self.values: print ' if((l_Value & %s) == %s) {' % (value, value) print ' Log::LiteralNamedConstant("%s", %s);' % (value, value) @@ -319,9 +319,9 @@ class Array(Type): def dump(self, instance): print ' if(%s) {' % instance index = '__i' + self.type.id - print ' Log::BeginArray("%s", %s);' % (self.type, self.length) + print ' Log::BeginArray(%s);' % (self.length,) print ' for (int %s = 0; %s < %s; ++%s) {' % (index, index, self.length, index) - print ' Log::BeginElement("%s");' % (self.type,) + print ' Log::BeginElement();' self.type.dump('(%s)[%s]' % (instance, index)) print ' Log::EndElement();' print ' }' @@ -362,9 +362,9 @@ class Struct(Concrete): return visitor.visit_struct(self, *args, **kwargs) def _dump(self, instance): - print ' Log::BeginStruct("%s");' % (self.name,) + print ' Log::BeginStruct("%s");' % self.name for type, name in self.members: - print ' Log::BeginMember("%s", "%s");' % (type, name) + print ' Log::BeginMember("%s");' % (name,) type.dump('(%s).%s' % (instance, name)) print ' Log::EndMember();' print ' Log::EndStruct();' @@ -478,18 +478,18 @@ class Function: for arg in self.args: if not arg.output: arg.type.unwrap_instance(arg.name) - print ' Log::BeginArg("%s", "%s");' % (arg.type, arg.name) + print ' Log::BeginArg("%s");' % (arg.name,) arg.type.dump(arg.name) print ' Log::EndArg();' print ' %s%s(%s);' % (result, pvalue, ', '.join([str(arg.name) for arg in self.args])) for arg in self.args: if arg.output: - print ' Log::BeginArg("%s", "%s");' % (arg.type, arg.name) + print ' Log::BeginArg("%s");' % (arg.name,) arg.type.dump(arg.name) print ' Log::EndArg();' arg.type.wrap_instance(arg.name) if self.type is not Void: - print ' Log::BeginReturn("%s");' % self.type + print ' Log::BeginReturn();' self.type.dump("result") print ' Log::EndReturn();' self.type.wrap_instance('result') @@ -565,20 +565,19 @@ class Interface(Type): print ' %s result;' % method.type result = 'result = ' print ' Log::BeginCall("%s");' % (self.name + '::' + method.name) - print ' Log::BeginArg("%s *", "this");' % self.name - print ' Log::BeginPointer("%s", (const void *)m_pInstance);' % self.name - print ' Log::EndPointer();' + print ' Log::BeginArg("this");' + print ' Log::LiteralOpaque((const void *)m_pInstance);' print ' Log::EndArg();' for arg in method.args: if not arg.output: arg.type.unwrap_instance(arg.name) - print ' Log::BeginArg("%s", "%s");' % (arg.type, arg.name) + print ' Log::BeginArg("%s");' % (arg.name,) arg.type.dump(arg.name) print ' Log::EndArg();' print ' %sm_pInstance->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args])) for arg in method.args: if arg.output: - print ' Log::BeginArg("%s", "%s");' % (arg.type, arg.name) + print ' Log::BeginArg("%s");' % (arg.name,) arg.type.dump(arg.name) print ' Log::EndArg();' arg.type.wrap_instance(arg.name) diff --git a/log.cpp b/log.cpp index b4708f3..f0f194b 100644 --- a/log.cpp +++ b/log.cpp @@ -156,31 +156,31 @@ void EndCall(void) { OS::ReleaseMutex(); } -void BeginArg(const char *type, const char *name) { +void BeginArg(const char *name) { WriteByte(Trace::CALL_ARG); WriteString(name); } void EndArg(void) { } -void BeginReturn(const char *type) { +void BeginReturn(void) { WriteByte(Trace::CALL_RET); } void EndReturn(void) { } -void BeginArray(const char *type, size_t length) { +void BeginArray(size_t length) { WriteByte(Trace::TYPE_ARRAY); WriteUInt(length); } void EndArray(void) { } -void BeginElement(const char *type) { } +void BeginElement(void) { } void EndElement(void) { } -void BeginStruct(const char *type) { +void BeginStruct(const char *name) { WriteByte(Trace::TYPE_STRUCT); } @@ -188,13 +188,13 @@ void EndStruct(void) { WriteString(""); } -void BeginMember(const char *type, const char *name) { +void BeginMember(const char *name) { WriteString(name); } void EndMember(void) { } -void BeginBitmask(const char *type) { +void BeginBitmask(void) { WriteByte(Trace::TYPE_BITMASK); } @@ -202,7 +202,7 @@ void EndBitmask(void) { WriteByte(Trace::TYPE_NULL); } -void BeginPointer(const char *type, const void *addr) +void BeginPointer(const void *addr) { WriteByte(Trace::TYPE_POINTER); WriteUInt((size_t)addr); diff --git a/log.hpp b/log.hpp index 33fe477..ffa1c2c 100644 --- a/log.hpp +++ b/log.hpp @@ -34,28 +34,28 @@ namespace Log { void BeginCall(const char *function); void EndCall(void); - void BeginArg(const char *type, const char *name); + void BeginArg(const char *name); void EndArg(void); - void BeginReturn(const char *type); + void BeginReturn(void); void EndReturn(void); - void BeginArray(const char *type, size_t length); + void BeginArray(size_t length); void EndArray(void); - void BeginElement(const char *type); + void BeginElement(void); void EndElement(void); - void BeginStruct(const char *type); + void BeginStruct(const char *name); void EndStruct(void); - void BeginMember(const char *type, const char *name); + void BeginMember(const char *name); void EndMember(void); - void BeginBitmask(const char *type); + void BeginBitmask(void); void EndBitmask(void); - void BeginPointer(const char *type, const void *addr); + void BeginPointer(const void *addr); void EndPointer(void); void LiteralBool(bool value); -- 2.45.2