Fix common HRESULT values.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 16 Apr 2012 19:47:56 +0000 (20:47 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 16 Apr 2012 19:47:56 +0000 (20:47 +0100)
specs/d3d.py
specs/d3d10.py
specs/d3d11.py
specs/d3d8.py
specs/d3d9.py
specs/ddraw.py
specs/dxgitype.py
specs/winapi.py

index 2a02afd..ca11551 100644 (file)
@@ -48,8 +48,7 @@ d3ddpFlags = Flags(DWORD, [
     "D3DDP_DONOTLIGHT",
 ])
 
-HRESULT = FakeEnum(HRESULT, [
-    "D3D_OK",
+HRESULT = MAKE_HRESULT(ok = "D3D_OK", errors = [
     "D3DERR_BADMAJORVERSION",
     "D3DERR_BADMINORVERSION",
     "D3DERR_INVALID_DEVICE",
index 3ee6179..defad5a 100644 (file)
@@ -28,7 +28,7 @@ from dxgi import *
 from d3dcommon import *
 
 
-HRESULT = FakeEnum(HRESULT, [
+HRESULT = MAKE_HRESULT([
     "D3D10_ERROR_FILE_NOT_FOUND",
     "D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS",
     "D3DERR_INVALIDCALL",
index bbbf7fa..5d0c626 100644 (file)
@@ -29,7 +29,7 @@ from d3dcommon import *
 from d3d11sdklayers import *
 
 
-HRESULT = FakeEnum(HRESULT, [
+HRESULT = MAKE_HRESULT([
     "D3D11_ERROR_FILE_NOT_FOUND",
     "D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS",
     "D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS",
index 79177cf..41e6402 100644 (file)
@@ -29,8 +29,7 @@ from winapi import *
 from d3d8types import *
 from d3d8caps import *
 
-HRESULT = FakeEnum(HRESULT, [
-    "D3D_OK",
+HRESULT = MAKE_HRESULT(ok = "D3D_OK", errors = [
     "D3DERR_WRONGTEXTUREFORMAT",
     "D3DERR_UNSUPPORTEDCOLOROPERATION",
     "D3DERR_UNSUPPORTEDCOLORARG",
index 475508c..050517b 100644 (file)
@@ -78,8 +78,7 @@ D3DPRESENT = Flags(DWORD, [
     "D3DPRESENT_VIDEO_RESTRICT_TO_MONITOR",
 ])
 
-HRESULT = FakeEnum(HRESULT, [
-    "D3D_OK",
+HRESULT = MAKE_HRESULT(ok = "D3D_OK", errors = [
     "D3DERR_WRONGTEXTUREFORMAT",
     "D3DERR_UNSUPPORTEDCOLOROPERATION",
     "D3DERR_UNSUPPORTEDCOLORARG",
index fe93a8f..aed2b0d 100644 (file)
@@ -1147,9 +1147,7 @@ DirectDrawEvaluateModeFlags = Flags(DWORD, [
     "DDEM_MODEFAILED",
 ])
 
-DDRESULT = FakeEnum(HRESULT, [
-    "DD_OK",
-    "DD_FALSE",
+DDRESULT = MAKE_HRESULT(ok = "DD_OK", false = "DD_FALSE", errors = [
     "DDERR_ALREADYINITIALIZED",
     "DDERR_CANNOTATTACHSURFACE",
     "DDERR_CANNOTDETACHSURFACE",
index c7c610c..e330d14 100644 (file)
@@ -27,7 +27,7 @@
 from dxgiformat import *
 
 
-HRESULT = FakeEnum(HRESULT, [
+HRESULT = MAKE_HRESULT([
     "DXGI_STATUS_OCCLUDED",
     "DXGI_STATUS_CLIPPED",
     "DXGI_STATUS_NO_REDIRECTION",
index 6fbdfae..0941118 100644 (file)
@@ -179,21 +179,25 @@ LOGFONTW = Struct("LOGFONTW", [
 
 # http://msdn.microsoft.com/en-us/library/ff485842.aspx
 # http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381.aspx
-HRESULT = Enum("HRESULT", [
-    "S_OK", # 0x0
-    "S_FALSE", # 0x1
-    "E_PENDING", # 0x8000000A
-    "E_NOTIMPL", # 0x80004001
-    "E_NOINTERFACE", # 0x80004002
-    "E_POINTER", # 0x80004003
-    "E_ABORT", # 0x80004004
-    "E_FAIL", # 0x80004005
-    "E_UNEXPECTED", # 0x8000FFFF
-    "E_ACCESSDENIED", # 0x80070005
-    "E_HANDLE", # 0x80070006
-    "E_OUTOFMEMORY", # 0x8007000E
-    "E_INVALIDARG", # 0x80070057
-])
+def MAKE_HRESULT(errors, ok = "S_OK", false = "S_FALSE"):
+    values = [ok, false]
+    values.extend(errors)
+    values.extend([
+        "E_PENDING", # 0x8000000A
+        "E_NOTIMPL", # 0x80004001
+        "E_NOINTERFACE", # 0x80004002
+        "E_POINTER", # 0x80004003
+        "E_ABORT", # 0x80004004
+        "E_FAIL", # 0x80004005
+        "E_UNEXPECTED", # 0x8000FFFF
+        "E_ACCESSDENIED", # 0x80070005
+        "E_HANDLE", # 0x80070006
+        "E_OUTOFMEMORY", # 0x8007000E
+        "E_INVALIDARG", # 0x80070057
+    ])
+    return Enum("HRESULT", values)
+
+HRESULT = MAKE_HRESULT([])
 
 
 IUnknown = Interface("IUnknown")