]> git.cworth.org Git - apitrace/blobdiff - retrace.hpp
Merge branch 'd3dretrace'
[apitrace] / retrace.hpp
index 8ce15ad6720c7e0696440fd5688da523d90452bc..c1e556a97fbb03d726be09de3cb92540de88e5fc 100644 (file)
 #include <ostream>
 
 #include "trace_model.hpp"
+#include "trace_parser.hpp"
 
 
 namespace retrace {
 
 
+extern trace::Parser parser;
+
+
 /**
  * Handle map.
  *
@@ -119,6 +123,24 @@ public:
         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) {
+        const trace::Array *array = dynamic_cast<const trace::Array *>(value);
+        if (array) {
+            return alloc<T>(array->size());
+        }
+        const trace::Null *null = dynamic_cast<const trace::Null *>(value);
+        if (null) {
+            return NULL;
+        }
+        assert(0);
+        return NULL;
+    }
+
     /**
      * Prevent this pointer from being automatically freed.
      */