From: José Fonseca Date: Wed, 22 Jul 2009 17:14:12 +0000 (+0100) Subject: First stab at arrays. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=ccae31cf39a558f1ca9d22175a10b96297edd738;p=apitrace First stab at arrays. --- diff --git a/base.py b/base.py index 2874489..0d94daa 100644 --- a/base.py +++ b/base.py @@ -206,6 +206,28 @@ class Flags(Concrete): print ' }' +class Array(Type): + + def __init__(self, type, length): + Type.__init__(self, type.expr + " *", 'P' + type.id) + self.type = type + self.length = length + + def dump(self, instance): + index = '__i' + self.type.id + print ' for (int %s; %s < %s; ++%s) {' % (index, index, self.length, index) + print ' Log::BeginElement("%s");' % (self.type,) + self.type.dump('(%s)[%s]' % (instance, index)) + print ' Log::EndElement();' + print ' }' + + def wrap_instance(self, instance): + self.type.wrap_instance("*" + instance) + + def unwrap_instance(self, instance): + self.type.wrap_instance("*" + instance) + + class Struct(Concrete): def __init__(self, name, members): diff --git a/opengl32.py b/opengl32.py index 6b946af..5cb4419 100644 --- a/opengl32.py +++ b/opengl32.py @@ -36,7 +36,7 @@ opengl32.functions += [ DllFunction(Void, "glColor3d", [(GLdouble, "red"), (GLdouble, "green"), (GLdouble, "blue")]), DllFunction(Void, "glColor3dv", [(Pointer(Const(GLdouble)), "v")]), DllFunction(Void, "glColor3f", [(GLfloat, "red"), (GLfloat, "green"), (GLfloat, "blue")]), - DllFunction(Void, "glColor3fv", [(Pointer(Const(GLfloat)), "v")]), + DllFunction(Void, "glColor3fv", [(Array(Const(GLfloat), "3"), "v")]), DllFunction(Void, "glColor3i", [(GLint, "red"), (GLint, "green"), (GLint, "blue")]), DllFunction(Void, "glColor3iv", [(Pointer(Const(GLint)), "v")]), DllFunction(Void, "glColor3s", [(GLshort, "red"), (GLshort, "green"), (GLshort, "blue")]),