From 48a92b99752143a34a6b5f6b94bad183564cecab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 20 Jul 2013 15:34:24 +0100 Subject: [PATCH] gltrace: Simplify AttribArray further. Make it look more like an Array. --- specs/cglapi.py | 2 +- specs/eglapi.py | 8 ++++---- specs/glxapi.py | 12 +++++------- specs/stdapi.py | 7 ++----- specs/wglapi.py | 10 +++++----- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/specs/cglapi.py b/specs/cglapi.py index 8cb9d8c..f54ce8a 100644 --- a/specs/cglapi.py +++ b/specs/cglapi.py @@ -92,7 +92,7 @@ CGLPixelFormatIntAttributes = [ CGLPixelFormatAttribute = Enum("CGLPixelFormatAttribute", CGLPixelFormatBoolAttributes + CGLPixelFormatIntAttributes) -CGLPixelFormatAttribs = AttribArray(CGLPixelFormatAttribute, +CGLPixelFormatAttribs = AttribArray(Const(CGLPixelFormatAttribute), [(a, None) for a in CGLPixelFormatBoolAttributes] + [(a, Int) for a in CGLPixelFormatIntAttributes]) diff --git a/specs/eglapi.py b/specs/eglapi.py index c4db7da..fc7aba3 100644 --- a/specs/eglapi.py +++ b/specs/eglapi.py @@ -88,7 +88,7 @@ EGLSurfaceFlags = Flags(Int, [ EGLConformantFlags = Flags(Int, ['EGL_OPENGL_BIT','EGL_OPENGL_ES_BIT', 'EGL_OPENGL_ES2_BIT', 'EGL_OPENVG_BIT',]) -EGLConfigAttribs = AttribArray(EGLint_enum, [ +EGLConfigAttribs = AttribArray(Const(EGLint_enum), [ ('EGL_ALPHA_MASK_SIZE', UInt), ('EGL_ALPHA_SIZE', UInt), ('EGL_BIND_TO_TEXTURE_RGB', EGLBoolean), @@ -125,7 +125,7 @@ EGLTextureFormat = FakeEnum(Int, ['EGL_NO_TEXTURE', 'EGL_TEXTURE_RGB', 'EGL_TEXT EGLTextureTarget = FakeEnum(Int, ['EGL_TEXTURE_2D', 'EGL_NO_TEXTURE' ]) def EGLAttribArray(values): - return AttribArray(EGLint_enum, values, terminator = 'EGL_NONE') + return AttribArray(Const(EGLint_enum), values, terminator = 'EGL_NONE') EGLWindowsSurfaceAttribs = EGLAttribArray([ ('EGL_RENDER_BUFFER', FakeEnum(Int, ['EGL_SINGLE_BUFFER', 'EGL_BACK_BUFFER'])), @@ -209,7 +209,7 @@ eglapi.addFunctions([ Function(EGLBoolean, "eglSwapInterval", [(EGLDisplay, "dpy"), (EGLint, "interval")]), - Function(EGLContext, "eglCreateContext", [(EGLDisplay, "dpy"), (EGLConfig, "config"), (EGLContext, "share_context"), (AttribArray(EGLint_enum, [('EGL_CONTEXT_CLIENT_VERSION', Int)]), "attrib_list")]), + Function(EGLContext, "eglCreateContext", [(EGLDisplay, "dpy"), (EGLConfig, "config"), (EGLContext, "share_context"), (AttribArray(Const(EGLint_enum), [('EGL_CONTEXT_CLIENT_VERSION', Int)]), "attrib_list")]), Function(EGLBoolean, "eglDestroyContext", [(EGLDisplay, "dpy"), (EGLContext, "ctx")]), Function(EGLBoolean, "eglMakeCurrent", [(EGLDisplay, "dpy"), (EGLSurface, "draw"), (EGLSurface, "read"), (EGLContext, "ctx")]), @@ -232,7 +232,7 @@ eglapi.addFunctions([ Function(EGLBoolean, "eglUnlockSurfaceKHR", [(EGLDisplay, "display"), (EGLSurface, "surface")]), # EGL_KHR_image_base - Function(EGLImageKHR, "eglCreateImageKHR", [(EGLDisplay, "dpy"), (EGLContext, "ctx"), (EGLenum, "target"), (EGLClientBuffer, "buffer"), (AttribArray(EGLint_enum, [('EGL_IMAGE_PRESERVED_KHR', EGLBoolean)]), "attrib_list")]), + Function(EGLImageKHR, "eglCreateImageKHR", [(EGLDisplay, "dpy"), (EGLContext, "ctx"), (EGLenum, "target"), (EGLClientBuffer, "buffer"), (AttribArray(Const(EGLint_enum), [('EGL_IMAGE_PRESERVED_KHR', EGLBoolean)]), "attrib_list")]), Function(EGLBoolean, "eglDestroyImageKHR", [(EGLDisplay, "dpy"), (EGLImageKHR, "image")]), # EGL_KHR_fence_sync diff --git a/specs/glxapi.py b/specs/glxapi.py index 1340711..ad2533c 100644 --- a/specs/glxapi.py +++ b/specs/glxapi.py @@ -208,7 +208,7 @@ GLXbuffer = Flags(Int, [ "GLX_PBUFFER_CLOBBER_MASK", ]) -UnusedAttribs = AttribArray(GLXEnum, []) +UnusedAttribs = AttribArray(Const(GLXEnum), []) GLXCommonSizeAttribs = [ ('GLX_RED_SIZE', UInt), @@ -233,7 +233,6 @@ GLXVisualAttribs = AttribArray(GLXEnum, GLXCommonSizeAttribs + [ ('GLX_AUX_BUFFERS', UInt), ('GLX_SAMPLE_BUFFERS', UInt), ('GLX_SAMPLES', UInt)], - isConst = False ) GLXFBConfigCommonAttribs = GLXCommonSizeAttribs + [ @@ -265,17 +264,17 @@ GLXFBConfigGLXAttribs = GLXFBConfigCommonAttribs + [ ('GLX_VISUAL_ID', Int) # another XID ] -GLXFBConfigAttribs = AttribArray(GLXEnum, GLXFBConfigGLXAttribs) -GLXFBConfigSGIXAttribs = AttribArray(GLXEnum, GLXFBConfigCommonAttribs, isConst = False) +GLXFBConfigAttribs = AttribArray(Const(GLXEnum), GLXFBConfigGLXAttribs) +GLXFBConfigSGIXAttribs = AttribArray(GLXEnum, GLXFBConfigCommonAttribs) -GLXContextARBAttribs = AttribArray(GLXEnum, [ +GLXContextARBAttribs = AttribArray(Const(GLXEnum), [ ('GLX_CONTEXT_MAJOR_VERSION_ARB', Int), ('GLX_CONTEXT_MINOR_VERSION_ARB', Int), ('GLX_CONTEXT_FLAGS_ARB', Flags(Int, ["GLX_CONTEXT_DEBUG_BIT_ARB", "GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB"])), ('GLX_CONTEXT_PROFILE_MASK_ARB', Flags(Int, ["GLX_CONTEXT_CORE_PROFILE_BIT_ARB", "GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB"])) ]) -GLXPbufferAttribs = AttribArray(GLXEnum, [ +GLXPbufferAttribs = AttribArray(Const(GLXEnum), [ ('GLX_PBUFFER_WIDTH', Int), ('GLX_PBUFFER_HEIGHT', Int), ('GLX_LARGEST_PBUFFER', Bool), @@ -286,7 +285,6 @@ GLXPbufferSGIXAttribs = AttribArray(GLXEnum, [ ('GLX_PRESERVED_CONTENTS_SGIX', Bool), ('GLX_LARGEST_PBUFFER', Bool), ('GLX_DIGITAL_MEDIA_PBUFFER_SGIX', Bool)], - isConst = False ) glxapi = Module("GLX") diff --git a/specs/stdapi.py b/specs/stdapi.py index 1988c65..c2a154d 100644 --- a/specs/stdapi.py +++ b/specs/stdapi.py @@ -272,12 +272,9 @@ class Array(Type): class AttribArray(Type): - def __init__(self, baseType, valueTypes, isConst = True, terminator = '0'): + def __init__(self, baseType, valueTypes, terminator = '0'): self.baseType = baseType - if isConst: - Type.__init__(self, (Pointer(Const(self.baseType))).expr) - else: - Type.__init__(self, (Pointer(self.baseType)).expr) + Type.__init__(self, (Pointer(self.baseType)).expr) self.valueTypes = valueTypes self.terminator = terminator self.hasKeysWithoutValues = False diff --git a/specs/wglapi.py b/specs/wglapi.py index 9c4b13b..e749554 100644 --- a/specs/wglapi.py +++ b/specs/wglapi.py @@ -138,7 +138,7 @@ WGLSWAP = Struct("WGLSWAP", [ (UINT, "uiFlags"), ]) -WGLContextAttribs = AttribArray(WGLenum, [ +WGLContextAttribs = AttribArray(Const(WGLenum), [ ('WGL_CONTEXT_MAJOR_VERSION_ARB', Int), ('WGL_CONTEXT_MINOR_VERSION_ARB', Int), ('WGL_CONTEXT_LAYER_PLANE_ARB', Int), @@ -187,10 +187,10 @@ WGLPixelFormatAttribsList = [ ('WGL_SAMPLES_ARB', Int), ] -WGLPixelFormatAttribs = AttribArray(WGLenum, WGLPixelFormatAttribsList) -WGLPixelFormatFloatAttribs = AttribArray(FLOAT, WGLPixelFormatAttribsList) +WGLPixelFormatAttribs = AttribArray(Const(WGLenum), WGLPixelFormatAttribsList) +WGLPixelFormatFloatAttribs = AttribArray(Const(FLOAT), WGLPixelFormatAttribsList) -WGLCreatePbufferARBAttribs = AttribArray(WGLenum, [ +WGLCreatePbufferARBAttribs = AttribArray(Const(WGLenum), [ ('WGL_PBUFFER_LARGEST_ARB', Int) ]) @@ -203,7 +203,7 @@ CubeFaceEnum = FakeEnum(Int, [ 'WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB' ]) -WGLSetPbufferARBAttribs = AttribArray(WGLenum, [ +WGLSetPbufferARBAttribs = AttribArray(Const(WGLenum), [ ('WGL_MIPMAP_LEVEL_ARB', Int), ('WGL_CUBE_MAP_FACE_ARB', CubeFaceEnum) ]) -- 2.43.0