]> git.cworth.org Git - apitrace/commitdiff
d3dretrace: Prevent ScopedAllocator::alloc<D3DPRESENT_PARAMETERS> clash.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 26 Nov 2012 19:45:54 +0000 (19:45 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 26 Nov 2012 19:45:54 +0000 (19:45 +0000)
D3D8 and D3D9 have different definitions of the D3DPRESENT_PARAMETERS.
This happens with other types, so the only solution is to stop using
templates here.

retrace/retrace.hpp
retrace/retrace.py

index ab1ba5c20dd7af242f226c8386b4201b898518fb..cc77029e7aba59839cb907fbf969234b4df4a9d0 100644 (file)
@@ -60,6 +60,7 @@ private:
     uintptr_t next;
 
 public:
+    inline
     ScopedAllocator() :
         next(0) {
     }
@@ -81,21 +82,14 @@ public:
         return static_cast<void *>(&buf[1]);
     }
 
-    template< class T >
-    inline T *
-    alloc(size_t n = 1) {
-        return static_cast<T *>(alloc(sizeof(T) * n));
-    }
-
     /**
      * Allocate an array with the same dimensions as the specified value.
      */
-    template< class T >
-    inline T *
-    alloc(const trace::Value *value) {
+    inline void *
+    alloc(const trace::Value *value, size_t size) {
         const trace::Array *array = dynamic_cast<const trace::Array *>(value);
         if (array) {
-            return alloc<T>(array->size());
+            return alloc(array->size() * size);
         }
         const trace::Null *null = dynamic_cast<const trace::Null *>(value);
         if (null) {
index 1e39d42a19346d9f3b6be8f226a6c44bc88a8158..cd5ef1d2136770f21c5097f0480c6c8b661059d7 100644 (file)
@@ -66,10 +66,10 @@ class ValueAllocator(stdapi.Visitor):
         pass
 
     def visitArray(self, array, lvalue, rvalue):
-        print '    %s = _allocator.alloc<%s>(&%s);' % (lvalue, array.type, rvalue)
+        print '    %s = static_cast<%s *>(_allocator.alloc(&%s, sizeof *%s));' % (lvalue, array.type, rvalue, lvalue)
 
     def visitPointer(self, pointer, lvalue, rvalue):
-        print '    %s = _allocator.alloc<%s>(&%s);' % (lvalue, pointer.type, rvalue)
+        print '    %s = static_cast<%s *>(_allocator.alloc(&%s, sizeof *%s));' % (lvalue, pointer.type, rvalue, lvalue)
 
     def visitIntPointer(self, pointer, lvalue, rvalue):
         pass