]> git.cworth.org Git - apitrace/blob - winapi.py
Bundle Snappy source code.
[apitrace] / 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 from stdapi import *
29
30 SHORT = Alias("SHORT", Short)
31 USHORT = Alias("USHORT", UShort)
32 INT = Alias("INT", Int)
33 UINT = Alias("UINT", UInt)
34 LONG = Alias("LONG", Long)
35 ULONG = Alias("ULONG", ULong)
36 LONGLONG = Alias("LONGLONG", LongLong)
37 FLOAT = Alias("FLOAT", Float)
38
39 INT32 = Literal("INT32", "SInt")
40 UINT32 = Literal("UINT32", "UInt")
41
42 BYTE = Literal("BYTE", "UInt", base=16)
43 WORD = Literal("WORD", "UInt", base=16)
44 DWORD = Literal("DWORD", "UInt", base=16)
45
46
47 BOOL = Alias("BOOL", Bool)
48
49 LPLONG = Pointer(LONG)
50 LPWORD = Pointer(WORD)
51 LPDWORD = Pointer(DWORD)
52 LPBOOL = Pointer(BOOL)
53
54 LPSTR = CString
55 LPCSTR = Const(CString)
56 LPWSTR = WString
57 LPCWSTR = Const(WString)
58
59 LARGE_INTEGER = Struct("LARGE_INTEGER", [
60     (LONGLONG, 'QuadPart'),
61 ])
62
63 SIZE_T = Alias("SIZE_T", SizeT)
64
65 HRESULT = Alias("HRESULT", Int)
66
67 VOID = Void
68 PVOID = Opaque("PVOID")
69 LPVOID = PVOID
70 HANDLE = Opaque("HANDLE")
71 HWND = Opaque("HWND")
72 HDC = Opaque("HDC")
73 HMONITOR = Opaque("HMONITOR")
74
75 GUID = Struct("GUID", [
76     (DWORD, "Data1"),
77     (WORD, "Data2"),
78     (WORD, "Data3"),
79     (Array(BYTE, "8"), "Data4"),
80 ])
81 LPGUID = Pointer(GUID)
82
83 #REFGUID = Alias("REFGUID", Pointer(GUID))
84 REFGUID = Alias("REFGUID", GUID)
85
86 IID = Alias("IID", GUID)
87 #REFIID = Alias("REFIID", Pointer(IID))
88 REFIID = Alias("REFIID", IID)
89
90 CLSID = Alias("CLSID", GUID)
91 #REFCLSID = Alias("REFCLSID", Pointer(CLSID))
92 REFCLSID = Alias("REFCLSID", CLSID)
93
94 LUID = Struct("LUID", [
95     (DWORD, "LowPart"),
96     (LONG, "HighPart"),
97 ])
98
99 POINT = Struct("POINT", (
100   (LONG, "x"),
101   (LONG, "y"),
102 )) 
103 LPPOINT = Pointer(POINT)
104
105 SIZE = Struct("SIZE", (
106   (LONG, "cx"),
107   (LONG, "cy"),
108 )) 
109 LPSIZE = Pointer(SIZE)
110
111 RECT = Struct("RECT", (
112   (LONG, "left"),
113   (LONG, "top"),
114   (LONG, "right"), 
115   (LONG, "bottom"), 
116 )) 
117 LPRECT = Pointer(RECT)
118
119 PALETTEENTRY = Struct("PALETTEENTRY", (
120   (BYTE, "peRed"),
121   (BYTE, "peGreen"),
122   (BYTE, "peBlue"), 
123   (BYTE, "peFlags"), 
124 )) 
125 LPPALETTEENTRY = Pointer(PALETTEENTRY)
126
127
128 RGNDATAHEADER = Struct("RGNDATAHEADER", [
129     (DWORD, "dwSize"),
130     (DWORD, "iType"),
131     (DWORD, "nCount"),
132     (DWORD, "nRgnSize"),
133     (RECT, "rcBound"),
134 ])
135
136 RGNDATA = Struct("RGNDATA", [
137     (RGNDATAHEADER, "rdh"),
138     #(Char, "Buffer[1]"),
139 ])
140 LPRGNDATA = Pointer(RGNDATA)
141
142 HMODULE = Opaque("HMODULE")
143
144 IUnknown = Interface("IUnknown")
145
146 HRESULT_com = FakeEnum(HRESULT, [
147     "S_OK",
148     "E_NOINTERFACE",
149     "E_POINTER",
150 ])
151
152 IUnknown.methods = (
153         Method(HRESULT_com, "QueryInterface", ((REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppvObj"))),
154         Method(ULONG, "AddRef", ()),
155         Method(ULONG, "Release", ()),
156 )
157
158