]> git.cworth.org Git - apitrace/commitdiff
Generated code formatting improvements.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 16 Oct 2011 13:15:36 +0000 (14:15 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 16 Oct 2011 13:15:36 +0000 (14:15 +0100)
common/trace_parser.cpp
glstate.py
gltrace.py
trace.py

index 530c19a5a06fe00c7009a5cf7f7744971a0e41f1..17f4a154590ab2db7f809cadb5d21e15b7c589ea 100644 (file)
@@ -171,7 +171,7 @@ void Parser::setBookmark(const ParseBookmark &bookmark) {
 Call *Parser::parse_call(Mode mode) {
     do {
         int c = read_byte();
-        switch(c) {
+        switch (c) {
         case Trace::EVENT_ENTER:
             parse_enter(mode);
             break;
@@ -373,7 +373,7 @@ Call *Parser::parse_leave(Mode mode) {
 bool Parser::parse_call_details(Call *call, Mode mode) {
     do {
         int c = read_byte();
-        switch(c) {
+        switch (c) {
         case Trace::CALL_END:
             return true;
         case Trace::CALL_ARG:
@@ -409,7 +409,7 @@ Value *Parser::parse_value(void) {
     int c;
     Value *value;
     c = read_byte();
-    switch(c) {
+    switch (c) {
     case Trace::TYPE_NULL:
         value = new Null;
         break;
@@ -470,7 +470,7 @@ Value *Parser::parse_value(void) {
 
 void Parser::scan_value(void) {
     int c = read_byte();
-    switch(c) {
+    switch (c) {
     case Trace::TYPE_NULL:
     case Trace::TYPE_FALSE:
     case Trace::TYPE_TRUE:
index 79cf2de12dc0bab07a7466833e00ff507f4ed008..7ab2dd14def421e0f6214fd9766eef55d2e08137 100644 (file)
@@ -249,7 +249,7 @@ class StateDumper:
         print 'const char *'
         print 'enumToString(GLenum pname)'
         print '{'
-        print '    switch(pname) {'
+        print '    switch (pname) {'
         for name in GLenum.values:
             print '    case %s:' % name
             print '        return "%s";' % name
index e5be57d3644f4aaacafabc72b4525f872b734ed1..5933b9ecd7e6a9f8338c994aa396faa4c2baac5f 100644 (file)
@@ -233,7 +233,7 @@ class GlTracer(Tracer):
         print
         print 'static inline struct buffer_mapping *'
         print 'get_buffer_mapping(GLenum target) {'
-        print '    switch(target) {'
+        print '    switch (target) {'
         for target in self.buffer_targets:
             print '    case GL_%s:' % target
             print '        return & __%s_mapping;' % target.lower()
@@ -248,7 +248,7 @@ class GlTracer(Tracer):
         # refers to a symbolic value or not
         print 'static bool'
         print 'is_symbolic_pname(GLenum pname) {'
-        print '    switch(pname) {'
+        print '    switch (pname) {'
         for function, type, count, name in glparams.parameters:
             if type is glapi.GLenum:
                 print '    case %s:' % name
@@ -272,7 +272,7 @@ class GlTracer(Tracer):
         # Generate a helper function to know how many elements a parameter has
         print 'static size_t'
         print '__gl_param_size(GLenum pname) {'
-        print '    switch(pname) {'
+        print '    switch (pname) {'
         for function, type, count, name in glparams.parameters:
             if type is not None:
                 print '    case %s: return %u;' % (name, count)
@@ -692,7 +692,7 @@ class GlTracer(Tracer):
             binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name
             function = api.get_function_by_name(function_name)
 
-            print '    // %s' % function.name
+            print '    // %s' % function.prototype()
             self.array_trace_prolog(api, uppercase_name)
             self.array_prolog(api, uppercase_name)
             print '    if (__glIsEnabled(%s)) {' % enable_name
@@ -749,7 +749,9 @@ class GlTracer(Tracer):
             else:
                 SUFFIX = suffix
             function_name = 'glVertexAttribPointer' + suffix
-            print '    // %s' % function_name
+            function = api.get_function_by_name(function_name)
+
+            print '    // %s' % function.prototype()
             print '    if (__vertex_attrib == VERTEX_ATTRIB%s) {' % SUFFIX
             if suffix == 'NV':
                 print '        GLint __max_vertex_attribs = 16;'
@@ -769,8 +771,6 @@ class GlTracer(Tracer):
                 print '                __glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING%s, &__binding);' % (suffix, SUFFIX)
             print '                if (!__binding) {'
 
-            function = api.get_function_by_name(function_name)
-
             # Get the arguments via glGet*
             for arg in function.args[1:]:
                 if suffix == 'NV':
index 2cb11e5b5d98e8f0fe0ba679ef8b9a761d746cd6..ccd709c4f8df7c09d399b890f6812bd8444fcce2 100644 (file)
--- a/trace.py
+++ b/trace.py
@@ -52,7 +52,7 @@ class DumpDeclarator(stdapi.OnceVisitor):
     def visit_struct(self, struct):
         for type, name in struct.members:
             self.visit(type)
-        print 'static void __traceStruct%s(const %s &value) {' % (struct.tag, struct.expr)
+        print 'static void _write__%s(const %s &value) {' % (struct.tag, struct.expr)
         print '    static const char * members[%u] = {' % (len(struct.members),)
         for type, name,  in struct.members:
             print '        "%s",' % (name,)
@@ -76,14 +76,14 @@ class DumpDeclarator(stdapi.OnceVisitor):
     __enum_id = 0
 
     def visit_enum(self, enum):
-        print 'static void __traceEnum%s(const %s value) {' % (enum.tag, enum.expr)
+        print 'static void _write__%s(const %s value) {' % (enum.tag, enum.expr)
         n = len(enum.values)
         for i in range(n):
             value = enum.values[i]
             print '    static const Trace::EnumSig sig%u = {%u, "%s", %s};' % (i, DumpDeclarator.__enum_id, value, value)
             DumpDeclarator.__enum_id += 1
         print '    const Trace::EnumSig *sig;'
-        print '    switch(value) {'
+        print '    switch (value) {'
         for i in range(n):
             value = enum.values[i]
             print '    case %s:' % value
@@ -136,7 +136,7 @@ class DumpDeclarator(stdapi.OnceVisitor):
         print
 
     def visit_polymorphic(self, polymorphic):
-        print 'static void __tracePolymorphic%s(int selector, const %s & value) {' % (polymorphic.tag, polymorphic.expr)
+        print 'static void _write__%s(int selector, const %s & value) {' % (polymorphic.tag, polymorphic.expr)
         print '    switch (selector) {'
         for cases, type in polymorphic.iterswitch():
             for case in cases:
@@ -164,7 +164,7 @@ class DumpImplementer(stdapi.Visitor):
         self.visit(const.type, instance)
 
     def visit_struct(self, struct, instance):
-        print '    __traceStruct%s(%s);' % (struct.tag, instance)
+        print '    _write__%s(%s);' % (struct.tag, instance)
 
     def visit_array(self, array, instance):
         length = '__c' + array.type.tag
@@ -186,7 +186,7 @@ class DumpImplementer(stdapi.Visitor):
         print '    Trace::localWriter.writeBlob(%s, %s);' % (instance, blob.size)
 
     def visit_enum(self, enum, instance):
-        print '    __traceEnum%s(%s);' % (enum.tag, instance)
+        print '    _write__%s(%s);' % (enum.tag, instance)
 
     def visit_bitmask(self, bitmask, instance):
         print '    Trace::localWriter.writeBitmask(&__bitmask%s_sig, %s);' % (bitmask.tag, instance)
@@ -215,7 +215,7 @@ class DumpImplementer(stdapi.Visitor):
         print '    Trace::localWriter.writeOpaque((const void *)&%s);' % instance
 
     def visit_polymorphic(self, polymorphic, instance):
-        print '    __tracePolymorphic%s(%s, %s);' % (polymorphic.tag, polymorphic.switch_expr, instance)
+        print '    _write__%s(%s, %s);' % (polymorphic.tag, polymorphic.switch_expr, instance)
 
 
 dump_instance = DumpImplementer().visit