diff options
-rwxr-xr-x | retrace/glstate_params.py | 4 | ||||
-rw-r--r-- | specs/d3d10.py | 6 | ||||
-rw-r--r-- | specs/d3d11.py | 6 | ||||
-rw-r--r-- | specs/d3d8types.py | 2 | ||||
-rw-r--r-- | specs/d3d9types.py | 2 | ||||
-rw-r--r-- | specs/stdapi.py | 15 |
6 files changed, 24 insertions, 11 deletions
diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py index accd885e..fb49ff9a 100755 --- a/retrace/glstate_params.py +++ b/retrace/glstate_params.py @@ -114,7 +114,7 @@ class StateGetter(Visitor): for type, count, name in self.iter(): if name == pname: if count != 1: - type = Array(type, str(count)) + type = Array(type, count) return type, self.visit(type, args) @@ -164,7 +164,7 @@ class StateGetter(Visitor): inflection = self.inflector.inflect(array.type) assert inflection.endswith('v' + self.inflector.suffix) array_length = array.length - if array_length.isdigit(): + if isinstance(array_length, int): # Static integer length print ' %s %s[%s + 1];' % (elem_type, temp_name, array_length) else: diff --git a/specs/d3d10.py b/specs/d3d10.py index 830cb1e1..ebb4b430 100644 --- a/specs/d3d10.py +++ b/specs/d3d10.py @@ -906,7 +906,7 @@ ID3D10Device.methods += [ StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")], sideeffects=False), StdMethod(Void, "ClearState", []), StdMethod(Void, "Flush", []), - StdMethod(HRESULT, "CreateBuffer", [(Pointer(Const(D3D10_BUFFER_DESC)), "pDesc"), (Array(Const(D3D10_SUBRESOURCE_DATA), "1"), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Buffer)), "ppBuffer")]), + StdMethod(HRESULT, "CreateBuffer", [(Pointer(Const(D3D10_BUFFER_DESC)), "pDesc"), (Array(Const(D3D10_SUBRESOURCE_DATA), 1), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Buffer)), "ppBuffer")]), StdMethod(HRESULT, "CreateTexture1D", [(Pointer(Const(D3D10_TEXTURE1D_DESC)), "pDesc"), (Array(Const(D3D10_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Texture1D)), "ppTexture1D")]), StdMethod(HRESULT, "CreateTexture2D", [(Pointer(Const(D3D10_TEXTURE2D_DESC)), "pDesc"), (Array(Const(D3D10_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Texture2D)), "ppTexture2D")]), StdMethod(HRESULT, "CreateTexture3D", [(Pointer(Const(D3D10_TEXTURE3D_DESC)), "pDesc"), (Array(Const(D3D10_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Texture3D)), "ppTexture3D")]), @@ -991,10 +991,12 @@ D3D10_RENDER_TARGET_BLEND_DESC1 = Struct("D3D10_RENDER_TARGET_BLEND_DESC1", [ (UINT8, "RenderTargetWriteMask"), ]) +D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT = 8 + D3D10_BLEND_DESC1 = Struct("D3D10_BLEND_DESC1", [ (BOOL, "AlphaToCoverageEnable"), (BOOL, "IndependentBlendEnable"), - (Array(D3D10_RENDER_TARGET_BLEND_DESC1, "D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT"), "RenderTarget"), + (Array(D3D10_RENDER_TARGET_BLEND_DESC1, D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT), "RenderTarget"), ]) ID3D10BlendState1 = Interface("ID3D10BlendState1", ID3D10BlendState) diff --git a/specs/d3d11.py b/specs/d3d11.py index add47c1e..5d4c5400 100644 --- a/specs/d3d11.py +++ b/specs/d3d11.py @@ -1277,7 +1277,7 @@ D3D11_CREATE_DEVICE_FLAG = Flags(UINT, [ ]) ID3D11Device.methods += [ - StdMethod(HRESULT, "CreateBuffer", [(Pointer(Const(D3D11_BUFFER_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), "1"), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Buffer)), "ppBuffer")]), + StdMethod(HRESULT, "CreateBuffer", [(Pointer(Const(D3D11_BUFFER_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), 1), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Buffer)), "ppBuffer")]), StdMethod(HRESULT, "CreateTexture1D", [(Pointer(Const(D3D11_TEXTURE1D_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture1D)), "ppTexture1D")]), StdMethod(HRESULT, "CreateTexture2D", [(Pointer(Const(D3D11_TEXTURE2D_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture2D)), "ppTexture2D")]), StdMethod(HRESULT, "CreateTexture3D", [(Pointer(Const(D3D11_TEXTURE3D_DESC)), "pDesc"), (Array(Const(D3D11_SUBRESOURCE_DATA), "_getNumSubResources(pDesc)"), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture3D)), "ppTexture3D")]), @@ -1394,10 +1394,12 @@ D3D11_RENDER_TARGET_BLEND_DESC1 = Struct("D3D11_RENDER_TARGET_BLEND_DESC1", [ (UINT8, "RenderTargetWriteMask"), ]) +D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT = 8 + D3D11_BLEND_DESC1 = Struct("D3D11_BLEND_DESC1", [ (BOOL, "AlphaToCoverageEnable"), (BOOL, "IndependentBlendEnable"), - (Array(D3D11_RENDER_TARGET_BLEND_DESC1, "D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT"), "RenderTarget"), + (Array(D3D11_RENDER_TARGET_BLEND_DESC1, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT), "RenderTarget"), ]) ID3D11BlendState1.methods += [ diff --git a/specs/d3d8types.py b/specs/d3d8types.py index df90f710..fe58a0cd 100644 --- a/specs/d3d8types.py +++ b/specs/d3d8types.py @@ -50,7 +50,7 @@ D3DRECT = Struct("D3DRECT", [ ]) D3DMATRIX = Struct("D3DMATRIX", [ - (Array(Array(Float, 4), "4"), "m"), + (Array(Array(Float, 4), 4), "m"), ]) D3DVIEWPORT8 = Struct("D3DVIEWPORT8", [ diff --git a/specs/d3d9types.py b/specs/d3d9types.py index a9aefffd..2545a767 100644 --- a/specs/d3d9types.py +++ b/specs/d3d9types.py @@ -51,7 +51,7 @@ D3DRECT = Struct("D3DRECT", [ ]) D3DMATRIX = Struct("D3DMATRIX", [ - (Array(Array(Float, 4), "4"), "m"), + (Array(Array(Float, 4), 4), "m"), ]) D3DVIEWPORT9 = Struct("D3DVIEWPORT9", [ diff --git a/specs/stdapi.py b/specs/stdapi.py index 97f58686..c72c264b 100644 --- a/specs/stdapi.py +++ b/specs/stdapi.py @@ -268,10 +268,19 @@ Flags = Bitmask class Array(Type): - def __init__(self, type, length): - Type.__init__(self, type.expr + " *") - self.type = type + def __init__(self, type_, length): + Type.__init__(self, type_.expr + " *") + self.type = type_ self.length = length + if not isinstance(length, int): + assert isinstance(length, basestring) + # Check if length is actually a valid constant expression + try: + eval(length, {}, {}) + except: + pass + else: + raise ValueError("length %r should be an integer" % length) def visit(self, visitor, *args, **kwargs): return visitor.visitArray(self, *args, **kwargs) |