diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2015-06-10 22:04:45 +0100 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2015-06-10 22:57:34 +0100 |
commit | a9b61380090fa1d726fb41aade658ac145ac0617 (patch) | |
tree | 9dcd77b467ae82424119cad85899b327b78bbc40 /specs | |
parent | 70b7fcbf7ff0ef38d04f82d68a56f2bb44ec694a (diff) |
specs: Ensure that constant array lengths are always of integer type.
And not a string with an integer expression.
Diffstat (limited to 'specs')
-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 |
5 files changed, 22 insertions, 9 deletions
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) |