From: José Fonseca Date: Wed, 9 Jul 2008 17:00:31 +0000 (+0900) Subject: Improve the XML semantic info. CSS magic. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=3bccbb1d72f99497e3f0499dbe5f335d0176709a;p=apitrace Improve the XML semantic info. CSS magic. --- diff --git a/base.py b/base.py index d2b4a22..64a02ed 100644 --- a/base.py +++ b/base.py @@ -128,10 +128,12 @@ class Pointer(Type): def dump(self, instance): print ' if(%s) {' % instance + print ' Log::BeginReference("%s", %s);' % (self.type, instance) try: self.type.dump("*" + instance) except NotImplementedError: - print ' Log::TextF("%%p", %s);' % instance + pass + print ' Log::EndReference();' print ' }' print ' else' print ' Log::Text("NULL");' @@ -201,15 +203,10 @@ class Struct(Concrete): self.members = members def _dump(self, instance): - print ' Log::Text("{");' - first = True for type, name in self.members: - if first: - first = False - else: - print ' Log::Text(", ");' + print ' Log::BeginElement("%s", "%s");' % (type, name) type.dump('(%s).%s' % (instance, name)) - print ' Log::Text("}");' + print ' Log::EndElement();' class Alias(Type): @@ -302,21 +299,21 @@ class Interface(Type): print ' %s result;' % method.type result = 'result = ' print ' Log::BeginCall("%s");' % (self.name + '::' + method.name) - print ' Log::BeginParam("this", "%s *");' % self.name + print ' Log::BeginArg("%s *", "this");' % self.name print ' Log::TextF("%p", m_pInstance);' - print ' Log::EndParam();' + print ' Log::EndArg();' for type, name in method.args: if not type.isoutput(): type.unwrap_instance(name) - print ' Log::BeginParam("%s", "%s");' % (name, type) + print ' Log::BeginArg("%s", "%s");' % (type, name) type.dump(name) - print ' Log::EndParam();' + print ' Log::EndArg();' print ' %sm_pInstance->%s(%s);' % (result, method.name, ', '.join([str(name) for type, name in method.args])) for type, name in method.args: if type.isoutput(): - print ' Log::BeginParam("%s", "%s");' % (name, type) + print ' Log::BeginArg("%s", "%s");' % (type, name) type.dump(name) - print ' Log::EndParam();' + print ' Log::EndArg();' type.wrap_instance(name) if method.type is not Void: print ' Log::BeginReturn("%s");' % method.type diff --git a/d3dtrace-txt.xsl b/d3dtrace-txt.xsl index 36caf1a..ea5c255 100644 --- a/d3dtrace-txt.xsl +++ b/d3dtrace-txt.xsl @@ -13,24 +13,48 @@ ( - + ) - + - + = - + , - + = - + + + + + & + + + + + + + + + + + + { + + } + + + + + + diff --git a/d3dtrace.css b/d3dtrace.css index c72f363..535d6d2 100644 --- a/d3dtrace.css +++ b/d3dtrace.css @@ -5,12 +5,33 @@ body { text-align : left; } -ul { +ul.calls { list-style: none; margin-left: 0px; padding-left: 0px; } +ul.args { + display:inline; + list-style: none; + margin-left: 0px; + padding-left: 0px; +} + +ul.args li { + display:inline; +} + +ul.elems { + list-style: none; + margin-left: 2em; + padding-left: 0px; +} + +ul.elems li { + display:block; +} + .fun { font-weight: bold; } @@ -26,3 +47,25 @@ ul { .lit { color: #0000ff; } + +.addr { + color: #008000; +} + +.ref { + position: relative; +} + +.def { + display: none; + position: absolute; + top: 1.5em; + left: 0; + width: 32em; + background: #f7f7f7; +} + +.ref:hover .def { + display: block; +} + diff --git a/d3dtrace.xsl b/d3dtrace.xsl index de4336f..99c36d4 100644 --- a/d3dtrace.xsl +++ b/d3dtrace.xsl @@ -4,6 +4,8 @@ + + @@ -11,7 +13,7 @@ -
    +
    @@ -24,34 +26,87 @@ ( - +
      + +
    ) - + - - - - - + +
  • + + + = + + + , + +
  • +
    + + + + + + + + - + + + + = - + + + + + + + + + + + + + + + & + + + + + + + + + + - - , - - - = + + + + + { +
      + +
    + } +
    + + + +
    +
    diff --git a/log.cpp b/log.cpp index 0c5a09e..20df332 100644 --- a/log.cpp +++ b/log.cpp @@ -124,8 +124,13 @@ static void Escape(const char *s) { Write(s); } + +DWORD g_dwIndent = 0; + void NewLine(void) { Write("\r\n"); + for(unsigned i = 0; i < g_dwIndent; ++i) + Write("\t"); } void Tag(const char *name) { @@ -138,6 +143,7 @@ void BeginTag(const char *name) { Write("<"); Write(name); Write(">"); + ++g_dwIndent; } void BeginTag(const char *name, @@ -149,6 +155,7 @@ void BeginTag(const char *name, Write("=\""); Escape(value1); Write("\">"); + ++g_dwIndent; } void BeginTag(const char *name, @@ -165,9 +172,33 @@ void BeginTag(const char *name, Write("=\""); Escape(value2); Write("\">"); + ++g_dwIndent; +} + +void BeginTag(const char *name, + const char *attr1, const char *value1, + const char *attr2, const char *value2, + const char *attr3, const char *value3) { + Write("<"); + Write(name); + Write(" "); + Write(attr1); + Write("=\""); + Escape(value1); + Write("\" "); + Write(attr2); + Write("=\""); + Escape(value2); + Write("\" "); + Write(attr3); + Write("=\""); + Escape(value3); + Write("\">"); + ++g_dwIndent; } void EndTag(const char *name) { + --g_dwIndent; Write(""); @@ -194,37 +225,55 @@ void TextF(const char *format, ...) { } void BeginCall(const char *function) { - Write("\t"); BeginTag("call", "name", function); NewLine(); } void EndCall(void) { - Write("\t"); EndTag("call"); NewLine(); } -void BeginParam(const char *name, const char *type) { - Write("\t\t"); - BeginTag("param", "name", name, "type", type); +void BeginArg(const char *type, const char *name) { + BeginTag("arg", "type", type, "name", name); } -void EndParam(void) { - EndTag("param"); +void EndArg(void) { + EndTag("arg"); NewLine(); } void BeginReturn(const char *type) { - Write("\t\t"); - BeginTag("return", "type", type); + BeginTag("ret", "type", type); } void EndReturn(void) { - EndTag("return"); + EndTag("ret"); NewLine(); } +void BeginElement(const char *type, const char *name) { + BeginTag("elem", "type", type, "name", name); +} + +void BeginElement(const char *type) { + BeginTag("elem", "type", type); +} + +void EndElement(void) { + EndTag("elem"); +} + +void BeginReference(const char *type, const void *addr) { + char saddr[256]; + _snprintf(saddr, sizeof(saddr), "%p", addr); + BeginTag("ref", "type", type, "addr", saddr); +} + +void EndReference(void) { + EndTag("ref"); +} + void DumpString(const char *str) { const unsigned char *p = (const unsigned char *)str; Log::Text("\""); diff --git a/log.hpp b/log.hpp index abeebe6..60ae3b7 100644 --- a/log.hpp +++ b/log.hpp @@ -31,6 +31,7 @@ namespace Log { void Close(void); void NewLine(void); + void Tag(const char *name); void BeginTag(const char *name); void BeginTag(const char *name, @@ -39,16 +40,28 @@ namespace Log { const char *attr1, const char *value1, const char *attr2, const char *value2); void EndTag(const char *name); + void Text(const char *text); void TextF(const char *format, ...); + void BeginCall(const char *function); void EndCall(void); - void BeginParam(const char *name, const char *type); - void EndParam(void); + + void BeginArg(const char *type, const char *name); + void EndArg(void); + void BeginReturn(const char *type); void EndReturn(void); + void BeginElement(const char *type); + void BeginElement(const char *type, const char *name); + void EndElement(void); + + void BeginReference(const char *type, const void *addr); + void EndReference(void); + void DumpString(const char *str); + } #endif /* _LOG_HPP_ */