]> git.cworth.org Git - apitrace/commitdiff
More GL handles.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 24 Nov 2010 10:12:22 +0000 (10:12 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 24 Nov 2010 10:12:22 +0000 (10:12 +0000)
base.py
glapi.py
glretrace.py
trace.py

diff --git a/base.py b/base.py
index c99d065e54086c1c1c6fe6982ca0f1aefd769db7..1637128ddc77fa7a15cd923e16dc1db8ab525bab 100644 (file)
--- a/base.py
+++ b/base.py
@@ -417,8 +417,8 @@ def WrapPointer(type):
 
 class String(Type):
 
-    def __init__(self, length = None):
-        Type.__init__(self, "char *")
+    def __init__(self, expr = "char *", length = None):
+        Type.__init__(self, expr)
         self.length = length
 
     def visit(self, visitor, *args, **kwargs):
@@ -441,25 +441,88 @@ def OpaquePointer(type):
     return Opaque(type.expr + ' *')
 
 
+class Collector(Visitor):
+    '''Collect.'''
+
+    def __init__(self):
+        self.__visited = set()
+        self.types = []
+
+    def visit(self, type):
+        if type in self.__visited:
+            return
+        self.__visited.add(type)
+        Visitor.visit(self, type)
+        self.types.append(type)
+
+    def visit_void(self, literal):
+        pass
+
+    def visit_literal(self, literal):
+        pass
+
+    def visit_string(self, string):
+        pass
+
+    def visit_const(self, const):
+        self.visit(const.type)
+
+    def visit_struct(self, struct):
+        for type, name in struct.members:
+            self.visit(type)
+
+    def visit_array(self, array):
+        self.visit(array.type)
+
+    def visit_blob(self, array):
+        pass
+
+    def visit_enum(self, enum):
+        pass
+
+    def visit_bitmask(self, bitmask):
+        self.visit(bitmask.type)
+
+    def visit_pointer(self, pointer):
+        self.visit(pointer.type)
+
+    def visit_handle(self, handle):
+        self.visit(handle.type)
+
+    def visit_alias(self, alias):
+        self.visit(alias.type)
+
+    def visit_opaque(self, opaque):
+        pass
+
+    def visit_interface(self, interface):
+        pass
+
 
 class API:
 
     def __init__(self, name):
         self.name = name
         self.headers = []
-        self.types = set()
         self.functions = []
         self.interfaces = []
 
-    def add_type(self, type):
-        if type not in self.types:
-            self.types.add(type)
+    def all_types(self):
+        collector = Collector()
+        for function in self.functions:
+            for arg in function.args:
+                collector.visit(arg.type)
+            collector.visit(function.type)
+        for interface in self.interfaces:
+            collector.visit(interface)
+            for method in interface.methods:
+                for arg in method.args:
+                    collector.visit(arg.type)
+                collector.visit(method.type)
+        return collector.types
 
     def add_function(self, function):
         self.functions.append(function)
-        for arg in function.args:
-            self.add_type(arg.type)
-        self.add_type(function.type)
 
     def add_functions(self, functions):
         for function in functions:
index a19c412f9302c09463ac828df24032a14ce519dc..2309ea9db885bd16fdb8390c4ebcac8871f868d4 100644 (file)
--- a/glapi.py
+++ b/glapi.py
@@ -54,8 +54,8 @@ GLhalfNV = Alias("GLhalfNV", UShort)
 GLint64EXT = Alias("GLint64EXT", LongLong)
 GLuint64EXT = Alias("GLuint64EXT", ULongLong)
 
-GLstring = Alias("const GLchar *", CString)
-GLstringARB = Alias("const GLcharARB *", CString)
+GLstring = String("const GLchar *")
+GLstringARB = String("const GLcharARB *")
 
 GLenum = Enum("GLenum", [
     #"GL_NO_ERROR",                       # 0x0
@@ -2518,9 +2518,14 @@ GLbitfield_client_attrib = Flags(GLbitfield, [
     "GL_CLIENT_VERTEX_ARRAY_BIT", # 0x00000002
 ])
 
-texture = Handle("texture", GLuint)
-framebuffer = Handle("framebuffer", GLuint)
-renderbuffer = Handle("renderbuffer", GLuint)
+GLlist = Handle("list", GLuint)
+GLtexture = Handle("texture", GLuint)
+GLbuffer = Handle("buffer", GLuint)
+GLquery = Handle("query", GLuint)
+GLfence = Handle("fence", GLuint)
+GLprogram = Handle("program", GLuint)
+GLframebuffer = Handle("framebuffer", GLuint)
+GLrenderbuffer = Handle("renderbuffer", GLuint)
 
 
 def GlFunction(*args, **kwargs):
@@ -2532,12 +2537,12 @@ def basic_functions(Function):
         kwargs.setdefault('call', 'GLAPIENTRY')
         return Function(*args, **kwargs)
     return [
-        F(Void, "glNewList", [(GLuint, "list"), (GLenum, "mode")]),
+        F(Void, "glNewList", [(GLlist, "list"), (GLenum, "mode")]),
         F(Void, "glEndList", []),
-        F(Void, "glCallList", [(GLuint, "list")]),
-        F(Void, "glCallLists", [(GLsizei, "n"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_calllists_size(n, type)"), "lists")]),
-        F(Void, "glDeleteLists", [(GLuint, "list"), (GLsizei, "range")]),
-        F(GLuint, "glGenLists", [(GLsizei, "range")]),
+        F(Void, "glCallList", [(GLlist, "list")]),
+        F(Void, "glCallLists", [(GLsizei, "n"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_calllists_size(n, type)"), "lists")]), # XXX
+        F(Void, "glDeleteLists", [(GLlist, "list"), (GLsizei, "range")]), # XXX
+        F(GLlist, "glGenLists", [(GLsizei, "range")]), # XXX
         F(Void, "glListBase", [(GLuint, "base")]),
         F(Void, "glBegin", [(GLenum_mode, "mode")]),
         F(Void, "glBitmap", [(GLsizei, "width"), (GLsizei, "height"), (GLfloat, "xorig"), (GLfloat, "yorig"), (GLfloat, "xmove"), (GLfloat, "ymove"), (Blob(Const(GLubyte), "__gl_bitmap_size(width, height)"), "bitmap")]),
@@ -2839,7 +2844,7 @@ def basic_functions(Function):
         F(Void, "glTranslatef", [(GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z")]),
         F(Void, "glViewport", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
         F(Void, "glArrayElement", [(GLint, "i")]),
-        F(Void, "glBindTexture", [(GLenum, "target"), (texture, "texture")]),
+        F(Void, "glBindTexture", [(GLenum, "target"), (GLtexture, "texture")]),
         F(Void, "glColorPointer", [(GLint, "size"), (GLenum, "type"), (GLsizei, "stride"), (OpaquePointer(Const(GLvoid)), "pointer")]),
         F(Void, "glDisableClientState", [(GLenum, "array")]),
         F(Void, "glDrawArrays", [(GLenum_mode, "mode"), (GLint, "first"), (GLsizei, "count")]),
@@ -2854,16 +2859,16 @@ def basic_functions(Function):
         F(Void, "glPolygonOffset", [(GLfloat, "factor"), (GLfloat, "units")]),
         F(Void, "glTexCoordPointer", [(GLint, "size"), (GLenum, "type"), (GLsizei, "stride"), (OpaquePointer(Const(GLvoid)), "pointer")]),
         F(Void, "glVertexPointer", [(GLint, "size"), (GLenum, "type"), (GLsizei, "stride"), (OpaquePointer(Const(GLvoid)), "pointer")]),
-        F(GLboolean, "glAreTexturesResident", [(GLsizei, "n"), (Array(Const(texture), "n"), "textures"), Out(Array(GLboolean, "n"), "residences")]),
+        F(GLboolean, "glAreTexturesResident", [(GLsizei, "n"), (Array(Const(GLtexture), "n"), "textures"), Out(Array(GLboolean, "n"), "residences")]),
         F(Void, "glCopyTexImage1D", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLint, "border")]),
         F(Void, "glCopyTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border")]),
         F(Void, "glCopyTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
         F(Void, "glCopyTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
-        F(Void, "glDeleteTextures", [(GLsizei, "n"), (Array(Const(texture), "n"), "textures")]),
-        F(Void, "glGenTextures", [(GLsizei, "n"), Out(Array(texture, "n"), "textures")]),
+        F(Void, "glDeleteTextures", [(GLsizei, "n"), (Array(Const(GLtexture), "n"), "textures")]),
+        F(Void, "glGenTextures", [(GLsizei, "n"), Out(Array(GLtexture, "n"), "textures")]),
         F(Void, "glGetPointerv", [(GLenum, "pname"), Out(Pointer(OpaquePointer(GLvoid)), "params")], sideeffects=False),
-        F(GLboolean, "glIsTexture", [(texture, "texture")]),
-        F(Void, "glPrioritizeTextures", [(GLsizei, "n"), (Array(Const(texture), "n"), "textures"), (Array(Const(GLclampf), "n"), "priorities")]),
+        F(GLboolean, "glIsTexture", [(GLtexture, "texture")]),
+        F(Void, "glPrioritizeTextures", [(GLsizei, "n"), (Array(Const(GLtexture), "n"), "textures"), (Array(Const(GLclampf), "n"), "priorities")]),
         F(Void, "glTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, 1, 1, 0)"), "pixels")]),
         F(Void, "glTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, height, 1, 0)"), "pixels")]),
         F(Void, "glPopClientAttrib", []),
@@ -3004,7 +3009,7 @@ def extended_functions(Function):
         F(Void, "glProgramLocalParameter4dvARB", [(GLenum, "target"), (GLuint, "index"), (OpaquePointer(Const(GLdouble)), "params")]),
         F(Void, "glProgramLocalParameter4fARB", [(GLenum, "target"), (GLuint, "index"), (GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z"), (GLfloat, "w")]),
         F(Void, "glProgramLocalParameter4fvARB", [(GLenum, "target"), (GLuint, "index"), (OpaquePointer(Const(GLfloat)), "params")]),
-        F(Void, "glProgramStringARB", [(GLenum, "target"), (GLenum, "format"), (GLsizei, "len"), (Alias("const void *", String("len")), "string")]),
+        F(Void, "glProgramStringARB", [(GLenum, "target"), (GLenum, "format"), (GLsizei, "len"), (String("const void *", "len"), "string")]),
         F(Void, "glVertexAttrib1dARB", [(GLuint, "index"), (GLdouble, "x")]),
         F(Void, "glVertexAttrib1dvARB", [(GLuint, "index"), (Array(Const(GLdouble), "1"), "v")]),
         F(Void, "glVertexAttrib1fARB", [(GLuint, "index"), (GLfloat, "x")]),
@@ -3042,25 +3047,25 @@ def extended_functions(Function):
         F(Void, "glVertexAttrib4uivARB", [(GLuint, "index"), (Array(Const(GLuint), "4"), "v")]),
         F(Void, "glVertexAttrib4usvARB", [(GLuint, "index"), (Array(Const(GLushort), "4"), "v")]),
         F(Void, "glVertexAttribPointerARB", [(GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLboolean, "normalized"), (GLsizei, "stride"), (OpaquePointer(Const(GLvoid)), "pointer")]),
-        F(Void, "glBindBufferARB", [(GLenum, "target"), (GLuint, "buffer")]),
+        F(Void, "glBindBufferARB", [(GLenum, "target"), (GLbuffer, "buffer")]),
         F(Void, "glBufferDataARB", [(GLenum, "target"), (GLsizeiptrARB, "size"), (Blob(Const(GLvoid), "size"), "data"), (GLenum, "usage")]),
         F(Void, "glBufferSubDataARB", [(GLenum, "target"), (GLintptrARB, "offset"), (GLsizeiptrARB, "size"), (Blob(Const(GLvoid), "size"), "data")]),
-        F(Void, "glDeleteBuffersARB", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "buffer")]),
-        F(Void, "glGenBuffersARB", [(GLsizei, "n"), Out(Array(GLuint, "n"), "buffer")]),
+        F(Void, "glDeleteBuffersARB", [(GLsizei, "n"), (Array(Const(GLbuffer), "n"), "buffer")]),
+        F(Void, "glGenBuffersARB", [(GLsizei, "n"), Out(Array(GLbuffer, "n"), "buffer")]),
         F(Void, "glGetBufferParameterivARB", [(GLenum, "target"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
         F(Void, "glGetBufferPointervARB", [(GLenum, "target"), (GLenum, "pname"), (OpaquePointer(OpaquePointer(GLvoid)), "params")], sideeffects=False),
         F(Void, "glGetBufferSubDataARB", [(GLenum, "target"), (GLintptrARB, "offset"), (GLsizeiptrARB, "size"), Out(Blob(GLvoid, "size"), "data")], sideeffects=False),
-        F(GLboolean, "glIsBufferARB", [(GLuint, "buffer")]),
+        F(GLboolean, "glIsBufferARB", [(GLbuffer, "buffer")]),
         F(OpaquePointer(GLvoid), "glMapBufferARB", [(GLenum, "target"), (GLenum, "access")]),
         F(GLboolean, "glUnmapBufferARB", [(GLenum, "target")]),
-        F(Void, "glBeginQueryARB", [(GLenum, "target"), (GLuint, "id")]),
-        F(Void, "glDeleteQueriesARB", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "ids")]),
+        F(Void, "glBeginQueryARB", [(GLenum, "target"), (GLquery, "id")]),
+        F(Void, "glDeleteQueriesARB", [(GLsizei, "n"), (Array(Const(GLquery), "n"), "ids")]),
         F(Void, "glEndQueryARB", [(GLenum, "target")]),
-        F(Void, "glGenQueriesARB", [(GLsizei, "n"), Out(Array(GLuint, "n"), "ids")]),
-        F(Void, "glGetQueryObjectivARB", [(GLuint, "id"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
-        F(Void, "glGetQueryObjectuivARB", [(GLuint, "id"), (GLenum, "pname"), (OpaquePointer(GLuint), "params")], sideeffects=False),
+        F(Void, "glGenQueriesARB", [(GLsizei, "n"), Out(Array(GLquery, "n"), "ids")]),
+        F(Void, "glGetQueryObjectivARB", [(GLquery, "id"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
+        F(Void, "glGetQueryObjectuivARB", [(GLquery, "id"), (GLenum, "pname"), (OpaquePointer(GLuint), "params")], sideeffects=False),
         F(Void, "glGetQueryivARB", [(GLenum, "target"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
-        F(GLboolean, "glIsQueryARB", [(GLuint, "id")]),
+        F(GLboolean, "glIsQueryARB", [(GLquery, "id")]),
         F(Void, "glAttachObjectARB", [(GLhandleARB, "containerObj"), (GLhandleARB, "obj")]),
         F(Void, "glCompileShaderARB", [(GLhandleARB, "shader")]),
         F(GLhandleARB, "glCreateProgramObjectARB", []),
@@ -3194,29 +3199,29 @@ def extended_functions(Function):
         F(Void, "glWindowPos4svMESA", [(Array(Const(GLshort), "4"), "v")]),
         F(Void, "glMultiModeDrawArraysIBM", [(Array(Const(GLenum_mode), "primcount"), "mode"), (Array(Const(GLint), "primcount"), "first"), (Array(Const(GLsizei), "primcount"), "count"), (GLsizei, "primcount"), (GLint, "modestride")]),
         F(Void, "glMultiModeDrawElementsIBM", [(Array(Const(GLenum_mode), "primcount"), "mode"), (Array(Const(GLsizei), "primcount"), "count"), (GLenum, "type"), (Array(Const(OpaquePointer(Const(GLvoid))), "primcount"), "indices"), (GLsizei, "primcount"), (GLint, "modestride")]),
-        F(Void, "glDeleteFencesNV", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "fences")]),
-        F(Void, "glFinishFenceNV", [(GLuint, "fence")]),
-        F(Void, "glGenFencesNV", [(GLsizei, "n"), Out(Array(GLuint, "n"), "fences")]),
-        F(Void, "glGetFenceivNV", [(GLuint, "fence"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
-        F(GLboolean, "glIsFenceNV", [(GLuint, "fence")]),
-        F(Void, "glSetFenceNV", [(GLuint, "fence"), (GLenum, "condition")]),
-        F(GLboolean, "glTestFenceNV", [(GLuint, "fence")]),
-        F(GLboolean, "glAreProgramsResidentNV", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "ids"), Out(Array(GLboolean, "n"), "residences")]),
-        F(Void, "glBindProgramNV", [(GLenum, "target"), (GLuint, "program")]),
-        F(Void, "glDeleteProgramsNV", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "programs")]),
-        F(Void, "glExecuteProgramNV", [(GLenum, "target"), (GLuint, "id"), (OpaquePointer(Const(GLfloat)), "params")]),
-        F(Void, "glGenProgramsNV", [(GLsizei, "n"), Out(Array(GLuint, "n"), "programs")]),
+        F(Void, "glDeleteFencesNV", [(GLsizei, "n"), (Array(Const(GLfence), "n"), "fences")]),
+        F(Void, "glFinishFenceNV", [(GLfence, "fence")]),
+        F(Void, "glGenFencesNV", [(GLsizei, "n"), Out(Array(GLfence, "n"), "fences")]),
+        F(Void, "glGetFenceivNV", [(GLfence, "fence"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
+        F(GLboolean, "glIsFenceNV", [(GLfence, "fence")]),
+        F(Void, "glSetFenceNV", [(GLfence, "fence"), (GLenum, "condition")]),
+        F(GLboolean, "glTestFenceNV", [(GLfence, "fence")]),
+        F(GLboolean, "glAreProgramsResidentNV", [(GLsizei, "n"), (Array(Const(GLprogram), "n"), "ids"), Out(Array(GLboolean, "n"), "residences")]),
+        F(Void, "glBindProgramNV", [(GLenum, "target"), (GLprogram, "program")]),
+        F(Void, "glDeleteProgramsNV", [(GLsizei, "n"), (Array(Const(GLprogram), "n"), "programs")]),
+        F(Void, "glExecuteProgramNV", [(GLenum, "target"), (GLprogram, "id"), (OpaquePointer(Const(GLfloat)), "params")]),
+        F(Void, "glGenProgramsNV", [(GLsizei, "n"), Out(Array(GLprogram, "n"), "programs")]),
         F(Void, "glGetProgramParameterdvNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), (OpaquePointer(GLdouble), "params")], sideeffects=False),
         F(Void, "glGetProgramParameterfvNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), (OpaquePointer(GLfloat), "params")], sideeffects=False),
-        F(Void, "glGetProgramStringNV", [(GLuint, "id"), (GLenum, "pname"), (OpaquePointer(GLubyte), "program")], sideeffects=False),
-        F(Void, "glGetProgramivNV", [(GLuint, "id"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
+        F(Void, "glGetProgramStringNV", [(GLprogram, "id"), (GLenum, "pname"), (OpaquePointer(GLubyte), "program")], sideeffects=False),
+        F(Void, "glGetProgramivNV", [(GLprogram, "id"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
         F(Void, "glGetTrackMatrixivNV", [(GLenum, "target"), (GLuint, "address"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
         F(Void, "glGetVertexAttribPointervNV", [(GLuint, "index"), (GLenum, "pname"), (OpaquePointer(OpaquePointer(GLvoid)), "pointer")], sideeffects=False),
         F(Void, "glGetVertexAttribdvNV", [(GLuint, "index"), (GLenum, "pname"), (OpaquePointer(GLdouble), "params")], sideeffects=False),
         F(Void, "glGetVertexAttribfvNV", [(GLuint, "index"), (GLenum, "pname"), (OpaquePointer(GLfloat), "params")], sideeffects=False),
         F(Void, "glGetVertexAttribivNV", [(GLuint, "index"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
-        F(GLboolean, "glIsProgramNV", [(GLuint, "program")]),
-        F(Void, "glLoadProgramNV", [(GLenum, "target"), (GLuint, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "program")]),
+        F(GLboolean, "glIsProgramNV", [(GLprogram, "program")]),
+        F(Void, "glLoadProgramNV", [(GLenum, "target"), (GLprogram, "id"), (GLsizei, "len"), (String("const GLubyte *", "len"), "program")]),
         F(Void, "glProgramParameters4dvNV", [(GLenum, "target"), (GLuint, "index"), (GLuint, "num"), (OpaquePointer(Const(GLdouble)), "params")]),
         F(Void, "glProgramParameters4fvNV", [(GLenum, "target"), (GLuint, "index"), (GLuint, "num"), (OpaquePointer(Const(GLfloat)), "params")]),
         F(Void, "glRequestResidentProgramsNV", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "ids")]),
@@ -3286,54 +3291,54 @@ def extended_functions(Function):
         F(Void, "glDeleteVertexArraysAPPLE", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "arrays")]),
         F(Void, "glGenVertexArraysAPPLE", [(GLsizei, "n"), Out(Array(GLuint, "n"), "arrays")]),
         F(GLboolean, "glIsVertexArrayAPPLE", [(GLuint, "array")]),
-        F(Void, "glGetProgramNamedParameterdvNV", [(GLuint, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (OpaquePointer(GLdouble), "params")], sideeffects=False),
-        F(Void, "glGetProgramNamedParameterfvNV", [(GLuint, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (OpaquePointer(GLfloat), "params")], sideeffects=False),
-        F(Void, "glProgramNamedParameter4dNV", [(GLuint, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (GLdouble, "x"), (GLdouble, "y"), (GLdouble, "z"), (GLdouble, "w")]),
-        F(Void, "glProgramNamedParameter4dvNV", [(GLuint, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (Array(Const(GLdouble), "4"), "v")]),
-        F(Void, "glProgramNamedParameter4fNV", [(GLuint, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z"), (GLfloat, "w")]),
-        F(Void, "glProgramNamedParameter4fvNV", [(GLuint, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (Array(Const(GLfloat), "4"), "v")]),
+        F(Void, "glGetProgramNamedParameterdvNV", [(GLprogram, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (OpaquePointer(GLdouble), "params")], sideeffects=False),
+        F(Void, "glGetProgramNamedParameterfvNV", [(GLprogram, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (OpaquePointer(GLfloat), "params")], sideeffects=False),
+        F(Void, "glProgramNamedParameter4dNV", [(GLprogram, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (GLdouble, "x"), (GLdouble, "y"), (GLdouble, "z"), (GLdouble, "w")]),
+        F(Void, "glProgramNamedParameter4dvNV", [(GLprogram, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (Array(Const(GLdouble), "4"), "v")]),
+        F(Void, "glProgramNamedParameter4fNV", [(GLprogram, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z"), (GLfloat, "w")]),
+        F(Void, "glProgramNamedParameter4fvNV", [(GLprogram, "id"), (GLsizei, "len"), (OpaquePointer(Const(GLubyte)), "name"), (Array(Const(GLfloat), "4"), "v")]),
         F(Void, "glDepthBoundsEXT", [(GLclampd, "zmin"), (GLclampd, "zmax")]),
         F(Void, "glBlendEquationSeparateEXT", [(GLenum, "modeRGB"), (GLenum, "modeA")]),
 
-        F(Void, "glBindFramebuffer", [(GLenum, "target"), (framebuffer, "framebuffer")]),
-        F(Void, "glBindRenderbuffer", [(GLenum, "target"), (renderbuffer, "renderbuffer")]),
+        F(Void, "glBindFramebuffer", [(GLenum, "target"), (GLframebuffer, "framebuffer")]),
+        F(Void, "glBindRenderbuffer", [(GLenum, "target"), (GLrenderbuffer, "renderbuffer")]),
         F(GLenum, "glCheckFramebufferStatus", [(GLenum, "target")]),
-        F(Void, "glDeleteFramebuffers", [(GLsizei, "n"), (Array(Const(framebuffer), "n"), "framebuffers")]),
-        F(Void, "glDeleteRenderbuffers", [(GLsizei, "n"), (Array(Const(renderbuffer), "n"), "renderbuffers")]),
+        F(Void, "glDeleteFramebuffers", [(GLsizei, "n"), (Array(Const(GLframebuffer), "n"), "framebuffers")]),
+        F(Void, "glDeleteRenderbuffers", [(GLsizei, "n"), (Array(Const(GLrenderbuffer), "n"), "renderbuffers")]),
         F(Void, "glFramebufferRenderbuffer", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "renderbuffertarget"), (GLuint, "renderbuffer")]),
-        F(Void, "glFramebufferTexture1D", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (texture, "texture"), (GLint, "level")]),
-        F(Void, "glFramebufferTexture2D", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (texture, "texture"), (GLint, "level")]),
-        F(Void, "glFramebufferTexture3D", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (texture, "texture"), (GLint, "level"), (GLint, "zoffset")]),
-        F(Void, "glGenFramebuffers", [(GLsizei, "n"), Out(Array(framebuffer, "n"), "framebuffers")]),
-        F(Void, "glGenRenderbuffers", [(GLsizei, "n"), Out(Array(renderbuffer, "n"), "renderbuffers")]),
+        F(Void, "glFramebufferTexture1D", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
+        F(Void, "glFramebufferTexture2D", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
+        F(Void, "glFramebufferTexture3D", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level"), (GLint, "zoffset")]),
+        F(Void, "glGenFramebuffers", [(GLsizei, "n"), Out(Array(GLframebuffer, "n"), "framebuffers")]),
+        F(Void, "glGenRenderbuffers", [(GLsizei, "n"), Out(Array(GLrenderbuffer, "n"), "renderbuffers")]),
         F(Void, "glGenerateMipmap", [(GLenum, "target")]),
         F(Void, "glGetFramebufferAttachmentParameteriv", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
         F(Void, "glGetRenderbufferParameteriv", [(GLenum, "target"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
-        F(GLboolean, "glIsFramebuffer", [(framebuffer, "framebuffer")]),
-        F(GLboolean, "glIsRenderbuffer", [(renderbuffer, "renderbuffer")]),
+        F(GLboolean, "glIsFramebuffer", [(GLframebuffer, "framebuffer")]),
+        F(GLboolean, "glIsRenderbuffer", [(GLrenderbuffer, "renderbuffer")]),
         F(Void, "glRenderbufferStorage", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
         F(Void, "glBlitFramebuffer", [(GLint, "srcX0"), (GLint, "srcY0"), (GLint, "srcX1"), (GLint, "srcY1"), (GLint, "dstX0"), (GLint, "dstY0"), (GLint, "dstX1"), (GLint, "dstY1"), (GLbitfield_attrib, "mask"), (GLenum, "filter")]),
-        F(Void, "glFramebufferTextureLayer", [(GLenum, "target"), (GLenum, "attachment"), (texture, "texture"), (GLint, "level"), (GLint, "layer")]),
+        F(Void, "glFramebufferTextureLayer", [(GLenum, "target"), (GLenum, "attachment"), (GLtexture, "texture"), (GLint, "level"), (GLint, "layer")]),
 
-        F(Void, "glBindFramebufferEXT", [(GLenum, "target"), (framebuffer, "framebuffer")]),
-        F(Void, "glBindRenderbufferEXT", [(GLenum, "target"), (renderbuffer, "renderbuffer")]),
+        F(Void, "glBindFramebufferEXT", [(GLenum, "target"), (GLframebuffer, "framebuffer")]),
+        F(Void, "glBindRenderbufferEXT", [(GLenum, "target"), (GLrenderbuffer, "renderbuffer")]),
         F(GLenum, "glCheckFramebufferStatusEXT", [(GLenum, "target")]),
-        F(Void, "glDeleteFramebuffersEXT", [(GLsizei, "n"), (Array(Const(framebuffer), "n"), "framebuffers")]),
-        F(Void, "glDeleteRenderbuffersEXT", [(GLsizei, "n"), (Array(Const(renderbuffer), "n"), "renderbuffers")]),
+        F(Void, "glDeleteFramebuffersEXT", [(GLsizei, "n"), (Array(Const(GLframebuffer), "n"), "framebuffers")]),
+        F(Void, "glDeleteRenderbuffersEXT", [(GLsizei, "n"), (Array(Const(GLrenderbuffer), "n"), "renderbuffers")]),
         F(Void, "glFramebufferRenderbufferEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "renderbuffertarget"), (GLuint, "renderbuffer")]),
-        F(Void, "glFramebufferTexture1DEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (texture, "texture"), (GLint, "level")]),
-        F(Void, "glFramebufferTexture2DEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (texture, "texture"), (GLint, "level")]),
-        F(Void, "glFramebufferTexture3DEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (texture, "texture"), (GLint, "level"), (GLint, "zoffset")]),
-        F(Void, "glGenFramebuffersEXT", [(GLsizei, "n"), Out(Array(framebuffer, "n"), "framebuffers")]),
-        F(Void, "glGenRenderbuffersEXT", [(GLsizei, "n"), Out(Array(renderbuffer, "n"), "renderbuffers")]),
+        F(Void, "glFramebufferTexture1DEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
+        F(Void, "glFramebufferTexture2DEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
+        F(Void, "glFramebufferTexture3DEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level"), (GLint, "zoffset")]),
+        F(Void, "glGenFramebuffersEXT", [(GLsizei, "n"), Out(Array(GLframebuffer, "n"), "framebuffers")]),
+        F(Void, "glGenRenderbuffersEXT", [(GLsizei, "n"), Out(Array(GLrenderbuffer, "n"), "renderbuffers")]),
         F(Void, "glGenerateMipmapEXT", [(GLenum, "target")]),
         F(Void, "glGetFramebufferAttachmentParameterivEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
         F(Void, "glGetRenderbufferParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), (OpaquePointer(GLint), "params")], sideeffects=False),
-        F(GLboolean, "glIsFramebufferEXT", [(framebuffer, "framebuffer")]),
-        F(GLboolean, "glIsRenderbufferEXT", [(renderbuffer, "renderbuffer")]),
+        F(GLboolean, "glIsFramebufferEXT", [(GLframebuffer, "framebuffer")]),
+        F(GLboolean, "glIsRenderbufferEXT", [(GLrenderbuffer, "renderbuffer")]),
         F(Void, "glRenderbufferStorageEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
         F(Void, "glBlitFramebufferEXT", [(GLint, "srcX0"), (GLint, "srcY0"), (GLint, "srcX1"), (GLint, "srcY1"), (GLint, "dstX0"), (GLint, "dstY0"), (GLint, "dstX1"), (GLint, "dstY1"), (GLbitfield_attrib, "mask"), (GLenum, "filter")]),
-        F(Void, "glFramebufferTextureLayerEXT", [(GLenum, "target"), (GLenum, "attachment"), (texture, "texture"), (GLint, "level"), (GLint, "layer")]),
+        F(Void, "glFramebufferTextureLayerEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLtexture, "texture"), (GLint, "level"), (GLint, "layer")]),
 
         F(Void, "glStencilFuncSeparateATI", [(GLenum, "frontfunc"), (GLenum, "backfunc"), (GLint, "ref"), (GLuint, "mask")]),
         F(Void, "glProgramEnvParameters4fvEXT", [(GLenum, "target"), (GLuint, "index"), (GLsizei, "count"), (OpaquePointer(Const(GLfloat)), "params")]),
index 8a0a68a19802c69ce3fa1d898ba32bf66eef2c69..a9fb82cb341f79fc291f03044df749d423df861d 100644 (file)
@@ -82,7 +82,7 @@ class ValueExtractor(base.Visitor):
         print '    %s = static_cast<%s>((%s).blob());' % (lvalue, blob, rvalue)
     
     def visit_string(self, string, lvalue, rvalue):
-        print '    %s = (%s).string();' % (lvalue, rvalue)
+        print '    %s = (%s)((%s).string());' % (lvalue, string.expr, rvalue)
 
 
 
@@ -145,7 +145,11 @@ def retrace_function(function):
         print '    std::cerr << "warning: unsupported call %s\\n";' % function.name
         print '    return;'
     arg_names = ", ".join([arg.name for arg in function.args])
-    print '    %s(%s);' % (function.name, arg_names)
+    if function.type is not base.Void:
+        print '    %s __result;' % (function.type)
+        print '    __result = %s(%s);' % (function.name, arg_names)
+    else:
+        print '    %s(%s);' % (function.name, arg_names)
     for arg in function.args:
         if arg.output:
             arg.type = ConstRemover().visit(arg.type)
@@ -155,6 +159,13 @@ def retrace_function(function):
                 ValueWrapper().visit(arg.type, lvalue, rvalue)
             except NotImplementedError:
                 print '   // FIXME: %s' % arg.name
+    if function.type is not base.Void:
+        rvalue = '*call.ret'
+        lvalue = '__result'
+        try:
+            ValueWrapper().visit(function.type, lvalue, rvalue)
+        except NotImplementedError:
+            print '   // FIXME: result'
     print '}'
     print
 
@@ -186,6 +197,17 @@ def retrace_functions(functions):
     print
 
 
+def retrace_api(api):
+    types = api.all_types()
+
+    handles = [type for type in types if isinstance(type, base.Handle)]
+    for handle in handles:
+        print 'static std::map<%s, %s> __%s_map;' % (handle.type, handle.type, handle.name)
+    print
+
+    retrace_functions(api.functions)
+
+
 if __name__ == '__main__':
     print
     print '#include <stdlib.h>'
@@ -195,12 +217,7 @@ if __name__ == '__main__':
     print
     print '#include "trace_parser.hpp"'
     print
-    for name in ['texture', 'framebuffer', 'renderbuffer']:
-        print 'static std::map<GLuint, GLuint> __%s_map;' % name
-    print
-
-    retrace_functions(glapi.glapi.functions)
-
+    retrace_api(glapi.glapi)
     print '''
 
 Trace::Parser parser;
index a866f2a6c8012393c8510299aa7571bc0d8d47e1..90f1ef6b03914ccad65e5941213a474bdb3e93c3 100644 (file)
--- a/trace.py
+++ b/trace.py
@@ -118,7 +118,10 @@ class DumpImplementer(base.Visitor):
         print '    Log::Literal%s(%s);' % (literal.format, instance)
 
     def visit_string(self, string, instance):
-        print '    Log::LiteralString((const char *)%s);' % instance
+        if string.length is not None:
+            print '    Log::LiteralString((const char *)%s, %s);' % (instance, string.length)
+        else:
+            print '    Log::LiteralString((const char *)%s);' % instance
 
     def visit_const(self, const, instance):
         self.visit(const.type, instance)
@@ -241,12 +244,13 @@ class Tracer:
 
         # Includes
         for header in api.headers:
-            print '#include <%s>' % header
+            print header
         print
 
         # Type dumpers
+        types = api.all_types()
         visitor = DumpDeclarator()
-        map(visitor.visit, api.types)
+        map(visitor.visit, types)
         print
 
         # Interfaces wrapers