summaryrefslogtreecommitdiffstats
path: root/opengl/libs/GLES2_dbg/generate_api_cpp.py
diff options
context:
space:
mode:
Diffstat (limited to 'opengl/libs/GLES2_dbg/generate_api_cpp.py')
-rwxr-xr-xopengl/libs/GLES2_dbg/generate_api_cpp.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/opengl/libs/GLES2_dbg/generate_api_cpp.py b/opengl/libs/GLES2_dbg/generate_api_cpp.py
index 93d6f7d..5b024ad 100755
--- a/opengl/libs/GLES2_dbg/generate_api_cpp.py
+++ b/opengl/libs/GLES2_dbg/generate_api_cpp.py
@@ -31,7 +31,16 @@ def generate_api(lines):
externs = []
i = 0
# these have been hand written
- skipFunctions = ["glTexImage2D", "glTexSubImage2D", "glShaderSource", "glReadPixels", "glDrawArrays", "glDrawElements"]
+ skipFunctions = ["glTexImage2D", "glTexSubImage2D", "glReadPixels",
+"glDrawArrays", "glDrawElements"]
+
+ # these have an EXTEND_Debug_* macro for getting data
+ extendFunctions = ["glCopyTexImage2D", "glCopyTexSubImage2D", "glShaderSource"]
+
+ # these also needs to be forwarded to DbgContext
+ contextFunctions = ["glUseProgram", "glEnableVertexAttribArray", "glDisableVertexAttribArray",
+"glVertexAttribPointer", "glBindBuffer", "glBufferData", "glBufferSubData", "glDeleteBuffers",]
+
for line in lines:
if line.find("API_ENTRY(") >= 0: # a function prototype
returnType = line[0: line.find(" API_ENTRY(")]
@@ -49,12 +58,13 @@ def generate_api(lines):
parameters = parameterList.split(',')
paramIndex = 0
- if line.find("*") >= 0 and (line.find("*") < line.find(":") or line.find("*") > line.rfind(":")):
- # add function to list of functions that should be hand written, but generate code anyways
- extern = "%s Debug_%s(%s);" % (returnType, functionName, RemoveAnnotation(parameterList))
- sys.stderr.write("%s should be hand written\n" % (extern))
- print "// FIXME: this function has pointers, it should be hand written"
- externs.append(extern)
+ if line.find("*") >= 0 and (line.find("*") < line.find(":") or line.find("*") > line.rfind(":")): # unannotated pointer
+ if not functionName in extendFunctions:
+ # add function to list of functions that should be hand written, but generate code anyways
+ extern = "%s Debug_%s(%s);" % (returnType, functionName, RemoveAnnotation(parameterList))
+ sys.stderr.write("%s should be hand written\n" % (extern))
+ print "// FIXME: this function has pointers, it should be hand written"
+ externs.append(extern)
print "%s Debug_%s(%s)\n{" % (returnType, functionName, RemoveAnnotation(parameterList))
print """ glesv2debugger::Message msg;
@@ -132,6 +142,8 @@ def generate_api(lines):
if inout in ["out", "inout"]:
print " msg.set_time((systemTime(timeMode) - c0) * 1e-6f);"
print " " + getData
+ if functionName in contextFunctions:
+ print " getDbgContextThreadSpecific()->%s(%s);" % (functionName, arguments)
if returnType == "void":
print " return 0;"
else:
@@ -145,6 +157,8 @@ def generate_api(lines):
print " // FIXME: check for pointer usage"
if inout in ["in", "inout"]:
print getData
+ if functionName in extendFunctions:
+ print " EXTEND_Debug_%s;" % (functionName)
print " int * ret = MessageLoop(caller, msg, expectResponse,"
print " glesv2debugger::Message_Function_%s);" % (functionName)
if returnType != "void":
@@ -160,7 +174,7 @@ def generate_api(lines):
print extern
if __name__ == "__main__":
- print """
+ print """\
/*
** Copyright 2011, The Android Open Source Project
**
@@ -179,7 +193,8 @@ if __name__ == "__main__":
// auto generated by generate_api_cpp.py
-#include "src/header.h"
+#include "src/header.h"
+#include "src/api.h"
template<typename T> static int ToInt(const T & t) { STATIC_ASSERT(sizeof(T) == sizeof(int), bitcast); return (int &)t; }
template<typename T> static T FromInt(const int & t) { STATIC_ASSERT(sizeof(T) == sizeof(int), bitcast); return (T &)t; }