]> git.cworth.org Git - apitrace/blobdiff - wrappers/trace.py
cgltrace: Fix CGLChoosePixelFormat prototype.
[apitrace] / wrappers / trace.py
index 9bacf8a2ff5b4d04bdc1c2f9827b1ac34a3283d0..4b25607879b587c42d39ad97ddb665c47707ae65 100644 (file)
@@ -212,12 +212,13 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin):
         # It is currently assumed that an unknown key means that it is followed by an int value.
 
         # determine the array length which must be passed to writeArray() up front
-        count = '_c' + array.keyType.tag
+        count = '_c' + array.baseType.tag
+        print '    {'
         print '    int %s;' % count
         print '    for (%(c)s = 0; %(array)s && %(array)s[%(c)s] != %(terminator)s; %(c)s += 2) {' \
               % {'c': count, 'array': instance, 'terminator': array.terminator}
         if array.hasKeysWithoutValues:
-            print '        switch (%(array)s[%(c)s]) {' % {'array': instance, 'c': count}
+            print '        switch (int(%(array)s[%(c)s])) {' % {'array': instance, 'c': count}
             for key, valueType in array.valueTypes:
                 if valueType is None:
                     print '        case %s:' % key
@@ -230,15 +231,15 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin):
 
         # for each key / key-value pair write the key and the value, if the key requires one
 
-        index = '_i' + array.keyType.tag
+        index = '_i' + array.baseType.tag
         print '    for (int %(i)s = 0; %(i)s < %(count)s; %(i)s++) {' % {'i': index, 'count': count}
         print '        trace::localWriter.beginElement();'
-        self.visitEnum(array.keyType, "%(array)s[%(i)s]" % {'array': instance, 'i': index})
+        self.visit(array.baseType, "%(array)s[%(i)s]" % {'array': instance, 'i': index})
         print '        trace::localWriter.endElement();'
         print '        if (%(i)s + 1 >= %(count)s) {' % {'i': index, 'count': count}
         print '            break;'
         print '        }'
-        print '        switch (%(array)s[%(i)s++]) {' % {'array': instance, 'i': index}
+        print '        switch (int(%(array)s[%(i)s++])) {' % {'array': instance, 'i': index}
         # write generic value the usual way
         for key, valueType in array.valueTypes:
             if valueType is not None:
@@ -258,13 +259,14 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin):
         print '        default:'
         print '            trace::localWriter.beginElement();'
         print '            os::log("apitrace: warning: %s: unknown key 0x%04X, interpreting value as int\\n", ' + \
-                           '__FUNCTION__, %(array)s[%(i)s]);'  % {'array': instance, 'i': index}
+                           '__FUNCTION__, int(%(array)s[%(i)s - 1]));'  % {'array': instance, 'i': index}
         print '            trace::localWriter.writeSInt(%(array)s[%(i)s]);' % {'array': instance, 'i': index}
         print '            trace::localWriter.endElement();'
         print '            break;'
         print '        }'
         print '    }'
         print '    trace::localWriter.endArray();'
+        print '    }'
 
 
     def visitBlob(self, blob, instance):