]> git.cworth.org Git - apitrace/blob - specs/winapi.py
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / specs / winapi.py
1 ##########################################################################
2 #
3 # Copyright 2008-2009 VMware, Inc.
4 # All Rights Reserved.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24 ##########################################################################/
25
26 """Win32 API type description."""
27
28
29 from stdapi import *
30
31
32 SHORT = Alias("SHORT", Short)
33 USHORT = Alias("USHORT", UShort)
34 INT = Alias("INT", Int)
35 UINT = Alias("UINT", UInt)
36 LONG = Alias("LONG", Long)
37 ULONG = Alias("ULONG", ULong)
38 LONGLONG = Alias("LONGLONG", LongLong)
39 FLOAT = Alias("FLOAT", Float)
40
41 INT8 = Alias("INT8", Int8)
42 UINT8 = Alias("UINT8", UInt8)
43 INT16 = Alias("INT16", Int16)
44 UINT16 = Alias("UINT16", UInt16)
45 INT32 = Alias("INT32", Int32)
46 UINT32 = Alias("UINT32", UInt32)
47 INT64 = Alias("INT64", Int64)
48 UINT64 = Alias("UINT64", UInt64)
49
50 BYTE = Alias("BYTE", UInt8)
51 WORD = Alias("WORD", UInt16)
52 DWORD = Alias("DWORD", UInt32)
53
54 UCHAR = Alias("UCHAR", UChar)
55 WCHAR = Alias("WCHAR", Short)
56
57 BOOL = Enum("BOOL", [
58     "FALSE",
59     "TRUE",
60 ])
61
62 LPLONG = Pointer(LONG)
63 LPWORD = Pointer(WORD)
64 LPDWORD = Pointer(DWORD)
65 LPBOOL = Pointer(BOOL)
66
67 LPSTR = CString
68 LPCSTR = ConstCString
69 LPWSTR = WString
70 LPCWSTR = ConstWString
71
72 LARGE_INTEGER = Struct("LARGE_INTEGER", [
73     (LONGLONG, 'QuadPart'),
74 ])
75
76 SIZE_T = Alias("SIZE_T", SizeT)
77
78 VOID = Void
79 PVOID = OpaquePointer(VOID)
80 LPVOID = PVOID
81 LPCVOID = OpaquePointer(Const(VOID))
82
83 def DECLARE_HANDLE(expr):
84     return Handle(expr, IntPointer(expr))
85
86 HANDLE = DECLARE_HANDLE("HANDLE")
87 HWND = DECLARE_HANDLE("HWND")
88 HDC = DECLARE_HANDLE("HDC")
89 HMONITOR = DECLARE_HANDLE("HMONITOR")
90
91 GUID = Struct("GUID", [
92     (DWORD, "Data1"),
93     (WORD, "Data2"),
94     (WORD, "Data3"),
95     (Array(BYTE, 8), "Data4"),
96 ])
97 LPGUID = Pointer(GUID)
98
99 REFGUID = Alias("REFGUID", Reference(GUID))
100
101 IID = Alias("IID", GUID)
102 REFIID = Alias("REFIID", Reference(IID))
103
104 CLSID = Alias("CLSID", GUID)
105 REFCLSID = Alias("REFCLSID", Reference(CLSID))
106
107 LUID = Struct("LUID", [
108     (DWORD, "LowPart"),
109     (LONG, "HighPart"),
110 ])
111
112 POINT = Struct("POINT", (
113   (LONG, "x"),
114   (LONG, "y"),
115 )) 
116 LPPOINT = Pointer(POINT)
117
118 SIZE = Struct("SIZE", (
119   (LONG, "cx"),
120   (LONG, "cy"),
121 )) 
122 LPSIZE = Pointer(SIZE)
123
124 RECT = Struct("RECT", (
125   (LONG, "left"),
126   (LONG, "top"),
127   (LONG, "right"), 
128   (LONG, "bottom"), 
129 )) 
130 LPRECT = Pointer(RECT)
131
132 PALETTEENTRY = Struct("PALETTEENTRY", (
133   (BYTE, "peRed"),
134   (BYTE, "peGreen"),
135   (BYTE, "peBlue"), 
136   (BYTE, "peFlags"), 
137 )) 
138 LPPALETTEENTRY = Pointer(PALETTEENTRY)
139
140
141 RGNDATAHEADER = Struct("RGNDATAHEADER", [
142     (DWORD, "dwSize"),
143     (DWORD, "iType"),
144     (DWORD, "nCount"),
145     (DWORD, "nRgnSize"),
146     (RECT, "rcBound"),
147 ])
148
149 RGNDATA = Struct("RGNDATA", [
150     (RGNDATAHEADER, "rdh"),
151     #(Char, "Buffer[1]"),
152 ])
153 LPRGNDATA = Pointer(RGNDATA)
154
155 HMODULE = IntPointer("HMODULE")
156
157 FILETIME = Struct("FILETIME", [
158     (DWORD, "dwLowDateTime"),
159     (DWORD, "dwHighDateTime"),
160 ])
161
162 COLORREF = Alias("COLORREF", DWORD)
163
164 LOGFONTW = Struct("LOGFONTW", [
165     (LONG, "lfHeight"),
166     (LONG, "lfWidth"),
167     (LONG, "lfEscapement"),
168     (LONG, "lfOrientation"),
169     (LONG, "lfWeight"),
170     (BYTE, "lfItalic"),
171     (BYTE, "lfUnderline"),
172     (BYTE, "lfStrikeOut"),
173     (BYTE, "lfCharSet"),
174     (BYTE, "lfOutPrecision"),
175     (BYTE, "lfClipPrecision"),
176     (BYTE, "lfQuality"),
177     (BYTE, "lfPitchAndFamily"),
178     (WString, "lfFaceName"),
179 ])
180
181 SECURITY_ATTRIBUTES = Struct("SECURITY_ATTRIBUTES", [
182     (DWORD, "nLength"),
183     (LPVOID, "lpSecurityDescriptor"),
184     (BOOL, "bInheritHandle"),
185 ])
186
187 # http://msdn.microsoft.com/en-us/library/ff485842.aspx
188 # http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381.aspx
189 def MAKE_HRESULT(errors, ok = "S_OK", false = "S_FALSE"):
190     values = [ok, false]
191     values.extend(errors)
192     values.extend([
193         "E_PENDING", # 0x8000000A
194         "E_NOTIMPL", # 0x80004001
195         "E_NOINTERFACE", # 0x80004002
196         "E_POINTER", # 0x80004003
197         "E_ABORT", # 0x80004004
198         "E_FAIL", # 0x80004005
199         "E_UNEXPECTED", # 0x8000FFFF
200         "E_ACCESSDENIED", # 0x80070005
201         "E_HANDLE", # 0x80070006
202         "E_OUTOFMEMORY", # 0x8007000E
203         "E_INVALIDARG", # 0x80070057
204     ])
205     return Enum("HRESULT", values)
206
207 HRESULT = MAKE_HRESULT([])
208
209
210 IUnknown = Interface("IUnknown")
211
212 IUnknown.methods = (
213         StdMethod(HRESULT, "QueryInterface", ((REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppvObj"))),
214         StdMethod(ULONG, "AddRef", ()),
215         StdMethod(ULONG, "Release", ()),
216 )
217
218