diff options
Diffstat (limited to 'recipes-graphics/imx-gpu-apitrace')
6 files changed, 3 insertions, 10573 deletions
diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-switch-from-python2-to-python3.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-switch-from-python2-to-python3.patch deleted file mode 100644 index 27382c34..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-switch-from-python2-to-python3.patch +++ /dev/null | |||
@@ -1,10004 +0,0 @@ | |||
1 | From bfa1b7c7e675f198f4573325f1252e91f80f0b4d Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Piotr=20Podsiad=C5=82y?= <ppodsiadly@mykolab.com> | ||
3 | Date: Thu, 3 Jan 2019 20:39:55 +0100 | ||
4 | Subject: [PATCH 1/4] switch from python2 to python3 | ||
5 | |||
6 | Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/0b8b019952f2668a5e8786cc2d331062b958f02e] | ||
7 | |||
8 | (cherry picked from commit 0b8b019952f2668a5e8786cc2d331062b958f02e) | ||
9 | Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> | ||
10 | --- | ||
11 | CMakeLists.txt | 7 +- | ||
12 | cli/CMakeLists.txt | 2 +- | ||
13 | dispatch/CMakeLists.txt | 2 +- | ||
14 | dispatch/__init__.py | 2 +- | ||
15 | dispatch/dispatch.py | 56 +- | ||
16 | dispatch/glproc.py | 204 +++---- | ||
17 | retrace/CMakeLists.txt | 14 +- | ||
18 | retrace/d3d9retrace.py | 248 ++++---- | ||
19 | retrace/ddrawretrace.py | 102 ++-- | ||
20 | retrace/dllretrace.py | 46 +- | ||
21 | retrace/dxgiretrace.py | 370 +++++------ | ||
22 | retrace/dxgistate_so.py | 98 +-- | ||
23 | retrace/glretrace.py | 660 ++++++++++---------- | ||
24 | retrace/glstate_params.py | 556 ++++++++--------- | ||
25 | retrace/retrace.py | 300 ++++----- | ||
26 | scripts/convert.py | 4 +- | ||
27 | scripts/jsondiff.py | 16 +- | ||
28 | scripts/jsonextractimages.py | 2 +- | ||
29 | scripts/leaks.py | 163 +++++ | ||
30 | scripts/profileshader.py | 18 +- | ||
31 | scripts/retracediff.py | 6 +- | ||
32 | scripts/snapdiff.py | 7 +- | ||
33 | scripts/tracediff.py | 16 +- | ||
34 | scripts/unpickle.py | 16 +- | ||
35 | specs/cglapi.py | 6 +- | ||
36 | specs/d2d1.py | 6 +- | ||
37 | specs/d3d.py | 8 +- | ||
38 | specs/d3d10.py | 4 +- | ||
39 | specs/d3d10sdklayers.py | 2 +- | ||
40 | specs/d3d11.py | 4 +- | ||
41 | specs/d3d11sdklayers.py | 2 +- | ||
42 | specs/d3d8.py | 6 +- | ||
43 | specs/d3d8caps.py | 4 +- | ||
44 | specs/d3d8types.py | 2 +- | ||
45 | specs/d3d9.py | 6 +- | ||
46 | specs/d3d9caps.py | 4 +- | ||
47 | specs/d3d9types.py | 2 +- | ||
48 | specs/d3dcaps.py | 4 +- | ||
49 | specs/d3dtypes.py | 2 +- | ||
50 | specs/dcommon.py | 2 +- | ||
51 | specs/dcomp.py | 303 +++++++++ | ||
52 | specs/ddraw.py | 2 +- | ||
53 | specs/debug.py | 2 +- | ||
54 | specs/dwrite.py | 4 +- | ||
55 | specs/dxgi.py | 2 +- | ||
56 | specs/dxva2.py | 2 +- | ||
57 | specs/eglapi.py | 6 +- | ||
58 | specs/eglenum.py | 2 +- | ||
59 | specs/glapi.py | 6 +- | ||
60 | specs/glparams.py | 4 +- | ||
61 | specs/gltypes.py | 2 +- | ||
62 | specs/glxapi.py | 4 +- | ||
63 | specs/scripts/c2api.py | 40 +- | ||
64 | specs/scripts/cxx2api.py | 488 +++++++++++++++ | ||
65 | specs/scripts/spec2api.py | 6 +- | ||
66 | specs/scripts/txt2api.py | 8 +- | ||
67 | specs/scripts/xml2api.py | 6 +- | ||
68 | specs/scripts/xml2enum.py | 4 +- | ||
69 | specs/scripts/xml2glparams.py | 4 +- | ||
70 | specs/stdapi.py | 43 +- | ||
71 | specs/wglapi.py | 6 +- | ||
72 | specs/wglenum.py | 2 +- | ||
73 | specs/winapi.py | 2 +- | ||
74 | wrappers/CMakeLists.txt | 18 +- | ||
75 | wrappers/cgltrace.py | 74 +-- | ||
76 | wrappers/d2d1trace.py | 18 +- | ||
77 | wrappers/d3d8trace.py | 36 +- | ||
78 | wrappers/d3d9trace.py | 62 +- | ||
79 | wrappers/ddrawtrace.py | 12 +- | ||
80 | wrappers/dlltrace.py | 36 +- | ||
81 | wrappers/dxgitrace.py | 98 +-- | ||
82 | wrappers/egltrace.py | 420 ++++++------- | ||
83 | wrappers/gltrace.py | 1080 ++++++++++++++++----------------- | ||
84 | wrappers/glxtrace.py | 54 +- | ||
85 | wrappers/trace.py | 707 ++++++++++----------- | ||
86 | wrappers/wgltrace.py | 86 +-- | ||
87 | 76 files changed, 3803 insertions(+), 2825 deletions(-) | ||
88 | create mode 100755 scripts/leaks.py | ||
89 | create mode 100644 specs/dcomp.py | ||
90 | create mode 100755 specs/scripts/cxx2api.py | ||
91 | |||
92 | diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
93 | index 900028c6..03ffd07c 100644 | ||
94 | --- a/CMakeLists.txt | ||
95 | +++ b/CMakeLists.txt | ||
96 | @@ -104,10 +104,7 @@ else () | ||
97 | endmacro() | ||
98 | endif () | ||
99 | |||
100 | -find_host_package (PythonInterp 2.7 REQUIRED) | ||
101 | -if (NOT PYTHON_VERSION_MAJOR EQUAL 2) | ||
102 | - message (FATAL_ERROR "Python 2.x required and requested, but Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} found.") | ||
103 | -endif () | ||
104 | +find_host_package(Python3 COMPONENTS Interpreter REQUIRED) | ||
105 | |||
106 | find_package (Threads) | ||
107 | |||
108 | @@ -591,7 +588,7 @@ set (CPACK_PACKAGE_VERSION_MINOR "0") | ||
109 | |||
110 | # Use current date in YYYYMMDD format as patch number | ||
111 | execute_process ( | ||
112 | - COMMAND ${PYTHON_EXECUTABLE} -c "import time, sys; sys.stdout.write(time.strftime('%Y%m%d'))" | ||
113 | + COMMAND ${Python3_EXECUTABLE} -c "import time, sys; sys.stdout.write(time.strftime('%Y%m%d'))" | ||
114 | OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH | ||
115 | ) | ||
116 | |||
117 | diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt | ||
118 | index 9b621bb1..eb5d485d 100644 | ||
119 | --- a/cli/CMakeLists.txt | ||
120 | +++ b/cli/CMakeLists.txt | ||
121 | @@ -13,7 +13,7 @@ add_definitions( | ||
122 | if (WIN32) | ||
123 | add_definitions (-DAPITRACE_PYTHON_EXECUTABLE="python") | ||
124 | else () | ||
125 | - add_definitions (-DAPITRACE_PYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}") | ||
126 | + add_definitions (-DAPITRACE_PYTHON_EXECUTABLE="${Python3_EXECUTABLE}") | ||
127 | endif () | ||
128 | |||
129 | add_executable (apitrace | ||
130 | diff --git a/dispatch/CMakeLists.txt b/dispatch/CMakeLists.txt | ||
131 | index d023e6e9..e51eec48 100644 | ||
132 | --- a/dispatch/CMakeLists.txt | ||
133 | +++ b/dispatch/CMakeLists.txt | ||
134 | @@ -7,7 +7,7 @@ add_custom_command ( | ||
135 | OUTPUT | ||
136 | ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp | ||
137 | ${CMAKE_CURRENT_BINARY_DIR}/glproc.cpp | ||
138 | - COMMAND ${PYTHON_EXECUTABLE} | ||
139 | + COMMAND ${Python3_EXECUTABLE} | ||
140 | ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py | ||
141 | ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp | ||
142 | ${CMAKE_CURRENT_BINARY_DIR}/glproc.cpp | ||
143 | diff --git a/dispatch/__init__.py b/dispatch/__init__.py | ||
144 | index b872135e..d8e8596e 100644 | ||
145 | --- a/dispatch/__init__.py | ||
146 | +++ b/dispatch/__init__.py | ||
147 | @@ -1 +1 @@ | ||
148 | -from dispatch import * | ||
149 | +from .dispatch import * | ||
150 | diff --git a/dispatch/dispatch.py b/dispatch/dispatch.py | ||
151 | index 9e778561..e1dd8bc9 100644 | ||
152 | --- a/dispatch/dispatch.py | ||
153 | +++ b/dispatch/dispatch.py | ||
154 | @@ -58,18 +58,18 @@ class Dispatcher: | ||
155 | # define standard name aliases for convenience, but only when not | ||
156 | # tracing, as that would cause symbol clashing with the tracing | ||
157 | # functions | ||
158 | - print '#ifdef RETRACE' | ||
159 | + print('#ifdef RETRACE') | ||
160 | for function in module.functions: | ||
161 | - print '#define %s _%s' % (function.name, function.name) | ||
162 | - print '#endif /* RETRACE */' | ||
163 | |||
164 | + print('#define %s _%s' % (function.name, function.name)) | ||
165 | + print('#endif /* RETRACE */') | ||
166 | + print() | ||
167 | |||
168 | def dispatchFunctionDecl(self, module, function): | ||
169 | ptype = function_pointer_type(function) | ||
170 | pvalue = function_pointer_value(function) | ||
171 | - print 'typedef ' + function.prototype('* %s' % ptype) + ';' | ||
172 | - print 'extern %s %s;' % (ptype, pvalue) | ||
173 | |||
174 | + print('typedef ' + function.prototype('* %s' % ptype) + ';') | ||
175 | + print('extern %s %s;' % (ptype, pvalue)) | ||
176 | + print() | ||
177 | |||
178 | def dispatchModuleImpl(self, module): | ||
179 | for function in module.functions: | ||
180 | @@ -84,19 +84,19 @@ class Dispatcher: | ||
181 | else: | ||
182 | ret = 'return ' | ||
183 | |||
184 | - print 'static ' + function.prototype('_fail_' + function.name) + ' {' | ||
185 | + print('static ' + function.prototype('_fail_' + function.name) + ' {') | ||
186 | self.failFunction(function) | ||
187 | - print '}' | ||
188 | |||
189 | + print('}') | ||
190 | + print() | ||
191 | |||
192 | - print 'static ' + function.prototype('_get_' + function.name) + ' {' | ||
193 | + print('static ' + function.prototype('_get_' + function.name) + ' {') | ||
194 | self.invokeGetProcAddress(module, function) | ||
195 | - print ' %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args])) | ||
196 | - print '}' | ||
197 | |||
198 | + print(' %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args]))) | ||
199 | + print('}') | ||
200 | + print() | ||
201 | |||
202 | - print '%s %s = &%s;' % (ptype, pvalue, '_get_' + function.name) | ||
203 | |||
204 | + print('%s %s = &%s;' % (ptype, pvalue, '_get_' + function.name)) | ||
205 | + print() | ||
206 | |||
207 | def getProcAddressName(self, module, function): | ||
208 | raise NotImplementedError | ||
209 | @@ -105,25 +105,25 @@ class Dispatcher: | ||
210 | ptype = function_pointer_type(function) | ||
211 | pvalue = function_pointer_value(function) | ||
212 | getProcAddressName = self.getProcAddressName(module, function) | ||
213 | - print ' %s _ptr;' % (ptype,) | ||
214 | - print ' _ptr = (%s)%s("%s");' % (ptype, getProcAddressName, function.name) | ||
215 | - print ' if (!_ptr) {' | ||
216 | - print ' _ptr = &%s;' % ('_fail_' + function.name) | ||
217 | - print ' }' | ||
218 | - print ' %s = _ptr;' % (pvalue,) | ||
219 | + print(' %s _ptr;' % (ptype,)) | ||
220 | + print(' _ptr = (%s)%s("%s");' % (ptype, getProcAddressName, function.name)) | ||
221 | + print(' if (!_ptr) {') | ||
222 | + print(' _ptr = &%s;' % ('_fail_' + function.name)) | ||
223 | + print(' }') | ||
224 | + print(' %s = _ptr;' % (pvalue,)) | ||
225 | |||
226 | def failFunction(self, function): | ||
227 | - print r' const char *_name = "%s";' % function.name | ||
228 | + print(r' const char *_name = "%s";' % function.name) | ||
229 | if function.type is stdapi.Void or function.fail is not None: | ||
230 | - print r' os::log("warning: ignoring call to unavailable function %s\n", _name);' | ||
231 | + print(r' os::log("warning: ignoring call to unavailable function %s\n", _name);') | ||
232 | if function.type is stdapi.Void: | ||
233 | assert function.fail is None | ||
234 | - print ' return;' | ||
235 | + print(' return;') | ||
236 | else: | ||
237 | assert function.fail is not None | ||
238 | - print ' return %s;' % function.fail | ||
239 | + print(' return %s;' % function.fail) | ||
240 | else: | ||
241 | - print r' os::log("error: unavailable function %s\n", _name);' | ||
242 | - print r' os::abort();' | ||
243 | + print(r' os::log("error: unavailable function %s\n", _name);') | ||
244 | + print(r' os::abort();') | ||
245 | |||
246 | |||
247 | diff --git a/dispatch/glproc.py b/dispatch/glproc.py | ||
248 | index f26a4f7d..93bba232 100644 | ||
249 | --- a/dispatch/glproc.py | ||
250 | +++ b/dispatch/glproc.py | ||
251 | @@ -506,15 +506,15 @@ class GlDispatcher(Dispatcher): | ||
252 | if sys.platform == 'darwin': | ||
253 | # Fallback to EXT_debug_label on MacOSX, some enums need to be translated. | ||
254 | if function.name in ('glObjectLabel', 'glObjectLabelKHR'): | ||
255 | - print r' if (translateDebugLabelIdentifier(identifier)) {' | ||
256 | - print r' _glLabelObjectEXT(identifier, name, length < 0 ? 0 : length, length == 0 ? "" : label);' | ||
257 | - print r' return;' | ||
258 | - print r' }' | ||
259 | + print(r' if (translateDebugLabelIdentifier(identifier)) {') | ||
260 | + print(r' _glLabelObjectEXT(identifier, name, length < 0 ? 0 : length, length == 0 ? "" : label);') | ||
261 | + print(r' return;') | ||
262 | + print(r' }') | ||
263 | if function.name in ('glGetObjectLabel', 'glGetObjectLabelKHR'): | ||
264 | - print r' if (translateDebugLabelIdentifier(identifier)) {' | ||
265 | - print r' _glGetObjectLabelEXT(identifier, name, bufSize, length, label);' | ||
266 | - print r' return;' | ||
267 | - print r' }' | ||
268 | + print(r' if (translateDebugLabelIdentifier(identifier)) {') | ||
269 | + print(r' _glGetObjectLabelEXT(identifier, name, bufSize, length, label);') | ||
270 | + print(r' return;') | ||
271 | + print(r' }') | ||
272 | if function.name in ( | ||
273 | # GL_KHR_debug | ||
274 | 'glDebugMessageControl', | ||
275 | @@ -549,25 +549,25 @@ class GlDispatcher(Dispatcher): | ||
276 | ): | ||
277 | return | ||
278 | if function.name.startswith('glGetObjectLabel'): | ||
279 | - print r' if (length != 0) *length = 0;' | ||
280 | - print r' if (label != 0 && bufSize > 0) *label = 0;' | ||
281 | + print(r' if (length != 0) *length = 0;') | ||
282 | + print(r' if (label != 0 && bufSize > 0) *label = 0;') | ||
283 | return | ||
284 | if function.name == 'glGetDebugMessageLogAMD': | ||
285 | - print r' if (categories != 0) *categories = 0;' | ||
286 | - print r' if (ids != 0) *ids = 0;' | ||
287 | - print r' if (severities != 0) *severities = 0;' | ||
288 | - print r' if (lengths != 0) *lengths = 0;' | ||
289 | - print r' if (message != 0 && bufsize > 0) *message = 0;' | ||
290 | - print r' return 0;' | ||
291 | + print(r' if (categories != 0) *categories = 0;') | ||
292 | + print(r' if (ids != 0) *ids = 0;') | ||
293 | + print(r' if (severities != 0) *severities = 0;') | ||
294 | + print(r' if (lengths != 0) *lengths = 0;') | ||
295 | + print(r' if (message != 0 && bufsize > 0) *message = 0;') | ||
296 | + print(r' return 0;') | ||
297 | return | ||
298 | if function.name.startswith('glGetDebugMessageLog'): | ||
299 | - print r' if (sources != 0) *sources = 0;' | ||
300 | - print r' if (types != 0) *types = 0;' | ||
301 | - print r' if (ids != 0) *ids = 0;' | ||
302 | - print r' if (severities != 0) *severities = 0;' | ||
303 | - print r' if (lengths != 0) *lengths = 0;' | ||
304 | - print r' if (messageLog != 0 && bufsize > 0) *messageLog = 0;' | ||
305 | - print r' return 0;' | ||
306 | + print(r' if (sources != 0) *sources = 0;') | ||
307 | + print(r' if (types != 0) *types = 0;') | ||
308 | + print(r' if (ids != 0) *ids = 0;') | ||
309 | + print(r' if (severities != 0) *severities = 0;') | ||
310 | + print(r' if (lengths != 0) *lengths = 0;') | ||
311 | + print(r' if (messageLog != 0 && bufsize > 0) *messageLog = 0;') | ||
312 | + print(r' return 0;') | ||
313 | return | ||
314 | |||
315 | Dispatcher.failFunction(self, function) | ||
316 | @@ -577,96 +577,96 @@ if __name__ == '__main__': | ||
317 | decl, impl = sys.argv[1:] | ||
318 | |||
319 | sys.stdout = open(decl, 'wt') | ||
320 | |||
321 | - print '#pragma once' | ||
322 | |||
323 | - print '#include "glimports.hpp"' | ||
324 | |||
325 | - print '#if defined(_WIN32)' | ||
326 | - print 'extern HMODULE _libGlHandle;' | ||
327 | - print '#else' | ||
328 | - print 'extern void * _libGlHandle;' | ||
329 | - print '#endif' | ||
330 | |||
331 | - print 'void * _getPublicProcAddress(const char *procName);' | ||
332 | - print 'void * _getPrivateProcAddress(const char *procName);' | ||
333 | |||
334 | + print() | ||
335 | + print('#pragma once') | ||
336 | + print() | ||
337 | + print('#include "glimports.hpp"') | ||
338 | + print() | ||
339 | + print('#if defined(_WIN32)') | ||
340 | + print('extern HMODULE _libGlHandle;') | ||
341 | + print('#else') | ||
342 | + print('extern void * _libGlHandle;') | ||
343 | + print('#endif') | ||
344 | + print() | ||
345 | + print('void * _getPublicProcAddress(const char *procName);') | ||
346 | + print('void * _getPrivateProcAddress(const char *procName);') | ||
347 | + print() | ||
348 | dispatcher = GlDispatcher() | ||
349 | |||
350 | + print() | ||
351 | dispatcher.dispatchModuleDecl(eglapi) | ||
352 | |||
353 | - print '#if defined(_WIN32)' | ||
354 | |||
355 | + print() | ||
356 | + print('#if defined(_WIN32)') | ||
357 | + print() | ||
358 | dispatcher.dispatchModuleDecl(wglapi) | ||
359 | |||
360 | - print '#elif defined(__APPLE__)' | ||
361 | |||
362 | + print() | ||
363 | + print('#elif defined(__APPLE__)') | ||
364 | + print() | ||
365 | dispatcher.dispatchModuleDecl(cglapi) | ||
366 | |||
367 | - print '#elif defined(HAVE_X11)' | ||
368 | |||
369 | + print() | ||
370 | + print('#elif defined(HAVE_X11)') | ||
371 | + print() | ||
372 | dispatcher.dispatchModuleDecl(glxapi) | ||
373 | |||
374 | - print '#endif' | ||
375 | |||
376 | + print() | ||
377 | + print('#endif') | ||
378 | + print() | ||
379 | dispatcher.dispatchModuleDecl(glapi) | ||
380 | |||
381 | + print() | ||
382 | |||
383 | sys.stdout = open(impl, 'wt') | ||
384 | |||
385 | - print '#include "glproc.hpp"' | ||
386 | - print '#include "os.hpp"' | ||
387 | |||
388 | + print() | ||
389 | + print('#include "glproc.hpp"') | ||
390 | + print('#include "os.hpp"') | ||
391 | + print() | ||
392 | dispatcher = GlDispatcher() | ||
393 | |||
394 | + print() | ||
395 | dispatcher.dispatchModuleImpl(eglapi) | ||
396 | |||
397 | - print '#if defined(_WIN32)' | ||
398 | |||
399 | + print() | ||
400 | + print('#if defined(_WIN32)') | ||
401 | + print() | ||
402 | dispatcher.dispatchModuleImpl(wglapi) | ||
403 | |||
404 | - print '#elif defined(__APPLE__)' | ||
405 | |||
406 | - print 'static inline bool' | ||
407 | - print 'translateDebugLabelIdentifier(GLenum & identifier)' | ||
408 | - print '{' | ||
409 | - print ' switch (identifier) {' | ||
410 | - print ' case GL_TEXTURE:' | ||
411 | - print ' case GL_FRAMEBUFFER:' | ||
412 | - print ' case GL_RENDERBUFFER:' | ||
413 | - print ' case GL_SAMPLER:' | ||
414 | - print ' case GL_TRANSFORM_FEEDBACK:' | ||
415 | - print ' return true;' | ||
416 | - print ' case GL_BUFFER:' | ||
417 | - print ' identifier = GL_BUFFER_OBJECT_EXT;' | ||
418 | - print ' return true;' | ||
419 | - print ' case GL_SHADER:' | ||
420 | - print ' identifier = GL_SHADER_OBJECT_EXT;' | ||
421 | - print ' return true;' | ||
422 | - print ' case GL_PROGRAM:' | ||
423 | - print ' identifier = GL_PROGRAM_OBJECT_EXT;' | ||
424 | - print ' return true;' | ||
425 | - print ' case GL_VERTEX_ARRAY:' | ||
426 | - print ' identifier = GL_VERTEX_ARRAY_OBJECT_EXT;' | ||
427 | - print ' return true;' | ||
428 | - print ' case GL_QUERY:' | ||
429 | - print ' identifier = GL_QUERY_OBJECT_EXT;' | ||
430 | - print ' return true;' | ||
431 | - print ' case GL_PROGRAM_PIPELINE:' | ||
432 | - print ' identifier = GL_PROGRAM_PIPELINE_OBJECT_EXT;' | ||
433 | - print ' return true;' | ||
434 | - print ' default:' | ||
435 | - print ' return false;' | ||
436 | - print ' }' | ||
437 | - print '}' | ||
438 | |||
439 | + print() | ||
440 | + print('#elif defined(__APPLE__)') | ||
441 | + print() | ||
442 | + print('static inline bool') | ||
443 | + print('translateDebugLabelIdentifier(GLenum & identifier)') | ||
444 | + print('{') | ||
445 | + print(' switch (identifier) {') | ||
446 | + print(' case GL_TEXTURE:') | ||
447 | + print(' case GL_FRAMEBUFFER:') | ||
448 | + print(' case GL_RENDERBUFFER:') | ||
449 | + print(' case GL_SAMPLER:') | ||
450 | + print(' case GL_TRANSFORM_FEEDBACK:') | ||
451 | + print(' return true;') | ||
452 | + print(' case GL_BUFFER:') | ||
453 | + print(' identifier = GL_BUFFER_OBJECT_EXT;') | ||
454 | + print(' return true;') | ||
455 | + print(' case GL_SHADER:') | ||
456 | + print(' identifier = GL_SHADER_OBJECT_EXT;') | ||
457 | + print(' return true;') | ||
458 | + print(' case GL_PROGRAM:') | ||
459 | + print(' identifier = GL_PROGRAM_OBJECT_EXT;') | ||
460 | + print(' return true;') | ||
461 | + print(' case GL_VERTEX_ARRAY:') | ||
462 | + print(' identifier = GL_VERTEX_ARRAY_OBJECT_EXT;') | ||
463 | + print(' return true;') | ||
464 | + print(' case GL_QUERY:') | ||
465 | + print(' identifier = GL_QUERY_OBJECT_EXT;') | ||
466 | + print(' return true;') | ||
467 | + print(' case GL_PROGRAM_PIPELINE:') | ||
468 | + print(' identifier = GL_PROGRAM_PIPELINE_OBJECT_EXT;') | ||
469 | + print(' return true;') | ||
470 | + print(' default:') | ||
471 | + print(' return false;') | ||
472 | + print(' }') | ||
473 | + print('}') | ||
474 | + print() | ||
475 | dispatcher.dispatchModuleImpl(cglapi) | ||
476 | |||
477 | - print '#elif defined(HAVE_X11)' | ||
478 | |||
479 | + print() | ||
480 | + print('#elif defined(HAVE_X11)') | ||
481 | + print() | ||
482 | dispatcher.dispatchModuleImpl(glxapi) | ||
483 | |||
484 | - print '#endif' | ||
485 | |||
486 | + print() | ||
487 | + print('#endif') | ||
488 | + print() | ||
489 | dispatcher.dispatchModuleImpl(glapi) | ||
490 | |||
491 | + print() | ||
492 | diff --git a/retrace/CMakeLists.txt b/retrace/CMakeLists.txt | ||
493 | index c0c4f316..2475abb8 100644 | ||
494 | --- a/retrace/CMakeLists.txt | ||
495 | +++ b/retrace/CMakeLists.txt | ||
496 | @@ -14,7 +14,7 @@ add_definitions (-DRETRACE) | ||
497 | |||
498 | add_custom_command ( | ||
499 | OUTPUT glretrace_gl.cpp | ||
500 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp | ||
501 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp | ||
502 | DEPENDS | ||
503 | glretrace.py | ||
504 | retrace.py | ||
505 | @@ -25,7 +25,7 @@ add_custom_command ( | ||
506 | |||
507 | add_custom_command ( | ||
508 | OUTPUT glstate_params.cpp | ||
509 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate_params.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate_params.cpp | ||
510 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate_params.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate_params.cpp | ||
511 | DEPENDS | ||
512 | glstate_params.py | ||
513 | ${CMAKE_SOURCE_DIR}/specs/glparams.py | ||
514 | @@ -273,7 +273,7 @@ if (WIN32) | ||
515 | include_directories (BEFORE SYSTEM ${DirectX_D3D_INCLUDE_DIR}) | ||
516 | add_custom_command ( | ||
517 | OUTPUT d3dretrace_ddraw.cpp | ||
518 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_ddraw.cpp | ||
519 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_ddraw.cpp | ||
520 | DEPENDS | ||
521 | ddrawretrace.py | ||
522 | dllretrace.py | ||
523 | @@ -306,7 +306,7 @@ if (WIN32) | ||
524 | endif () | ||
525 | add_custom_command ( | ||
526 | OUTPUT d3dretrace_d3d8.cpp | ||
527 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py d3d8 ${HAVE_D3D8} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d8.cpp | ||
528 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py d3d8 ${HAVE_D3D8} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d8.cpp | ||
529 | DEPENDS | ||
530 | d3d9retrace.py | ||
531 | dllretrace.py | ||
532 | @@ -327,7 +327,7 @@ if (WIN32) | ||
533 | endif () | ||
534 | add_custom_command ( | ||
535 | OUTPUT d3dretrace_d3d9.cpp | ||
536 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py d3d9 ${HAVE_D3D9} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp | ||
537 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py d3d9 ${HAVE_D3D9} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp | ||
538 | DEPENDS | ||
539 | d3d9retrace.py | ||
540 | dllretrace.py | ||
541 | @@ -359,7 +359,7 @@ if (WIN32) | ||
542 | ) | ||
543 | add_custom_command ( | ||
544 | OUTPUT dxgistate_so.cpp | ||
545 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgistate_so.py > ${CMAKE_CURRENT_BINARY_DIR}/dxgistate_so.cpp | ||
546 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgistate_so.py > ${CMAKE_CURRENT_BINARY_DIR}/dxgistate_so.cpp | ||
547 | DEPENDS | ||
548 | ${CMAKE_CURRENT_SOURCE_DIR}/dxgistate_so.py | ||
549 | ${CMAKE_SOURCE_DIR}/specs/d3d11.py | ||
550 | @@ -372,7 +372,7 @@ if (WIN32) | ||
551 | ) | ||
552 | add_custom_command ( | ||
553 | OUTPUT d3dretrace_dxgi.cpp | ||
554 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgiretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_dxgi.cpp | ||
555 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgiretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_dxgi.cpp | ||
556 | DEPENDS | ||
557 | dxgiretrace.py | ||
558 | dllretrace.py | ||
559 | diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py | ||
560 | index 7313acc9..22364476 100644 | ||
561 | --- a/retrace/d3d9retrace.py | ||
562 | +++ b/retrace/d3d9retrace.py | ||
563 | @@ -35,32 +35,32 @@ from specs.stdapi import API | ||
564 | class D3DRetracer(Retracer): | ||
565 | |||
566 | def retraceApi(self, api): | ||
567 | - print '// Swizzling mapping for lock addresses' | ||
568 | - print 'typedef std::pair<void *, UINT> MappingKey;' | ||
569 | - print 'static std::map<MappingKey, void *> _maps;' | ||
570 | |||
571 | + print('// Swizzling mapping for lock addresses') | ||
572 | + print('typedef std::pair<void *, UINT> MappingKey;') | ||
573 | + print('static std::map<MappingKey, void *> _maps;') | ||
574 | + print() | ||
575 | |||
576 | Retracer.retraceApi(self, api) | ||
577 | |||
578 | def invokeFunction(self, function): | ||
579 | if function.name in ('Direct3DCreate9', 'Direct3DCreate9Ex'): | ||
580 | - print 'if (retrace::debug >= 2 && !g_szD3D9DllName && LoadLibraryA("d3d9d.dll")) {' | ||
581 | - print ' /*' | ||
582 | - print ' * D3D9D only works for simple applications, it will often report bogus errors' | ||
583 | - print ' * on complex traces, or traces which use unofficial D3D9 features.' | ||
584 | - print ' */' | ||
585 | - print ' g_szD3D9DllName = "d3d9d.dll";' | ||
586 | - print ' SDKVersion |= 0x80000000;' | ||
587 | - print '} else {' | ||
588 | - print ' SDKVersion &= ~0x80000000;' | ||
589 | - print '}' | ||
590 | + print('if (retrace::debug >= 2 && !g_szD3D9DllName && LoadLibraryA("d3d9d.dll")) {') | ||
591 | + print(' /*') | ||
592 | + print(' * D3D9D only works for simple applications, it will often report bogus errors') | ||
593 | + print(' * on complex traces, or traces which use unofficial D3D9 features.') | ||
594 | + print(' */') | ||
595 | + print(' g_szD3D9DllName = "d3d9d.dll";') | ||
596 | + print(' SDKVersion |= 0x80000000;') | ||
597 | + print('} else {') | ||
598 | + print(' SDKVersion &= ~0x80000000;') | ||
599 | + print('}') | ||
600 | |||
601 | # d3d8d.dll can be found in the Aug 2007 DXSDK. It works on XP, but | ||
602 | # not on Windows 7. | ||
603 | if function.name in ('Direct3DCreate8'): | ||
604 | - print 'if (retrace::debug >= 2 && !g_szD3D8DllName && LoadLibraryA("d3d8d.dll")) {' | ||
605 | - print ' g_szD3D8DllName = "d3d8d.dll";' | ||
606 | - print '}' | ||
607 | + print('if (retrace::debug >= 2 && !g_szD3D8DllName && LoadLibraryA("d3d8d.dll")) {') | ||
608 | + print(' g_szD3D8DllName = "d3d8d.dll";') | ||
609 | + print('}') | ||
610 | |||
611 | Retracer.invokeFunction(self, function) | ||
612 | |||
613 | @@ -73,37 +73,37 @@ class D3DRetracer(Retracer): | ||
614 | # keep track of the last used device for state dumping | ||
615 | if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'): | ||
616 | if method.name == 'Release': | ||
617 | - print r' if (call.ret->toUInt() == 0) {' | ||
618 | - print r' d3d9Dumper.unbindDevice(_this);' | ||
619 | - print r' }' | ||
620 | + print(r' if (call.ret->toUInt() == 0) {') | ||
621 | + print(r' d3d9Dumper.unbindDevice(_this);') | ||
622 | + print(r' }') | ||
623 | else: | ||
624 | - print r' d3d9Dumper.bindDevice(_this);' | ||
625 | + print(r' d3d9Dumper.bindDevice(_this);') | ||
626 | if interface.name in ('IDirect3DDevice8', 'IDirect3DDevice8Ex'): | ||
627 | if method.name == 'Release': | ||
628 | - print r' if (call.ret->toUInt() == 0) {' | ||
629 | - print r' d3d8Dumper.unbindDevice(_this);' | ||
630 | - print r' }' | ||
631 | + print(r' if (call.ret->toUInt() == 0) {') | ||
632 | + print(r' d3d8Dumper.unbindDevice(_this);') | ||
633 | + print(r' }') | ||
634 | else: | ||
635 | - print r' d3d8Dumper.bindDevice(_this);' | ||
636 | + print(r' d3d8Dumper.bindDevice(_this);') | ||
637 | |||
638 | # create windows as neccessary | ||
639 | if method.name in ('CreateDevice', 'CreateDeviceEx', 'CreateAdditionalSwapChain'): | ||
640 | - print r' HWND hWnd = d3dretrace::createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' | ||
641 | - print r' pPresentationParameters->hDeviceWindow = hWnd;' | ||
642 | + print(r' HWND hWnd = d3dretrace::createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);') | ||
643 | + print(r' pPresentationParameters->hDeviceWindow = hWnd;') | ||
644 | if 'hFocusWindow' in method.argNames(): | ||
645 | - print r' hFocusWindow = hWnd;' | ||
646 | + print(r' hFocusWindow = hWnd;') | ||
647 | |||
648 | # force windowed mode | ||
649 | - print r' if (retrace::forceWindowed) {' | ||
650 | - print r' pPresentationParameters->Windowed = TRUE;' | ||
651 | - print r' pPresentationParameters->FullScreen_RefreshRateInHz = 0;' | ||
652 | + print(r' if (retrace::forceWindowed) {') | ||
653 | + print(r' pPresentationParameters->Windowed = TRUE;') | ||
654 | + print(r' pPresentationParameters->FullScreen_RefreshRateInHz = 0;') | ||
655 | if interface.name.startswith('IDirect3D8'): | ||
656 | - print r' pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;' | ||
657 | - print r' }' | ||
658 | + print(r' pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;') | ||
659 | + print(r' }') | ||
660 | if 'BehaviorFlags' in method.argNames(): | ||
661 | - print r' if (retrace::dumpingState) {' | ||
662 | - print r' BehaviorFlags &= ~D3DCREATE_PUREDEVICE;' | ||
663 | - print r' }' | ||
664 | + print(r' if (retrace::dumpingState) {') | ||
665 | + print(r' BehaviorFlags &= ~D3DCREATE_PUREDEVICE;') | ||
666 | + print(r' }') | ||
667 | |||
668 | # On D3D8, ensure we use BackBufferFormat compatible with the | ||
669 | # current DisplayFormat. | ||
670 | @@ -113,76 +113,76 @@ class D3DRetracer(Retracer): | ||
671 | # valid values for BackBufferFormat include D3DFMT_X1R5G5B5 and | ||
672 | # D3DFMT_A1R5G5B5, but exclude D3DFMT_R5G6B5. | ||
673 | if interface.name.startswith('IDirect3D8'): | ||
674 | - print r' if (pPresentationParameters->Windowed) {' | ||
675 | - print r' D3DDISPLAYMODE Mode;' | ||
676 | - print r' HRESULT hr;' | ||
677 | - print r' hr = _this->GetAdapterDisplayMode(Adapter, &Mode);' | ||
678 | - print r' assert(SUCCEEDED(hr));' | ||
679 | - print r' hr = _this->CheckDeviceType(Adapter, DeviceType, Mode.Format, pPresentationParameters->BackBufferFormat, pPresentationParameters->Windowed);' | ||
680 | - print r' if (hr == D3DERR_NOTAVAILABLE) {' | ||
681 | - print r' retrace::warning(call) << "forcing back buffer format to match display mode format\n";' | ||
682 | - print r' pPresentationParameters->BackBufferFormat = Mode.Format;' | ||
683 | - print r' }' | ||
684 | - print r' }' | ||
685 | + print(r' if (pPresentationParameters->Windowed) {') | ||
686 | + print(r' D3DDISPLAYMODE Mode;') | ||
687 | + print(r' HRESULT hr;') | ||
688 | + print(r' hr = _this->GetAdapterDisplayMode(Adapter, &Mode);') | ||
689 | + print(r' assert(SUCCEEDED(hr));') | ||
690 | + print(r' hr = _this->CheckDeviceType(Adapter, DeviceType, Mode.Format, pPresentationParameters->BackBufferFormat, pPresentationParameters->Windowed);') | ||
691 | + print(r' if (hr == D3DERR_NOTAVAILABLE) {') | ||
692 | + print(r' retrace::warning(call) << "forcing back buffer format to match display mode format\n";') | ||
693 | + print(r' pPresentationParameters->BackBufferFormat = Mode.Format;') | ||
694 | + print(r' }') | ||
695 | + print(r' }') | ||
696 | |||
697 | if method.name in self.createDeviceMethodNames: | ||
698 | # override the device type | ||
699 | - print r' switch (retrace::driver) {' | ||
700 | - print r' case retrace::DRIVER_HARDWARE:' | ||
701 | - print r' DeviceType = D3DDEVTYPE_HAL;' | ||
702 | - print r' break;' | ||
703 | - print r' case retrace::DRIVER_SOFTWARE:' | ||
704 | - print r' case retrace::DRIVER_REFERENCE:' | ||
705 | - print r' DeviceType = D3DDEVTYPE_REF;' | ||
706 | - print r' break;' | ||
707 | - print r' case retrace::DRIVER_NULL:' | ||
708 | + print(r' switch (retrace::driver) {') | ||
709 | + print(r' case retrace::DRIVER_HARDWARE:') | ||
710 | + print(r' DeviceType = D3DDEVTYPE_HAL;') | ||
711 | + print(r' break;') | ||
712 | + print(r' case retrace::DRIVER_SOFTWARE:') | ||
713 | + print(r' case retrace::DRIVER_REFERENCE:') | ||
714 | + print(r' DeviceType = D3DDEVTYPE_REF;') | ||
715 | + print(r' break;') | ||
716 | + print(r' case retrace::DRIVER_NULL:') | ||
717 | if interface.name.startswith('IDirect3D9'): | ||
718 | - print r' DeviceType = D3DDEVTYPE_NULLREF;' | ||
719 | + print(r' DeviceType = D3DDEVTYPE_NULLREF;') | ||
720 | else: | ||
721 | - print r' retrace::warning(call) << "null driver not supported\n";' | ||
722 | - print r' break;' | ||
723 | - print r' case retrace::DRIVER_MODULE:' | ||
724 | - print r' retrace::warning(call) << "driver module not supported\n";' | ||
725 | - print r' break;' | ||
726 | - print r' default:' | ||
727 | - print r' assert(0);' | ||
728 | - print r' /* fall-through */' | ||
729 | - print r' case retrace::DRIVER_DEFAULT:' | ||
730 | - print r' break;' | ||
731 | - print r' }' | ||
732 | + print(r' retrace::warning(call) << "null driver not supported\n";') | ||
733 | + print(r' break;') | ||
734 | + print(r' case retrace::DRIVER_MODULE:') | ||
735 | + print(r' retrace::warning(call) << "driver module not supported\n";') | ||
736 | + print(r' break;') | ||
737 | + print(r' default:') | ||
738 | + print(r' assert(0);') | ||
739 | + print(r' /* fall-through */') | ||
740 | + print(r' case retrace::DRIVER_DEFAULT:') | ||
741 | + print(r' break;') | ||
742 | + print(r' }') | ||
743 | |||
744 | if method.name in ('Reset', 'ResetEx'): | ||
745 | # force windowed mode | ||
746 | - print r' if (retrace::forceWindowed) {' | ||
747 | - print r' pPresentationParameters->Windowed = TRUE;' | ||
748 | - print r' pPresentationParameters->FullScreen_RefreshRateInHz = 0;' | ||
749 | - print r' }' | ||
750 | + print(r' if (retrace::forceWindowed) {') | ||
751 | + print(r' pPresentationParameters->Windowed = TRUE;') | ||
752 | + print(r' pPresentationParameters->FullScreen_RefreshRateInHz = 0;') | ||
753 | + print(r' }') | ||
754 | # resize window | ||
755 | - print r' if (pPresentationParameters->Windowed) {' | ||
756 | - print r' d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' | ||
757 | - print r' }' | ||
758 | + print(r' if (pPresentationParameters->Windowed) {') | ||
759 | + print(r' d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);') | ||
760 | + print(r' }') | ||
761 | |||
762 | # notify frame has been completed | ||
763 | if method.name in ('Present', 'PresentEx'): | ||
764 | if interface.name.startswith('IDirect3DSwapChain9'): | ||
765 | - print r' d3d9scDumper.bindDevice(_this);' | ||
766 | - print r' retrace::frameComplete(call);' | ||
767 | - print r' hDestWindowOverride = NULL;' | ||
768 | + print(r' d3d9scDumper.bindDevice(_this);') | ||
769 | + print(r' retrace::frameComplete(call);') | ||
770 | + print(r' hDestWindowOverride = NULL;') | ||
771 | |||
772 | # Ensure textures can be locked when dumping | ||
773 | # TODO: Pre-check with CheckDeviceFormat | ||
774 | if method.name in ('CreateTexture', 'CreateCubeTexture', 'CreateVolumeTexture'): | ||
775 | - print r' if (retrace::dumpingState &&' | ||
776 | - print r' Pool == D3DPOOL_DEFAULT &&' | ||
777 | - print r' !(Usage & (D3DUSAGE_RENDERTARGET|D3DUSAGE_DEPTHSTENCIL))) {' | ||
778 | - print r' Usage |= D3DUSAGE_DYNAMIC;' | ||
779 | - print r' }' | ||
780 | + print(r' if (retrace::dumpingState &&') | ||
781 | + print(r' Pool == D3DPOOL_DEFAULT &&') | ||
782 | + print(r' !(Usage & (D3DUSAGE_RENDERTARGET|D3DUSAGE_DEPTHSTENCIL))) {') | ||
783 | + print(r' Usage |= D3DUSAGE_DYNAMIC;') | ||
784 | + print(r' }') | ||
785 | |||
786 | if 'pSharedHandle' in method.argNames(): | ||
787 | - print r' if (pSharedHandle) {' | ||
788 | - print r' retrace::warning(call) << "shared surfaces unsupported\n";' | ||
789 | - print r' pSharedHandle = NULL;' | ||
790 | - print r' }' | ||
791 | + print(r' if (pSharedHandle) {') | ||
792 | + print(r' retrace::warning(call) << "shared surfaces unsupported\n";') | ||
793 | + print(r' pSharedHandle = NULL;') | ||
794 | + print(r' }') | ||
795 | |||
796 | if method.name in ('Lock', 'LockRect', 'LockBox'): | ||
797 | # Reset _DONOTWAIT flags. Otherwise they may fail, and we have no | ||
798 | @@ -190,7 +190,7 @@ class D3DRetracer(Retracer): | ||
799 | mapFlagsArg = method.getArgByName('Flags') | ||
800 | for flag in mapFlagsArg.type.values: | ||
801 | if flag.endswith('_DONOTWAIT'): | ||
802 | - print r' Flags &= ~%s;' % flag | ||
803 | + print(r' Flags &= ~%s;' % flag) | ||
804 | |||
805 | Retracer.invokeInterfaceMethod(self, interface, method) | ||
806 | |||
807 | @@ -201,7 +201,7 @@ class D3DRetracer(Retracer): | ||
808 | |||
809 | # process events after presents | ||
810 | if method.name == 'Present': | ||
811 | - print r' d3dretrace::processEvents();' | ||
812 | + print(r' d3dretrace::processEvents();') | ||
813 | |||
814 | def mapping_subkey(): | ||
815 | if 'Level' in method.argNames(): | ||
816 | @@ -210,35 +210,35 @@ class D3DRetracer(Retracer): | ||
817 | return ('0',) | ||
818 | |||
819 | if method.name in ('Lock', 'LockRect', 'LockBox'): | ||
820 | - print ' VOID *_pbData = NULL;' | ||
821 | - print ' size_t _MappedSize = 0;' | ||
822 | - print ' if (!(Flags & D3DLOCK_READONLY)) {' | ||
823 | - print ' _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames()[:-1]) | ||
824 | - print ' }' | ||
825 | - print ' if (_MappedSize) {' | ||
826 | - print ' _maps[MappingKey(_this, %s)] = _pbData;' % mapping_subkey() | ||
827 | + print(' VOID *_pbData = NULL;') | ||
828 | + print(' size_t _MappedSize = 0;') | ||
829 | + print(' if (!(Flags & D3DLOCK_READONLY)) {') | ||
830 | + print(' _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames()[:-1])) | ||
831 | + print(' }') | ||
832 | + print(' if (_MappedSize) {') | ||
833 | + print(' _maps[MappingKey(_this, %s)] = _pbData;' % mapping_subkey()) | ||
834 | self.checkPitchMismatch(method) | ||
835 | - print ' } else {' | ||
836 | - print ' return;' | ||
837 | - print ' }' | ||
838 | + print(' } else {') | ||
839 | + print(' return;') | ||
840 | + print(' }') | ||
841 | |||
842 | if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): | ||
843 | - print ' VOID *_pbData = 0;' | ||
844 | - print ' MappingKey _mappingKey(_this, %s);' % mapping_subkey() | ||
845 | - print ' _pbData = _maps[_mappingKey];' | ||
846 | - print ' if (_pbData) {' | ||
847 | - print ' retrace::delRegionByPointer(_pbData);' | ||
848 | - print ' _maps[_mappingKey] = 0;' | ||
849 | - print ' }' | ||
850 | + print(' VOID *_pbData = 0;') | ||
851 | + print(' MappingKey _mappingKey(_this, %s);' % mapping_subkey()) | ||
852 | + print(' _pbData = _maps[_mappingKey];') | ||
853 | + print(' if (_pbData) {') | ||
854 | + print(' retrace::delRegionByPointer(_pbData);') | ||
855 | + print(' _maps[_mappingKey] = 0;') | ||
856 | + print(' }') | ||
857 | |||
858 | |||
859 | def main(): | ||
860 | - print r'#include <string.h>' | ||
861 | |||
862 | - print r'#include <iostream>' | ||
863 | |||
864 | - print r'#include "d3dretrace.hpp"' | ||
865 | |||
866 | + print(r'#include <string.h>') | ||
867 | + print() | ||
868 | + print(r'#include <iostream>') | ||
869 | + print() | ||
870 | + print(r'#include "d3dretrace.hpp"') | ||
871 | + print() | ||
872 | |||
873 | moduleName = sys.argv[1] | ||
874 | support = int(sys.argv[2]) | ||
875 | @@ -249,24 +249,24 @@ def main(): | ||
876 | if moduleName == 'd3d9': | ||
877 | from specs.d3d9 import d3d9, d3dperf | ||
878 | from specs.dxva2 import dxva2 | ||
879 | - print r'#include "d3d9imports.hpp"' | ||
880 | - print r'#include "d3d9size.hpp"' | ||
881 | - print r'#include "dxva2imports.hpp"' | ||
882 | + print(r'#include "d3d9imports.hpp"') | ||
883 | + print(r'#include "d3d9size.hpp"') | ||
884 | + print(r'#include "dxva2imports.hpp"') | ||
885 | d3d9.mergeModule(d3dperf) | ||
886 | api.addModule(d3d9) | ||
887 | api.addModule(dxva2) | ||
888 | |||
889 | - print '''static d3dretrace::D3DDumper<IDirect3DDevice9> d3d9Dumper;''' | ||
890 | - print '''static d3dretrace::D3DDumper<IDirect3DSwapChain9> d3d9scDumper;''' | ||
891 | |||
892 | + print() | ||
893 | + print('''static d3dretrace::D3DDumper<IDirect3DDevice9> d3d9Dumper;''') | ||
894 | + print('''static d3dretrace::D3DDumper<IDirect3DSwapChain9> d3d9scDumper;''') | ||
895 | + print() | ||
896 | elif moduleName == 'd3d8': | ||
897 | from specs.d3d8 import d3d8 | ||
898 | - print r'#include "d3d8imports.hpp"' | ||
899 | - print r'#include "d3d8size.hpp"' | ||
900 | + print(r'#include "d3d8imports.hpp"') | ||
901 | + print(r'#include "d3d8size.hpp"') | ||
902 | api.addModule(d3d8) | ||
903 | |||
904 | - print '''static d3dretrace::D3DDumper<IDirect3DDevice8> d3d8Dumper;''' | ||
905 | |||
906 | + print() | ||
907 | + print('''static d3dretrace::D3DDumper<IDirect3DDevice8> d3d8Dumper;''') | ||
908 | + print() | ||
909 | else: | ||
910 | assert False | ||
911 | |||
912 | diff --git a/retrace/ddrawretrace.py b/retrace/ddrawretrace.py | ||
913 | index 4f2ff944..863283fd 100644 | ||
914 | --- a/retrace/ddrawretrace.py | ||
915 | +++ b/retrace/ddrawretrace.py | ||
916 | @@ -37,12 +37,12 @@ from specs.ddraw import DDCREATE_LPGUID | ||
917 | class D3DRetracer(Retracer): | ||
918 | |||
919 | def retraceApi(self, api): | ||
920 | - print '// Swizzling mapping for lock addresses' | ||
921 | - print 'static std::map<void *, void *> _maps;' | ||
922 | |||
923 | + print('// Swizzling mapping for lock addresses') | ||
924 | + print('static std::map<void *, void *> _maps;') | ||
925 | + print() | ||
926 | # TODO: Keep a table of windows | ||
927 | - print 'static HWND g_hWnd;' | ||
928 | |||
929 | + print('static HWND g_hWnd;') | ||
930 | + print() | ||
931 | |||
932 | Retracer.retraceApi(self, api) | ||
933 | |||
934 | @@ -50,20 +50,20 @@ class D3DRetracer(Retracer): | ||
935 | # keep track of the last used device for state dumping | ||
936 | if interface.name in ('IDirect3DDevice7',): | ||
937 | if method.name == 'Release': | ||
938 | - print r' if (call.ret->toUInt() == 0) {' | ||
939 | - print r' d3d7Dumper.unbindDevice(_this);' | ||
940 | - print r' }' | ||
941 | + print(r' if (call.ret->toUInt() == 0) {') | ||
942 | + print(r' d3d7Dumper.unbindDevice(_this);') | ||
943 | + print(r' }') | ||
944 | else: | ||
945 | - print r' d3d7Dumper.bindDevice(_this);' | ||
946 | + print(r' d3d7Dumper.bindDevice(_this);') | ||
947 | |||
948 | # create windows as neccessary | ||
949 | hWndArg = method.getArgByType(HWND) | ||
950 | if hWndArg is not None: | ||
951 | # FIXME: Try to guess the window size (e.g., from IDirectDrawSurface7::Blt) | ||
952 | - print r' if (!g_hWnd) {' | ||
953 | - print r' g_hWnd = d3dretrace::createWindow(512, 512);' | ||
954 | - print r' }' | ||
955 | - print r' %s = g_hWnd;' % hWndArg.name | ||
956 | + print(r' if (!g_hWnd) {') | ||
957 | + print(r' g_hWnd = d3dretrace::createWindow(512, 512);') | ||
958 | + print(r' }') | ||
959 | + print(r' %s = g_hWnd;' % hWndArg.name) | ||
960 | |||
961 | |||
962 | if method.name == 'Lock': | ||
963 | @@ -71,74 +71,74 @@ class D3DRetracer(Retracer): | ||
964 | # way to cope with it (other than retry). | ||
965 | mapFlagsArg = method.getArgByName('dwFlags') | ||
966 | if mapFlagsArg is not None: | ||
967 | - print r' dwFlags &= DDLOCK_DONOTWAIT;' | ||
968 | - print r' dwFlags |= DDLOCK_WAIT;' | ||
969 | + print(r' dwFlags &= DDLOCK_DONOTWAIT;') | ||
970 | + print(r' dwFlags |= DDLOCK_WAIT;') | ||
971 | |||
972 | Retracer.invokeInterfaceMethod(self, interface, method) | ||
973 | |||
974 | if method.name == 'CreateDevice': | ||
975 | - print r' if (FAILED(_result)) {' | ||
976 | - print r' exit(1);' | ||
977 | - print r' }' | ||
978 | + print(r' if (FAILED(_result)) {') | ||
979 | + print(r' exit(1);') | ||
980 | + print(r' }') | ||
981 | |||
982 | # notify frame has been completed | ||
983 | # process events after presents | ||
984 | if interface.name == 'IDirectDrawSurface7' and method.name == 'Blt': | ||
985 | - print r' DDSCAPS2 ddsCaps;' | ||
986 | - print r' if (SUCCEEDED(_this->GetCaps(&ddsCaps)) &&' | ||
987 | - print r' (ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) {' | ||
988 | - print r' retrace::frameComplete(call);' | ||
989 | - print r' d3dretrace::processEvents();' | ||
990 | - print r' }' | ||
991 | + print(r' DDSCAPS2 ddsCaps;') | ||
992 | + print(r' if (SUCCEEDED(_this->GetCaps(&ddsCaps)) &&') | ||
993 | + print(r' (ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) {') | ||
994 | + print(r' retrace::frameComplete(call);') | ||
995 | + print(r' d3dretrace::processEvents();') | ||
996 | + print(r' }') | ||
997 | |||
998 | if method.name == 'Lock': | ||
999 | - print ' VOID *_pbData = NULL;' | ||
1000 | - print ' size_t _MappedSize = 0;' | ||
1001 | + print(' VOID *_pbData = NULL;') | ||
1002 | + print(' size_t _MappedSize = 0;') | ||
1003 | # FIXME: determine the mapping size | ||
1004 | #print ' _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames()[:-1]) | ||
1005 | - print ' if (_MappedSize) {' | ||
1006 | - print ' _maps[_this] = _pbData;' | ||
1007 | + print(' if (_MappedSize) {') | ||
1008 | + print(' _maps[_this] = _pbData;') | ||
1009 | # TODO: check pitches match | ||
1010 | - print ' } else {' | ||
1011 | - print ' return;' | ||
1012 | - print ' }' | ||
1013 | + print(' } else {') | ||
1014 | + print(' return;') | ||
1015 | + print(' }') | ||
1016 | |||
1017 | if method.name == 'Unlock': | ||
1018 | - print ' VOID *_pbData = 0;' | ||
1019 | - print ' _pbData = _maps[_this];' | ||
1020 | - print ' if (_pbData) {' | ||
1021 | - print ' retrace::delRegionByPointer(_pbData);' | ||
1022 | - print ' _maps[_this] = 0;' | ||
1023 | - print ' }' | ||
1024 | + print(' VOID *_pbData = 0;') | ||
1025 | + print(' _pbData = _maps[_this];') | ||
1026 | + print(' if (_pbData) {') | ||
1027 | + print(' retrace::delRegionByPointer(_pbData);') | ||
1028 | + print(' _maps[_this] = 0;') | ||
1029 | + print(' }') | ||
1030 | |||
1031 | def extractArg(self, function, arg, arg_type, lvalue, rvalue): | ||
1032 | # Handle DDCREATE_* flags | ||
1033 | if arg.type is DDCREATE_LPGUID: | ||
1034 | - print ' if (%s.toArray()) {' % rvalue | ||
1035 | + print(' if (%s.toArray()) {' % rvalue) | ||
1036 | Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) | ||
1037 | - print ' } else {' | ||
1038 | - print ' %s = static_cast<%s>(%s.toPointer());' % (lvalue, arg_type, rvalue) | ||
1039 | - print ' }' | ||
1040 | + print(' } else {') | ||
1041 | + print(' %s = static_cast<%s>(%s.toPointer());' % (lvalue, arg_type, rvalue)) | ||
1042 | + print(' }') | ||
1043 | return | ||
1044 | |||
1045 | Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) | ||
1046 | |||
1047 | |||
1048 | def main(): | ||
1049 | - print r'#include <string.h>' | ||
1050 | |||
1051 | - print r'#include <iostream>' | ||
1052 | |||
1053 | - print r'#include "d3dretrace.hpp"' | ||
1054 | |||
1055 | + print(r'#include <string.h>') | ||
1056 | + print() | ||
1057 | + print(r'#include <iostream>') | ||
1058 | + print() | ||
1059 | + print(r'#include "d3dretrace.hpp"') | ||
1060 | + print() | ||
1061 | |||
1062 | api = API() | ||
1063 | |||
1064 | - print r'#include "d3dimports.hpp"' | ||
1065 | + print(r'#include "d3dimports.hpp"') | ||
1066 | api.addModule(ddraw) | ||
1067 | |||
1068 | - print '''static d3dretrace::D3DDumper<IDirect3DDevice7> d3d7Dumper;''' | ||
1069 | |||
1070 | + print() | ||
1071 | + print('''static d3dretrace::D3DDumper<IDirect3DDevice7> d3d7Dumper;''') | ||
1072 | + print() | ||
1073 | |||
1074 | retracer = D3DRetracer() | ||
1075 | retracer.table_name = 'd3dretrace::ddraw_callbacks' | ||
1076 | diff --git a/retrace/dllretrace.py b/retrace/dllretrace.py | ||
1077 | index c818b0a9..ad9db9a4 100644 | ||
1078 | --- a/retrace/dllretrace.py | ||
1079 | +++ b/retrace/dllretrace.py | ||
1080 | @@ -33,29 +33,29 @@ class DllDispatcher(Dispatcher): | ||
1081 | |||
1082 | def dispatchModule(self, module): | ||
1083 | tag = module.name.upper() | ||
1084 | - print r'const char *g_sz%sDllName = NULL;' % (tag,) | ||
1085 | - print r'HMODULE g_h%sModule = NULL;' % (tag,) | ||
1086 | - print r'' | ||
1087 | - print r'static PROC' | ||
1088 | - print r'_get%sProcAddress(LPCSTR lpProcName) {' % tag | ||
1089 | - print r' if (!g_h%sModule) {' % tag | ||
1090 | - print r' if (g_sz%sDllName) {' % tag | ||
1091 | - print r' g_h%sModule = LoadLibraryA(g_sz%sDllName);' % (tag, tag) | ||
1092 | - print r' if (!g_h%sModule) {' % tag | ||
1093 | - print r' os::log("warning: failed to load %%s\n", g_sz%sDllName);' % tag | ||
1094 | - print r' }' | ||
1095 | - print r' }' | ||
1096 | - print r' if (!g_h%sModule) {' % tag | ||
1097 | - print r' g_h%sModule = LoadLibraryA("%s.dll");' % (tag, module.name) | ||
1098 | - print r' }' | ||
1099 | - print r' if (!g_h%sModule) {' % tag | ||
1100 | - print r' os::log("error: failed to load %s.dll\n");' % module.name | ||
1101 | - print r' exit(1);' | ||
1102 | - print r' }' | ||
1103 | - print r' }' | ||
1104 | - print r' return GetProcAddress(g_h%sModule, lpProcName);' % tag | ||
1105 | - print r'}' | ||
1106 | - print r'' | ||
1107 | + print(r'const char *g_sz%sDllName = NULL;' % (tag,)) | ||
1108 | + print(r'HMODULE g_h%sModule = NULL;' % (tag,)) | ||
1109 | + print(r'') | ||
1110 | + print(r'static PROC') | ||
1111 | + print(r'_get%sProcAddress(LPCSTR lpProcName) {' % tag) | ||
1112 | + print(r' if (!g_h%sModule) {' % tag) | ||
1113 | + print(r' if (g_sz%sDllName) {' % tag) | ||
1114 | + print(r' g_h%sModule = LoadLibraryA(g_sz%sDllName);' % (tag, tag)) | ||
1115 | + print(r' if (!g_h%sModule) {' % tag) | ||
1116 | + print(r' os::log("warning: failed to load %%s\n", g_sz%sDllName);' % tag) | ||
1117 | + print(r' }') | ||
1118 | + print(r' }') | ||
1119 | + print(r' if (!g_h%sModule) {' % tag) | ||
1120 | + print(r' g_h%sModule = LoadLibraryA("%s.dll");' % (tag, module.name)) | ||
1121 | + print(r' }') | ||
1122 | + print(r' if (!g_h%sModule) {' % tag) | ||
1123 | + print(r' os::log("error: failed to load %s.dll\n");' % module.name) | ||
1124 | + print(r' exit(1);') | ||
1125 | + print(r' }') | ||
1126 | + print(r' }') | ||
1127 | + print(r' return GetProcAddress(g_h%sModule, lpProcName);' % tag) | ||
1128 | + print(r'}') | ||
1129 | + print(r'') | ||
1130 | |||
1131 | Dispatcher.dispatchModule(self, module) | ||
1132 | |||
1133 | diff --git a/retrace/dxgiretrace.py b/retrace/dxgiretrace.py | ||
1134 | index 799e3df9..8986a767 100755 | ||
1135 | --- a/retrace/dxgiretrace.py | ||
1136 | +++ b/retrace/dxgiretrace.py | ||
1137 | @@ -40,10 +40,10 @@ from specs.d3d11 import d3d11 | ||
1138 | class D3DRetracer(Retracer): | ||
1139 | |||
1140 | def retraceApi(self, api): | ||
1141 | - print '// Swizzling mapping for lock addresses, mapping a (pDeviceContext, pResource, Subresource) -> void *' | ||
1142 | - print 'typedef std::pair< IUnknown *, UINT > SubresourceKey;' | ||
1143 | - print 'static std::map< IUnknown *, std::map< SubresourceKey, void * > > g_Maps;' | ||
1144 | |||
1145 | + print('// Swizzling mapping for lock addresses, mapping a (pDeviceContext, pResource, Subresource) -> void *') | ||
1146 | + print('typedef std::pair< IUnknown *, UINT > SubresourceKey;') | ||
1147 | + print('static std::map< IUnknown *, std::map< SubresourceKey, void * > > g_Maps;') | ||
1148 | + print() | ||
1149 | self.table_name = 'd3dretrace::dxgi_callbacks' | ||
1150 | |||
1151 | Retracer.retraceApi(self, api) | ||
1152 | @@ -61,41 +61,41 @@ class D3DRetracer(Retracer): | ||
1153 | if function.name in self.createDeviceFunctionNames: | ||
1154 | # create windows as neccessary | ||
1155 | if 'pSwapChainDesc' in function.argNames(): | ||
1156 | - print r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);' | ||
1157 | + print(r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);') | ||
1158 | |||
1159 | # Compensate for the fact we don't trace DXGI object creation | ||
1160 | if function.name.startswith('D3D11CreateDevice'): | ||
1161 | - print r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' | ||
1162 | - print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;' | ||
1163 | - print r' }' | ||
1164 | + print(r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {') | ||
1165 | + print(r' DriverType = D3D_DRIVER_TYPE_HARDWARE;') | ||
1166 | + print(r' }') | ||
1167 | |||
1168 | if function.name.startswith('D3D10CreateDevice'): | ||
1169 | # Toggle debugging | ||
1170 | - print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' | ||
1171 | - print r' if (retrace::debug) {' | ||
1172 | - print r' HMODULE hD3d10SdkLayers = LoadLibraryA("d3d10sdklayers");' | ||
1173 | - print r' if (hD3d10SdkLayers) {' | ||
1174 | - print r' FreeLibrary(hD3d10SdkLayers);' | ||
1175 | - print r' Flags |= D3D10_CREATE_DEVICE_DEBUG;' | ||
1176 | - print r' } else {' | ||
1177 | - print r' retrace::warning(call) << "Direct3D 10.x SDK Debug Layer (d3d10sdklayers.dll) not available, continuing without debug output\n";' | ||
1178 | - print r' }' | ||
1179 | - print r' }' | ||
1180 | + print(r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;') | ||
1181 | + print(r' if (retrace::debug) {') | ||
1182 | + print(r' HMODULE hD3d10SdkLayers = LoadLibraryA("d3d10sdklayers");') | ||
1183 | + print(r' if (hD3d10SdkLayers) {') | ||
1184 | + print(r' FreeLibrary(hD3d10SdkLayers);') | ||
1185 | + print(r' Flags |= D3D10_CREATE_DEVICE_DEBUG;') | ||
1186 | + print(r' } else {') | ||
1187 | + print(r' retrace::warning(call) << "Direct3D 10.x SDK Debug Layer (d3d10sdklayers.dll) not available, continuing without debug output\n";') | ||
1188 | + print(r' }') | ||
1189 | + print(r' }') | ||
1190 | |||
1191 | # Force driver | ||
1192 | self.forceDriver('D3D10_DRIVER_TYPE') | ||
1193 | |||
1194 | if function.name.startswith('D3D11CreateDevice'): | ||
1195 | # Toggle debugging | ||
1196 | - print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' | ||
1197 | - print r' if (retrace::debug) {' | ||
1198 | - print r' HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_NULL, 0, D3D11_CREATE_DEVICE_DEBUG, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);' | ||
1199 | - print r' if (SUCCEEDED(hr)) {' | ||
1200 | - print r' Flags |= D3D11_CREATE_DEVICE_DEBUG;' | ||
1201 | - print r' } else {' | ||
1202 | - print r' retrace::warning(call) << "Direct3D 11.x SDK Debug Layer (d3d11*sdklayers.dll) not available, continuing without debug output\n";' | ||
1203 | - print r' }' | ||
1204 | - print r' }' | ||
1205 | + print(r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;') | ||
1206 | + print(r' if (retrace::debug) {') | ||
1207 | + print(r' HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_NULL, 0, D3D11_CREATE_DEVICE_DEBUG, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);') | ||
1208 | + print(r' if (SUCCEEDED(hr)) {') | ||
1209 | + print(r' Flags |= D3D11_CREATE_DEVICE_DEBUG;') | ||
1210 | + print(r' } else {') | ||
1211 | + print(r' retrace::warning(call) << "Direct3D 11.x SDK Debug Layer (d3d11*sdklayers.dll) not available, continuing without debug output\n";') | ||
1212 | + print(r' }') | ||
1213 | + print(r' }') | ||
1214 | |||
1215 | # Force driver | ||
1216 | self.forceDriver('D3D_DRIVER_TYPE') | ||
1217 | @@ -108,15 +108,15 @@ class D3DRetracer(Retracer): | ||
1218 | if interface is not None: | ||
1219 | getDeviceRemovedReasonMethod = interface.getMethodByName("GetDeviceRemovedReason") | ||
1220 | if getDeviceRemovedReasonMethod is not None: | ||
1221 | - print r' if (FAILED(_result)) {' | ||
1222 | - print r' retrace::failed(call, _result);' | ||
1223 | - print r' if (_result == DXGI_ERROR_DEVICE_REMOVED) {' | ||
1224 | - print r' HRESULT _reason = _this->GetDeviceRemovedReason();' | ||
1225 | - print r' retrace::failed(call, _reason);' | ||
1226 | - print r' exit(1);' | ||
1227 | - print r' }' | ||
1228 | - print r' return;' | ||
1229 | - print r' }' | ||
1230 | + print(r' if (FAILED(_result)) {') | ||
1231 | + print(r' retrace::failed(call, _result);') | ||
1232 | + print(r' if (_result == DXGI_ERROR_DEVICE_REMOVED) {') | ||
1233 | + print(r' HRESULT _reason = _this->GetDeviceRemovedReason();') | ||
1234 | + print(r' retrace::failed(call, _reason);') | ||
1235 | + print(r' exit(1);') | ||
1236 | + print(r' }') | ||
1237 | + print(r' return;') | ||
1238 | + print(r' }') | ||
1239 | return | ||
1240 | |||
1241 | Retracer.checkResult(self, interface, methodOrFunction) | ||
1242 | @@ -124,112 +124,112 @@ class D3DRetracer(Retracer): | ||
1243 | def forceDriver(self, enum): | ||
1244 | # This can only work when pAdapter is NULL. For non-NULL pAdapter we | ||
1245 | # need to override inside the EnumAdapters call below | ||
1246 | - print r' if (pAdapter == NULL) {' | ||
1247 | - print r' switch (retrace::driver) {' | ||
1248 | - print r' case retrace::DRIVER_HARDWARE:' | ||
1249 | - print r' DriverType = %s_HARDWARE;' % enum | ||
1250 | - print r' Software = NULL;' | ||
1251 | - print r' break;' | ||
1252 | - print r' case retrace::DRIVER_SOFTWARE:' | ||
1253 | - print r' DriverType = %s_WARP;' % enum | ||
1254 | - print r' Software = NULL;' | ||
1255 | - print r' break;' | ||
1256 | - print r' case retrace::DRIVER_REFERENCE:' | ||
1257 | - print r' DriverType = %s_REFERENCE;' % enum | ||
1258 | - print r' Software = NULL;' | ||
1259 | - print r' break;' | ||
1260 | - print r' case retrace::DRIVER_NULL:' | ||
1261 | - print r' DriverType = %s_NULL;' % enum | ||
1262 | - print r' Software = NULL;' | ||
1263 | - print r' break;' | ||
1264 | - print r' case retrace::DRIVER_MODULE:' | ||
1265 | - print r' DriverType = %s_SOFTWARE;' % enum | ||
1266 | - print r' Software = LoadLibraryA(retrace::driverModule);' | ||
1267 | - print r' if (!Software) {' | ||
1268 | - print r' retrace::warning(call) << "failed to load " << retrace::driverModule << "\n";' | ||
1269 | - print r' }' | ||
1270 | - print r' break;' | ||
1271 | - print r' default:' | ||
1272 | - print r' assert(0);' | ||
1273 | - print r' /* fall-through */' | ||
1274 | - print r' case retrace::DRIVER_DEFAULT:' | ||
1275 | - print r' if (DriverType == %s_SOFTWARE) {' % enum | ||
1276 | - print r' Software = LoadLibraryA("d3d10warp");' | ||
1277 | - print r' if (!Software) {' | ||
1278 | - print r' retrace::warning(call) << "failed to load d3d10warp.dll\n";' | ||
1279 | - print r' }' | ||
1280 | - print r' }' | ||
1281 | - print r' break;' | ||
1282 | - print r' }' | ||
1283 | - print r' } else {' | ||
1284 | - print r' Software = NULL;' | ||
1285 | - print r' }' | ||
1286 | + print(r' if (pAdapter == NULL) {') | ||
1287 | + print(r' switch (retrace::driver) {') | ||
1288 | + print(r' case retrace::DRIVER_HARDWARE:') | ||
1289 | + print(r' DriverType = %s_HARDWARE;' % enum) | ||
1290 | + print(r' Software = NULL;') | ||
1291 | + print(r' break;') | ||
1292 | + print(r' case retrace::DRIVER_SOFTWARE:') | ||
1293 | + print(r' DriverType = %s_WARP;' % enum) | ||
1294 | + print(r' Software = NULL;') | ||
1295 | + print(r' break;') | ||
1296 | + print(r' case retrace::DRIVER_REFERENCE:') | ||
1297 | + print(r' DriverType = %s_REFERENCE;' % enum) | ||
1298 | + print(r' Software = NULL;') | ||
1299 | + print(r' break;') | ||
1300 | + print(r' case retrace::DRIVER_NULL:') | ||
1301 | + print(r' DriverType = %s_NULL;' % enum) | ||
1302 | + print(r' Software = NULL;') | ||
1303 | + print(r' break;') | ||
1304 | + print(r' case retrace::DRIVER_MODULE:') | ||
1305 | + print(r' DriverType = %s_SOFTWARE;' % enum) | ||
1306 | + print(r' Software = LoadLibraryA(retrace::driverModule);') | ||
1307 | + print(r' if (!Software) {') | ||
1308 | + print(r' retrace::warning(call) << "failed to load " << retrace::driverModule << "\n";') | ||
1309 | + print(r' }') | ||
1310 | + print(r' break;') | ||
1311 | + print(r' default:') | ||
1312 | + print(r' assert(0);') | ||
1313 | + print(r' /* fall-through */') | ||
1314 | + print(r' case retrace::DRIVER_DEFAULT:') | ||
1315 | + print(r' if (DriverType == %s_SOFTWARE) {' % enum) | ||
1316 | + print(r' Software = LoadLibraryA("d3d10warp");') | ||
1317 | + print(r' if (!Software) {') | ||
1318 | + print(r' retrace::warning(call) << "failed to load d3d10warp.dll\n";') | ||
1319 | + print(r' }') | ||
1320 | + print(r' }') | ||
1321 | + print(r' break;') | ||
1322 | + print(r' }') | ||
1323 | + print(r' } else {') | ||
1324 | + print(r' Software = NULL;') | ||
1325 | + print(r' }') | ||
1326 | |||
1327 | def invokeInterfaceMethod(self, interface, method): | ||
1328 | # keep track of the last used device for state dumping | ||
1329 | if interface.name in ('ID3D10Device', 'ID3D10Device1'): | ||
1330 | if method.name == 'Release': | ||
1331 | - print r' if (call.ret->toUInt() == 0) {' | ||
1332 | - print r' d3d10Dumper.unbindDevice(_this);' | ||
1333 | - print r' }' | ||
1334 | + print(r' if (call.ret->toUInt() == 0) {') | ||
1335 | + print(r' d3d10Dumper.unbindDevice(_this);') | ||
1336 | + print(r' }') | ||
1337 | else: | ||
1338 | - print r' d3d10Dumper.bindDevice(_this);' | ||
1339 | + print(r' d3d10Dumper.bindDevice(_this);') | ||
1340 | if interface.name.startswith('ID3D11DeviceContext'): | ||
1341 | if method.name == 'Release': | ||
1342 | - print r' if (call.ret->toUInt() == 0) {' | ||
1343 | - print r' d3d11Dumper.unbindDevice(_this);' | ||
1344 | - print r' }' | ||
1345 | + print(r' if (call.ret->toUInt() == 0) {') | ||
1346 | + print(r' d3d11Dumper.unbindDevice(_this);') | ||
1347 | + print(r' }') | ||
1348 | else: | ||
1349 | - print r' if (_this->GetType() == D3D11_DEVICE_CONTEXT_IMMEDIATE) {' | ||
1350 | - print r' d3d11Dumper.bindDevice(_this);' | ||
1351 | - print r' }' | ||
1352 | + print(r' if (_this->GetType() == D3D11_DEVICE_CONTEXT_IMMEDIATE) {') | ||
1353 | + print(r' d3d11Dumper.bindDevice(_this);') | ||
1354 | + print(r' }') | ||
1355 | |||
1356 | # intercept private interfaces | ||
1357 | if method.name == 'QueryInterface': | ||
1358 | - print r' if (!d3dretrace::overrideQueryInterface(_this, riid, ppvObj, &_result)) {' | ||
1359 | + print(r' if (!d3dretrace::overrideQueryInterface(_this, riid, ppvObj, &_result)) {') | ||
1360 | Retracer.invokeInterfaceMethod(self, interface, method) | ||
1361 | - print r' }' | ||
1362 | + print(r' }') | ||
1363 | return | ||
1364 | |||
1365 | # create windows as neccessary | ||
1366 | if method.name == 'CreateSwapChain': | ||
1367 | - print r' d3dretrace::createWindowForSwapChain(pDesc);' | ||
1368 | + print(r' d3dretrace::createWindowForSwapChain(pDesc);') | ||
1369 | if method.name == 'CreateSwapChainForHwnd': | ||
1370 | - print r' WindowHandle = d3dretrace::createWindow(pDesc->Width, pDesc->Height);' | ||
1371 | - print r' // DXGI_SCALING_NONE is only supported on Win8 and beyond' | ||
1372 | - print r' if (pDesc->Scaling == DXGI_SCALING_NONE && !IsWindows8OrGreater()) {' | ||
1373 | - print r' pDesc->Scaling = DXGI_SCALING_STRETCH;' | ||
1374 | - print r' }' | ||
1375 | + print(r' WindowHandle = d3dretrace::createWindow(pDesc->Width, pDesc->Height);') | ||
1376 | + print(r' // DXGI_SCALING_NONE is only supported on Win8 and beyond') | ||
1377 | + print(r' if (pDesc->Scaling == DXGI_SCALING_NONE && !IsWindows8OrGreater()) {') | ||
1378 | + print(r' pDesc->Scaling = DXGI_SCALING_STRETCH;') | ||
1379 | + print(r' }') | ||
1380 | if method.name == 'CreateSwapChainForComposition': | ||
1381 | - print r' HWND hWnd = d3dretrace::createWindow(pDesc->Width, pDesc->Height);' | ||
1382 | - print r' _result = _this->CreateSwapChainForHwnd(pDevice, hWnd, pDesc, NULL, pRestrictToOutput, ppSwapChain);' | ||
1383 | + print(r' HWND hWnd = d3dretrace::createWindow(pDesc->Width, pDesc->Height);') | ||
1384 | + print(r' _result = _this->CreateSwapChainForHwnd(pDevice, hWnd, pDesc, NULL, pRestrictToOutput, ppSwapChain);') | ||
1385 | self.checkResult(interface, method) | ||
1386 | return | ||
1387 | |||
1388 | if method.name == 'SetFullscreenState': | ||
1389 | - print r' if (retrace::forceWindowed) {' | ||
1390 | - print r' Fullscreen = FALSE;' | ||
1391 | - print r' pTarget = NULL;' | ||
1392 | - print r' }' | ||
1393 | + print(r' if (retrace::forceWindowed) {') | ||
1394 | + print(r' Fullscreen = FALSE;') | ||
1395 | + print(r' pTarget = NULL;') | ||
1396 | + print(r' }') | ||
1397 | |||
1398 | # notify frame has been completed | ||
1399 | if interface.name.startswith('IDXGISwapChain') and method.name.startswith('Present'): | ||
1400 | if interface.name.startswith('IDXGISwapChainDWM'): | ||
1401 | - print r' com_ptr<IDXGISwapChain> pSwapChain;' | ||
1402 | - print r' if (SUCCEEDED(_this->QueryInterface(IID_IDXGISwapChain, (void **) &pSwapChain))) {' | ||
1403 | - print r' dxgiDumper.bindDevice(pSwapChain);' | ||
1404 | - print r' } else {' | ||
1405 | - print r' assert(0);' | ||
1406 | - print r' }' | ||
1407 | + print(r' com_ptr<IDXGISwapChain> pSwapChain;') | ||
1408 | + print(r' if (SUCCEEDED(_this->QueryInterface(IID_IDXGISwapChain, (void **) &pSwapChain))) {') | ||
1409 | + print(r' dxgiDumper.bindDevice(pSwapChain);') | ||
1410 | + print(r' } else {') | ||
1411 | + print(r' assert(0);') | ||
1412 | + print(r' }') | ||
1413 | else: | ||
1414 | - print r' dxgiDumper.bindDevice(_this);' | ||
1415 | - print r' retrace::frameComplete(call);' | ||
1416 | + print(r' dxgiDumper.bindDevice(_this);') | ||
1417 | + print(r' retrace::frameComplete(call);') | ||
1418 | |||
1419 | if 'pSharedResource' in method.argNames(): | ||
1420 | - print r' if (pSharedResource) {' | ||
1421 | - print r' retrace::warning(call) << "shared surfaces unsupported\n";' | ||
1422 | - print r' pSharedResource = NULL;' | ||
1423 | - print r' }' | ||
1424 | + print(r' if (pSharedResource) {') | ||
1425 | + print(r' retrace::warning(call) << "shared surfaces unsupported\n";') | ||
1426 | + print(r' pSharedResource = NULL;') | ||
1427 | + print(r' }') | ||
1428 | |||
1429 | # Force driver | ||
1430 | if interface.name.startswith('IDXGIFactory') and method.name.startswith('EnumAdapters'): | ||
1431 | @@ -260,31 +260,31 @@ class D3DRetracer(Retracer): | ||
1432 | return | ||
1433 | |||
1434 | if interface.name.startswith('ID3D10Device') and method.name.startswith('OpenSharedResource'): | ||
1435 | - print r' retrace::warning(call) << "replacing shared resource with checker pattern\n";' | ||
1436 | - print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);' | ||
1437 | + print(r' retrace::warning(call) << "replacing shared resource with checker pattern\n";') | ||
1438 | + print(r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);') | ||
1439 | self.checkResult(interface, method) | ||
1440 | return | ||
1441 | if interface.name.startswith('ID3D11Device') and method.name == 'OpenSharedResource': | ||
1442 | # Some applications (e.g., video playing in IE11) create shared resources within the same process. | ||
1443 | # TODO: Generalize to other OpenSharedResource variants | ||
1444 | - print r' retrace::map<HANDLE>::const_iterator it = _shared_handle_map.find(hResource);' | ||
1445 | - print r' if (it == _shared_handle_map.end()) {' | ||
1446 | - print r' retrace::warning(call) << "replacing shared resource with checker pattern\n";' | ||
1447 | - print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);' | ||
1448 | + print(r' retrace::map<HANDLE>::const_iterator it = _shared_handle_map.find(hResource);') | ||
1449 | + print(r' if (it == _shared_handle_map.end()) {') | ||
1450 | + print(r' retrace::warning(call) << "replacing shared resource with checker pattern\n";') | ||
1451 | + print(r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);') | ||
1452 | self.checkResult(interface, method) | ||
1453 | - print r' } else {' | ||
1454 | - print r' hResource = it->second;' | ||
1455 | + print(r' } else {') | ||
1456 | + print(r' hResource = it->second;') | ||
1457 | Retracer.invokeInterfaceMethod(self, interface, method) | ||
1458 | - print r' }' | ||
1459 | + print(r' }') | ||
1460 | return | ||
1461 | if interface.name.startswith('ID3D11Device') and method.name.startswith('OpenSharedResource'): | ||
1462 | - print r' retrace::warning(call) << "replacing shared resource with checker pattern\n";' | ||
1463 | - print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);' | ||
1464 | + print(r' retrace::warning(call) << "replacing shared resource with checker pattern\n";') | ||
1465 | + print(r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);') | ||
1466 | if method.name == 'OpenSharedResourceByName': | ||
1467 | - print r' (void)lpName;' | ||
1468 | - print r' (void)dwDesiredAccess;' | ||
1469 | + print(r' (void)lpName;') | ||
1470 | + print(r' (void)dwDesiredAccess;') | ||
1471 | else: | ||
1472 | - print r' (void)hResource;' | ||
1473 | + print(r' (void)hResource;') | ||
1474 | self.checkResult(interface, method) | ||
1475 | return | ||
1476 | |||
1477 | @@ -294,7 +294,7 @@ class D3DRetracer(Retracer): | ||
1478 | mapFlagsArg = method.getArgByName('MapFlags') | ||
1479 | for flag in mapFlagsArg.type.values: | ||
1480 | if flag.endswith('_MAP_FLAG_DO_NOT_WAIT'): | ||
1481 | - print r' MapFlags &= ~%s;' % flag | ||
1482 | + print(r' MapFlags &= ~%s;' % flag) | ||
1483 | |||
1484 | if method.name.startswith('UpdateSubresource'): | ||
1485 | # The D3D10 debug layer is buggy (or at least inconsistent with the | ||
1486 | @@ -303,108 +303,108 @@ class D3DRetracer(Retracer): | ||
1487 | # SrcDepthPitch is garbagge for non 3D textures. | ||
1488 | # XXX: It also seems to expect padding bytes at the end of the last | ||
1489 | # row, but we never record (or allocate) those... | ||
1490 | - print r' if (retrace::debug && pDstBox && pDstBox->front == 0 && pDstBox->back == 1) {' | ||
1491 | - print r' SrcDepthPitch = 0;' | ||
1492 | - print r' }' | ||
1493 | + print(r' if (retrace::debug && pDstBox && pDstBox->front == 0 && pDstBox->back == 1) {') | ||
1494 | + print(r' SrcDepthPitch = 0;') | ||
1495 | + print(r' }') | ||
1496 | |||
1497 | if method.name == 'SetGammaControl': | ||
1498 | # This method is only supported while in full-screen mode | ||
1499 | - print r' if (retrace::forceWindowed) {' | ||
1500 | - print r' return;' | ||
1501 | - print r' }' | ||
1502 | + print(r' if (retrace::forceWindowed) {') | ||
1503 | + print(r' return;') | ||
1504 | + print(r' }') | ||
1505 | |||
1506 | Retracer.invokeInterfaceMethod(self, interface, method) | ||
1507 | |||
1508 | if method.name in ('AcquireSync', 'ReleaseSync'): | ||
1509 | - print r' if (SUCCEEDED(_result) && _result != S_OK) {' | ||
1510 | - print r' retrace::warning(call) << " returned " << _result << "\n";' | ||
1511 | - print r' }' | ||
1512 | + print(r' if (SUCCEEDED(_result) && _result != S_OK) {') | ||
1513 | + print(r' retrace::warning(call) << " returned " << _result << "\n";') | ||
1514 | + print(r' }') | ||
1515 | |||
1516 | # process events after presents | ||
1517 | if interface.name.startswith('IDXGISwapChain') and method.name.startswith('Present'): | ||
1518 | - print r' d3dretrace::processEvents();' | ||
1519 | + print(r' d3dretrace::processEvents();') | ||
1520 | |||
1521 | if method.name in ('Map', 'Unmap'): | ||
1522 | if interface.name.startswith('ID3D11DeviceContext'): | ||
1523 | - print ' void * & _pbData = g_Maps[_this][SubresourceKey(pResource, Subresource)];' | ||
1524 | + print(' void * & _pbData = g_Maps[_this][SubresourceKey(pResource, Subresource)];') | ||
1525 | else: | ||
1526 | subresourceArg = method.getArgByName('Subresource') | ||
1527 | if subresourceArg is None: | ||
1528 | - print ' UINT Subresource = 0;' | ||
1529 | - print ' void * & _pbData = g_Maps[0][SubresourceKey(_this, Subresource)];' | ||
1530 | + print(' UINT Subresource = 0;') | ||
1531 | + print(' void * & _pbData = g_Maps[0][SubresourceKey(_this, Subresource)];') | ||
1532 | |||
1533 | if method.name == 'Map': | ||
1534 | - print ' _MAP_DESC _MapDesc;' | ||
1535 | - print ' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames()) | ||
1536 | - print ' size_t _MappedSize = _MapDesc.Size;' | ||
1537 | - print ' if (_MapDesc.Size) {' | ||
1538 | - print ' _pbData = _MapDesc.pData;' | ||
1539 | + print(' _MAP_DESC _MapDesc;') | ||
1540 | + print(' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames())) | ||
1541 | + print(' size_t _MappedSize = _MapDesc.Size;') | ||
1542 | + print(' if (_MapDesc.Size) {') | ||
1543 | + print(' _pbData = _MapDesc.pData;') | ||
1544 | if interface.name.startswith('ID3D11DeviceContext'): | ||
1545 | # Prevent false warnings on 1D and 2D resources, since the | ||
1546 | # pitches are often junk there... | ||
1547 | - print ' _normalizeMap(pResource, pMappedResource);' | ||
1548 | + print(' _normalizeMap(pResource, pMappedResource);') | ||
1549 | self.checkPitchMismatch(method) | ||
1550 | else: | ||
1551 | - print ' _pbData = _MapDesc.pData;' | ||
1552 | + print(' _pbData = _MapDesc.pData;') | ||
1553 | self.checkPitchMismatch(method) | ||
1554 | - print ' } else {' | ||
1555 | - print ' return;' | ||
1556 | - print ' }' | ||
1557 | + print(' } else {') | ||
1558 | + print(' return;') | ||
1559 | + print(' }') | ||
1560 | |||
1561 | if method.name == 'Unmap': | ||
1562 | - print ' if (_pbData) {' | ||
1563 | - print ' retrace::delRegionByPointer(_pbData);' | ||
1564 | - print ' _pbData = 0;' | ||
1565 | - print ' }' | ||
1566 | + print(' if (_pbData) {') | ||
1567 | + print(' retrace::delRegionByPointer(_pbData);') | ||
1568 | + print(' _pbData = 0;') | ||
1569 | + print(' }') | ||
1570 | |||
1571 | # Attach shader byte code for lookup | ||
1572 | if 'pShaderBytecode' in method.argNames(): | ||
1573 | ppShader = method.args[-1] | ||
1574 | assert ppShader.output | ||
1575 | - print r' if (retrace::dumpingState && SUCCEEDED(_result)) {' | ||
1576 | - print r' (*%s)->SetPrivateData(d3dstate::GUID_D3DSTATE, BytecodeLength, pShaderBytecode);' % ppShader.name | ||
1577 | - print r' }' | ||
1578 | + print(r' if (retrace::dumpingState && SUCCEEDED(_result)) {') | ||
1579 | + print(r' (*%s)->SetPrivateData(d3dstate::GUID_D3DSTATE, BytecodeLength, pShaderBytecode);' % ppShader.name) | ||
1580 | + print(r' }') | ||
1581 | |||
1582 | def extractArg(self, function, arg, arg_type, lvalue, rvalue): | ||
1583 | # Set object names | ||
1584 | if function.name == 'SetPrivateData' and arg.name == 'pData': | ||
1585 | iid = function.args[0].name | ||
1586 | - print r' if (%s != WKPDID_D3DDebugObjectName) {' % iid | ||
1587 | - print r' return;' | ||
1588 | - print r' }' | ||
1589 | + print(r' if (%s != WKPDID_D3DDebugObjectName) {' % iid) | ||
1590 | + print(r' return;') | ||
1591 | + print(r' }') | ||
1592 | # Interpret argument as string | ||
1593 | Retracer.extractArg(self, function, arg, LPCSTR, lvalue, rvalue) | ||
1594 | - print r' assert(pData);' | ||
1595 | - print r' assert(DataSize >= strlen((const char *)pData));' | ||
1596 | - print r' // Some applications include the trailing zero terminator in the data' | ||
1597 | - print r' DataSize = strlen((const char *)pData);' | ||
1598 | + print(r' assert(pData);') | ||
1599 | + print(r' assert(DataSize >= strlen((const char *)pData));') | ||
1600 | + print(r' // Some applications include the trailing zero terminator in the data') | ||
1601 | + print(r' DataSize = strlen((const char *)pData);') | ||
1602 | return | ||
1603 | |||
1604 | Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) | ||
1605 | |||
1606 | |||
1607 | def main(): | ||
1608 | - print r'#define INITGUID' | ||
1609 | |||
1610 | - print r'#include <string.h>' | ||
1611 | |||
1612 | - print r'#include <iostream>' | ||
1613 | |||
1614 | - print r'#include "d3dretrace.hpp"' | ||
1615 | - print r'#include "os_version.hpp"' | ||
1616 | |||
1617 | - print r'#include "d3dretrace_dxgi.hpp"' | ||
1618 | - print r'#include "d3d10imports.hpp"' | ||
1619 | - print r'#include "d3d10size.hpp"' | ||
1620 | - print r'#include "d3d10state.hpp"' | ||
1621 | - print r'#include "d3d11imports.hpp"' | ||
1622 | - print r'#include "d3d11size.hpp"' | ||
1623 | - print r'#include "d3dstate.hpp"' | ||
1624 | |||
1625 | - print '''static d3dretrace::D3DDumper<IDXGISwapChain> dxgiDumper;''' | ||
1626 | - print '''static d3dretrace::D3DDumper<ID3D10Device> d3d10Dumper;''' | ||
1627 | - print '''static d3dretrace::D3DDumper<ID3D11DeviceContext> d3d11Dumper;''' | ||
1628 | |||
1629 | + print(r'#define INITGUID') | ||
1630 | + print() | ||
1631 | + print(r'#include <string.h>') | ||
1632 | + print() | ||
1633 | + print(r'#include <iostream>') | ||
1634 | + print() | ||
1635 | + print(r'#include "d3dretrace.hpp"') | ||
1636 | + print(r'#include "os_version.hpp"') | ||
1637 | + print() | ||
1638 | + print(r'#include "d3dretrace_dxgi.hpp"') | ||
1639 | + print(r'#include "d3d10imports.hpp"') | ||
1640 | + print(r'#include "d3d10size.hpp"') | ||
1641 | + print(r'#include "d3d10state.hpp"') | ||
1642 | + print(r'#include "d3d11imports.hpp"') | ||
1643 | + print(r'#include "d3d11size.hpp"') | ||
1644 | + print(r'#include "d3dstate.hpp"') | ||
1645 | + print() | ||
1646 | + print('''static d3dretrace::D3DDumper<IDXGISwapChain> dxgiDumper;''') | ||
1647 | + print('''static d3dretrace::D3DDumper<ID3D10Device> d3d10Dumper;''') | ||
1648 | + print('''static d3dretrace::D3DDumper<ID3D11DeviceContext> d3d11Dumper;''') | ||
1649 | + print() | ||
1650 | |||
1651 | api = API() | ||
1652 | api.addModule(dxgi) | ||
1653 | diff --git a/retrace/dxgistate_so.py b/retrace/dxgistate_so.py | ||
1654 | index 86f6db57..33745c8f 100644 | ||
1655 | --- a/retrace/dxgistate_so.py | ||
1656 | +++ b/retrace/dxgistate_so.py | ||
1657 | @@ -48,9 +48,9 @@ class ValueDumper(stdapi.Visitor, stdapi.ExpanderMixin): | ||
1658 | |||
1659 | def visitLiteral(self, literal, instance): | ||
1660 | if literal.kind in ('SInt', 'UInt'): | ||
1661 | - print ' writer.writeInt(%s);' % (instance) | ||
1662 | + print(' writer.writeInt(%s);' % (instance)) | ||
1663 | elif literal.kind in ('Float',): | ||
1664 | - print ' writer.writeFloat(%s);' % (instance) | ||
1665 | + print(' writer.writeFloat(%s);' % (instance)) | ||
1666 | else: | ||
1667 | raise NotImplementedError | ||
1668 | |||
1669 | @@ -66,36 +66,36 @@ class ValueDumper(stdapi.Visitor, stdapi.ExpanderMixin): | ||
1670 | # reinterpret_cast is necessary for GLubyte * <=> char * | ||
1671 | instance = 'reinterpret_cast<%s>(%s)' % (cast, instance) | ||
1672 | assert string.length is None | ||
1673 | - print ' writer.write%s(%s);' % (suffix, instance) | ||
1674 | + print(' writer.write%s(%s);' % (suffix, instance)) | ||
1675 | |||
1676 | def visitConst(self, const, instance): | ||
1677 | self.visit(const.type, instance) | ||
1678 | |||
1679 | def visitStruct(self, struct, instance): | ||
1680 | - print ' writer.beginObject();' | ||
1681 | + print(' writer.beginObject();') | ||
1682 | for member in struct.members: | ||
1683 | memberType, memberName = member | ||
1684 | if memberName is not None: | ||
1685 | - print ' writer.beginMember("%s");' % memberName | ||
1686 | + print(' writer.beginMember("%s");' % memberName) | ||
1687 | self.visitMember(member, instance) | ||
1688 | if memberName is not None: | ||
1689 | - print ' writer.endMember(); // %s' % memberName | ||
1690 | - print ' writer.endObject();' | ||
1691 | + print(' writer.endMember(); // %s' % memberName) | ||
1692 | + print(' writer.endObject();') | ||
1693 | |||
1694 | def visitArray(self, array, instance): | ||
1695 | length = '_c' + array.type.tag | ||
1696 | index = '_i' + array.type.tag | ||
1697 | array_length = self.expand(array.length) | ||
1698 | - print ' if (%s) {' % instance | ||
1699 | - print ' size_t %s = %s > 0 ? %s : 0;' % (length, array_length, array_length) | ||
1700 | - print ' writer.beginArray();' | ||
1701 | - print ' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index) | ||
1702 | + print(' if (%s) {' % instance) | ||
1703 | + print(' size_t %s = %s > 0 ? %s : 0;' % (length, array_length, array_length)) | ||
1704 | + print(' writer.beginArray();') | ||
1705 | + print(' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index)) | ||
1706 | self.visitElement(index, array.type, '(%s)[%s]' % (instance, index)) | ||
1707 | - print ' }' | ||
1708 | - print ' writer.endArray();' | ||
1709 | - print ' } else {' | ||
1710 | - print ' writer.writeNull();' | ||
1711 | - print ' }' | ||
1712 | + print(' }') | ||
1713 | + print(' writer.endArray();') | ||
1714 | + print(' } else {') | ||
1715 | + print(' writer.writeNull();') | ||
1716 | + print(' }') | ||
1717 | |||
1718 | def visitAttribArray(self, array, instance): | ||
1719 | raise NotImplementedError | ||
1720 | @@ -104,37 +104,37 @@ class ValueDumper(stdapi.Visitor, stdapi.ExpanderMixin): | ||
1721 | raise NotImplementedError | ||
1722 | |||
1723 | def visitEnum(self, enum, instance): | ||
1724 | - print ' switch (%s) {' % instance | ||
1725 | + print(' switch (%s) {' % instance) | ||
1726 | for value in enum.values: | ||
1727 | - print ' case %s:' % value | ||
1728 | - print ' writer.writeString("%s");' % value | ||
1729 | - print ' break;' | ||
1730 | - print ' default:' | ||
1731 | - print ' writer.writeInt(%s);' % instance | ||
1732 | - print ' break;' | ||
1733 | - print ' }' | ||
1734 | + print(' case %s:' % value) | ||
1735 | + print(' writer.writeString("%s");' % value) | ||
1736 | + print(' break;') | ||
1737 | + print(' default:') | ||
1738 | + print(' writer.writeInt(%s);' % instance) | ||
1739 | + print(' break;') | ||
1740 | + print(' }') | ||
1741 | |||
1742 | def visitBitmask(self, bitmask, instance): | ||
1743 | # TODO | ||
1744 | self.visit(bitmask.type, instance) | ||
1745 | |||
1746 | def visitPointer(self, pointer, instance): | ||
1747 | - print ' if (%s) {' % instance | ||
1748 | - print ' writer.beginArray();' | ||
1749 | + print(' if (%s) {' % instance) | ||
1750 | + print(' writer.beginArray();') | ||
1751 | self.visit(pointer.type, "*" + instance) | ||
1752 | - print ' writer.endArray();' | ||
1753 | - print ' } else {' | ||
1754 | - print ' writer.writeNull();' | ||
1755 | - print ' }' | ||
1756 | + print(' writer.endArray();') | ||
1757 | + print(' } else {') | ||
1758 | + print(' writer.writeNull();') | ||
1759 | + print(' }') | ||
1760 | |||
1761 | def visitIntPointer(self, pointer, instance): | ||
1762 | - print ' writer.writeInt((uintptr_t)%s);' % instance | ||
1763 | + print(' writer.writeInt((uintptr_t)%s);' % instance) | ||
1764 | |||
1765 | def visitObjPointer(self, pointer, instance): | ||
1766 | - print ' writer.writeInt((uintptr_t)%s);' % instance | ||
1767 | + print(' writer.writeInt((uintptr_t)%s);' % instance) | ||
1768 | |||
1769 | def visitLinearPointer(self, pointer, instance): | ||
1770 | - print ' writer.writeInt((uintptr_t)%s);' % instance | ||
1771 | + print(' writer.writeInt((uintptr_t)%s);' % instance) | ||
1772 | |||
1773 | def visitReference(self, reference, instance): | ||
1774 | self.visit(reference.type, instance) | ||
1775 | @@ -146,23 +146,23 @@ class ValueDumper(stdapi.Visitor, stdapi.ExpanderMixin): | ||
1776 | self.visit(alias.type, instance) | ||
1777 | |||
1778 | def visitOpaque(self, opaque, instance): | ||
1779 | - print ' writer.writeInt((uintptr_t)%s);' % instance | ||
1780 | + print(' writer.writeInt((uintptr_t)%s);' % instance) | ||
1781 | |||
1782 | def visitInterface(self, interface, instance): | ||
1783 | assert False | ||
1784 | |||
1785 | def visitPolymorphic(self, polymorphic, instance): | ||
1786 | switchExpr = self.expand(polymorphic.switchExpr) | ||
1787 | - print ' switch (static_cast<int>(%s)) {' % switchExpr | ||
1788 | + print(' switch (static_cast<int>(%s)) {' % switchExpr) | ||
1789 | for cases, type in polymorphic.iterSwitch(): | ||
1790 | for case in cases: | ||
1791 | - print ' %s:' % case | ||
1792 | + print(' %s:' % case) | ||
1793 | caseInstance = instance | ||
1794 | if type.expr is not None: | ||
1795 | caseInstance = 'static_cast<%s>(%s)' % (type, caseInstance) | ||
1796 | self.visit(type, caseInstance) | ||
1797 | - print ' break;' | ||
1798 | - print ' }' | ||
1799 | + print(' break;') | ||
1800 | + print(' }') | ||
1801 | |||
1802 | |||
1803 | class Dumper: | ||
1804 | @@ -187,8 +187,8 @@ class Dumper: | ||
1805 | # Includes | ||
1806 | for module in api.modules: | ||
1807 | for header in module.headers: | ||
1808 | - print header | ||
1809 | |||
1810 | + print(header) | ||
1811 | + print() | ||
1812 | |||
1813 | # Generate the dumper functions | ||
1814 | types = api.getAllTypes() | ||
1815 | @@ -196,13 +196,13 @@ class Dumper: | ||
1816 | self.dumpType(type) | ||
1817 | |||
1818 | def dumpType(self, type): | ||
1819 | - print r'void' | ||
1820 | - print r'dumpStateObject(StateWriter &writer, const %s & so)' % type | ||
1821 | - print r'{' | ||
1822 | + print(r'void') | ||
1823 | + print(r'dumpStateObject(StateWriter &writer, const %s & so)' % type) | ||
1824 | + print(r'{') | ||
1825 | visitor = self.dumperFactory() | ||
1826 | visitor.visit(type, 'so') | ||
1827 | - print r'}' | ||
1828 | |||
1829 | + print(r'}') | ||
1830 | + print() | ||
1831 | |||
1832 | def header(self): | ||
1833 | pass | ||
1834 | @@ -212,10 +212,10 @@ class Dumper: | ||
1835 | |||
1836 | |||
1837 | if __name__ == '__main__': | ||
1838 | - print r'#include "dxgistate_so.hpp"' | ||
1839 | |||
1840 | - print r'#include "state_writer.hpp"' | ||
1841 | |||
1842 | + print(r'#include "dxgistate_so.hpp"') | ||
1843 | + print() | ||
1844 | + print(r'#include "state_writer.hpp"') | ||
1845 | + print() | ||
1846 | |||
1847 | api = stdapi.API() | ||
1848 | api.addModule(dxgi.dxgi) | ||
1849 | diff --git a/retrace/glretrace.py b/retrace/glretrace.py | ||
1850 | index 2ead195d..0dfe5c5b 100644 | ||
1851 | --- a/retrace/glretrace.py | ||
1852 | +++ b/retrace/glretrace.py | ||
1853 | @@ -127,190 +127,190 @@ class GlRetracer(Retracer): | ||
1854 | |||
1855 | # For backwards compatibility with old traces where non VBO drawing was supported | ||
1856 | if (is_array_pointer or is_draw_arrays or is_draw_elements) and not is_draw_indirect: | ||
1857 | - print ' if (retrace::parser->getVersion() < 1) {' | ||
1858 | + print(' if (retrace::parser->getVersion() < 1) {') | ||
1859 | |||
1860 | if is_array_pointer or is_draw_arrays: | ||
1861 | - print ' GLint _array_buffer = 0;' | ||
1862 | - print ' glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &_array_buffer);' | ||
1863 | - print ' if (!_array_buffer) {' | ||
1864 | + print(' GLint _array_buffer = 0;') | ||
1865 | + print(' glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &_array_buffer);') | ||
1866 | + print(' if (!_array_buffer) {') | ||
1867 | self.failFunction(function) | ||
1868 | - print ' }' | ||
1869 | + print(' }') | ||
1870 | |||
1871 | if is_draw_elements: | ||
1872 | - print ' GLint _element_array_buffer = 0;' | ||
1873 | - print ' glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &_element_array_buffer);' | ||
1874 | - print ' if (!_element_array_buffer) {' | ||
1875 | + print(' GLint _element_array_buffer = 0;') | ||
1876 | + print(' glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &_element_array_buffer);') | ||
1877 | + print(' if (!_element_array_buffer) {') | ||
1878 | self.failFunction(function) | ||
1879 | - print ' }' | ||
1880 | + print(' }') | ||
1881 | |||
1882 | - print ' }' | ||
1883 | + print(' }') | ||
1884 | |||
1885 | # When no pack buffer object is bound, the pack functions are no-ops. | ||
1886 | if self.pack_function_regex.match(function.name): | ||
1887 | - print ' GLint _pack_buffer = 0;' | ||
1888 | - print ' glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &_pack_buffer);' | ||
1889 | - print ' if (!_pack_buffer) {' | ||
1890 | - print ' return;' | ||
1891 | - print ' }' | ||
1892 | + print(' GLint _pack_buffer = 0;') | ||
1893 | + print(' glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &_pack_buffer);') | ||
1894 | + print(' if (!_pack_buffer) {') | ||
1895 | + print(' return;') | ||
1896 | + print(' }') | ||
1897 | |||
1898 | # Pre-snapshots | ||
1899 | if self.bind_framebuffer_function_regex.match(function.name): | ||
1900 | - print ' assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);' | ||
1901 | + print(' assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);') | ||
1902 | if function.name == 'glStringMarkerGREMEDY': | ||
1903 | return | ||
1904 | if function.name == 'glFrameTerminatorGREMEDY': | ||
1905 | - print ' glretrace::frame_complete(call);' | ||
1906 | + print(' glretrace::frame_complete(call);') | ||
1907 | return | ||
1908 | |||
1909 | Retracer.retraceFunctionBody(self, function) | ||
1910 | |||
1911 | # Post-snapshots | ||
1912 | if function.name in ('glFlush', 'glFinish'): | ||
1913 | - print ' if (!retrace::doubleBuffer) {' | ||
1914 | - print ' glretrace::frame_complete(call);' | ||
1915 | - print ' }' | ||
1916 | + print(' if (!retrace::doubleBuffer) {') | ||
1917 | + print(' glretrace::frame_complete(call);') | ||
1918 | + print(' }') | ||
1919 | if is_draw_arrays or is_draw_elements or is_misc_draw: | ||
1920 | - print ' assert(call.flags & trace::CALL_FLAG_RENDER);' | ||
1921 | + print(' assert(call.flags & trace::CALL_FLAG_RENDER);') | ||
1922 | |||
1923 | |||
1924 | def invokeFunction(self, function): | ||
1925 | if function.name == "glTexDirectVIVMap" or function.name == "glTexDirectMapVIV" or function.name == "glTexDirectTiledMapVIV": | ||
1926 | - print '#if defined(HAVE_VIVANTE_G2D)' | ||
1927 | - print ' GLint tex;' | ||
1928 | - print ' glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);' | ||
1929 | - print ' int32_t size = 0;' | ||
1930 | - print ' switch(format){' | ||
1931 | - print ' case GL_VIV_YV12:' | ||
1932 | - print ' case GL_VIV_I420:' | ||
1933 | - print ' case GL_VIV_NV12:' | ||
1934 | - print ' case GL_VIV_NV21:' | ||
1935 | - print ' size=width * height * 3 / 2;' | ||
1936 | - print ' break;' | ||
1937 | - print ' case GL_RGBA:' | ||
1938 | - print ' case GL_BGRA_EXT:' | ||
1939 | - print ' size=width * height * 4;' | ||
1940 | - print ' break;' | ||
1941 | - print ' case GL_RGB:' | ||
1942 | - print ' size=width * height *3;' | ||
1943 | - print ' break;' | ||
1944 | - print ' case GL_VIV_YUY2:' | ||
1945 | - print ' case GL_VIV_UYVY:' | ||
1946 | - print ' case GL_RGB565_OES:' | ||
1947 | - print ' case GL_LUMINANCE8_ALPHA8_EXT:' | ||
1948 | - print ' size=width * height *2;' | ||
1949 | - print ' break;' | ||
1950 | - print ' case GL_ALPHA:' | ||
1951 | - print ' size=width * height;' | ||
1952 | - print ' break;' | ||
1953 | - print ' default:' | ||
1954 | - print ' break;' | ||
1955 | - print ' }' | ||
1956 | - print ' if(tex != 0)' | ||
1957 | - print ' {' | ||
1958 | - print ' GLuint pindex = *(GLuint*)Logical;' | ||
1959 | - print ' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];' | ||
1960 | - print ' if(data.privateData == 0) // new entry' | ||
1961 | - print ' {' | ||
1962 | - print ' data.privateData = alloc_dma_buffer(size, (uintptr_t*)&data.logical, &data.physical);' | ||
1963 | - print ' data.index = pindex;' | ||
1964 | - print ' data.size = size;' | ||
1965 | - print ' retrace::addRegion(call,data.index,data.logical,size);' | ||
1966 | - print ' }' | ||
1967 | - print ' else // already have one; check size and index' | ||
1968 | - print ' {' | ||
1969 | - print ' if((size!=data.size)||(pindex!=data.index))' | ||
1970 | - print ' {' | ||
1971 | - print ' retrace::delRegionByPointer(data.logical);' | ||
1972 | - print ' free_dma_buffer(data.privateData);' | ||
1973 | - print ' data.privateData = alloc_dma_buffer(size, (uintptr_t*)&data.logical, &data.physical);' | ||
1974 | - print ' data.index = pindex;' | ||
1975 | - print ' data.size = size;' | ||
1976 | - print ' retrace::addRegion(call,data.index,data.logical,size);' | ||
1977 | - print ' }' | ||
1978 | - print ' }' | ||
1979 | - print ' *Logical = data.logical;' | ||
1980 | - print ' *Physical = data.physical;' | ||
1981 | - print ' }' | ||
1982 | - print '#endif /* HAVE_VIVANTE_G2D */' | ||
1983 | + print('#if defined(HAVE_VIVANTE_G2D)') | ||
1984 | + print(' GLint tex;') | ||
1985 | + print(' glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);') | ||
1986 | + print(' int32_t size = 0;') | ||
1987 | + print(' switch(format){') | ||
1988 | + print(' case GL_VIV_YV12:') | ||
1989 | + print(' case GL_VIV_I420:') | ||
1990 | + print(' case GL_VIV_NV12:') | ||
1991 | + print(' case GL_VIV_NV21:') | ||
1992 | + print(' size=width * height * 3 / 2;') | ||
1993 | + print(' break;') | ||
1994 | + print(' case GL_RGBA:') | ||
1995 | + print(' case GL_BGRA_EXT:') | ||
1996 | + print(' size=width * height * 4;') | ||
1997 | + print(' break;') | ||
1998 | + print(' case GL_RGB:') | ||
1999 | + print(' size=width * height *3;') | ||
2000 | + print(' break;') | ||
2001 | + print(' case GL_VIV_YUY2:') | ||
2002 | + print(' case GL_VIV_UYVY:') | ||
2003 | + print(' case GL_RGB565_OES:') | ||
2004 | + print(' case GL_LUMINANCE8_ALPHA8_EXT:') | ||
2005 | + print(' size=width * height *2;') | ||
2006 | + print(' break;') | ||
2007 | + print(' case GL_ALPHA:') | ||
2008 | + print(' size=width * height;') | ||
2009 | + print(' break;') | ||
2010 | + print(' default:') | ||
2011 | + print(' break;') | ||
2012 | + print(' }') | ||
2013 | + print(' if(tex != 0)') | ||
2014 | + print(' {') | ||
2015 | + print(' GLuint pindex = *(GLuint*)Logical;') | ||
2016 | + print(' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];') | ||
2017 | + print(' if(data.privateData == 0) // new entry') | ||
2018 | + print(' {') | ||
2019 | + print(' data.privateData = alloc_dma_buffer(size, (uintptr_t*)&data.logical, &data.physical);') | ||
2020 | + print(' data.index = pindex;') | ||
2021 | + print(' data.size = size;') | ||
2022 | + print(' retrace::addRegion(call,data.index,data.logical,size);') | ||
2023 | + print(' }') | ||
2024 | + print(' else // already have one; check size and index') | ||
2025 | + print(' {') | ||
2026 | + print(' if((size!=data.size)||(pindex!=data.index))') | ||
2027 | + print(' {') | ||
2028 | + print(' retrace::delRegionByPointer(data.logical);') | ||
2029 | + print(' free_dma_buffer(data.privateData);') | ||
2030 | + print(' data.privateData = alloc_dma_buffer(size, (uintptr_t*)&data.logical, &data.physical);') | ||
2031 | + print(' data.index = pindex;') | ||
2032 | + print(' data.size = size;') | ||
2033 | + print(' retrace::addRegion(call,data.index,data.logical,size);') | ||
2034 | + print(' }') | ||
2035 | + print(' }') | ||
2036 | + print(' *Logical = data.logical;') | ||
2037 | + print(' *Physical = data.physical;') | ||
2038 | + print(' }') | ||
2039 | + print('#endif /* HAVE_VIVANTE_G2D */') | ||
2040 | # Infer the drawable size from GL calls | ||
2041 | if function.name == "glViewport": | ||
2042 | - print ' glretrace::updateDrawable(x + width, y + height);' | ||
2043 | + print(' glretrace::updateDrawable(x + width, y + height);') | ||
2044 | if function.name == "glViewportArray": | ||
2045 | # We are concerned about drawables so only care for the first viewport | ||
2046 | - print ' if (first == 0 && count > 0) {' | ||
2047 | - print ' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];' | ||
2048 | - print ' glretrace::updateDrawable(x + w, y + h);' | ||
2049 | - print ' }' | ||
2050 | + print(' if (first == 0 && count > 0) {') | ||
2051 | + print(' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];') | ||
2052 | + print(' glretrace::updateDrawable(x + w, y + h);') | ||
2053 | + print(' }') | ||
2054 | if function.name == "glViewportIndexedf": | ||
2055 | - print ' if (index == 0) {' | ||
2056 | - print ' glretrace::updateDrawable(x + w, y + h);' | ||
2057 | - print ' }' | ||
2058 | + print(' if (index == 0) {') | ||
2059 | + print(' glretrace::updateDrawable(x + w, y + h);') | ||
2060 | + print(' }') | ||
2061 | if function.name == "glViewportIndexedfv": | ||
2062 | - print ' if (index == 0) {' | ||
2063 | - print ' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];' | ||
2064 | - print ' glretrace::updateDrawable(x + w, y + h);' | ||
2065 | - print ' }' | ||
2066 | + print(' if (index == 0) {') | ||
2067 | + print(' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];') | ||
2068 | + print(' glretrace::updateDrawable(x + w, y + h);') | ||
2069 | + print(' }') | ||
2070 | if function.name in ('glBlitFramebuffer', 'glBlitFramebufferEXT'): | ||
2071 | # Some applications do all their rendering in a framebuffer, and | ||
2072 | # then just blit to the drawable without ever calling glViewport. | ||
2073 | - print ' glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));' | ||
2074 | + print(' glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));') | ||
2075 | |||
2076 | if function.name.startswith('gl') and not function.name.startswith('glX'): | ||
2077 | # The Windows OpenGL runtime will skip calls when there's no | ||
2078 | # context bound to the current context, but this might cause | ||
2079 | # crashes on other systems, particularly with NVIDIA Linux drivers. | ||
2080 | - print r' glretrace::Context *currentContext = glretrace::getCurrentContext();' | ||
2081 | - print r' if (!currentContext) {' | ||
2082 | - print r' if (retrace::debug) {' | ||
2083 | - print r' retrace::warning(call) << "no current context\n";' | ||
2084 | - print r' }' | ||
2085 | - print r'#ifndef _WIN32' | ||
2086 | - print r' return;' | ||
2087 | - print r'#endif' | ||
2088 | - print r' }' | ||
2089 | + print(r' glretrace::Context *currentContext = glretrace::getCurrentContext();') | ||
2090 | + print(r' if (!currentContext) {') | ||
2091 | + print(r' if (retrace::debug) {') | ||
2092 | + print(r' retrace::warning(call) << "no current context\n";') | ||
2093 | + print(r' }') | ||
2094 | + print(r'#ifndef _WIN32') | ||
2095 | + print(r' return;') | ||
2096 | + print(r'#endif') | ||
2097 | + print(r' }') | ||
2098 | |||
2099 | if function.name == "glEnd": | ||
2100 | - print r' if (currentContext) {' | ||
2101 | - print r' currentContext->insideBeginEnd = false;' | ||
2102 | - print r' }' | ||
2103 | + print(r' if (currentContext) {') | ||
2104 | + print(r' currentContext->insideBeginEnd = false;') | ||
2105 | + print(r' }') | ||
2106 | |||
2107 | if function.name == 'memcpy': | ||
2108 | - print ' if (!dest || !src || !n) return;' | ||
2109 | + print(' if (!dest || !src || !n) return;') | ||
2110 | |||
2111 | # Skip glEnable/Disable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) as we don't | ||
2112 | # faithfully set the CONTEXT_DEBUG_BIT_ARB flags on context creation. | ||
2113 | if function.name in ('glEnable', 'glDisable'): | ||
2114 | - print ' if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) return;' | ||
2115 | + print(' if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) return;') | ||
2116 | |||
2117 | # Destroy the buffer mapping | ||
2118 | if self.unmap_function_regex.match(function.name): | ||
2119 | - print r' GLvoid *ptr = NULL;' | ||
2120 | + print(r' GLvoid *ptr = NULL;') | ||
2121 | if function.name == 'glUnmapBuffer': | ||
2122 | - print r' glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);' | ||
2123 | + print(r' glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);') | ||
2124 | elif function.name == 'glUnmapBufferARB': | ||
2125 | - print r' glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);' | ||
2126 | + print(r' glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);') | ||
2127 | elif function.name == 'glUnmapBufferOES': | ||
2128 | - print r' glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);' | ||
2129 | + print(r' glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);') | ||
2130 | elif function.name == 'glUnmapNamedBuffer': | ||
2131 | - print r' glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &ptr);' | ||
2132 | + print(r' glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &ptr);') | ||
2133 | elif function.name == 'glUnmapNamedBufferEXT': | ||
2134 | - print r' glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);' | ||
2135 | + print(r' glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);') | ||
2136 | elif function.name == 'glUnmapObjectBufferATI': | ||
2137 | # TODO | ||
2138 | pass | ||
2139 | else: | ||
2140 | assert False | ||
2141 | - print r' if (ptr) {' | ||
2142 | - print r' retrace::delRegionByPointer(ptr);' | ||
2143 | - print r' } else {' | ||
2144 | - print r' retrace::warning(call) << "failed to get mapped pointer\n";' | ||
2145 | - print r' }' | ||
2146 | + print(r' if (ptr) {') | ||
2147 | + print(r' retrace::delRegionByPointer(ptr);') | ||
2148 | + print(r' } else {') | ||
2149 | + print(r' retrace::warning(call) << "failed to get mapped pointer\n";') | ||
2150 | + print(r' }') | ||
2151 | |||
2152 | if function.name in ('glBindProgramPipeline', 'glBindProgramPipelineEXT'): | ||
2153 | # Note if glBindProgramPipeline has ever been called | ||
2154 | - print r' if (pipeline) {' | ||
2155 | - print r' _pipelineHasBeenBound = true;' | ||
2156 | - print r' }' | ||
2157 | + print(r' if (pipeline) {') | ||
2158 | + print(r' _pipelineHasBeenBound = true;') | ||
2159 | + print(r' }') | ||
2160 | |||
2161 | is_draw_arrays = self.draw_arrays_function_regex.match(function.name) is not None | ||
2162 | is_draw_elements = self.draw_elements_function_regex.match(function.name) is not None | ||
2163 | @@ -325,240 +325,240 @@ class GlRetracer(Retracer): | ||
2164 | |||
2165 | # Keep track of active program for call lists | ||
2166 | if function.name in ('glUseProgram', 'glUseProgramObjectARB'): | ||
2167 | - print r' if (currentContext) {' | ||
2168 | - print r' currentContext->activeProgram = call.arg(0).toUInt();' | ||
2169 | - print r' }' | ||
2170 | + print(r' if (currentContext) {') | ||
2171 | + print(r' currentContext->activeProgram = call.arg(0).toUInt();') | ||
2172 | + print(r' }') | ||
2173 | |||
2174 | # Only profile if not inside a list as the queries get inserted into list | ||
2175 | if function.name == 'glNewList': | ||
2176 | - print r' if (currentContext) {' | ||
2177 | - print r' currentContext->insideList = true;' | ||
2178 | - print r' }' | ||
2179 | + print(r' if (currentContext) {') | ||
2180 | + print(r' currentContext->insideList = true;') | ||
2181 | + print(r' }') | ||
2182 | |||
2183 | if function.name == 'glEndList': | ||
2184 | - print r' if (currentContext) {' | ||
2185 | - print r' currentContext->insideList = false;' | ||
2186 | - print r' }' | ||
2187 | + print(r' if (currentContext) {') | ||
2188 | + print(r' currentContext->insideList = false;') | ||
2189 | + print(r' }') | ||
2190 | |||
2191 | if function.name == 'glBegin' or \ | ||
2192 | is_draw_arrays or \ | ||
2193 | is_draw_elements or \ | ||
2194 | function.name.startswith('glBeginTransformFeedback'): | ||
2195 | - print r' if (retrace::debug) {' | ||
2196 | - print r' _validateActiveProgram(call);' | ||
2197 | - print r' }' | ||
2198 | + print(r' if (retrace::debug) {') | ||
2199 | + print(r' _validateActiveProgram(call);') | ||
2200 | + print(r' }') | ||
2201 | |||
2202 | if function.name != 'glEnd': | ||
2203 | - print r' if (currentContext && !currentContext->insideList && !currentContext->insideBeginEnd && retrace::profiling) {' | ||
2204 | + print(r' if (currentContext && !currentContext->insideList && !currentContext->insideBeginEnd && retrace::profiling) {') | ||
2205 | if profileDraw: | ||
2206 | - print r' glretrace::beginProfile(call, true);' | ||
2207 | + print(r' glretrace::beginProfile(call, true);') | ||
2208 | else: | ||
2209 | - print r' glretrace::beginProfile(call, false);' | ||
2210 | - print r' }' | ||
2211 | + print(r' glretrace::beginProfile(call, false);') | ||
2212 | + print(r' }') | ||
2213 | |||
2214 | if function.name in ('glCreateShaderProgramv', 'glCreateShaderProgramEXT', 'glCreateShaderProgramvEXT'): | ||
2215 | # When dumping state, break down glCreateShaderProgram* so that the | ||
2216 | # shader source can be recovered. | ||
2217 | - print r' if (retrace::dumpingState) {' | ||
2218 | - print r' GLuint _shader = glCreateShader(type);' | ||
2219 | - print r' if (_shader) {' | ||
2220 | + print(r' if (retrace::dumpingState) {') | ||
2221 | + print(r' GLuint _shader = glCreateShader(type);') | ||
2222 | + print(r' if (_shader) {') | ||
2223 | if not function.name.startswith('glCreateShaderProgramv'): | ||
2224 | - print r' GLsizei count = 1;' | ||
2225 | - print r' const GLchar **strings = &string;' | ||
2226 | - print r' glShaderSource(_shader, count, strings, NULL);' | ||
2227 | - print r' glCompileShader(_shader);' | ||
2228 | - print r' const GLuint _program = glCreateProgram();' | ||
2229 | - print r' if (_program) {' | ||
2230 | - print r' GLint compiled = GL_FALSE;' | ||
2231 | - print r' glGetShaderiv(_shader, GL_COMPILE_STATUS, &compiled);' | ||
2232 | + print(r' GLsizei count = 1;') | ||
2233 | + print(r' const GLchar **strings = &string;') | ||
2234 | + print(r' glShaderSource(_shader, count, strings, NULL);') | ||
2235 | + print(r' glCompileShader(_shader);') | ||
2236 | + print(r' const GLuint _program = glCreateProgram();') | ||
2237 | + print(r' if (_program) {') | ||
2238 | + print(r' GLint compiled = GL_FALSE;') | ||
2239 | + print(r' glGetShaderiv(_shader, GL_COMPILE_STATUS, &compiled);') | ||
2240 | if function.name == 'glCreateShaderProgramvEXT': | ||
2241 | - print r' glProgramParameteriEXT(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);' | ||
2242 | + print(r' glProgramParameteriEXT(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);') | ||
2243 | else: | ||
2244 | - print r' glProgramParameteri(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);' | ||
2245 | - print r' if (compiled) {' | ||
2246 | - print r' glAttachShader(_program, _shader);' | ||
2247 | - print r' glLinkProgram(_program);' | ||
2248 | - print r' if (false) glDetachShader(_program, _shader);' | ||
2249 | - print r' }' | ||
2250 | - print r' // TODO: append shader info log to program info log' | ||
2251 | - print r' }' | ||
2252 | - print r' glDeleteShader(_shader);' | ||
2253 | - print r' _result = _program;' | ||
2254 | - print r' } else {' | ||
2255 | - print r' _result = 0;' | ||
2256 | - print r' }' | ||
2257 | - print r' } else {' | ||
2258 | + print(r' glProgramParameteri(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);') | ||
2259 | + print(r' if (compiled) {') | ||
2260 | + print(r' glAttachShader(_program, _shader);') | ||
2261 | + print(r' glLinkProgram(_program);') | ||
2262 | + print(r' if (false) glDetachShader(_program, _shader);') | ||
2263 | + print(r' }') | ||
2264 | + print(r' // TODO: append shader info log to program info log') | ||
2265 | + print(r' }') | ||
2266 | + print(r' glDeleteShader(_shader);') | ||
2267 | + print(r' _result = _program;') | ||
2268 | + print(r' } else {') | ||
2269 | + print(r' _result = 0;') | ||
2270 | + print(r' }') | ||
2271 | + print(r' } else {') | ||
2272 | Retracer.invokeFunction(self, function) | ||
2273 | - print r' }' | ||
2274 | + print(r' }') | ||
2275 | elif function.name in ('glDetachShader', 'glDetachObjectARB'): | ||
2276 | - print r' if (!retrace::dumpingState) {' | ||
2277 | + print(r' if (!retrace::dumpingState) {') | ||
2278 | Retracer.invokeFunction(self, function) | ||
2279 | - print r' }' | ||
2280 | + print(r' }') | ||
2281 | elif function.name == 'glClientWaitSync': | ||
2282 | - print r' _result = glretrace::clientWaitSync(call, sync, flags, timeout);' | ||
2283 | - print r' (void)_result;' | ||
2284 | + print(r' _result = glretrace::clientWaitSync(call, sync, flags, timeout);') | ||
2285 | + print(r' (void)_result;') | ||
2286 | elif function.name == 'glGetSynciv': | ||
2287 | - print r' if (pname == GL_SYNC_STATUS &&' | ||
2288 | - print r' bufSize >= 1 &&' | ||
2289 | - print r' values != NULL &&' | ||
2290 | - print r' call.arg(4)[0].toSInt() == GL_SIGNALED) {' | ||
2291 | - print r' // Fence was signalled, so ensure it happened here' | ||
2292 | - print r' glretrace::blockOnFence(call, sync, GL_SYNC_FLUSH_COMMANDS_BIT);' | ||
2293 | - print r' (void)length;' | ||
2294 | - print r' }' | ||
2295 | + print(r' if (pname == GL_SYNC_STATUS &&') | ||
2296 | + print(r' bufSize >= 1 &&') | ||
2297 | + print(r' values != NULL &&') | ||
2298 | + print(r' call.arg(4)[0].toSInt() == GL_SIGNALED) {') | ||
2299 | + print(r' // Fence was signalled, so ensure it happened here') | ||
2300 | + print(r' glretrace::blockOnFence(call, sync, GL_SYNC_FLUSH_COMMANDS_BIT);') | ||
2301 | + print(r' (void)length;') | ||
2302 | + print(r' }') | ||
2303 | else: | ||
2304 | Retracer.invokeFunction(self, function) | ||
2305 | |||
2306 | if function.name == "glBegin": | ||
2307 | - print ' if (currentContext) {' | ||
2308 | - print ' currentContext->insideBeginEnd = true;' | ||
2309 | - print ' }' | ||
2310 | + print(' if (currentContext) {') | ||
2311 | + print(' currentContext->insideBeginEnd = true;') | ||
2312 | + print(' }') | ||
2313 | |||
2314 | if function.name == "glTexDirectVIV": | ||
2315 | - print '#if defined(HAVE_VIVANTE_G2D)' | ||
2316 | - print ' int32_t ysize = 0;' | ||
2317 | - print ' int32_t usize = 0;' | ||
2318 | - print ' int32_t vsize = 0;' | ||
2319 | - print ' switch(format){' | ||
2320 | - print ' case GL_VIV_YV12:' | ||
2321 | - print ' case GL_VIV_I420:' | ||
2322 | - print ' ysize=width * height;' | ||
2323 | - print ' usize=ysize/4;' | ||
2324 | - print ' vsize=usize;' | ||
2325 | - print ' break;' | ||
2326 | - print ' case GL_VIV_NV12:' | ||
2327 | - print ' case GL_VIV_NV21:' | ||
2328 | - print ' ysize=width * height;' | ||
2329 | - print ' usize=ysize/2;' | ||
2330 | - print ' vsize=0;' | ||
2331 | - print ' break;' | ||
2332 | - print ' case GL_RGBA:' | ||
2333 | - print ' case GL_BGRA_EXT:' | ||
2334 | - print ' ysize=width * height *4;' | ||
2335 | - print ' usize=0;' | ||
2336 | - print ' vsize=0;' | ||
2337 | - print ' break;' | ||
2338 | - print ' case GL_RGB:' | ||
2339 | - print ' ysize=width * height *3;' | ||
2340 | - print ' usize=0;' | ||
2341 | - print ' vsize=0;' | ||
2342 | - print ' break;' | ||
2343 | - print ' case GL_VIV_YUY2:' | ||
2344 | - print ' case GL_VIV_UYVY:' | ||
2345 | - print ' case GL_RGB565_OES:' | ||
2346 | - print ' ysize=width * height *2;' | ||
2347 | - print ' usize=0;' | ||
2348 | - print ' vsize=0;' | ||
2349 | - print ' break;' | ||
2350 | - print ' default:' | ||
2351 | - print ' break;' | ||
2352 | - print ' }' | ||
2353 | - print ' const trace::Array * arrayGLvoid = (call.arg(4)).toArray();' | ||
2354 | - print ' if(ysize > 0)' | ||
2355 | - print ' retrace::addRegion(call,(*arrayGLvoid->values[0]).toUInt(),(GLvoid*)pixels[0], ysize);' | ||
2356 | - print ' if(usize > 0)' | ||
2357 | - print ' retrace::addRegion(call,(*arrayGLvoid->values[1]).toUInt(),(GLvoid*)pixels[1], usize);' | ||
2358 | - print ' if(vsize > 0)' | ||
2359 | - print ' retrace::addRegion(call,(*arrayGLvoid->values[2]).toUInt(),(GLvoid*)pixels[2], vsize);' | ||
2360 | - print '#endif /* HAVE_VIVANTE_G2D */' | ||
2361 | - | ||
2362 | - print r' if (currentContext && !currentContext->insideList && !currentContext->insideBeginEnd && retrace::profiling) {' | ||
2363 | + print('#if defined(HAVE_VIVANTE_G2D)') | ||
2364 | + print(' int32_t ysize = 0;') | ||
2365 | + print(' int32_t usize = 0;') | ||
2366 | + print(' int32_t vsize = 0;') | ||
2367 | + print(' switch(format){') | ||
2368 | + print(' case GL_VIV_YV12:') | ||
2369 | + print(' case GL_VIV_I420:') | ||
2370 | + print(' ysize=width * height;') | ||
2371 | + print(' usize=ysize/4;') | ||
2372 | + print(' vsize=usize;') | ||
2373 | + print(' break;') | ||
2374 | + print(' case GL_VIV_NV12:') | ||
2375 | + print(' case GL_VIV_NV21:') | ||
2376 | + print(' ysize=width * height;') | ||
2377 | + print(' usize=ysize/2;') | ||
2378 | + print(' vsize=0;') | ||
2379 | + print(' break;') | ||
2380 | + print(' case GL_RGBA:') | ||
2381 | + print(' case GL_BGRA_EXT:') | ||
2382 | + print(' ysize=width * height *4;') | ||
2383 | + print(' usize=0;') | ||
2384 | + print(' vsize=0;') | ||
2385 | + print(' break;') | ||
2386 | + print(' case GL_RGB:') | ||
2387 | + print(' ysize=width * height *3;') | ||
2388 | + print(' usize=0;') | ||
2389 | + print(' vsize=0;') | ||
2390 | + print(' break;') | ||
2391 | + print(' case GL_VIV_YUY2:') | ||
2392 | + print(' case GL_VIV_UYVY:') | ||
2393 | + print(' case GL_RGB565_OES:') | ||
2394 | + print(' ysize=width * height *2;') | ||
2395 | + print(' usize=0;') | ||
2396 | + print(' vsize=0;') | ||
2397 | + print(' break;') | ||
2398 | + print(' default:') | ||
2399 | + print(' break;') | ||
2400 | + print(' }') | ||
2401 | + print(' const trace::Array * arrayGLvoid = (call.arg(4)).toArray();') | ||
2402 | + print(' if(ysize > 0)') | ||
2403 | + print(' retrace::addRegion(call,(*arrayGLvoid->values[0]).toUInt(),(GLvoid*)pixels[0], ysize);') | ||
2404 | + print(' if(usize > 0)') | ||
2405 | + print(' retrace::addRegion(call,(*arrayGLvoid->values[1]).toUInt(),(GLvoid*)pixels[1], usize);') | ||
2406 | + print(' if(vsize > 0)') | ||
2407 | + print(' retrace::addRegion(call,(*arrayGLvoid->values[2]).toUInt(),(GLvoid*)pixels[2], vsize);') | ||
2408 | + print('#endif /* HAVE_VIVANTE_G2D */') | ||
2409 | + | ||
2410 | + print(r' if (currentContext && !currentContext->insideList && !currentContext->insideBeginEnd && retrace::profiling) {') | ||
2411 | if profileDraw: | ||
2412 | - print r' glretrace::endProfile(call, true);' | ||
2413 | + print(r' glretrace::endProfile(call, true);') | ||
2414 | else: | ||
2415 | - print r' glretrace::endProfile(call, false);' | ||
2416 | - print r' }' | ||
2417 | + print(r' glretrace::endProfile(call, false);') | ||
2418 | + print(r' }') | ||
2419 | |||
2420 | # Error checking | ||
2421 | if function.name.startswith('gl'): | ||
2422 | # glGetError is not allowed inside glBegin/glEnd | ||
2423 | - print ' if (retrace::debug && currentContext && !currentContext->insideBeginEnd) {' | ||
2424 | - print ' glretrace::checkGlError(call);' | ||
2425 | + print(' if (retrace::debug && currentContext && !currentContext->insideBeginEnd) {') | ||
2426 | + print(' glretrace::checkGlError(call);') | ||
2427 | if function.name in ('glProgramStringARB', 'glLoadProgramNV'): | ||
2428 | - print r' GLint error_position = -1;' | ||
2429 | - print r' glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_position);' | ||
2430 | - print r' if (error_position != -1) {' | ||
2431 | - print r' const char *error_string = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);' | ||
2432 | - print r' retrace::warning(call) << "error in position " << error_position << ": " << error_string << "\n";' | ||
2433 | - print r' }' | ||
2434 | + print(r' GLint error_position = -1;') | ||
2435 | + print(r' glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_position);') | ||
2436 | + print(r' if (error_position != -1) {') | ||
2437 | + print(r' const char *error_string = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);') | ||
2438 | + print(r' retrace::warning(call) << "error in position " << error_position << ": " << error_string << "\n";') | ||
2439 | + print(r' }') | ||
2440 | if function.name == 'glCompileShader': | ||
2441 | - print r' GLint compile_status = 0;' | ||
2442 | - print r' glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);' | ||
2443 | - print r' if (!compile_status) {' | ||
2444 | - print r' retrace::warning(call) << "compilation failed\n";' | ||
2445 | - print r' }' | ||
2446 | - print r' GLint info_log_length = 0;' | ||
2447 | - print r' glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);' | ||
2448 | - print r' if (info_log_length > 1) {' | ||
2449 | - print r' GLchar *infoLog = new GLchar[info_log_length];' | ||
2450 | - print r' glGetShaderInfoLog(shader, info_log_length, NULL, infoLog);' | ||
2451 | - print r' retrace::warning(call) << infoLog << "\n";' | ||
2452 | - print r' delete [] infoLog;' | ||
2453 | - print r' }' | ||
2454 | + print(r' GLint compile_status = 0;') | ||
2455 | + print(r' glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);') | ||
2456 | + print(r' if (!compile_status) {') | ||
2457 | + print(r' retrace::warning(call) << "compilation failed\n";') | ||
2458 | + print(r' }') | ||
2459 | + print(r' GLint info_log_length = 0;') | ||
2460 | + print(r' glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);') | ||
2461 | + print(r' if (info_log_length > 1) {') | ||
2462 | + print(r' GLchar *infoLog = new GLchar[info_log_length];') | ||
2463 | + print(r' glGetShaderInfoLog(shader, info_log_length, NULL, infoLog);') | ||
2464 | + print(r' retrace::warning(call) << infoLog << "\n";') | ||
2465 | + print(r' delete [] infoLog;') | ||
2466 | + print(r' }') | ||
2467 | if function.name in ('glLinkProgram', 'glCreateShaderProgramv', 'glCreateShaderProgramEXT', 'glCreateShaderProgramvEXT', 'glProgramBinary', 'glProgramBinaryOES'): | ||
2468 | if function.name.startswith('glCreateShaderProgram'): | ||
2469 | - print r' GLuint program = _result;' | ||
2470 | - print r' GLint link_status = 0;' | ||
2471 | - print r' glGetProgramiv(program, GL_LINK_STATUS, &link_status);' | ||
2472 | - print r' if (!link_status) {' | ||
2473 | - print r' retrace::warning(call) << "link failed\n";' | ||
2474 | - print r' }' | ||
2475 | - print r' GLint info_log_length = 0;' | ||
2476 | - print r' glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);' | ||
2477 | - print r' if (info_log_length > 1) {' | ||
2478 | - print r' GLchar *infoLog = new GLchar[info_log_length];' | ||
2479 | - print r' glGetProgramInfoLog(program, info_log_length, NULL, infoLog);' | ||
2480 | - print r' retrace::warning(call) << infoLog << "\n";' | ||
2481 | - print r' delete [] infoLog;' | ||
2482 | - print r' }' | ||
2483 | + print(r' GLuint program = _result;') | ||
2484 | + print(r' GLint link_status = 0;') | ||
2485 | + print(r' glGetProgramiv(program, GL_LINK_STATUS, &link_status);') | ||
2486 | + print(r' if (!link_status) {') | ||
2487 | + print(r' retrace::warning(call) << "link failed\n";') | ||
2488 | + print(r' }') | ||
2489 | + print(r' GLint info_log_length = 0;') | ||
2490 | + print(r' glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);') | ||
2491 | + print(r' if (info_log_length > 1) {') | ||
2492 | + print(r' GLchar *infoLog = new GLchar[info_log_length];') | ||
2493 | + print(r' glGetProgramInfoLog(program, info_log_length, NULL, infoLog);') | ||
2494 | + print(r' retrace::warning(call) << infoLog << "\n";') | ||
2495 | + print(r' delete [] infoLog;') | ||
2496 | + print(r' }') | ||
2497 | if function.name == 'glCompileShaderARB': | ||
2498 | - print r' GLint compile_status = 0;' | ||
2499 | - print r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_COMPILE_STATUS_ARB, &compile_status);' | ||
2500 | - print r' if (!compile_status) {' | ||
2501 | - print r' retrace::warning(call) << "compilation failed\n";' | ||
2502 | - print r' }' | ||
2503 | - print r' GLint info_log_length = 0;' | ||
2504 | - print r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);' | ||
2505 | - print r' if (info_log_length > 1) {' | ||
2506 | - print r' GLchar *infoLog = new GLchar[info_log_length];' | ||
2507 | - print r' glGetInfoLogARB(shaderObj, info_log_length, NULL, infoLog);' | ||
2508 | - print r' retrace::warning(call) << infoLog << "\n";' | ||
2509 | - print r' delete [] infoLog;' | ||
2510 | - print r' }' | ||
2511 | + print(r' GLint compile_status = 0;') | ||
2512 | + print(r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_COMPILE_STATUS_ARB, &compile_status);') | ||
2513 | + print(r' if (!compile_status) {') | ||
2514 | + print(r' retrace::warning(call) << "compilation failed\n";') | ||
2515 | + print(r' }') | ||
2516 | + print(r' GLint info_log_length = 0;') | ||
2517 | + print(r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);') | ||
2518 | + print(r' if (info_log_length > 1) {') | ||
2519 | + print(r' GLchar *infoLog = new GLchar[info_log_length];') | ||
2520 | + print(r' glGetInfoLogARB(shaderObj, info_log_length, NULL, infoLog);') | ||
2521 | + print(r' retrace::warning(call) << infoLog << "\n";') | ||
2522 | + print(r' delete [] infoLog;') | ||
2523 | + print(r' }') | ||
2524 | if function.name == 'glLinkProgramARB': | ||
2525 | - print r' GLint link_status = 0;' | ||
2526 | - print r' glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB, &link_status);' | ||
2527 | - print r' if (!link_status) {' | ||
2528 | - print r' retrace::warning(call) << "link failed\n";' | ||
2529 | - print r' }' | ||
2530 | - print r' GLint info_log_length = 0;' | ||
2531 | - print r' glGetObjectParameterivARB(programObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);' | ||
2532 | - print r' if (info_log_length > 1) {' | ||
2533 | - print r' GLchar *infoLog = new GLchar[info_log_length];' | ||
2534 | - print r' glGetInfoLogARB(programObj, info_log_length, NULL, infoLog);' | ||
2535 | - print r' retrace::warning(call) << infoLog << "\n";' | ||
2536 | - print r' delete [] infoLog;' | ||
2537 | - print r' }' | ||
2538 | + print(r' GLint link_status = 0;') | ||
2539 | + print(r' glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB, &link_status);') | ||
2540 | + print(r' if (!link_status) {') | ||
2541 | + print(r' retrace::warning(call) << "link failed\n";') | ||
2542 | + print(r' }') | ||
2543 | + print(r' GLint info_log_length = 0;') | ||
2544 | + print(r' glGetObjectParameterivARB(programObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);') | ||
2545 | + print(r' if (info_log_length > 1) {') | ||
2546 | + print(r' GLchar *infoLog = new GLchar[info_log_length];') | ||
2547 | + print(r' glGetInfoLogARB(programObj, info_log_length, NULL, infoLog);') | ||
2548 | + print(r' retrace::warning(call) << infoLog << "\n";') | ||
2549 | + print(r' delete [] infoLog;') | ||
2550 | + print(r' }') | ||
2551 | if self.map_function_regex.match(function.name): | ||
2552 | - print r' if (!_result) {' | ||
2553 | - print r' retrace::warning(call) << "failed to map buffer\n";' | ||
2554 | - print r' }' | ||
2555 | + print(r' if (!_result) {') | ||
2556 | + print(r' retrace::warning(call) << "failed to map buffer\n";') | ||
2557 | + print(r' }') | ||
2558 | if self.unmap_function_regex.match(function.name) and function.type is not stdapi.Void: | ||
2559 | - print r' if (!_result) {' | ||
2560 | - print r' retrace::warning(call) << "failed to unmap buffer\n";' | ||
2561 | - print r' }' | ||
2562 | + print(r' if (!_result) {') | ||
2563 | + print(r' retrace::warning(call) << "failed to unmap buffer\n";') | ||
2564 | + print(r' }') | ||
2565 | if function.name in ('glGetAttribLocation', 'glGetAttribLocationARB'): | ||
2566 | - print r' GLint _origResult = call.ret->toSInt();' | ||
2567 | - print r' if (_result != _origResult) {' | ||
2568 | - print r' retrace::warning(call) << "vertex attrib location mismatch " << _origResult << " -> " << _result << "\n";' | ||
2569 | - print r' }' | ||
2570 | + print(r' GLint _origResult = call.ret->toSInt();') | ||
2571 | + print(r' if (_result != _origResult) {') | ||
2572 | + print(r' retrace::warning(call) << "vertex attrib location mismatch " << _origResult << " -> " << _result << "\n";') | ||
2573 | + print(r' }') | ||
2574 | if function.name in ('glCheckFramebufferStatus', 'glCheckFramebufferStatusEXT', 'glCheckNamedFramebufferStatus', 'glCheckNamedFramebufferStatusEXT'): | ||
2575 | - print r' GLint _origResult = call.ret->toSInt();' | ||
2576 | - print r' if (_origResult == GL_FRAMEBUFFER_COMPLETE &&' | ||
2577 | - print r' _result != GL_FRAMEBUFFER_COMPLETE) {' | ||
2578 | - print r' retrace::warning(call) << "incomplete framebuffer (" << glstate::enumToString(_result) << ")\n";' | ||
2579 | - print r' }' | ||
2580 | - print ' }' | ||
2581 | + print(r' GLint _origResult = call.ret->toSInt();') | ||
2582 | + print(r' if (_origResult == GL_FRAMEBUFFER_COMPLETE &&') | ||
2583 | + print(r' _result != GL_FRAMEBUFFER_COMPLETE) {') | ||
2584 | + print(r' retrace::warning(call) << "incomplete framebuffer (" << glstate::enumToString(_result) << ")\n";') | ||
2585 | + print(r' }') | ||
2586 | + print(' }') | ||
2587 | |||
2588 | # Query the buffer length for whole buffer mappings | ||
2589 | if self.map_function_regex.match(function.name): | ||
2590 | @@ -566,23 +566,23 @@ class GlRetracer(Retracer): | ||
2591 | assert 'BufferRange' in function.name | ||
2592 | else: | ||
2593 | assert 'BufferRange' not in function.name | ||
2594 | - print r' GLint length = 0;' | ||
2595 | + print(r' GLint length = 0;') | ||
2596 | if function.name in ('glMapBuffer', 'glMapBufferOES'): | ||
2597 | - print r' glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);' | ||
2598 | + print(r' glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);') | ||
2599 | elif function.name == 'glMapBufferARB': | ||
2600 | - print r' glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);' | ||
2601 | + print(r' glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);') | ||
2602 | elif function.name == 'glMapNamedBuffer': | ||
2603 | - print r' glGetNamedBufferParameteriv(buffer, GL_BUFFER_SIZE, &length);' | ||
2604 | + print(r' glGetNamedBufferParameteriv(buffer, GL_BUFFER_SIZE, &length);') | ||
2605 | elif function.name == 'glMapNamedBufferEXT': | ||
2606 | - print r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);' | ||
2607 | + print(r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);') | ||
2608 | elif function.name == 'glMapObjectBufferATI': | ||
2609 | - print r' glGetObjectBufferivATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI, &length);' | ||
2610 | + print(r' glGetObjectBufferivATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI, &length);') | ||
2611 | else: | ||
2612 | assert False | ||
2613 | |||
2614 | def extractArg(self, function, arg, arg_type, lvalue, rvalue): | ||
2615 | if function.name in self.array_pointer_function_names and arg.name == 'pointer': | ||
2616 | - print ' %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue) | ||
2617 | + print(' %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)) | ||
2618 | return | ||
2619 | |||
2620 | if self.draw_elements_function_regex.match(function.name) and arg.name == 'indices' or\ | ||
2621 | @@ -594,18 +594,18 @@ class GlRetracer(Retracer): | ||
2622 | # object. | ||
2623 | if self.pack_function_regex.match(function.name) and arg.output: | ||
2624 | assert isinstance(arg_type, (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque)) | ||
2625 | - print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue) | ||
2626 | + print(' %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue)) | ||
2627 | return | ||
2628 | |||
2629 | if (arg.type.depends(glapi.GLlocation) or \ | ||
2630 | arg.type.depends(glapi.GLsubroutine)) \ | ||
2631 | and 'program' not in function.argNames(): | ||
2632 | # Determine the active program for uniforms swizzling | ||
2633 | - print ' GLint program = _getActiveProgram();' | ||
2634 | + print(' GLint program = _getActiveProgram();') | ||
2635 | |||
2636 | if arg.type is glapi.GLlocationARB \ | ||
2637 | and 'programObj' not in function.argNames(): | ||
2638 | - print ' GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);' | ||
2639 | + print(' GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);') | ||
2640 | |||
2641 | Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) | ||
2642 | |||
2643 | @@ -613,28 +613,28 @@ class GlRetracer(Retracer): | ||
2644 | if arg.name == 'samples': | ||
2645 | if function.name == 'glRasterSamplesEXT': | ||
2646 | assert arg.type is glapi.GLuint | ||
2647 | - print ' GLint max_samples = 0;' | ||
2648 | - print ' glGetIntegerv(GL_MAX_RASTER_SAMPLES_EXT, &max_samples);' | ||
2649 | - print ' if (samples > static_cast<GLuint>(max_samples)) {' | ||
2650 | - print ' samples = static_cast<GLuint>(max_samples);' | ||
2651 | - print ' }' | ||
2652 | + print(' GLint max_samples = 0;') | ||
2653 | + print(' glGetIntegerv(GL_MAX_RASTER_SAMPLES_EXT, &max_samples);') | ||
2654 | + print(' if (samples > static_cast<GLuint>(max_samples)) {') | ||
2655 | + print(' samples = static_cast<GLuint>(max_samples);') | ||
2656 | + print(' }') | ||
2657 | else: | ||
2658 | assert arg.type is glapi.GLsizei | ||
2659 | - print ' GLint max_samples = 0;' | ||
2660 | - print ' glGetIntegerv(GL_MAX_SAMPLES, &max_samples);' | ||
2661 | - print ' if (samples > max_samples) {' | ||
2662 | - print ' samples = max_samples;' | ||
2663 | - print ' }' | ||
2664 | + print(' GLint max_samples = 0;') | ||
2665 | + print(' glGetIntegerv(GL_MAX_SAMPLES, &max_samples);') | ||
2666 | + print(' if (samples > max_samples) {') | ||
2667 | + print(' samples = max_samples;') | ||
2668 | + print(' }') | ||
2669 | |||
2670 | # These parameters are referred beyond the call life-time | ||
2671 | # TODO: Replace ad-hoc solution for bindable parameters with general one | ||
2672 | if function.name in ('glFeedbackBuffer', 'glSelectBuffer') and arg.output: | ||
2673 | - print ' _allocator.bind(%s);' % arg.name | ||
2674 | + print(' _allocator.bind(%s);' % arg.name) | ||
2675 | |||
2676 | |||
2677 | |||
2678 | if __name__ == '__main__': | ||
2679 | - print r''' | ||
2680 | + print(r''' | ||
2681 | #include <string.h> | ||
2682 | |||
2683 | #include "glproc.hpp" | ||
2684 | @@ -692,13 +692,13 @@ static void free_dma_buffer(void *buf) | ||
2685 | |||
2686 | #endif /* HAVE_VIVANTE_G2D */ | ||
2687 | |||
2688 | -''' | ||
2689 | +''') | ||
2690 | api = stdapi.API() | ||
2691 | api.addModule(glapi.glapi) | ||
2692 | retracer = GlRetracer() | ||
2693 | retracer.retraceApi(api) | ||
2694 | |||
2695 | - print r''' | ||
2696 | + print(r''' | ||
2697 | static GLint | ||
2698 | _getActiveProgram(void) | ||
2699 | { | ||
2700 | @@ -771,4 +771,4 @@ _validateActiveProgram(trace::Call &call) | ||
2701 | } | ||
2702 | } | ||
2703 | |||
2704 | -''' | ||
2705 | +''') | ||
2706 | diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py | ||
2707 | index fb49ff9a..bc90f66b 100755 | ||
2708 | --- a/retrace/glstate_params.py | ||
2709 | +++ b/retrace/glstate_params.py | ||
2710 | @@ -134,17 +134,17 @@ class StateGetter(Visitor): | ||
2711 | elem_type = self.inflector.reduced_type(type) | ||
2712 | inflection = self.inflector.inflect(type) | ||
2713 | if inflection.endswith('v' + self.inflector.suffix): | ||
2714 | - print ' %s %s = 0;' % (elem_type, temp_name) | ||
2715 | - print ' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name) | ||
2716 | + print(' %s %s = 0;' % (elem_type, temp_name)) | ||
2717 | + print(' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name)) | ||
2718 | else: | ||
2719 | - print ' %s %s = %s(%s);' % (elem_type, temp_name, inflection, ', '.join(args)) | ||
2720 | + print(' %s %s = %s(%s);' % (elem_type, temp_name, inflection, ', '.join(args))) | ||
2721 | return temp_name | ||
2722 | |||
2723 | def visitString(self, string, args): | ||
2724 | temp_name = self.temp_name(args) | ||
2725 | inflection = self.inflector.inflect(string) | ||
2726 | assert not inflection.endswith('v' + self.inflector.suffix) | ||
2727 | - print ' %s %s = (%s)%s(%s);' % (string, temp_name, string, inflection, ', '.join(args)) | ||
2728 | + print(' %s %s = (%s)%s(%s);' % (string, temp_name, string, inflection, ', '.join(args))) | ||
2729 | return temp_name | ||
2730 | |||
2731 | def visitAlias(self, alias, args): | ||
2732 | @@ -166,28 +166,28 @@ class StateGetter(Visitor): | ||
2733 | array_length = array.length | ||
2734 | if isinstance(array_length, int): | ||
2735 | # Static integer length | ||
2736 | - print ' %s %s[%s + 1];' % (elem_type, temp_name, array_length) | ||
2737 | + print(' %s %s[%s + 1];' % (elem_type, temp_name, array_length)) | ||
2738 | else: | ||
2739 | # Put the length in a variable to avoid recomputing it every time | ||
2740 | - print ' size_t _%s_length = %s;' % (temp_name, array_length) | ||
2741 | + print(' size_t _%s_length = %s;' % (temp_name, array_length)) | ||
2742 | array_length = '_%s_length' % temp_name | ||
2743 | # Allocate a dynamic sized array | ||
2744 | - print ' %s *%s = _allocator.alloc<%s>(%s + 1);' % (elem_type, temp_name, elem_type, array_length) | ||
2745 | - print ' memset(%s, 0, %s * sizeof *%s);' % (temp_name, array_length, temp_name) | ||
2746 | - print ' %s[%s] = (%s)0xdeadc0de;' % (temp_name, array_length, elem_type) | ||
2747 | - print ' if (%s) {' % array_length | ||
2748 | - print ' %s(%s, %s);' % (inflection, ', '.join(args), temp_name) | ||
2749 | - print ' }' | ||
2750 | + print(' %s *%s = _allocator.alloc<%s>(%s + 1);' % (elem_type, temp_name, elem_type, array_length)) | ||
2751 | + print(' memset(%s, 0, %s * sizeof *%s);' % (temp_name, array_length, temp_name)) | ||
2752 | + print(' %s[%s] = (%s)0xdeadc0de;' % (temp_name, array_length, elem_type)) | ||
2753 | + print(' if (%s) {' % array_length) | ||
2754 | + print(' %s(%s, %s);' % (inflection, ', '.join(args), temp_name)) | ||
2755 | + print(' }') | ||
2756 | # Simple buffer overflow detection | ||
2757 | - print ' assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array_length, elem_type) | ||
2758 | + print(' assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array_length, elem_type)) | ||
2759 | return temp_name | ||
2760 | |||
2761 | def visitOpaque(self, pointer, args): | ||
2762 | temp_name = self.temp_name(args) | ||
2763 | inflection = self.inflector.inflect(pointer) | ||
2764 | assert inflection.endswith('v' + self.inflector.suffix) | ||
2765 | - print ' GLvoid *%s;' % temp_name | ||
2766 | - print ' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name) | ||
2767 | + print(' GLvoid *%s;' % temp_name) | ||
2768 | + print(' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name)) | ||
2769 | return temp_name | ||
2770 | |||
2771 | |||
2772 | @@ -236,26 +236,26 @@ class JsonWriter(Visitor): | ||
2773 | |||
2774 | def visitLiteral(self, literal, instance): | ||
2775 | if literal.kind == 'Bool': | ||
2776 | - print ' writer.writeBool(%s);' % instance | ||
2777 | + print(' writer.writeBool(%s);' % instance) | ||
2778 | elif literal.kind in ('SInt', 'Uint'): | ||
2779 | - print ' writer.writeInt(%s);' % instance | ||
2780 | + print(' writer.writeInt(%s);' % instance) | ||
2781 | elif literal.kind in ('Float', 'Double'): | ||
2782 | - print ' writer.writeFloat(%s);' % instance | ||
2783 | + print(' writer.writeFloat(%s);' % instance) | ||
2784 | else: | ||
2785 | raise NotImplementedError | ||
2786 | |||
2787 | def visitString(self, string, instance): | ||
2788 | assert string.length is None | ||
2789 | - print ' writer.writeString((const char *)%s);' % instance | ||
2790 | + print(' writer.writeString((const char *)%s);' % instance) | ||
2791 | |||
2792 | def visitEnum(self, enum, instance): | ||
2793 | if enum is GLboolean: | ||
2794 | - print ' dumpBoolean(writer, %s);' % instance | ||
2795 | + print(' dumpBoolean(writer, %s);' % instance) | ||
2796 | elif enum is GLenum: | ||
2797 | - print ' dumpEnum(writer, %s);' % instance | ||
2798 | + print(' dumpEnum(writer, %s);' % instance) | ||
2799 | else: | ||
2800 | assert False | ||
2801 | - print ' writer.writeInt(%s);' % instance | ||
2802 | + print(' writer.writeInt(%s);' % instance) | ||
2803 | |||
2804 | def visitBitmask(self, bitmask, instance): | ||
2805 | raise NotImplementedError | ||
2806 | @@ -264,18 +264,18 @@ class JsonWriter(Visitor): | ||
2807 | self.visit(alias.type, instance) | ||
2808 | |||
2809 | def visitOpaque(self, opaque, instance): | ||
2810 | - print ' writer.writeInt((size_t)%s);' % instance | ||
2811 | + print(' writer.writeInt((size_t)%s);' % instance) | ||
2812 | |||
2813 | __index = 0 | ||
2814 | |||
2815 | def visitArray(self, array, instance): | ||
2816 | index = '_i%u' % JsonWriter.__index | ||
2817 | JsonWriter.__index += 1 | ||
2818 | - print ' writer.beginArray();' | ||
2819 | - print ' for (unsigned %s = 0; %s < %s; ++%s) {' % (index, index, array.length, index) | ||
2820 | + print(' writer.beginArray();') | ||
2821 | + print(' for (unsigned %s = 0; %s < %s; ++%s) {' % (index, index, array.length, index)) | ||
2822 | self.visit(array.type, '%s[%s]' % (instance, index)) | ||
2823 | - print ' }' | ||
2824 | - print ' writer.endArray();' | ||
2825 | + print(' }') | ||
2826 | + print(' writer.endArray();') | ||
2827 | |||
2828 | |||
2829 | |||
2830 | @@ -287,75 +287,75 @@ class StateDumper: | ||
2831 | pass | ||
2832 | |||
2833 | def dump(self): | ||
2834 | - print '#include <assert.h>' | ||
2835 | - print '#include <string.h>' | ||
2836 | |||
2837 | - print '#include "state_writer.hpp"' | ||
2838 | - print '#include "scoped_allocator.hpp"' | ||
2839 | - print '#include "glproc.hpp"' | ||
2840 | - print '#include "glsize.hpp"' | ||
2841 | - print '#include "glstate.hpp"' | ||
2842 | - print '#include "glstate_internal.hpp"' | ||
2843 | |||
2844 | - print 'namespace glstate {' | ||
2845 | |||
2846 | - | ||
2847 | - print 'const char *' | ||
2848 | - print 'enumToString(GLenum pname)' | ||
2849 | - print '{' | ||
2850 | - print ' switch (pname) {' | ||
2851 | + print('#include <assert.h>') | ||
2852 | + print('#include <string.h>') | ||
2853 | + print() | ||
2854 | + print('#include "state_writer.hpp"') | ||
2855 | + print('#include "scoped_allocator.hpp"') | ||
2856 | + print('#include "glproc.hpp"') | ||
2857 | + print('#include "glsize.hpp"') | ||
2858 | + print('#include "glstate.hpp"') | ||
2859 | + print('#include "glstate_internal.hpp"') | ||
2860 | + print() | ||
2861 | + print('namespace glstate {') | ||
2862 | + print() | ||
2863 | + | ||
2864 | + print('const char *') | ||
2865 | + print('enumToString(GLenum pname)') | ||
2866 | + print('{') | ||
2867 | + print(' switch (pname) {') | ||
2868 | for name in GLenum.values: | ||
2869 | - print ' case %s:' % name | ||
2870 | - print ' return "%s";' % name | ||
2871 | - print ' default:' | ||
2872 | - print ' return NULL;' | ||
2873 | - print ' }' | ||
2874 | - print '}' | ||
2875 | |||
2876 | - | ||
2877 | - print 'static void' | ||
2878 | - print 'dumpTextureTargetParameters(StateWriter &writer, Context &context, GLenum target, GLuint texture)' | ||
2879 | - print '{' | ||
2880 | - print ' writer.beginMember(enumToString(target));' | ||
2881 | - print ' writer.beginObject();' | ||
2882 | - print ' dumpObjectLabel(writer, context, GL_TEXTURE, texture, "GL_TEXTURE_LABEL");' | ||
2883 | + print(' case %s:' % name) | ||
2884 | + print(' return "%s";' % name) | ||
2885 | + print(' default:') | ||
2886 | + print(' return NULL;') | ||
2887 | + print(' }') | ||
2888 | + print('}') | ||
2889 | + print() | ||
2890 | + | ||
2891 | + print('static void') | ||
2892 | + print('dumpTextureTargetParameters(StateWriter &writer, Context &context, GLenum target, GLuint texture)') | ||
2893 | + print('{') | ||
2894 | + print(' writer.beginMember(enumToString(target));') | ||
2895 | + print(' writer.beginObject();') | ||
2896 | + print(' dumpObjectLabel(writer, context, GL_TEXTURE, texture, "GL_TEXTURE_LABEL");') | ||
2897 | # ARB_texture_buffer forbids glGetTexParameter and | ||
2898 | # glGetTexLevelParameter for TEXTURE_BUFFER, but | ||
2899 | # ARB_texture_buffer_range introduced parameters which can be queries | ||
2900 | # with glGetTexLevelParameter... | ||
2901 | - print ' if (target != GL_TEXTURE_BUFFER) {' | ||
2902 | + print(' if (target != GL_TEXTURE_BUFFER) {') | ||
2903 | self.dump_atoms(glGetTexParameter, 'target') | ||
2904 | - print ' }' | ||
2905 | - print ' if (!context.ES) {' | ||
2906 | - print ' GLenum levelTarget;' | ||
2907 | - print ' if (target == GL_TEXTURE_CUBE_MAP ||' | ||
2908 | - print ' target == GL_TEXTURE_CUBE_MAP_ARRAY) {' | ||
2909 | - print ' // Must pick a face' | ||
2910 | - print ' levelTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X;' | ||
2911 | - print ' } else {' | ||
2912 | - print ' levelTarget = target;' | ||
2913 | - print ' }' | ||
2914 | + print(' }') | ||
2915 | + print(' if (!context.ES) {') | ||
2916 | + print(' GLenum levelTarget;') | ||
2917 | + print(' if (target == GL_TEXTURE_CUBE_MAP ||') | ||
2918 | + print(' target == GL_TEXTURE_CUBE_MAP_ARRAY) {') | ||
2919 | + print(' // Must pick a face') | ||
2920 | + print(' levelTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X;') | ||
2921 | + print(' } else {') | ||
2922 | + print(' levelTarget = target;') | ||
2923 | + print(' }') | ||
2924 | self.dump_atoms(glGetTexLevelParameter, 'levelTarget', '0') | ||
2925 | - print ' }' | ||
2926 | - print ' writer.endObject();' | ||
2927 | - print ' writer.endMember(); // target' | ||
2928 | - print '}' | ||
2929 | |||
2930 | - | ||
2931 | - print 'static void' | ||
2932 | - print 'dumpFramebufferAttachementParameters(StateWriter &writer, Context &context, GLenum target, GLenum attachment)' | ||
2933 | - print '{' | ||
2934 | + print(' }') | ||
2935 | + print(' writer.endObject();') | ||
2936 | + print(' writer.endMember(); // target') | ||
2937 | + print('}') | ||
2938 | + print() | ||
2939 | + | ||
2940 | + print('static void') | ||
2941 | + print('dumpFramebufferAttachementParameters(StateWriter &writer, Context &context, GLenum target, GLenum attachment)') | ||
2942 | + print('{') | ||
2943 | self.dump_attachment_parameters('target', 'attachment') | ||
2944 | - print '}' | ||
2945 | |||
2946 | - | ||
2947 | - print 'void dumpParameters(StateWriter &writer, Context &context)' | ||
2948 | - print '{' | ||
2949 | - print ' ScopedAllocator _allocator;' | ||
2950 | - print ' (void)_allocator;' | ||
2951 | |||
2952 | - print ' writer.beginMember("parameters");' | ||
2953 | - print ' writer.beginObject();' | ||
2954 | + print('}') | ||
2955 | + print() | ||
2956 | + | ||
2957 | + print('void dumpParameters(StateWriter &writer, Context &context)') | ||
2958 | + print('{') | ||
2959 | + print(' ScopedAllocator _allocator;') | ||
2960 | + print(' (void)_allocator;') | ||
2961 | + print() | ||
2962 | + print(' writer.beginMember("parameters");') | ||
2963 | + print(' writer.beginObject();') | ||
2964 | |||
2965 | self.dump_atoms(glGet) | ||
2966 | |||
2967 | @@ -368,58 +368,58 @@ class StateDumper: | ||
2968 | self.dump_framebuffer_parameters() | ||
2969 | self.dump_labels() | ||
2970 | |||
2971 | - print ' writer.endObject();' | ||
2972 | - print ' writer.endMember(); // parameters' | ||
2973 | - print '}' | ||
2974 | |||
2975 | + print(' writer.endObject();') | ||
2976 | + print(' writer.endMember(); // parameters') | ||
2977 | + print('}') | ||
2978 | + print() | ||
2979 | |||
2980 | - print '} /*namespace glstate */' | ||
2981 | + print('} /*namespace glstate */') | ||
2982 | |||
2983 | def dump_material_params(self): | ||
2984 | - print ' if (!context.ES) {' | ||
2985 | + print(' if (!context.ES) {') | ||
2986 | for face in ['GL_FRONT', 'GL_BACK']: | ||
2987 | - print ' writer.beginMember("%s");' % face | ||
2988 | - print ' writer.beginObject();' | ||
2989 | + print(' writer.beginMember("%s");' % face) | ||
2990 | + print(' writer.beginObject();') | ||
2991 | self.dump_atoms(glGetMaterial, face) | ||
2992 | - print ' writer.endObject();' | ||
2993 | - print ' }' | ||
2994 | |||
2995 | + print(' writer.endObject();') | ||
2996 | + print(' }') | ||
2997 | + print() | ||
2998 | |||
2999 | def dump_light_params(self): | ||
3000 | - print ' GLint max_lights = 0;' | ||
3001 | - print ' _glGetIntegerv(GL_MAX_LIGHTS, &max_lights);' | ||
3002 | - print ' for (GLint index = 0; index < max_lights; ++index) {' | ||
3003 | - print ' GLenum light = GL_LIGHT0 + index;' | ||
3004 | - print ' if (glIsEnabled(light)) {' | ||
3005 | - print ' char name[32];' | ||
3006 | - print ' snprintf(name, sizeof name, "GL_LIGHT%i", index);' | ||
3007 | - print ' writer.beginMember(name);' | ||
3008 | - print ' writer.beginObject();' | ||
3009 | + print(' GLint max_lights = 0;') | ||
3010 | + print(' _glGetIntegerv(GL_MAX_LIGHTS, &max_lights);') | ||
3011 | + print(' for (GLint index = 0; index < max_lights; ++index) {') | ||
3012 | + print(' GLenum light = GL_LIGHT0 + index;') | ||
3013 | + print(' if (glIsEnabled(light)) {') | ||
3014 | + print(' char name[32];') | ||
3015 | + print(' snprintf(name, sizeof name, "GL_LIGHT%i", index);') | ||
3016 | + print(' writer.beginMember(name);') | ||
3017 | + print(' writer.beginObject();') | ||
3018 | self.dump_atoms(glGetLight, ' GL_LIGHT0 + index') | ||
3019 | - print ' writer.endObject();' | ||
3020 | - print ' writer.endMember(); // GL_LIGHTi' | ||
3021 | - print ' }' | ||
3022 | - print ' }' | ||
3023 | |||
3024 | + print(' writer.endObject();') | ||
3025 | + print(' writer.endMember(); // GL_LIGHTi') | ||
3026 | + print(' }') | ||
3027 | + print(' }') | ||
3028 | + print() | ||
3029 | |||
3030 | def dump_sampler_params(self): | ||
3031 | - print ' // GL_SAMPLER_BINDING' | ||
3032 | - print ' if (context.ARB_sampler_objects) {' | ||
3033 | - print ' GLint sampler_binding = 0;' | ||
3034 | - print ' glGetIntegerv(GL_SAMPLER_BINDING, &sampler_binding);' | ||
3035 | - print ' writer.beginMember("GL_SAMPLER_BINDING");' | ||
3036 | - print ' writer.writeInt(sampler_binding);' | ||
3037 | - print ' writer.endMember();' | ||
3038 | - print ' if (sampler_binding) {' | ||
3039 | - print ' writer.beginMember("GL_SAMPLER");' | ||
3040 | - print ' writer.beginObject();' | ||
3041 | - print ' dumpObjectLabel(writer, context, GL_SAMPLER, sampler_binding, "GL_SAMPLER_LABEL");' | ||
3042 | + print(' // GL_SAMPLER_BINDING') | ||
3043 | + print(' if (context.ARB_sampler_objects) {') | ||
3044 | + print(' GLint sampler_binding = 0;') | ||
3045 | + print(' glGetIntegerv(GL_SAMPLER_BINDING, &sampler_binding);') | ||
3046 | + print(' writer.beginMember("GL_SAMPLER_BINDING");') | ||
3047 | + print(' writer.writeInt(sampler_binding);') | ||
3048 | + print(' writer.endMember();') | ||
3049 | + print(' if (sampler_binding) {') | ||
3050 | + print(' writer.beginMember("GL_SAMPLER");') | ||
3051 | + print(' writer.beginObject();') | ||
3052 | + print(' dumpObjectLabel(writer, context, GL_SAMPLER, sampler_binding, "GL_SAMPLER_LABEL");') | ||
3053 | for _, _, name in glGetSamplerParameter.iter(): | ||
3054 | self.dump_atom(glGetSamplerParameter, 'sampler_binding', name) | ||
3055 | - print ' writer.endObject();' | ||
3056 | - print ' writer.endMember(); // GL_SAMPLER' | ||
3057 | - print ' }' | ||
3058 | - print ' }' | ||
3059 | + print(' writer.endObject();') | ||
3060 | + print(' writer.endMember(); // GL_SAMPLER') | ||
3061 | + print(' }') | ||
3062 | + print(' }') | ||
3063 | |||
3064 | def texenv_param_target(self, name): | ||
3065 | if name == 'GL_TEXTURE_LOD_BIAS': | ||
3066 | @@ -431,34 +431,34 @@ class StateDumper: | ||
3067 | |||
3068 | def dump_texenv_params(self): | ||
3069 | for target in ['GL_TEXTURE_ENV', 'GL_TEXTURE_FILTER_CONTROL', 'GL_POINT_SPRITE']: | ||
3070 | - print ' if (!context.ES) {' | ||
3071 | - print ' writer.beginMember("%s");' % target | ||
3072 | - print ' writer.beginObject();' | ||
3073 | + print(' if (!context.ES) {') | ||
3074 | + print(' writer.beginMember("%s");' % target) | ||
3075 | + print(' writer.beginObject();') | ||
3076 | for _, _, name in glGetTexEnv.iter(): | ||
3077 | if self.texenv_param_target(name) == target: | ||
3078 | self.dump_atom(glGetTexEnv, target, name) | ||
3079 | - print ' writer.endObject();' | ||
3080 | - print ' }' | ||
3081 | + print(' writer.endObject();') | ||
3082 | + print(' }') | ||
3083 | |||
3084 | def dump_vertex_attribs(self): | ||
3085 | - print ' GLint max_vertex_attribs = 0;' | ||
3086 | - print ' _glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs);' | ||
3087 | - print ' for (GLint index = 0; index < max_vertex_attribs; ++index) {' | ||
3088 | - print ' char name[32];' | ||
3089 | - print ' snprintf(name, sizeof name, "GL_VERTEX_ATTRIB_ARRAY%i", index);' | ||
3090 | - print ' writer.beginMember(name);' | ||
3091 | - print ' writer.beginObject();' | ||
3092 | + print(' GLint max_vertex_attribs = 0;') | ||
3093 | + print(' _glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs);') | ||
3094 | + print(' for (GLint index = 0; index < max_vertex_attribs; ++index) {') | ||
3095 | + print(' char name[32];') | ||
3096 | + print(' snprintf(name, sizeof name, "GL_VERTEX_ATTRIB_ARRAY%i", index);') | ||
3097 | + print(' writer.beginMember(name);') | ||
3098 | + print(' writer.beginObject();') | ||
3099 | self.dump_atoms(glGetVertexAttrib, 'index') | ||
3100 | |||
3101 | # Dump vertex attrib buffer label | ||
3102 | - print ' GLint buffer_binding = 0;' | ||
3103 | - print ' glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &buffer_binding);' | ||
3104 | - print ' dumpObjectLabel(writer, context, GL_BUFFER, buffer_binding, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_LABEL");' | ||
3105 | + print(' GLint buffer_binding = 0;') | ||
3106 | + print(' glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &buffer_binding);') | ||
3107 | + print(' dumpObjectLabel(writer, context, GL_BUFFER, buffer_binding, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_LABEL");') | ||
3108 | |||
3109 | - print ' writer.endObject();' | ||
3110 | - print ' writer.endMember(); // GL_VERTEX_ATTRIB_ARRAYi' | ||
3111 | - print ' }' | ||
3112 | |||
3113 | + print(' writer.endObject();') | ||
3114 | + print(' writer.endMember(); // GL_VERTEX_ATTRIB_ARRAYi') | ||
3115 | + print(' }') | ||
3116 | + print() | ||
3117 | |||
3118 | object_bindings = [ | ||
3119 | ('GL_BUFFER', 'GL_ARRAY_BUFFER_BINDING'), | ||
3120 | @@ -488,11 +488,11 @@ class StateDumper: | ||
3121 | member_name = object_binding.replace('BINDING', 'LABEL') | ||
3122 | if member_name == object_binding: | ||
3123 | member_name += '_LABEL' | ||
3124 | - print ' {' | ||
3125 | - print ' GLint binding = 0;' | ||
3126 | - print ' glGetIntegerv(%s, &binding);' % object_binding | ||
3127 | - print ' dumpObjectLabel(writer, context, %s, binding, "%s");' % (object_type, member_name) | ||
3128 | - print ' }' | ||
3129 | + print(' {') | ||
3130 | + print(' GLint binding = 0;') | ||
3131 | + print(' glGetIntegerv(%s, &binding);' % object_binding) | ||
3132 | + print(' dumpObjectLabel(writer, context, %s, binding, "%s");' % (object_type, member_name)) | ||
3133 | + print(' }') | ||
3134 | |||
3135 | program_targets = [ | ||
3136 | 'GL_FRAGMENT_PROGRAM_ARB', | ||
3137 | @@ -501,12 +501,12 @@ class StateDumper: | ||
3138 | |||
3139 | def dump_program_params(self): | ||
3140 | for target in self.program_targets: | ||
3141 | - print ' if (glIsEnabled(%s)) {' % target | ||
3142 | - print ' writer.beginMember("%s");' % target | ||
3143 | - print ' writer.beginObject();' | ||
3144 | + print(' if (glIsEnabled(%s)) {' % target) | ||
3145 | + print(' writer.beginMember("%s");' % target) | ||
3146 | + print(' writer.beginObject();') | ||
3147 | self.dump_atoms(glGetProgramARB, target) | ||
3148 | - print ' writer.endObject();' | ||
3149 | - print ' }' | ||
3150 | + print(' writer.endObject();') | ||
3151 | + print(' }') | ||
3152 | |||
3153 | buffer_targets = [ | ||
3154 | ('GL_ARRAY_BUFFER', 'GL_ARRAY_BUFFER_BINDING', None), | ||
3155 | @@ -529,135 +529,135 @@ class StateDumper: | ||
3156 | def dump_buffer_parameters(self): | ||
3157 | # general binding points | ||
3158 | for target, binding, max_bindings in self.buffer_targets: | ||
3159 | - print ' // %s' % target | ||
3160 | - print ' {' | ||
3161 | - print ' writer.beginMember("%s");' % target | ||
3162 | - print ' writer.beginObject();' | ||
3163 | - print ' GLint buffer = 0;' | ||
3164 | - print ' glGetIntegerv(%s, &buffer);' % binding | ||
3165 | - print ' if (buffer) {' | ||
3166 | + print(' // %s' % target) | ||
3167 | + print(' {') | ||
3168 | + print(' writer.beginMember("%s");' % target) | ||
3169 | + print(' writer.beginObject();') | ||
3170 | + print(' GLint buffer = 0;') | ||
3171 | + print(' glGetIntegerv(%s, &buffer);' % binding) | ||
3172 | + print(' if (buffer) {') | ||
3173 | self.dump_atoms(glGetBufferParameter, target) | ||
3174 | - print ' }' | ||
3175 | + print(' }') | ||
3176 | if max_bindings is not None: | ||
3177 | # indexed binding points | ||
3178 | start = target + '_START' | ||
3179 | size = target + '_SIZE' | ||
3180 | - print ' GLint max_bindings = 0;' | ||
3181 | - print ' glGetIntegerv(%s, &max_bindings);' % max_bindings | ||
3182 | - print ' if (max_bindings) {' | ||
3183 | - print ' writer.beginMember("i");' | ||
3184 | - print ' writer.beginArray();' | ||
3185 | - print ' for (GLint i = 0; i < max_bindings; ++i) {' | ||
3186 | - print ' writer.beginObject();' | ||
3187 | + print(' GLint max_bindings = 0;') | ||
3188 | + print(' glGetIntegerv(%s, &max_bindings);' % max_bindings) | ||
3189 | + print(' if (max_bindings) {') | ||
3190 | + print(' writer.beginMember("i");') | ||
3191 | + print(' writer.beginArray();') | ||
3192 | + print(' for (GLint i = 0; i < max_bindings; ++i) {') | ||
3193 | + print(' writer.beginObject();') | ||
3194 | for pname in [binding, start, size]: | ||
3195 | self.dump_atom(glGet_i, pname, 'i') | ||
3196 | - print ' writer.endObject();' | ||
3197 | - print ' }' | ||
3198 | - print ' writer.endArray();' | ||
3199 | - print ' writer.endMember();' | ||
3200 | - print ' }' | ||
3201 | + print(' writer.endObject();') | ||
3202 | + print(' }') | ||
3203 | + print(' writer.endArray();') | ||
3204 | + print(' writer.endMember();') | ||
3205 | + print(' }') | ||
3206 | |||
3207 | - print ' writer.endObject();' | ||
3208 | - print ' writer.endMember();' | ||
3209 | - print ' }' | ||
3210 | |||
3211 | + print(' writer.endObject();') | ||
3212 | + print(' writer.endMember();') | ||
3213 | + print(' }') | ||
3214 | + print() | ||
3215 | |||
3216 | def dump_texture_parameters(self): | ||
3217 | - print ' {' | ||
3218 | - print ' GLint active_texture = GL_TEXTURE0;' | ||
3219 | - print ' glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);' | ||
3220 | - print ' GLint max_texture_coords = 0;' | ||
3221 | - print ' if (!context.core) {' | ||
3222 | - print ' glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);' | ||
3223 | - print ' }' | ||
3224 | - print ' GLint max_combined_texture_image_units = 0;' | ||
3225 | - print ' glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);' | ||
3226 | - print ' max_combined_texture_image_units = std::max(max_combined_texture_image_units, 2);' | ||
3227 | - print ' GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);' | ||
3228 | - print ' for (GLint unit = 0; unit < max_units; ++unit) {' | ||
3229 | - print ' char name[32];' | ||
3230 | - print ' snprintf(name, sizeof name, "GL_TEXTURE%i", unit);' | ||
3231 | - print ' writer.beginMember(name);' | ||
3232 | - print ' glActiveTexture(GL_TEXTURE0 + unit);' | ||
3233 | - print ' writer.beginObject();' | ||
3234 | |||
3235 | + print(' {') | ||
3236 | + print(' GLint active_texture = GL_TEXTURE0;') | ||
3237 | + print(' glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);') | ||
3238 | + print(' GLint max_texture_coords = 0;') | ||
3239 | + print(' if (!context.core) {') | ||
3240 | + print(' glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);') | ||
3241 | + print(' }') | ||
3242 | + print(' GLint max_combined_texture_image_units = 0;') | ||
3243 | + print(' glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);') | ||
3244 | + print(' max_combined_texture_image_units = std::max(max_combined_texture_image_units, 2);') | ||
3245 | + print(' GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);') | ||
3246 | + print(' for (GLint unit = 0; unit < max_units; ++unit) {') | ||
3247 | + print(' char name[32];') | ||
3248 | + print(' snprintf(name, sizeof name, "GL_TEXTURE%i", unit);') | ||
3249 | + print(' writer.beginMember(name);') | ||
3250 | + print(' glActiveTexture(GL_TEXTURE0 + unit);') | ||
3251 | + print(' writer.beginObject();') | ||
3252 | + print() | ||
3253 | self.dump_atoms(glGet_texture) | ||
3254 | |||
3255 | - print ' for (unsigned i = 0; i < numTextureTargets; ++i) {' | ||
3256 | - print ' GLenum target = textureTargets[i];' | ||
3257 | - print ' GLboolean enabled = GL_FALSE;' | ||
3258 | - print ' if (unit < max_texture_coords &&' | ||
3259 | - print ' (target == GL_TEXTURE_1D ||' | ||
3260 | - print ' target == GL_TEXTURE_2D ||' | ||
3261 | - print ' target == GL_TEXTURE_3D ||' | ||
3262 | - print ' target == GL_TEXTURE_CUBE_MAP ||' | ||
3263 | - print ' target == GL_TEXTURE_RECTANGLE)) {' | ||
3264 | - print ' glGetBooleanv(target, &enabled);' | ||
3265 | - print ' writer.beginMember(enumToString(target));' | ||
3266 | - print ' dumpBoolean(writer, enabled);' | ||
3267 | - print ' writer.endMember();' | ||
3268 | - print ' }' | ||
3269 | - print ' GLint texture = 0;' | ||
3270 | - print ' GLenum binding = getTextureBinding(target);' | ||
3271 | - print ' glGetIntegerv(binding, &texture);' | ||
3272 | - print ' if (enabled || texture) {' | ||
3273 | - print ' dumpTextureTargetParameters(writer, context, target, texture);' | ||
3274 | - print ' }' | ||
3275 | - print ' }' | ||
3276 | |||
3277 | + print() | ||
3278 | + print(' for (unsigned i = 0; i < numTextureTargets; ++i) {') | ||
3279 | + print(' GLenum target = textureTargets[i];') | ||
3280 | + print(' GLboolean enabled = GL_FALSE;') | ||
3281 | + print(' if (unit < max_texture_coords &&') | ||
3282 | + print(' (target == GL_TEXTURE_1D ||') | ||
3283 | + print(' target == GL_TEXTURE_2D ||') | ||
3284 | + print(' target == GL_TEXTURE_3D ||') | ||
3285 | + print(' target == GL_TEXTURE_CUBE_MAP ||') | ||
3286 | + print(' target == GL_TEXTURE_RECTANGLE)) {') | ||
3287 | + print(' glGetBooleanv(target, &enabled);') | ||
3288 | + print(' writer.beginMember(enumToString(target));') | ||
3289 | + print(' dumpBoolean(writer, enabled);') | ||
3290 | + print(' writer.endMember();') | ||
3291 | + print(' }') | ||
3292 | + print(' GLint texture = 0;') | ||
3293 | + print(' GLenum binding = getTextureBinding(target);') | ||
3294 | + print(' glGetIntegerv(binding, &texture);') | ||
3295 | + print(' if (enabled || texture) {') | ||
3296 | + print(' dumpTextureTargetParameters(writer, context, target, texture);') | ||
3297 | + print(' }') | ||
3298 | + print(' }') | ||
3299 | + print() | ||
3300 | self.dump_sampler_params() | ||
3301 | |||
3302 | - print ' if (unit < max_texture_coords) {' | ||
3303 | + print() | ||
3304 | + print(' if (unit < max_texture_coords) {') | ||
3305 | self.dump_texenv_params() | ||
3306 | - print ' }' | ||
3307 | - print ' writer.endObject();' | ||
3308 | - print ' writer.endMember(); // GL_TEXTUREi' | ||
3309 | - print ' }' | ||
3310 | - print ' glActiveTexture(active_texture);' | ||
3311 | - print ' }' | ||
3312 | |||
3313 | + print(' }') | ||
3314 | + print(' writer.endObject();') | ||
3315 | + print(' writer.endMember(); // GL_TEXTUREi') | ||
3316 | + print(' }') | ||
3317 | + print(' glActiveTexture(active_texture);') | ||
3318 | + print(' }') | ||
3319 | + print() | ||
3320 | |||
3321 | def dump_framebuffer_parameters(self): | ||
3322 | - print ' {' | ||
3323 | - print ' GLint max_color_attachments = 0;' | ||
3324 | - print ' glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);' | ||
3325 | - print ' GLint framebuffer;' | ||
3326 | + print(' {') | ||
3327 | + print(' GLint max_color_attachments = 0;') | ||
3328 | + print(' glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);') | ||
3329 | + print(' GLint framebuffer;') | ||
3330 | for target, binding in framebuffer_targets: | ||
3331 | - print ' // %s' % target | ||
3332 | - print ' framebuffer = 0;' | ||
3333 | - print ' glGetIntegerv(%s, &framebuffer);' % binding | ||
3334 | - print ' if (framebuffer) {' | ||
3335 | - print ' writer.beginMember("%s");' % target | ||
3336 | - print ' writer.beginObject();' | ||
3337 | - print ' dumpObjectLabel(writer, context, GL_FRAMEBUFFER, framebuffer, "GL_FRAMEBUFFER_LABEL");' | ||
3338 | - print ' for (GLint i = 0; i < max_color_attachments; ++i) {' | ||
3339 | - print ' GLint color_attachment = GL_COLOR_ATTACHMENT0 + i;' | ||
3340 | - print ' dumpFramebufferAttachementParameters(writer, context, %s, color_attachment);' % target | ||
3341 | - print ' }' | ||
3342 | - print ' dumpFramebufferAttachementParameters(writer, context, %s, GL_DEPTH_ATTACHMENT);' % target | ||
3343 | - print ' dumpFramebufferAttachementParameters(writer, context, %s, GL_STENCIL_ATTACHMENT);' % target | ||
3344 | - print ' writer.endObject();' | ||
3345 | - print ' writer.endMember(); // %s' % target | ||
3346 | - print ' }' | ||
3347 | |||
3348 | - print ' }' | ||
3349 | |||
3350 | + print(' // %s' % target) | ||
3351 | + print(' framebuffer = 0;') | ||
3352 | + print(' glGetIntegerv(%s, &framebuffer);' % binding) | ||
3353 | + print(' if (framebuffer) {') | ||
3354 | + print(' writer.beginMember("%s");' % target) | ||
3355 | + print(' writer.beginObject();') | ||
3356 | + print(' dumpObjectLabel(writer, context, GL_FRAMEBUFFER, framebuffer, "GL_FRAMEBUFFER_LABEL");') | ||
3357 | + print(' for (GLint i = 0; i < max_color_attachments; ++i) {') | ||
3358 | + print(' GLint color_attachment = GL_COLOR_ATTACHMENT0 + i;') | ||
3359 | + print(' dumpFramebufferAttachementParameters(writer, context, %s, color_attachment);' % target) | ||
3360 | + print(' }') | ||
3361 | + print(' dumpFramebufferAttachementParameters(writer, context, %s, GL_DEPTH_ATTACHMENT);' % target) | ||
3362 | + print(' dumpFramebufferAttachementParameters(writer, context, %s, GL_STENCIL_ATTACHMENT);' % target) | ||
3363 | + print(' writer.endObject();') | ||
3364 | + print(' writer.endMember(); // %s' % target) | ||
3365 | + print(' }') | ||
3366 | + print() | ||
3367 | + print(' }') | ||
3368 | + print() | ||
3369 | |||
3370 | def dump_attachment_parameters(self, target, attachment): | ||
3371 | - print ' {' | ||
3372 | - print ' GLint object_type = GL_NONE;' | ||
3373 | - print ' glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);' % (target, attachment) | ||
3374 | - print ' if (object_type != GL_NONE) {' | ||
3375 | - print ' writer.beginMember(enumToString(%s));' % attachment | ||
3376 | - print ' writer.beginObject();' | ||
3377 | + print(' {') | ||
3378 | + print(' GLint object_type = GL_NONE;') | ||
3379 | + print(' glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);' % (target, attachment)) | ||
3380 | + print(' if (object_type != GL_NONE) {') | ||
3381 | + print(' writer.beginMember(enumToString(%s));' % attachment) | ||
3382 | + print(' writer.beginObject();') | ||
3383 | self.dump_atoms(glGetFramebufferAttachmentParameter, target, attachment) | ||
3384 | - print ' GLint object_name = 0;' | ||
3385 | - print ' glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &object_name);' % (target, attachment) | ||
3386 | - print ' dumpObjectLabel(writer, context, object_type, object_name, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_LABEL");' | ||
3387 | - print ' writer.endObject();' | ||
3388 | - print ' writer.endMember(); // GL_x_ATTACHMENT' | ||
3389 | - print ' }' | ||
3390 | - print ' }' | ||
3391 | + print(' GLint object_name = 0;') | ||
3392 | + print(' glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &object_name);' % (target, attachment)) | ||
3393 | + print(' dumpObjectLabel(writer, context, object_type, object_name, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_LABEL");') | ||
3394 | + print(' writer.endObject();') | ||
3395 | + print(' writer.endMember(); // GL_x_ATTACHMENT') | ||
3396 | + print(' }') | ||
3397 | + print(' }') | ||
3398 | |||
3399 | def dump_atoms(self, getter, *args): | ||
3400 | for _, _, name in getter.iter(): | ||
3401 | @@ -666,20 +666,20 @@ class StateDumper: | ||
3402 | def dump_atom(self, getter, *args): | ||
3403 | name = args[getter.pnameIdx] | ||
3404 | |||
3405 | - print ' // %s' % name | ||
3406 | - print ' {' | ||
3407 | - print ' flushErrors();' | ||
3408 | + print(' // %s' % name) | ||
3409 | + print(' {') | ||
3410 | + print(' flushErrors();') | ||
3411 | type, value = getter(*args) | ||
3412 | - print ' if (glGetError() != GL_NO_ERROR) {' | ||
3413 | + print(' if (glGetError() != GL_NO_ERROR) {') | ||
3414 | #print ' std::cerr << "warning: %s(%s) failed\\n";' % (inflection, name) | ||
3415 | - print ' flushErrors();' | ||
3416 | - print ' } else {' | ||
3417 | - print ' writer.beginMember("%s");' % name | ||
3418 | + print(' flushErrors();') | ||
3419 | + print(' } else {') | ||
3420 | + print(' writer.beginMember("%s");' % name) | ||
3421 | JsonWriter().visit(type, value) | ||
3422 | - print ' writer.endMember();' | ||
3423 | - print ' }' | ||
3424 | - print ' }' | ||
3425 | |||
3426 | + print(' writer.endMember();') | ||
3427 | + print(' }') | ||
3428 | + print(' }') | ||
3429 | + print() | ||
3430 | |||
3431 | |||
3432 | if __name__ == '__main__': | ||
3433 | diff --git a/retrace/retrace.py b/retrace/retrace.py | ||
3434 | index 164944ed..0149817c 100644 | ||
3435 | --- a/retrace/retrace.py | ||
3436 | +++ b/retrace/retrace.py | ||
3437 | @@ -69,10 +69,10 @@ class ValueAllocator(stdapi.Visitor): | ||
3438 | pass | ||
3439 | |||
3440 | def visitArray(self, array, lvalue, rvalue): | ||
3441 | - print ' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, array.type, rvalue) | ||
3442 | + print(' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, array.type, rvalue)) | ||
3443 | |||
3444 | def visitPointer(self, pointer, lvalue, rvalue): | ||
3445 | - print ' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, pointer.type, rvalue) | ||
3446 | + print(' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, pointer.type, rvalue)) | ||
3447 | |||
3448 | def visitIntPointer(self, pointer, lvalue, rvalue): | ||
3449 | pass | ||
3450 | @@ -109,7 +109,7 @@ class ValueAllocator(stdapi.Visitor): | ||
3451 | class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3452 | |||
3453 | def visitLiteral(self, literal, lvalue, rvalue): | ||
3454 | - print ' %s = (%s).to%s();' % (lvalue, rvalue, literal.kind) | ||
3455 | + print(' %s = (%s).to%s();' % (lvalue, rvalue, literal.kind)) | ||
3456 | |||
3457 | def visitConst(self, const, lvalue, rvalue): | ||
3458 | self.visit(const.type, lvalue, rvalue) | ||
3459 | @@ -118,7 +118,7 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3460 | self.visit(alias.type, lvalue, rvalue) | ||
3461 | |||
3462 | def visitEnum(self, enum, lvalue, rvalue): | ||
3463 | - print ' %s = static_cast<%s>((%s).toSInt());' % (lvalue, enum, rvalue) | ||
3464 | + print(' %s = static_cast<%s>((%s).toSInt());' % (lvalue, enum, rvalue)) | ||
3465 | |||
3466 | def visitBitmask(self, bitmask, lvalue, rvalue): | ||
3467 | self.visit(bitmask.type, lvalue, rvalue) | ||
3468 | @@ -127,50 +127,50 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3469 | tmp = '_a_' + array.tag + '_' + str(self.seq) | ||
3470 | self.seq += 1 | ||
3471 | |||
3472 | - print ' const trace::Array *%s = (%s).toArray();' % (tmp, rvalue) | ||
3473 | - print ' if (%s) {' % (tmp,) | ||
3474 | + print(' const trace::Array *%s = (%s).toArray();' % (tmp, rvalue)) | ||
3475 | + print(' if (%s) {' % (tmp,)) | ||
3476 | |||
3477 | length = '%s->values.size()' % (tmp,) | ||
3478 | if self.insideStruct: | ||
3479 | if isinstance(array.length, int): | ||
3480 | # Member is an array | ||
3481 | - print r' static_assert( std::is_array< std::remove_reference< decltype( %s ) >::type >::value , "lvalue must be an array" );' % lvalue | ||
3482 | - print r' static_assert( std::extent< std::remove_reference< decltype( %s ) >::type >::value == %s, "array size mismatch" );' % (lvalue, array.length) | ||
3483 | - print r' assert( %s );' % (tmp,) | ||
3484 | - print r' assert( %s->size() == %s );' % (tmp, array.length) | ||
3485 | + print(r' static_assert( std::is_array< std::remove_reference< decltype( %s ) >::type >::value , "lvalue must be an array" );' % lvalue) | ||
3486 | + print(r' static_assert( std::extent< std::remove_reference< decltype( %s ) >::type >::value == %s, "array size mismatch" );' % (lvalue, array.length)) | ||
3487 | + print(r' assert( %s );' % (tmp,)) | ||
3488 | + print(r' assert( %s->size() == %s );' % (tmp, array.length)) | ||
3489 | length = str(array.length) | ||
3490 | else: | ||
3491 | # Member is a pointer to an array, hence must be allocated | ||
3492 | - print r' static_assert( std::is_pointer< std::remove_reference< decltype( %s ) >::type >::value , "lvalue must be a pointer" );' % lvalue | ||
3493 | - print r' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, array.type, rvalue) | ||
3494 | + print(r' static_assert( std::is_pointer< std::remove_reference< decltype( %s ) >::type >::value , "lvalue must be a pointer" );' % lvalue) | ||
3495 | + print(r' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, array.type, rvalue)) | ||
3496 | |||
3497 | index = '_j' + array.tag | ||
3498 | - print ' for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length) | ||
3499 | + print(' for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)) | ||
3500 | try: | ||
3501 | self.visit(array.type, '%s[%s]' % (lvalue, index), '*%s->values[%s]' % (tmp, index)) | ||
3502 | finally: | ||
3503 | - print ' }' | ||
3504 | - print ' }' | ||
3505 | + print(' }') | ||
3506 | + print(' }') | ||
3507 | |||
3508 | def visitPointer(self, pointer, lvalue, rvalue): | ||
3509 | tmp = '_a_' + pointer.tag + '_' + str(self.seq) | ||
3510 | self.seq += 1 | ||
3511 | |||
3512 | - print ' if (%s) {' % (lvalue,) | ||
3513 | - print ' const trace::Array *%s = (%s).toArray();' % (tmp, rvalue) | ||
3514 | + print(' if (%s) {' % (lvalue,)) | ||
3515 | + print(' const trace::Array *%s = (%s).toArray();' % (tmp, rvalue)) | ||
3516 | try: | ||
3517 | self.visit(pointer.type, '%s[0]' % (lvalue,), '*%s->values[0]' % (tmp,)) | ||
3518 | finally: | ||
3519 | - print ' }' | ||
3520 | + print(' }') | ||
3521 | |||
3522 | def visitIntPointer(self, pointer, lvalue, rvalue): | ||
3523 | - print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, pointer, rvalue) | ||
3524 | + print(' %s = static_cast<%s>((%s).toPointer());' % (lvalue, pointer, rvalue)) | ||
3525 | |||
3526 | def visitObjPointer(self, pointer, lvalue, rvalue): | ||
3527 | - print ' %s = retrace::asObjPointer<%s>(call, %s);' % (lvalue, pointer.type, rvalue) | ||
3528 | + print(' %s = retrace::asObjPointer<%s>(call, %s);' % (lvalue, pointer.type, rvalue)) | ||
3529 | |||
3530 | def visitLinearPointer(self, pointer, lvalue, rvalue): | ||
3531 | - print ' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, pointer, rvalue) | ||
3532 | + print(' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, pointer, rvalue)) | ||
3533 | |||
3534 | def visitReference(self, reference, lvalue, rvalue): | ||
3535 | self.visit(reference.type, lvalue, rvalue); | ||
3536 | @@ -179,23 +179,23 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3537 | #OpaqueValueDeserializer().visit(handle.type, lvalue, rvalue); | ||
3538 | self.visit(handle.type, lvalue, rvalue); | ||
3539 | new_lvalue = lookupHandle(handle, lvalue) | ||
3540 | - print ' if (retrace::verbosity >= 2) {' | ||
3541 | - print ' std::cout << "%s " << size_t(%s) << " <- " << size_t(%s) << "\\n";' % (handle.name, lvalue, new_lvalue) | ||
3542 | - print ' }' | ||
3543 | + print(' if (retrace::verbosity >= 2) {') | ||
3544 | + print(' std::cout << "%s " << size_t(%s) << " <- " << size_t(%s) << "\\n";' % (handle.name, lvalue, new_lvalue)) | ||
3545 | + print(' }') | ||
3546 | if (new_lvalue.startswith('_program_map') or new_lvalue.startswith('_shader_map')): | ||
3547 | - print 'if (glretrace::supportsARBShaderObjects) {' | ||
3548 | - print ' %s = _handleARB_map[%s];' % (lvalue, lvalue) | ||
3549 | - print '} else {' | ||
3550 | - print ' %s = %s;' % (lvalue, new_lvalue) | ||
3551 | - print '}' | ||
3552 | + print('if (glretrace::supportsARBShaderObjects) {') | ||
3553 | + print(' %s = _handleARB_map[%s];' % (lvalue, lvalue)) | ||
3554 | + print('} else {') | ||
3555 | + print(' %s = %s;' % (lvalue, new_lvalue)) | ||
3556 | + print('}') | ||
3557 | else: | ||
3558 | - print ' %s = %s;' % (lvalue, new_lvalue) | ||
3559 | + print(' %s = %s;' % (lvalue, new_lvalue)) | ||
3560 | |||
3561 | def visitBlob(self, blob, lvalue, rvalue): | ||
3562 | - print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, blob, rvalue) | ||
3563 | + print(' %s = static_cast<%s>((%s).toPointer());' % (lvalue, blob, rvalue)) | ||
3564 | |||
3565 | def visitString(self, string, lvalue, rvalue): | ||
3566 | - print ' %s = (%s)((%s).toString());' % (lvalue, string.expr, rvalue) | ||
3567 | + print(' %s = (%s)((%s).toString());' % (lvalue, string.expr, rvalue)) | ||
3568 | |||
3569 | seq = 0 | ||
3570 | |||
3571 | @@ -207,8 +207,8 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3572 | |||
3573 | self.insideStruct += 1 | ||
3574 | |||
3575 | - print ' const trace::Struct *%s = (%s).toStruct();' % (tmp, rvalue) | ||
3576 | - print ' assert(%s);' % (tmp) | ||
3577 | + print(' const trace::Struct *%s = (%s).toStruct();' % (tmp, rvalue)) | ||
3578 | + print(' assert(%s);' % (tmp)) | ||
3579 | for i in range(len(struct.members)): | ||
3580 | member = struct.members[i] | ||
3581 | self.visitMember(member, lvalue, '*%s->members[%s]' % (tmp, i)) | ||
3582 | @@ -218,24 +218,24 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3583 | def visitPolymorphic(self, polymorphic, lvalue, rvalue): | ||
3584 | if polymorphic.defaultType is None: | ||
3585 | switchExpr = self.expand(polymorphic.switchExpr) | ||
3586 | - print r' switch (%s) {' % switchExpr | ||
3587 | + print(r' switch (%s) {' % switchExpr) | ||
3588 | for cases, type in polymorphic.iterSwitch(): | ||
3589 | for case in cases: | ||
3590 | - print r' %s:' % case | ||
3591 | + print(r' %s:' % case) | ||
3592 | caseLvalue = lvalue | ||
3593 | if type.expr is not None: | ||
3594 | caseLvalue = 'static_cast<%s>(%s)' % (type, caseLvalue) | ||
3595 | - print r' {' | ||
3596 | + print(r' {') | ||
3597 | try: | ||
3598 | self.visit(type, caseLvalue, rvalue) | ||
3599 | finally: | ||
3600 | - print r' }' | ||
3601 | - print r' break;' | ||
3602 | + print(r' }') | ||
3603 | + print(r' break;') | ||
3604 | if polymorphic.defaultType is None: | ||
3605 | - print r' default:' | ||
3606 | - print r' retrace::warning(call) << "unexpected polymorphic case" << %s << "\n";' % (switchExpr,) | ||
3607 | - print r' break;' | ||
3608 | - print r' }' | ||
3609 | + print(r' default:') | ||
3610 | + print(r' retrace::warning(call) << "unexpected polymorphic case" << %s << "\n";' % (switchExpr,)) | ||
3611 | + print(r' break;') | ||
3612 | + print(r' }') | ||
3613 | else: | ||
3614 | self.visit(polymorphic.defaultType, lvalue, rvalue) | ||
3615 | |||
3616 | @@ -250,7 +250,7 @@ class OpaqueValueDeserializer(ValueDeserializer): | ||
3617 | in the context of handles.''' | ||
3618 | |||
3619 | def visitOpaque(self, opaque, lvalue, rvalue): | ||
3620 | - print ' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, opaque, rvalue) | ||
3621 | + print(' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, opaque, rvalue)) | ||
3622 | |||
3623 | |||
3624 | class SwizzledValueRegistrator(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3625 | @@ -270,67 +270,67 @@ class SwizzledValueRegistrator(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3626 | pass | ||
3627 | |||
3628 | def visitArray(self, array, lvalue, rvalue): | ||
3629 | - print ' const trace::Array *_a%s = (%s).toArray();' % (array.tag, rvalue) | ||
3630 | - print ' if (_a%s) {' % (array.tag) | ||
3631 | + print(' const trace::Array *_a%s = (%s).toArray();' % (array.tag, rvalue)) | ||
3632 | + print(' if (_a%s) {' % (array.tag)) | ||
3633 | length = '_a%s->values.size()' % array.tag | ||
3634 | index = '_j' + array.tag | ||
3635 | - print ' for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length) | ||
3636 | + print(' for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)) | ||
3637 | try: | ||
3638 | self.visit(array.type, '%s[%s]' % (lvalue, index), '*_a%s->values[%s]' % (array.tag, index)) | ||
3639 | finally: | ||
3640 | - print ' }' | ||
3641 | - print ' }' | ||
3642 | + print(' }') | ||
3643 | + print(' }') | ||
3644 | |||
3645 | def visitPointer(self, pointer, lvalue, rvalue): | ||
3646 | - print ' const trace::Array *_a%s = (%s).toArray();' % (pointer.tag, rvalue) | ||
3647 | - print ' if (_a%s) {' % (pointer.tag) | ||
3648 | + print(' const trace::Array *_a%s = (%s).toArray();' % (pointer.tag, rvalue)) | ||
3649 | + print(' if (_a%s) {' % (pointer.tag)) | ||
3650 | try: | ||
3651 | self.visit(pointer.type, '%s[0]' % (lvalue,), '*_a%s->values[0]' % (pointer.tag,)) | ||
3652 | finally: | ||
3653 | - print ' }' | ||
3654 | + print(' }') | ||
3655 | |||
3656 | def visitIntPointer(self, pointer, lvalue, rvalue): | ||
3657 | pass | ||
3658 | |||
3659 | def visitObjPointer(self, pointer, lvalue, rvalue): | ||
3660 | - print r' retrace::addObj(call, %s, %s);' % (rvalue, lvalue) | ||
3661 | + print(r' retrace::addObj(call, %s, %s);' % (rvalue, lvalue)) | ||
3662 | |||
3663 | def visitLinearPointer(self, pointer, lvalue, rvalue): | ||
3664 | assert pointer.size is not None | ||
3665 | if pointer.size is not None: | ||
3666 | - print r' retrace::addRegion(call, (%s).toUIntPtr(), %s, %s);' % (rvalue, lvalue, pointer.size) | ||
3667 | + print(r' retrace::addRegion(call, (%s).toUIntPtr(), %s, %s);' % (rvalue, lvalue, pointer.size)) | ||
3668 | |||
3669 | def visitReference(self, reference, lvalue, rvalue): | ||
3670 | pass | ||
3671 | |||
3672 | def visitHandle(self, handle, lvalue, rvalue): | ||
3673 | - print ' %s _origResult;' % handle.type | ||
3674 | + print(' %s _origResult;' % handle.type) | ||
3675 | OpaqueValueDeserializer().visit(handle.type, '_origResult', rvalue); | ||
3676 | if handle.range is None: | ||
3677 | rvalue = "_origResult" | ||
3678 | entry = lookupHandle(handle, rvalue, True) | ||
3679 | if (entry.startswith('_program_map') or entry.startswith('_shader_map')): | ||
3680 | - print 'if (glretrace::supportsARBShaderObjects) {' | ||
3681 | - print ' _handleARB_map[%s] = %s;' % (rvalue, lvalue) | ||
3682 | - print '} else {' | ||
3683 | - print ' %s = %s;' % (entry, lvalue) | ||
3684 | - print '}' | ||
3685 | + print('if (glretrace::supportsARBShaderObjects) {') | ||
3686 | + print(' _handleARB_map[%s] = %s;' % (rvalue, lvalue)) | ||
3687 | + print('} else {') | ||
3688 | + print(' %s = %s;' % (entry, lvalue)) | ||
3689 | + print('}') | ||
3690 | else: | ||
3691 | - print " %s = %s;" % (entry, lvalue) | ||
3692 | - print ' if (retrace::verbosity >= 2) {' | ||
3693 | - print ' std::cout << "{handle.name} " << {rvalue} << " -> " << {lvalue} << "\\n";'.format(**locals()) | ||
3694 | - print ' }' | ||
3695 | + print(" %s = %s;" % (entry, lvalue)) | ||
3696 | + print(' if (retrace::verbosity >= 2) {') | ||
3697 | + print(' std::cout << "{handle.name} " << {rvalue} << " -> " << {lvalue} << "\\n";'.format(**locals())) | ||
3698 | + print(' }') | ||
3699 | else: | ||
3700 | i = '_h' + handle.tag | ||
3701 | lvalue = "%s + %s" % (lvalue, i) | ||
3702 | rvalue = "_origResult + %s" % (i,) | ||
3703 | entry = lookupHandle(handle, rvalue) | ||
3704 | - print ' for ({handle.type} {i} = 0; {i} < {handle.range}; ++{i}) {{'.format(**locals()) | ||
3705 | - print ' {entry} = {lvalue};'.format(**locals()) | ||
3706 | - print ' if (retrace::verbosity >= 2) {' | ||
3707 | - print ' std::cout << "{handle.name} " << ({rvalue}) << " -> " << ({lvalue}) << "\\n";'.format(**locals()) | ||
3708 | - print ' }' | ||
3709 | - print ' }' | ||
3710 | + print(' for ({handle.type} {i} = 0; {i} < {handle.range}; ++{i}) {{'.format(**locals())) | ||
3711 | + print(' {entry} = {lvalue};'.format(**locals())) | ||
3712 | + print(' if (retrace::verbosity >= 2) {') | ||
3713 | + print(' std::cout << "{handle.name} " << ({rvalue}) << " -> " << ({lvalue}) << "\\n";'.format(**locals())) | ||
3714 | + print(' }') | ||
3715 | + print(' }') | ||
3716 | |||
3717 | def visitBlob(self, blob, lvalue, rvalue): | ||
3718 | pass | ||
3719 | @@ -344,9 +344,9 @@ class SwizzledValueRegistrator(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3720 | tmp = '_s_' + struct.tag + '_' + str(self.seq) | ||
3721 | self.seq += 1 | ||
3722 | |||
3723 | - print ' const trace::Struct *%s = (%s).toStruct();' % (tmp, rvalue) | ||
3724 | - print ' assert(%s);' % (tmp,) | ||
3725 | - print ' (void)%s;' % (tmp,) | ||
3726 | + print(' const trace::Struct *%s = (%s).toStruct();' % (tmp, rvalue)) | ||
3727 | + print(' assert(%s);' % (tmp,)) | ||
3728 | + print(' (void)%s;' % (tmp,)) | ||
3729 | for i in range(len(struct.members)): | ||
3730 | member = struct.members[i] | ||
3731 | self.visitMember(member, lvalue, '*%s->members[%s]' % (tmp, i)) | ||
3732 | @@ -362,16 +362,16 @@ class SwizzledValueRegistrator(stdapi.Visitor, stdapi.ExpanderMixin): | ||
3733 | class Retracer: | ||
3734 | |||
3735 | def retraceFunction(self, function): | ||
3736 | - print 'static void retrace_%s(trace::Call &call) {' % function.name | ||
3737 | + print('static void retrace_%s(trace::Call &call) {' % function.name) | ||
3738 | self.retraceFunctionBody(function) | ||
3739 | - print '}' | ||
3740 | |||
3741 | + print('}') | ||
3742 | + print() | ||
3743 | |||
3744 | def retraceInterfaceMethod(self, interface, method): | ||
3745 | - print 'static void retrace_%s__%s(trace::Call &call) {' % (interface.name, method.name) | ||
3746 | + print('static void retrace_%s__%s(trace::Call &call) {' % (interface.name, method.name)) | ||
3747 | self.retraceInterfaceMethodBody(interface, method) | ||
3748 | - print '}' | ||
3749 | |||
3750 | + print('}') | ||
3751 | + print() | ||
3752 | |||
3753 | def retraceFunctionBody(self, function): | ||
3754 | assert function.sideeffects | ||
3755 | @@ -409,38 +409,38 @@ class Retracer: | ||
3756 | assert function.type is not stdapi.Void | ||
3757 | |||
3758 | if str(function.type) == 'HRESULT': | ||
3759 | - print r' if (call.ret && FAILED(call.ret->toSInt())) {' | ||
3760 | - print r' return;' | ||
3761 | - print r' }' | ||
3762 | + print(r' if (call.ret && FAILED(call.ret->toSInt())) {') | ||
3763 | + print(r' return;') | ||
3764 | + print(r' }') | ||
3765 | |||
3766 | def deserializeThisPointer(self, interface): | ||
3767 | - print r' %s *_this;' % (interface.name,) | ||
3768 | - print r' _this = retrace::asObjPointer<%s>(call, call.arg(0));' % (interface.name,) | ||
3769 | - print r' if (!_this) {' | ||
3770 | - print r' return;' | ||
3771 | - print r' }' | ||
3772 | + print(r' %s *_this;' % (interface.name,)) | ||
3773 | + print(r' _this = retrace::asObjPointer<%s>(call, call.arg(0));' % (interface.name,)) | ||
3774 | + print(r' if (!_this) {') | ||
3775 | + print(r' return;') | ||
3776 | + print(r' }') | ||
3777 | |||
3778 | def deserializeArgs(self, function): | ||
3779 | - print ' retrace::ScopedAllocator _allocator;' | ||
3780 | - print ' (void)_allocator;' | ||
3781 | + print(' retrace::ScopedAllocator _allocator;') | ||
3782 | + print(' (void)_allocator;') | ||
3783 | success = True | ||
3784 | for arg in function.args: | ||
3785 | arg_type = arg.type.mutable() | ||
3786 | - print ' %s %s;' % (arg_type, arg.name) | ||
3787 | + print(' %s %s;' % (arg_type, arg.name)) | ||
3788 | rvalue = 'call.arg(%u)' % (arg.index,) | ||
3789 | lvalue = arg.name | ||
3790 | try: | ||
3791 | self.extractArg(function, arg, arg_type, lvalue, rvalue) | ||
3792 | except UnsupportedType: | ||
3793 | success = False | ||
3794 | - print ' memset(&%s, 0, sizeof %s); // FIXME' % (arg.name, arg.name) | ||
3795 | |||
3796 | + print(' memset(&%s, 0, sizeof %s); // FIXME' % (arg.name, arg.name)) | ||
3797 | + print() | ||
3798 | |||
3799 | if not success: | ||
3800 | - print ' if (1) {' | ||
3801 | + print(' if (1) {') | ||
3802 | self.failFunction(function) | ||
3803 | sys.stderr.write('warning: unsupported %s call\n' % function.name) | ||
3804 | - print ' }' | ||
3805 | + print(' }') | ||
3806 | |||
3807 | def swizzleValues(self, function): | ||
3808 | for arg in function.args: | ||
3809 | @@ -451,7 +451,7 @@ class Retracer: | ||
3810 | try: | ||
3811 | self.regiterSwizzledValue(arg_type, lvalue, rvalue) | ||
3812 | except UnsupportedType: | ||
3813 | - print ' // XXX: %s' % arg.name | ||
3814 | + print(' // XXX: %s' % arg.name) | ||
3815 | if function.type is not stdapi.Void: | ||
3816 | rvalue = '*call.ret' | ||
3817 | lvalue = '_result' | ||
3818 | @@ -459,15 +459,15 @@ class Retracer: | ||
3819 | self.regiterSwizzledValue(function.type, lvalue, rvalue) | ||
3820 | except UnsupportedType: | ||
3821 | raise | ||
3822 | - print ' // XXX: result' | ||
3823 | + print(' // XXX: result') | ||
3824 | |||
3825 | def failFunction(self, function): | ||
3826 | - print ' if (retrace::verbosity >= 0) {' | ||
3827 | - print ' retrace::unsupported(call);' | ||
3828 | - print ' }' | ||
3829 | + print(' if (retrace::verbosity >= 0) {') | ||
3830 | + print(' retrace::unsupported(call);') | ||
3831 | + print(' }') | ||
3832 | # MGS-469: GPU hangs when retracing OGLESParticles on mx6sx | ||
3833 | # Workaround: do not `return` | ||
3834 | - #print ' return;' | ||
3835 | + #print(' return;') | ||
3836 | |||
3837 | def extractArg(self, function, arg, arg_type, lvalue, rvalue): | ||
3838 | ValueAllocator().visit(arg_type, lvalue, rvalue) | ||
3839 | @@ -487,22 +487,22 @@ class Retracer: | ||
3840 | |||
3841 | def declareRet(self, function): | ||
3842 | if function.type is not stdapi.Void: | ||
3843 | - print ' %s _result;' % (function.type) | ||
3844 | + print(' %s _result;' % (function.type)) | ||
3845 | |||
3846 | def invokeFunction(self, function): | ||
3847 | arg_names = ", ".join(function.argNames()) | ||
3848 | if function.type is not stdapi.Void: | ||
3849 | - print ' _result = %s(%s);' % (function.name, arg_names) | ||
3850 | + print(' _result = %s(%s);' % (function.name, arg_names)) | ||
3851 | self.checkResult(None, function) | ||
3852 | else: | ||
3853 | - print ' %s(%s);' % (function.name, arg_names) | ||
3854 | + print(' %s(%s);' % (function.name, arg_names)) | ||
3855 | |||
3856 | def invokeInterfaceMethod(self, interface, method): | ||
3857 | arg_names = ", ".join(method.argNames()) | ||
3858 | if method.type is not stdapi.Void: | ||
3859 | - print ' _result = _this->%s(%s);' % (method.name, arg_names) | ||
3860 | + print(' _result = _this->%s(%s);' % (method.name, arg_names)) | ||
3861 | else: | ||
3862 | - print ' _this->%s(%s);' % (method.name, arg_names) | ||
3863 | + print(' _this->%s(%s);' % (method.name, arg_names)) | ||
3864 | |||
3865 | # Adjust reference count when QueryInterface fails. This is | ||
3866 | # particularly useful when replaying traces on older Direct3D runtimes | ||
3867 | @@ -511,12 +511,12 @@ class Retracer: | ||
3868 | # | ||
3869 | # TODO: Generalize to other methods that return interfaces | ||
3870 | if method.name == 'QueryInterface': | ||
3871 | - print r' if (FAILED(_result)) {' | ||
3872 | - print r' IUnknown *pObj = retrace::asObjPointer<IUnknown>(call, *call.arg(2).toArray()->values[0]);' | ||
3873 | - print r' if (pObj) {' | ||
3874 | - print r' pObj->AddRef();' | ||
3875 | - print r' }' | ||
3876 | - print r' }' | ||
3877 | + print(r' if (FAILED(_result)) {') | ||
3878 | + print(r' IUnknown *pObj = retrace::asObjPointer<IUnknown>(call, *call.arg(2).toArray()->values[0]);') | ||
3879 | + print(r' if (pObj) {') | ||
3880 | + print(r' pObj->AddRef();') | ||
3881 | + print(r' }') | ||
3882 | + print(r' }') | ||
3883 | |||
3884 | if method.type is not stdapi.Void: | ||
3885 | self.checkResult(interface, method) | ||
3886 | @@ -524,28 +524,28 @@ class Retracer: | ||
3887 | # Debug COM reference counting. Disabled by default as reported | ||
3888 | # reference counts depend on internal implementation details. | ||
3889 | if method.name in ('AddRef', 'Release'): | ||
3890 | - print r' if (0) retrace::checkMismatch(call, "cRef", call.ret, _result);' | ||
3891 | + print(r' if (0) retrace::checkMismatch(call, "cRef", call.ret, _result);') | ||
3892 | |||
3893 | # On release our reference when we reach Release() == 0 call in the | ||
3894 | # trace. | ||
3895 | if method.name == 'Release': | ||
3896 | - print r' ULONG _orig_result = call.ret->toUInt();' | ||
3897 | - print r' if (_orig_result == 0 || _result == 0) {' | ||
3898 | - print r' if (_orig_result != 0) {' | ||
3899 | - print r' retrace::warning(call) << "unexpected object destruction\n";' | ||
3900 | - print r' }' | ||
3901 | - print r' retrace::delObj(call.arg(0));' | ||
3902 | - print r' }' | ||
3903 | + print(r' ULONG _orig_result = call.ret->toUInt();') | ||
3904 | + print(r' if (_orig_result == 0 || _result == 0) {') | ||
3905 | + print(r' if (_orig_result != 0) {') | ||
3906 | + print(r' retrace::warning(call) << "unexpected object destruction\n";') | ||
3907 | + print(r' }') | ||
3908 | + print(r' retrace::delObj(call.arg(0));') | ||
3909 | + print(r' }') | ||
3910 | |||
3911 | def checkResult(self, interface, methodOrFunction): | ||
3912 | assert methodOrFunction.type is not stdapi.Void | ||
3913 | if str(methodOrFunction.type) == 'HRESULT': | ||
3914 | - print r' if (FAILED(_result)) {' | ||
3915 | - print r' retrace::failed(call, _result);' | ||
3916 | - print r' return;' | ||
3917 | - print r' }' | ||
3918 | + print(r' if (FAILED(_result)) {') | ||
3919 | + print(r' retrace::failed(call, _result);') | ||
3920 | + print(r' return;') | ||
3921 | + print(r' }') | ||
3922 | else: | ||
3923 | - print r' (void)_result;' | ||
3924 | + print(r' (void)_result;') | ||
3925 | |||
3926 | def checkPitchMismatch(self, method): | ||
3927 | # Warn for mismatches in 2D/3D mappings. | ||
3928 | @@ -554,19 +554,19 @@ class Retracer: | ||
3929 | if outArg.output \ | ||
3930 | and isinstance(outArg.type, stdapi.Pointer) \ | ||
3931 | and isinstance(outArg.type.type, stdapi.Struct): | ||
3932 | - print r' const trace::Array *_%s = call.arg(%u).toArray();' % (outArg.name, outArg.index) | ||
3933 | - print r' if (%s) {' % outArg.name | ||
3934 | - print r' const trace::Struct *_struct = _%s->values[0]->toStruct();' % (outArg.name) | ||
3935 | - print r' if (_struct) {' | ||
3936 | + print(r' const trace::Array *_%s = call.arg(%u).toArray();' % (outArg.name, outArg.index)) | ||
3937 | + print(r' if (%s) {' % outArg.name) | ||
3938 | + print(r' const trace::Struct *_struct = _%s->values[0]->toStruct();' % (outArg.name)) | ||
3939 | + print(r' if (_struct) {') | ||
3940 | struct = outArg.type.type | ||
3941 | for memberIndex in range(len(struct.members)): | ||
3942 | memberType, memberName = struct.members[memberIndex] | ||
3943 | if memberName.endswith('Pitch'): | ||
3944 | - print r' if (%s->%s) {' % (outArg.name, memberName) | ||
3945 | - print r' retrace::checkMismatch(call, "%s", _struct->members[%u], %s->%s);' % (memberName, memberIndex, outArg.name, memberName) | ||
3946 | - print r' }' | ||
3947 | - print r' }' | ||
3948 | - print r' }' | ||
3949 | + print(r' if (%s->%s) {' % (outArg.name, memberName)) | ||
3950 | + print(r' retrace::checkMismatch(call, "%s", _struct->members[%u], %s->%s);' % (memberName, memberIndex, outArg.name, memberName)) | ||
3951 | + print(r' }') | ||
3952 | + print(r' }') | ||
3953 | + print(r' }') | ||
3954 | |||
3955 | def filterFunction(self, function): | ||
3956 | return True | ||
3957 | @@ -575,11 +575,11 @@ class Retracer: | ||
3958 | |||
3959 | def retraceApi(self, api): | ||
3960 | |||
3961 | - print '#include "os_time.hpp"' | ||
3962 | - print '#include "trace_parser.hpp"' | ||
3963 | - print '#include "retrace.hpp"' | ||
3964 | - print '#include "retrace_swizzle.hpp"' | ||
3965 | |||
3966 | + print('#include "os_time.hpp"') | ||
3967 | + print('#include "trace_parser.hpp"') | ||
3968 | + print('#include "retrace.hpp"') | ||
3969 | + print('#include "retrace_swizzle.hpp"') | ||
3970 | + print() | ||
3971 | |||
3972 | types = api.getAllTypes() | ||
3973 | handles = [type for type in types if isinstance(type, stdapi.Handle)] | ||
3974 | @@ -587,14 +587,14 @@ class Retracer: | ||
3975 | for handle in handles: | ||
3976 | if handle.name not in handle_names: | ||
3977 | if handle.key is None: | ||
3978 | - print 'static retrace::map<%s> _%s_map;' % (handle.type, handle.name) | ||
3979 | + print('static retrace::map<%s> _%s_map;' % (handle.type, handle.name)) | ||
3980 | else: | ||
3981 | key_name, key_type = handle.key | ||
3982 | - print 'static std::map<%s, retrace::map<%s> > _%s_map;' % (key_type, handle.type, handle.name) | ||
3983 | + print('static std::map<%s, retrace::map<%s> > _%s_map;' % (key_type, handle.type, handle.name)) | ||
3984 | handle_names.add(handle.name) | ||
3985 | |||
3986 | + print() | ||
3987 | |||
3988 | - functions = filter(self.filterFunction, api.getAllFunctions()) | ||
3989 | + functions = list(filter(self.filterFunction, api.getAllFunctions())) | ||
3990 | for function in functions: | ||
3991 | if function.sideeffects and not function.internal: | ||
3992 | self.retraceFunction(function) | ||
3993 | @@ -604,20 +604,20 @@ class Retracer: | ||
3994 | if method.sideeffects and not method.internal: | ||
3995 | self.retraceInterfaceMethod(interface, method) | ||
3996 | |||
3997 | - print 'const retrace::Entry %s[] = {' % self.table_name | ||
3998 | + print('const retrace::Entry %s[] = {' % self.table_name) | ||
3999 | for function in functions: | ||
4000 | if not function.internal: | ||
4001 | if function.sideeffects: | ||
4002 | - print ' {"%s", &retrace_%s},' % (function.name, function.name) | ||
4003 | + print(' {"%s", &retrace_%s},' % (function.name, function.name)) | ||
4004 | else: | ||
4005 | - print ' {"%s", &retrace::ignore},' % (function.name,) | ||
4006 | + print(' {"%s", &retrace::ignore},' % (function.name,)) | ||
4007 | for interface in interfaces: | ||
4008 | for base, method in interface.iterBaseMethods(): | ||
4009 | if method.sideeffects: | ||
4010 | - print ' {"%s::%s", &retrace_%s__%s},' % (interface.name, method.name, base.name, method.name) | ||
4011 | + print(' {"%s::%s", &retrace_%s__%s},' % (interface.name, method.name, base.name, method.name)) | ||
4012 | else: | ||
4013 | - print ' {"%s::%s", &retrace::ignore},' % (interface.name, method.name) | ||
4014 | - print ' {NULL, NULL}' | ||
4015 | - print '};' | ||
4016 | |||
4017 | + print(' {"%s::%s", &retrace::ignore},' % (interface.name, method.name)) | ||
4018 | + print(' {NULL, NULL}') | ||
4019 | + print('};') | ||
4020 | + print() | ||
4021 | |||
4022 | diff --git a/scripts/convert.py b/scripts/convert.py | ||
4023 | index 5f338d80..83df70ce 100755 | ||
4024 | --- a/scripts/convert.py | ||
4025 | +++ b/scripts/convert.py | ||
4026 | @@ -100,9 +100,9 @@ def detectApiFromCsv(inCsv): | ||
4027 | import csv | ||
4028 | csvReader = csv.reader(open(inCsv, 'rt'), ) | ||
4029 | for row in csvReader: | ||
4030 | - print row | ||
4031 | + print(row) | ||
4032 | event = row[2] | ||
4033 | - print event | ||
4034 | + print(event) | ||
4035 | if event.startswith("Direct3DCreate9"): | ||
4036 | return "d3d9" | ||
4037 | if event.startswith("CreateDXGIFactory"): | ||
4038 | diff --git a/scripts/jsondiff.py b/scripts/jsondiff.py | ||
4039 | index 3b1f9110..25c4840e 100755 | ||
4040 | --- a/scripts/jsondiff.py | ||
4041 | +++ b/scripts/jsondiff.py | ||
4042 | @@ -36,7 +36,7 @@ import sys | ||
4043 | def strip_object_hook(obj): | ||
4044 | if '__class__' in obj: | ||
4045 | return None | ||
4046 | - for name in obj.keys(): | ||
4047 | + for name in list(obj.keys()): | ||
4048 | if name.startswith('__') and name.endswith('__'): | ||
4049 | del obj[name] | ||
4050 | return obj | ||
4051 | @@ -80,7 +80,7 @@ class Dumper(Visitor): | ||
4052 | def visitObject(self, node): | ||
4053 | self.enter_object() | ||
4054 | |||
4055 | - members = node.keys() | ||
4056 | + members = list(node.keys()) | ||
4057 | members.sort() | ||
4058 | for i in range(len(members)): | ||
4059 | name = members[i] | ||
4060 | @@ -148,8 +148,8 @@ class Comparer(Visitor): | ||
4061 | return False | ||
4062 | if len(a) != len(b) and not self.ignore_added: | ||
4063 | return False | ||
4064 | - ak = a.keys() | ||
4065 | - bk = b.keys() | ||
4066 | + ak = list(a.keys()) | ||
4067 | + bk = list(b.keys()) | ||
4068 | ak.sort() | ||
4069 | bk.sort() | ||
4070 | if ak != bk and not self.ignore_added: | ||
4071 | @@ -175,8 +175,8 @@ class Comparer(Visitor): | ||
4072 | return True | ||
4073 | |||
4074 | def visitValue(self, a, b): | ||
4075 | - if isinstance(a, float) and isinstance(b, (int, long, float)) or \ | ||
4076 | - isinstance(b, float) and isinstance(a, (int, long, float)): | ||
4077 | + if isinstance(a, float) and isinstance(b, (int, float)) or \ | ||
4078 | + isinstance(b, float) and isinstance(a, (int, float)): | ||
4079 | if a is b: | ||
4080 | # NaNs take this path | ||
4081 | return True | ||
4082 | @@ -208,7 +208,7 @@ class Differ(Visitor): | ||
4083 | self.dumper.enter_object() | ||
4084 | names = set(a.keys()) | ||
4085 | if not self.comparer.ignore_added: | ||
4086 | - names.update(b.keys()) | ||
4087 | + names.update(list(b.keys())) | ||
4088 | names = list(names) | ||
4089 | names.sort() | ||
4090 | |||
4091 | @@ -284,7 +284,7 @@ class Differ(Visitor): | ||
4092 | self.dumper.visit(b) | ||
4093 | |||
4094 | def isMultilineString(self, value): | ||
4095 | - return isinstance(value, basestring) and '\n' in value | ||
4096 | + return isinstance(value, str) and '\n' in value | ||
4097 | |||
4098 | |||
4099 | # | ||
4100 | diff --git a/scripts/jsonextractimages.py b/scripts/jsonextractimages.py | ||
4101 | index ea1c927d..917ee7e4 100755 | ||
4102 | --- a/scripts/jsonextractimages.py | ||
4103 | +++ b/scripts/jsonextractimages.py | ||
4104 | @@ -38,7 +38,7 @@ pngSignature = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A" | ||
4105 | |||
4106 | |||
4107 | def dumpSurfaces(state, memberName): | ||
4108 | - for name, imageObj in state[memberName].iteritems(): | ||
4109 | + for name, imageObj in state[memberName].items(): | ||
4110 | data = imageObj['__data__'] | ||
4111 | data = base64.b64decode(data) | ||
4112 | |||
4113 | diff --git a/scripts/leaks.py b/scripts/leaks.py | ||
4114 | new file mode 100755 | ||
4115 | index 00000000..325af1e2 | ||
4116 | --- /dev/null | ||
4117 | +++ b/scripts/leaks.py | ||
4118 | @@ -0,0 +1,163 @@ | ||
4119 | +#!/usr/bin/env python | ||
4120 | +########################################################################## | ||
4121 | +# | ||
4122 | +# Copyright 2014-2016 VMware, Inc. | ||
4123 | +# All Rights Reserved. | ||
4124 | +# | ||
4125 | +# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
4126 | +# of this software and associated documentation files (the "Software"), to deal | ||
4127 | +# in the Software without restriction, including without limitation the rights | ||
4128 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
4129 | +# copies of the Software, and to permit persons to whom the Software is | ||
4130 | +# furnished to do so, subject to the following conditions: | ||
4131 | +# | ||
4132 | +# The above copyright notice and this permission notice shall be included in | ||
4133 | +# all copies or substantial portions of the Software. | ||
4134 | +# | ||
4135 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
4136 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
4137 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
4138 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
4139 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
4140 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
4141 | +# THE SOFTWARE. | ||
4142 | +# | ||
4143 | +##########################################################################/ | ||
4144 | + | ||
4145 | + | ||
4146 | +import subprocess | ||
4147 | +import sys | ||
4148 | +import os.path | ||
4149 | +import optparse | ||
4150 | +import re | ||
4151 | + | ||
4152 | +import unpickle | ||
4153 | + | ||
4154 | + | ||
4155 | +class LeakDetector(unpickle.Unpickler): | ||
4156 | + | ||
4157 | + def __init__(self, apitrace, trace): | ||
4158 | + | ||
4159 | + cmd = [apitrace, 'pickle', '--symbolic', trace] | ||
4160 | + p = subprocess.Popen(args = cmd, stdout = subprocess.PIPE) | ||
4161 | + | ||
4162 | + unpickle.Unpickler.__init__(self, p.stdout) | ||
4163 | + | ||
4164 | + self.numContexts = 0 | ||
4165 | + | ||
4166 | + # a map of maps | ||
4167 | + self.objectDicts = {} | ||
4168 | + | ||
4169 | + def parse(self): | ||
4170 | + unpickle.Unpickler.parse(self) | ||
4171 | + | ||
4172 | + # Reached the end of the trace -- dump any live objects | ||
4173 | + self.dumpLeaks("<EOF>") | ||
4174 | + | ||
4175 | + genDelRegExp = re.compile('^gl(Gen|Delete)(Buffers|Textures|FrameBuffers|RenderBuffers)[A-Z]*$') | ||
4176 | + | ||
4177 | + def handleCall(self, call): | ||
4178 | + # Ignore calls without side effects | ||
4179 | + if call.flags & unpickle.CALL_FLAG_NO_SIDE_EFFECTS: | ||
4180 | + return | ||
4181 | + | ||
4182 | + # Dump call for debugging: | ||
4183 | + if 0: | ||
4184 | + sys.stderr.write('%s\n' % call) | ||
4185 | + | ||
4186 | + mo = self.genDelRegExp.match(call.functionName) | ||
4187 | + if mo: | ||
4188 | + verb = mo.group(1) | ||
4189 | + subject = mo.group(2) | ||
4190 | + | ||
4191 | + subject = subject.lower().rstrip('s') | ||
4192 | + objectDict = self.objectDicts.setdefault(subject, {}) | ||
4193 | + | ||
4194 | + if verb == 'Gen': | ||
4195 | + self.handleGenerate(call, objectDict) | ||
4196 | + elif verb == 'Delete': | ||
4197 | + self.handleDelete(call, objectDict) | ||
4198 | + else: | ||
4199 | + assert 0 | ||
4200 | + | ||
4201 | + # TODO: Track labels via glObjectLabel* calls | ||
4202 | + | ||
4203 | + if call.functionName in [ | ||
4204 | + 'CGLCreateContext', | ||
4205 | + 'eglCreateContext', | ||
4206 | + 'glXCreateContext', | ||
4207 | + 'glXCreateNewContext', | ||
4208 | + 'glXCreateContextAttribsARB', | ||
4209 | + 'glXCreateContextWithConfigSGIX', | ||
4210 | + 'wglCreateContext', | ||
4211 | + 'wglCreateContextAttribsARB', | ||
4212 | + ]: | ||
4213 | + # FIXME: Ignore failing context creation calls | ||
4214 | + self.numContexts += 1 | ||
4215 | + | ||
4216 | + if call.functionName in [ | ||
4217 | + 'CGLDestroyContext', | ||
4218 | + 'glXDestroyContext', | ||
4219 | + 'eglDestroyContext', | ||
4220 | + 'wglDeleteContext', | ||
4221 | + ]: | ||
4222 | + assert self.numContexts > 0 | ||
4223 | + self.numContexts -= 1 | ||
4224 | + if self.numContexts == 0: | ||
4225 | + self.dumpLeaks(call.no) | ||
4226 | + | ||
4227 | + def handleGenerate(self, call, objectDict): | ||
4228 | + n, names = call.argValues() | ||
4229 | + for i in range(n): | ||
4230 | + name = names[i] | ||
4231 | + objectDict[name] = call.no | ||
4232 | + # TODO: Keep track of call stack backtrace too | ||
4233 | + | ||
4234 | + def handleDelete(self, call, objectDict): | ||
4235 | + n, names = call.argValues() | ||
4236 | + for i in range(n): | ||
4237 | + name = names[i] | ||
4238 | + try: | ||
4239 | + del objectDict[name] | ||
4240 | + except KeyError: | ||
4241 | + # Ignore if texture name was never generated | ||
4242 | + pass | ||
4243 | + | ||
4244 | + def dumpLeaks(self, currentCallNo): | ||
4245 | + for kind, objectDict in self.objectDicts.items(): | ||
4246 | + self.dumpNamespaceLeaks(currentCallNo, objectDict, kind) | ||
4247 | + | ||
4248 | + def dumpNamespaceLeaks(self, currentCallNo, objectDict, kind): | ||
4249 | + for name, creationCallNo in (sorted(iter(objectDict.items()),key=lambda t: t[1])): | ||
4250 | + sys.stderr.write('%u: error: %s %u was not destroyed until %s\n' % (creationCallNo, kind, name, currentCallNo)) | ||
4251 | + objectDict.clear() | ||
4252 | + | ||
4253 | + | ||
4254 | +def main(): | ||
4255 | + '''Main program. | ||
4256 | + ''' | ||
4257 | + | ||
4258 | + # Parse command line options | ||
4259 | + optparser = optparse.OptionParser( | ||
4260 | + usage='\n\t%prog [options] TRACE', | ||
4261 | + version='%%prog') | ||
4262 | + optparser.add_option( | ||
4263 | + '-a', '--apitrace', metavar='PROGRAM', | ||
4264 | + type='string', dest='apitrace', default='apitrace', | ||
4265 | + help='apitrace command [default: %default]') | ||
4266 | + | ||
4267 | + options, args = optparser.parse_args(sys.argv[1:]) | ||
4268 | + if len(args) != 1: | ||
4269 | + optparser.error("incorrect number of arguments") | ||
4270 | + | ||
4271 | + inTrace = args[0] | ||
4272 | + if not os.path.isfile(inTrace): | ||
4273 | + sys.stderr.write("error: `%s` does not exist\n" % inTrace) | ||
4274 | + sys.exit(1) | ||
4275 | + | ||
4276 | + detector = LeakDetector(options.apitrace, inTrace) | ||
4277 | + detector.parse() | ||
4278 | + | ||
4279 | + | ||
4280 | +if __name__ == '__main__': | ||
4281 | + main() | ||
4282 | diff --git a/scripts/profileshader.py b/scripts/profileshader.py | ||
4283 | index 3c490a0e..5c2a58fb 100755 | ||
4284 | --- a/scripts/profileshader.py | ||
4285 | +++ b/scripts/profileshader.py | ||
4286 | @@ -58,13 +58,13 @@ def process(stream, groupField): | ||
4287 | continue | ||
4288 | |||
4289 | if fields[callCol] == 'call': | ||
4290 | - callId = long(fields[callIdCol]) | ||
4291 | - duration = long(fields[gpuDuraCol]) | ||
4292 | + callId = int(fields[callIdCol]) | ||
4293 | + duration = int(fields[gpuDuraCol]) | ||
4294 | group = fields[groupCol] | ||
4295 | |||
4296 | maxGroupLen = max(maxGroupLen, len(group)) | ||
4297 | |||
4298 | - if times.has_key(group): | ||
4299 | + if group in times: | ||
4300 | times[group]['draws'] += 1 | ||
4301 | times[group]['duration'] += duration | ||
4302 | |||
4303 | @@ -74,7 +74,7 @@ def process(stream, groupField): | ||
4304 | else: | ||
4305 | times[group] = {'draws': 1, 'duration': duration, 'longest': callId, 'longestDuration': duration} | ||
4306 | |||
4307 | - times = sorted(times.items(), key=lambda x: x[1]['duration'], reverse=True) | ||
4308 | + times = sorted(list(times.items()), key=lambda x: x[1]['duration'], reverse=True) | ||
4309 | |||
4310 | if groupField == 'program': | ||
4311 | groupTitle = 'Shader[id]' | ||
4312 | @@ -84,9 +84,9 @@ def process(stream, groupField): | ||
4313 | groupTitle = groupField.center(maxGroupLen) | ||
4314 | groupLine = '-' * maxGroupLen | ||
4315 | |||
4316 | - print '+-%s-+--------------+--------------------+--------------+-------------+' % groupLine | ||
4317 | - print '| %s | Draws [#] | Duration [ns] v | Per Call[ns] | Longest[id] |' % groupTitle | ||
4318 | - print '+-%s-+--------------+--------------------+--------------+-------------+' % groupLine | ||
4319 | + print('+-%s-+--------------+--------------------+--------------+-------------+' % groupLine) | ||
4320 | + print('| %s | Draws [#] | Duration [ns] v | Per Call[ns] | Longest[id] |' % groupTitle) | ||
4321 | + print('+-%s-+--------------+--------------------+--------------+-------------+' % groupLine) | ||
4322 | |||
4323 | for group in times: | ||
4324 | id = str(group[0]).rjust(maxGroupLen) | ||
4325 | @@ -94,9 +94,9 @@ def process(stream, groupField): | ||
4326 | dura = str(group[1]['duration']).rjust(18) | ||
4327 | perCall = str(group[1]['duration'] / group[1]['draws']).rjust(12) | ||
4328 | longest = str(group[1]['longest']).rjust(11) | ||
4329 | - print "| %s | %s | %s | %s | %s |" % (id, draw, dura, perCall, longest) | ||
4330 | + print("| %s | %s | %s | %s | %s |" % (id, draw, dura, perCall, longest)) | ||
4331 | |||
4332 | - print '+-%s-+--------------+--------------------+--------------+-------------+' % groupLine | ||
4333 | + print('+-%s-+--------------+--------------------+--------------+-------------+' % groupLine) | ||
4334 | |||
4335 | |||
4336 | def main(): | ||
4337 | diff --git a/scripts/retracediff.py b/scripts/retracediff.py | ||
4338 | index bb5aa7f5..8105f536 100755 | ||
4339 | --- a/scripts/retracediff.py | ||
4340 | +++ b/scripts/retracediff.py | ||
4341 | @@ -83,12 +83,12 @@ class Retracer: | ||
4342 | self.retraceExe, | ||
4343 | ] + args + self.args | ||
4344 | if self.env: | ||
4345 | - for name, value in self.env.iteritems(): | ||
4346 | + for name, value in self.env.items(): | ||
4347 | sys.stderr.write('%s=%s ' % (name, value)) | ||
4348 | sys.stderr.write(' '.join(cmd) + '\n') | ||
4349 | try: | ||
4350 | return subprocess.Popen(cmd, env=self.env, stdout=stdout, stderr=NULL) | ||
4351 | - except OSError, ex: | ||
4352 | + except OSError as ex: | ||
4353 | sys.stderr.write('error: failed to execute %s: %s\n' % (cmd[0], ex.strerror)) | ||
4354 | sys.exit(1) | ||
4355 | |||
4356 | @@ -160,7 +160,7 @@ def read_pnm(stream): | ||
4357 | while line.startswith('#'): | ||
4358 | comment += line[1:] | ||
4359 | line = stream.readline() | ||
4360 | - width, height = map(int, line.strip().split()) | ||
4361 | + width, height = list(map(int, line.strip().split())) | ||
4362 | maximum = int(stream.readline().strip()) | ||
4363 | if bytesPerChannel == 1: | ||
4364 | assert maximum == 255 | ||
4365 | diff --git a/scripts/snapdiff.py b/scripts/snapdiff.py | ||
4366 | index 59ec870e..b0d5f757 100755 | ||
4367 | --- a/scripts/snapdiff.py | ||
4368 | +++ b/scripts/snapdiff.py | ||
4369 | @@ -40,6 +40,7 @@ from PIL import Image | ||
4370 | from PIL import ImageChops | ||
4371 | from PIL import ImageEnhance | ||
4372 | from PIL import ImageFilter | ||
4373 | +from functools import reduce | ||
4374 | |||
4375 | |||
4376 | thumbSize = 320 | ||
4377 | @@ -50,12 +51,12 @@ class Comparer: | ||
4378 | '''Image comparer.''' | ||
4379 | |||
4380 | def __init__(self, ref_image, src_image, alpha = False): | ||
4381 | - if isinstance(ref_image, basestring): | ||
4382 | + if isinstance(ref_image, str): | ||
4383 | self.ref_im = Image.open(ref_image) | ||
4384 | else: | ||
4385 | self.ref_im = ref_image | ||
4386 | |||
4387 | - if isinstance(src_image, basestring): | ||
4388 | + if isinstance(src_image, str): | ||
4389 | self.src_im = Image.open(src_image) | ||
4390 | else: | ||
4391 | self.src_im = src_image | ||
4392 | @@ -106,7 +107,7 @@ class Comparer: | ||
4393 | # Compute absolute error | ||
4394 | |||
4395 | if self.size_mismatch(): | ||
4396 | - return sys.maxint | ||
4397 | + return sys.maxsize | ||
4398 | |||
4399 | # TODO: this is approximate due to the grayscale conversion | ||
4400 | h = self.diff.convert('L').histogram() | ||
4401 | diff --git a/scripts/tracediff.py b/scripts/tracediff.py | ||
4402 | index f111322a..0cd9c8c6 100755 | ||
4403 | --- a/scripts/tracediff.py | ||
4404 | +++ b/scripts/tracediff.py | ||
4405 | @@ -237,7 +237,7 @@ class BlobReplacer(Rebuilder): | ||
4406 | return Blob(len(obj), hash(str(obj))) | ||
4407 | |||
4408 | def visitCall(self, call): | ||
4409 | - call.args = map(self.visit, call.args) | ||
4410 | + call.args = list(map(self.visit, call.args)) | ||
4411 | call.ret = self.visit(call.ret) | ||
4412 | |||
4413 | |||
4414 | @@ -312,7 +312,7 @@ class PythonDiffer(Differ): | ||
4415 | elif tag == 'equal': | ||
4416 | self.equal(alo, ahi, blo, bhi) | ||
4417 | else: | ||
4418 | - raise ValueError, 'unknown tag %s' % (tag,) | ||
4419 | + raise ValueError('unknown tag %s' % (tag,)) | ||
4420 | |||
4421 | def isjunk(self, call): | ||
4422 | return call.functionName == 'glGetError' and call.ret in ('GL_NO_ERROR', 0) | ||
4423 | @@ -338,12 +338,12 @@ class PythonDiffer(Differ): | ||
4424 | elif tag == 'equal': | ||
4425 | self.replace_similar(_alo, _ahi, _blo, _bhi) | ||
4426 | else: | ||
4427 | - raise ValueError, 'unknown tag %s' % (tag,) | ||
4428 | + raise ValueError('unknown tag %s' % (tag,)) | ||
4429 | |||
4430 | def replace_similar(self, alo, ahi, blo, bhi): | ||
4431 | assert alo < ahi and blo < bhi | ||
4432 | assert ahi - alo == bhi - blo | ||
4433 | - for i in xrange(0, bhi - blo): | ||
4434 | + for i in range(0, bhi - blo): | ||
4435 | self.highlighter.write('| ') | ||
4436 | a_call = self.a[alo + i] | ||
4437 | b_call = self.b[blo + i] | ||
4438 | @@ -355,7 +355,7 @@ class PythonDiffer(Differ): | ||
4439 | self.highlighter.write('(') | ||
4440 | sep = '' | ||
4441 | numArgs = max(len(a_call.args), len(b_call.args)) | ||
4442 | - for j in xrange(numArgs): | ||
4443 | + for j in range(numArgs): | ||
4444 | self.highlighter.write(sep) | ||
4445 | try: | ||
4446 | a_argName, a_argVal = a_call.args[j] | ||
4447 | @@ -402,7 +402,7 @@ class PythonDiffer(Differ): | ||
4448 | def delete(self, alo, ahi, blo, bhi): | ||
4449 | assert alo < ahi | ||
4450 | assert blo == bhi | ||
4451 | - for i in xrange(alo, ahi): | ||
4452 | + for i in range(alo, ahi): | ||
4453 | call = self.a[i] | ||
4454 | self.highlighter.write('- ') | ||
4455 | self.dumpCallNos(call.no, None) | ||
4456 | @@ -413,7 +413,7 @@ class PythonDiffer(Differ): | ||
4457 | def insert(self, alo, ahi, blo, bhi): | ||
4458 | assert alo == ahi | ||
4459 | assert blo < bhi | ||
4460 | - for i in xrange(blo, bhi): | ||
4461 | + for i in range(blo, bhi): | ||
4462 | call = self.b[i] | ||
4463 | self.highlighter.write('+ ') | ||
4464 | self.dumpCallNos(None, call.no) | ||
4465 | @@ -425,7 +425,7 @@ class PythonDiffer(Differ): | ||
4466 | return | ||
4467 | assert alo < ahi and blo < bhi | ||
4468 | assert ahi - alo == bhi - blo | ||
4469 | - for i in xrange(0, bhi - blo): | ||
4470 | + for i in range(0, bhi - blo): | ||
4471 | self.highlighter.write(' ') | ||
4472 | a_call = self.a[alo + i] | ||
4473 | b_call = self.b[blo + i] | ||
4474 | diff --git a/scripts/unpickle.py b/scripts/unpickle.py | ||
4475 | index 334c1a01..86891d29 100755 | ||
4476 | --- a/scripts/unpickle.py | ||
4477 | +++ b/scripts/unpickle.py | ||
4478 | @@ -38,7 +38,7 @@ import optparse | ||
4479 | import sys | ||
4480 | import time | ||
4481 | import re | ||
4482 | -import cPickle as pickle | ||
4483 | +import pickle as pickle | ||
4484 | |||
4485 | |||
4486 | # Same as trace_model.hpp's call flags | ||
4487 | @@ -58,7 +58,7 @@ CALL_FLAG_MARKER_POP = (1 << 10) | ||
4488 | class Pointer(long): | ||
4489 | |||
4490 | def __str__(self): | ||
4491 | - if self == 0L: | ||
4492 | + if self == 0: | ||
4493 | return 'NULL' | ||
4494 | else: | ||
4495 | return hex(self).rstrip('L') | ||
4496 | @@ -73,7 +73,7 @@ class Visitor: | ||
4497 | self.dispatch[type(None)] = self.visitNone | ||
4498 | self.dispatch[bool] = self.visitBool | ||
4499 | self.dispatch[int] = self.visitInt | ||
4500 | - self.dispatch[long] = self.visitInt | ||
4501 | + self.dispatch[int] = self.visitInt | ||
4502 | self.dispatch[float] = self.visitFloat | ||
4503 | self.dispatch[str] = self.visitStr | ||
4504 | self.dispatch[tuple] = self.visitTuple | ||
4505 | @@ -140,18 +140,18 @@ class Dumper(Visitor): | ||
4506 | return repr(obj) | ||
4507 | |||
4508 | def visitTuple(self, obj): | ||
4509 | - return '(' + ', '.join(itertools.imap(self.visit, obj)) + ')' | ||
4510 | + return '(' + ', '.join(map(self.visit, obj)) + ')' | ||
4511 | |||
4512 | def visitList(self, obj): | ||
4513 | if len(obj) == 1: | ||
4514 | return '&' + self.visit(obj[0]) | ||
4515 | - return '{' + ', '.join(itertools.imap(self.visit, obj)) + '}' | ||
4516 | + return '{' + ', '.join(map(self.visit, obj)) + '}' | ||
4517 | |||
4518 | def visitItems(self, items): | ||
4519 | return ', '.join(['%s = %s' % (name, self.visit(value)) for name, value in items]) | ||
4520 | |||
4521 | def visitDict(self, obj): | ||
4522 | - return '{' + self.visitItems(obj.iteritems()) + '}' | ||
4523 | + return '{' + self.visitItems(iter(obj.items())) + '}' | ||
4524 | |||
4525 | def visitByteArray(self, obj): | ||
4526 | return 'blob(%u)' % len(obj) | ||
4527 | @@ -167,7 +167,7 @@ class Hasher(Visitor): | ||
4528 | return obj | ||
4529 | |||
4530 | def visitIterable(self, obj): | ||
4531 | - return tuple(itertools.imap(self.visit, obj)) | ||
4532 | + return tuple(map(self.visit, obj)) | ||
4533 | |||
4534 | def visitByteArray(self, obj): | ||
4535 | return str(obj) | ||
4536 | @@ -268,7 +268,7 @@ class Counter(Unpickler): | ||
4537 | def parse(self): | ||
4538 | Unpickler.parse(self) | ||
4539 | |||
4540 | - functionFrequencies = self.functionFrequencies.items() | ||
4541 | + functionFrequencies = list(self.functionFrequencies.items()) | ||
4542 | functionFrequencies.sort(lambda (name1, freq1), (name2, freq2): cmp(freq1, freq2)) | ||
4543 | for name, frequency in functionFrequencies: | ||
4544 | sys.stdout.write('%8u %s\n' % (frequency, name)) | ||
4545 | diff --git a/specs/cglapi.py b/specs/cglapi.py | ||
4546 | index 69faeeb4..5d61886f 100644 | ||
4547 | --- a/specs/cglapi.py | ||
4548 | +++ b/specs/cglapi.py | ||
4549 | @@ -29,9 +29,9 @@ http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/ | ||
4550 | """ | ||
4551 | |||
4552 | |||
4553 | -from stdapi import * | ||
4554 | -from glapi import * | ||
4555 | -from glapi import glapi | ||
4556 | +from .stdapi import * | ||
4557 | +from .glapi import * | ||
4558 | +from .glapi import glapi | ||
4559 | |||
4560 | IOSurfaceRef = Opaque("IOSurfaceRef") | ||
4561 | CGLContextObj = Opaque("CGLContextObj") | ||
4562 | diff --git a/specs/d2d1.py b/specs/d2d1.py | ||
4563 | index dacbea69..9bae43c5 100644 | ||
4564 | --- a/specs/d2d1.py | ||
4565 | +++ b/specs/d2d1.py | ||
4566 | @@ -25,9 +25,9 @@ | ||
4567 | ##########################################################################/ | ||
4568 | |||
4569 | |||
4570 | -from winapi import * | ||
4571 | -from dxgi import DXGI_FORMAT, IDXGISurface | ||
4572 | -from dwrite import * | ||
4573 | +from .winapi import * | ||
4574 | +from .dxgi import DXGI_FORMAT, IDXGISurface | ||
4575 | +from .dwrite import * | ||
4576 | |||
4577 | |||
4578 | |||
4579 | diff --git a/specs/d3d.py b/specs/d3d.py | ||
4580 | index 0dde09f4..4b7244b2 100644 | ||
4581 | --- a/specs/d3d.py | ||
4582 | +++ b/specs/d3d.py | ||
4583 | @@ -25,10 +25,10 @@ | ||
4584 | |||
4585 | """d3d.h""" | ||
4586 | |||
4587 | -from winapi import * | ||
4588 | -from ddraw import * | ||
4589 | -from d3dtypes import * | ||
4590 | -from d3dcaps import * | ||
4591 | +from .winapi import * | ||
4592 | +from .ddraw import * | ||
4593 | +from .d3dtypes import * | ||
4594 | +from .d3dcaps import * | ||
4595 | |||
4596 | d3dnextFlags = Flags(DWORD, [ | ||
4597 | "D3DNEXT_NEXT", | ||
4598 | diff --git a/specs/d3d10.py b/specs/d3d10.py | ||
4599 | index 2161a5fd..e22bc230 100644 | ||
4600 | --- a/specs/d3d10.py | ||
4601 | +++ b/specs/d3d10.py | ||
4602 | @@ -24,8 +24,8 @@ | ||
4603 | ##########################################################################/ | ||
4604 | |||
4605 | |||
4606 | -from dxgi import * | ||
4607 | -from d3d10sdklayers import * | ||
4608 | +from .dxgi import * | ||
4609 | +from .d3d10sdklayers import * | ||
4610 | |||
4611 | |||
4612 | HRESULT = MAKE_HRESULT([ | ||
4613 | diff --git a/specs/d3d10sdklayers.py b/specs/d3d10sdklayers.py | ||
4614 | index aad53f04..82beb721 100644 | ||
4615 | --- a/specs/d3d10sdklayers.py | ||
4616 | +++ b/specs/d3d10sdklayers.py | ||
4617 | @@ -24,7 +24,7 @@ | ||
4618 | ##########################################################################/ | ||
4619 | |||
4620 | |||
4621 | -from dxgi import * | ||
4622 | +from .dxgi import * | ||
4623 | |||
4624 | |||
4625 | D3D10_DEBUG_FEATURE = Flags(UINT, [ | ||
4626 | diff --git a/specs/d3d11.py b/specs/d3d11.py | ||
4627 | index f704b062..0a28caa3 100644 | ||
4628 | --- a/specs/d3d11.py | ||
4629 | +++ b/specs/d3d11.py | ||
4630 | @@ -24,8 +24,8 @@ | ||
4631 | ##########################################################################/ | ||
4632 | |||
4633 | |||
4634 | -from dxgi import * | ||
4635 | -from d3d11sdklayers import * | ||
4636 | +from .dxgi import * | ||
4637 | +from .d3d11sdklayers import * | ||
4638 | |||
4639 | |||
4640 | HRESULT = MAKE_HRESULT([ | ||
4641 | diff --git a/specs/d3d11sdklayers.py b/specs/d3d11sdklayers.py | ||
4642 | index 907c4b09..97d07750 100644 | ||
4643 | --- a/specs/d3d11sdklayers.py | ||
4644 | +++ b/specs/d3d11sdklayers.py | ||
4645 | @@ -24,7 +24,7 @@ | ||
4646 | ##########################################################################/ | ||
4647 | |||
4648 | |||
4649 | -from dxgi import * | ||
4650 | +from .dxgi import * | ||
4651 | |||
4652 | |||
4653 | ID3D11DeviceChild = Interface("ID3D11DeviceChild", IUnknown) | ||
4654 | diff --git a/specs/d3d8.py b/specs/d3d8.py | ||
4655 | index 2dbf1140..400af498 100644 | ||
4656 | --- a/specs/d3d8.py | ||
4657 | +++ b/specs/d3d8.py | ||
4658 | @@ -25,9 +25,9 @@ | ||
4659 | |||
4660 | """d3d8.h""" | ||
4661 | |||
4662 | -from winapi import * | ||
4663 | -from d3d8types import * | ||
4664 | -from d3d8caps import * | ||
4665 | +from .winapi import * | ||
4666 | +from .d3d8types import * | ||
4667 | +from .d3d8caps import * | ||
4668 | |||
4669 | |||
4670 | D3DSHADER8 = Blob(Const(DWORD), "_shaderSize(pFunction)") | ||
4671 | diff --git a/specs/d3d8caps.py b/specs/d3d8caps.py | ||
4672 | index 1af1a19f..b7ee5873 100644 | ||
4673 | --- a/specs/d3d8caps.py | ||
4674 | +++ b/specs/d3d8caps.py | ||
4675 | @@ -25,8 +25,8 @@ | ||
4676 | |||
4677 | """d3d8caps.h""" | ||
4678 | |||
4679 | -from winapi import * | ||
4680 | -from d3d8types import * | ||
4681 | +from .winapi import * | ||
4682 | +from .d3d8types import * | ||
4683 | |||
4684 | D3DCAPS = Flags(DWORD, [ | ||
4685 | "D3DCAPS_READ_SCANLINE", | ||
4686 | diff --git a/specs/d3d8types.py b/specs/d3d8types.py | ||
4687 | index fe58a0cd..a2482328 100644 | ||
4688 | --- a/specs/d3d8types.py | ||
4689 | +++ b/specs/d3d8types.py | ||
4690 | @@ -25,7 +25,7 @@ | ||
4691 | |||
4692 | """d3d8types.h""" | ||
4693 | |||
4694 | -from winapi import * | ||
4695 | +from .winapi import * | ||
4696 | |||
4697 | D3DCOLOR = Alias("D3DCOLOR", DWORD) | ||
4698 | |||
4699 | diff --git a/specs/d3d9.py b/specs/d3d9.py | ||
4700 | index 21015149..68dcaca2 100644 | ||
4701 | --- a/specs/d3d9.py | ||
4702 | +++ b/specs/d3d9.py | ||
4703 | @@ -25,9 +25,9 @@ | ||
4704 | |||
4705 | """d3d9.h""" | ||
4706 | |||
4707 | -from winapi import * | ||
4708 | -from d3d9types import * | ||
4709 | -from d3d9caps import * | ||
4710 | +from .winapi import * | ||
4711 | +from .d3d9types import * | ||
4712 | +from .d3d9caps import * | ||
4713 | |||
4714 | |||
4715 | D3DSHADER9 = Blob(Const(DWORD), "_shaderSize(pFunction)") | ||
4716 | diff --git a/specs/d3d9caps.py b/specs/d3d9caps.py | ||
4717 | index b3582879..541263b6 100644 | ||
4718 | --- a/specs/d3d9caps.py | ||
4719 | +++ b/specs/d3d9caps.py | ||
4720 | @@ -25,8 +25,8 @@ | ||
4721 | |||
4722 | """d3d9caps.h""" | ||
4723 | |||
4724 | -from winapi import * | ||
4725 | -from d3d9types import * | ||
4726 | +from .winapi import * | ||
4727 | +from .d3d9types import * | ||
4728 | |||
4729 | D3DVS20CAPS = Flags(DWORD, [ | ||
4730 | "D3DVS20CAPS_PREDICATION", | ||
4731 | diff --git a/specs/d3d9types.py b/specs/d3d9types.py | ||
4732 | index 2545a767..c9847030 100644 | ||
4733 | --- a/specs/d3d9types.py | ||
4734 | +++ b/specs/d3d9types.py | ||
4735 | @@ -26,7 +26,7 @@ | ||
4736 | |||
4737 | """d3d9types.h""" | ||
4738 | |||
4739 | -from winapi import * | ||
4740 | +from .winapi import * | ||
4741 | |||
4742 | D3DCOLOR = Alias("D3DCOLOR", DWORD) | ||
4743 | |||
4744 | diff --git a/specs/d3dcaps.py b/specs/d3dcaps.py | ||
4745 | index 0fa9f1cc..88725067 100644 | ||
4746 | --- a/specs/d3dcaps.py | ||
4747 | +++ b/specs/d3dcaps.py | ||
4748 | @@ -25,8 +25,8 @@ | ||
4749 | |||
4750 | """d3dcaps.h""" | ||
4751 | |||
4752 | -from winapi import * | ||
4753 | -from d3dtypes import * | ||
4754 | +from .winapi import * | ||
4755 | +from .d3dtypes import * | ||
4756 | |||
4757 | D3DTRANSFORMCAPS = Flags(DWORD, [ | ||
4758 | "D3DTRANSFORMCAPS_CLIP", | ||
4759 | diff --git a/specs/d3dtypes.py b/specs/d3dtypes.py | ||
4760 | index e1507975..ba460022 100644 | ||
4761 | --- a/specs/d3dtypes.py | ||
4762 | +++ b/specs/d3dtypes.py | ||
4763 | @@ -25,7 +25,7 @@ | ||
4764 | |||
4765 | """d3dtypes.h""" | ||
4766 | |||
4767 | -from winapi import * | ||
4768 | +from .winapi import * | ||
4769 | |||
4770 | D3DVALUE = Float | ||
4771 | LPD3DVALUE = Pointer(D3DVALUE) | ||
4772 | diff --git a/specs/dcommon.py b/specs/dcommon.py | ||
4773 | index 21659a5e..6324db3a 100644 | ||
4774 | --- a/specs/dcommon.py | ||
4775 | +++ b/specs/dcommon.py | ||
4776 | @@ -24,7 +24,7 @@ | ||
4777 | ##########################################################################/ | ||
4778 | |||
4779 | |||
4780 | -from winapi import * | ||
4781 | +from .winapi import * | ||
4782 | |||
4783 | |||
4784 | DWRITE_MEASURING_MODE = Enum("DWRITE_MEASURING_MODE", [ | ||
4785 | diff --git a/specs/dcomp.py b/specs/dcomp.py | ||
4786 | new file mode 100644 | ||
4787 | index 00000000..b139a89e | ||
4788 | --- /dev/null | ||
4789 | +++ b/specs/dcomp.py | ||
4790 | @@ -0,0 +1,303 @@ | ||
4791 | +########################################################################## | ||
4792 | +# | ||
4793 | +# Copyright 2009-2016 VMware, Inc. | ||
4794 | +# All Rights Reserved. | ||
4795 | +# | ||
4796 | +# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
4797 | +# of this software and associated documentation files (the "Software"), to deal | ||
4798 | +# in the Software without restriction, including without limitation the rights | ||
4799 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
4800 | +# copies of the Software, and to permit persons to whom the Software is | ||
4801 | +# furnished to do so, subject to the following conditions: | ||
4802 | +# | ||
4803 | +# The above copyright notice and this permission notice shall be included in | ||
4804 | +# all copies or substantial portions of the Software. | ||
4805 | +# | ||
4806 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
4807 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
4808 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
4809 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
4810 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
4811 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
4812 | +# THE SOFTWARE. | ||
4813 | +# | ||
4814 | +##########################################################################/ | ||
4815 | + | ||
4816 | + | ||
4817 | +from .dxgi import * | ||
4818 | +from .d2d1 import D2D_MATRIX_3X2_F, D2D_RECT_F | ||
4819 | +from .d3d9types import D3DMATRIX | ||
4820 | +from .d2d1 import D2D1_COMPOSITE_MODE | ||
4821 | + | ||
4822 | +DCOMPOSITION_BITMAP_INTERPOLATION_MODE = Enum('DCOMPOSITION_BITMAP_INTERPOLATION_MODE', [ | ||
4823 | + 'DCOMPOSITION_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR', | ||
4824 | + 'DCOMPOSITION_BITMAP_INTERPOLATION_MODE_LINEAR', | ||
4825 | + 'DCOMPOSITION_BITMAP_INTERPOLATION_MODE_INHERIT', | ||
4826 | +]) | ||
4827 | + | ||
4828 | +DCOMPOSITION_BORDER_MODE = Enum('DCOMPOSITION_BORDER_MODE', [ | ||
4829 | + 'DCOMPOSITION_BORDER_MODE_SOFT', | ||
4830 | + 'DCOMPOSITION_BORDER_MODE_HARD', | ||
4831 | + 'DCOMPOSITION_BORDER_MODE_INHERIT', | ||
4832 | +]) | ||
4833 | + | ||
4834 | +DCOMPOSITION_COMPOSITE_MODE = Enum('DCOMPOSITION_COMPOSITE_MODE', [ | ||
4835 | + 'DCOMPOSITION_COMPOSITE_MODE_SOURCE_OVER', | ||
4836 | + 'DCOMPOSITION_COMPOSITE_MODE_DESTINATION_INVERT', | ||
4837 | + 'DCOMPOSITION_COMPOSITE_MODE_INHERIT', | ||
4838 | +]) | ||
4839 | + | ||
4840 | +DCOMPOSITION_FRAME_STATISTICS = Struct('DCOMPOSITION_FRAME_STATISTICS', [ | ||
4841 | + (LARGE_INTEGER, 'lastFrameTime'), | ||
4842 | + (DXGI_RATIONAL, 'currentCompositionRate'), | ||
4843 | + (LARGE_INTEGER, 'currentTime'), | ||
4844 | + (LARGE_INTEGER, 'timeFrequency'), | ||
4845 | + (LARGE_INTEGER, 'nextEstimatedFrameTime'), | ||
4846 | +]) | ||
4847 | + | ||
4848 | +COMPOSITIONOBJECT = Flags(DWORD, [ | ||
4849 | + 'COMPOSITIONOBJECT_ALL_ACCESS', # 0x0003 | ||
4850 | + 'COMPOSITIONOBJECT_READ', # 0x0001 | ||
4851 | + 'COMPOSITIONOBJECT_WRITE', # 0x0002 | ||
4852 | +]) | ||
4853 | + | ||
4854 | +IDCompositionAnimation = Interface('IDCompositionAnimation', IUnknown) | ||
4855 | +IDCompositionDevice = Interface('IDCompositionDevice', IUnknown) | ||
4856 | +IDCompositionTarget = Interface('IDCompositionTarget', IUnknown) | ||
4857 | +IDCompositionVisual = Interface('IDCompositionVisual', IUnknown) | ||
4858 | +IDCompositionEffect = Interface('IDCompositionEffect', IUnknown) | ||
4859 | +IDCompositionEffectGroup = Interface('IDCompositionEffectGroup', IDCompositionEffect) | ||
4860 | +IDCompositionTransform3D = Interface('IDCompositionTransform3D', IDCompositionEffect) | ||
4861 | +IDCompositionTransform = Interface('IDCompositionTransform', IDCompositionTransform3D) | ||
4862 | +IDCompositionTranslateTransform = Interface('IDCompositionTranslateTransform', IDCompositionTransform) | ||
4863 | +IDCompositionTranslateTransform3D = Interface('IDCompositionTranslateTransform3D', IDCompositionTransform3D) | ||
4864 | +IDCompositionScaleTransform = Interface('IDCompositionScaleTransform', IDCompositionTransform) | ||
4865 | +IDCompositionScaleTransform3D = Interface('IDCompositionScaleTransform3D', IDCompositionTransform3D) | ||
4866 | +IDCompositionRotateTransform = Interface('IDCompositionRotateTransform', IDCompositionTransform) | ||
4867 | +IDCompositionRotateTransform3D = Interface('IDCompositionRotateTransform3D', IDCompositionTransform3D) | ||
4868 | +IDCompositionSkewTransform = Interface('IDCompositionSkewTransform', IDCompositionTransform) | ||
4869 | +IDCompositionMatrixTransform = Interface('IDCompositionMatrixTransform', IDCompositionTransform) | ||
4870 | +IDCompositionMatrixTransform3D = Interface('IDCompositionMatrixTransform3D', IDCompositionTransform3D) | ||
4871 | +IDCompositionClip = Interface('IDCompositionClip', IUnknown) | ||
4872 | +IDCompositionRectangleClip = Interface('IDCompositionRectangleClip', IDCompositionClip) | ||
4873 | +IDCompositionSurface = Interface('IDCompositionSurface', IUnknown) | ||
4874 | +IDCompositionVirtualSurface = Interface('IDCompositionVirtualSurface', IDCompositionSurface) | ||
4875 | + | ||
4876 | +IDCompositionAnimation.methods += [ | ||
4877 | + StdMethod(HRESULT, 'Reset', []), | ||
4878 | + StdMethod(HRESULT, 'SetAbsoluteBeginTime', [(LARGE_INTEGER, 'beginTime')]), | ||
4879 | + StdMethod(HRESULT, 'AddCubic', [(Double, 'beginOffset'), (Float, 'constantCoefficient'), (Float, 'linearCoefficient'), (Float, 'quadraticCoefficient'), (Float, 'cubicCoefficient')]), | ||
4880 | + StdMethod(HRESULT, 'AddSinusoidal', [(Double, 'beginOffset'), (Float, 'bias'), (Float, 'amplitude'), (Float, 'frequency'), (Float, 'phase')]), | ||
4881 | + StdMethod(HRESULT, 'AddRepeat', [(Double, 'beginOffset'), (Double, 'durationToRepeat')]), | ||
4882 | + StdMethod(HRESULT, 'End', [(Double, 'endOffset'), (Float, 'endValue')]), | ||
4883 | +] | ||
4884 | + | ||
4885 | +IDCompositionDevice.methods += [ | ||
4886 | + StdMethod(HRESULT, 'Commit', []), | ||
4887 | + StdMethod(HRESULT, 'WaitForCommitCompletion', []), | ||
4888 | + StdMethod(HRESULT, 'GetFrameStatistics', [Out(Pointer(DCOMPOSITION_FRAME_STATISTICS), 'statistics')]), | ||
4889 | + StdMethod(HRESULT, 'CreateTargetForHwnd', [(HWND, 'hwnd'), (BOOL, 'topmost'), Out(Pointer(ObjPointer(IDCompositionTarget)), 'target')]), | ||
4890 | + StdMethod(HRESULT, 'CreateVisual', [Out(Pointer(ObjPointer(IDCompositionVisual)), 'visual')]), | ||
4891 | + StdMethod(HRESULT, 'CreateSurface', [(UINT, 'width'), (UINT, 'height'), (DXGI_FORMAT, 'pixelFormat'), (DXGI_ALPHA_MODE, 'alphaMode'), Out(Pointer(ObjPointer(IDCompositionSurface)), 'surface')]), | ||
4892 | + StdMethod(HRESULT, 'CreateVirtualSurface', [(UINT, 'initialWidth'), (UINT, 'initialHeight'), (DXGI_FORMAT, 'pixelFormat'), (DXGI_ALPHA_MODE, 'alphaMode'), Out(Pointer(ObjPointer(IDCompositionVirtualSurface)), 'virtualSurface')]), | ||
4893 | + StdMethod(HRESULT, 'CreateSurfaceFromHandle', [(HANDLE, 'handle'), Out(Pointer(ObjPointer(IUnknown)), 'surface')]), | ||
4894 | + StdMethod(HRESULT, 'CreateSurfaceFromHwnd', [(HWND, 'hwnd'), Out(Pointer(ObjPointer(IUnknown)), 'surface')]), | ||
4895 | + StdMethod(HRESULT, 'CreateTranslateTransform', [Out(Pointer(ObjPointer(IDCompositionTranslateTransform)), 'translateTransform')]), | ||
4896 | + StdMethod(HRESULT, 'CreateScaleTransform', [Out(Pointer(ObjPointer(IDCompositionScaleTransform)), 'scaleTransform')]), | ||
4897 | + StdMethod(HRESULT, 'CreateRotateTransform', [Out(Pointer(ObjPointer(IDCompositionRotateTransform)), 'rotateTransform')]), | ||
4898 | + StdMethod(HRESULT, 'CreateSkewTransform', [Out(Pointer(ObjPointer(IDCompositionSkewTransform)), 'skewTransform')]), | ||
4899 | + StdMethod(HRESULT, 'CreateMatrixTransform', [Out(Pointer(ObjPointer(IDCompositionMatrixTransform)), 'matrixTransform')]), | ||
4900 | + StdMethod(HRESULT, 'CreateTransformGroup', [(Array(ObjPointer(IDCompositionTransform), 'elements'), 'transforms'), (UINT, 'elements'), Out(Pointer(ObjPointer(IDCompositionTransform)), 'transformGroup')]), | ||
4901 | + StdMethod(HRESULT, 'CreateTranslateTransform3D', [Out(Pointer(ObjPointer(IDCompositionTranslateTransform3D)), 'translateTransform3D')]), | ||
4902 | + StdMethod(HRESULT, 'CreateScaleTransform3D', [Out(Pointer(ObjPointer(IDCompositionScaleTransform3D)), 'scaleTransform3D')]), | ||
4903 | + StdMethod(HRESULT, 'CreateRotateTransform3D', [Out(Pointer(ObjPointer(IDCompositionRotateTransform3D)), 'rotateTransform3D')]), | ||
4904 | + StdMethod(HRESULT, 'CreateMatrixTransform3D', [Out(Pointer(ObjPointer(IDCompositionMatrixTransform3D)), 'matrixTransform3D')]), | ||
4905 | + StdMethod(HRESULT, 'CreateTransform3DGroup', [(Array(ObjPointer(IDCompositionTransform3D), 'elements'), 'transforms3D'), (UINT, 'elements'), Out(Pointer(ObjPointer(IDCompositionTransform3D)), 'transform3DGroup')]), | ||
4906 | + StdMethod(HRESULT, 'CreateEffectGroup', [Out(Pointer(ObjPointer(IDCompositionEffectGroup)), 'effectGroup')]), | ||
4907 | + StdMethod(HRESULT, 'CreateRectangleClip', [Out(Pointer(ObjPointer(IDCompositionRectangleClip)), 'clip')]), | ||
4908 | + StdMethod(HRESULT, 'CreateAnimation', [Out(Pointer(ObjPointer(IDCompositionAnimation)), 'animation')]), | ||
4909 | + StdMethod(HRESULT, 'CheckDeviceState', [Out(Pointer(BOOL), 'pfValid')]), | ||
4910 | +] | ||
4911 | + | ||
4912 | +IDCompositionTarget.methods += [ | ||
4913 | + StdMethod(HRESULT, 'SetRoot', [(ObjPointer(IDCompositionVisual), 'visual')]), | ||
4914 | +] | ||
4915 | + | ||
4916 | +IDCompositionVisual.methods += [ | ||
4917 | + StdMethod(HRESULT, 'SetOffsetX', [(Float, 'offsetX')], overloaded=True), | ||
4918 | + StdMethod(HRESULT, 'SetOffsetX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4919 | + StdMethod(HRESULT, 'SetOffsetY', [(Float, 'offsetY')], overloaded=True), | ||
4920 | + StdMethod(HRESULT, 'SetOffsetY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4921 | + StdMethod(HRESULT, 'SetTransform', [(Reference(Const(D2D_MATRIX_3X2_F)), 'matrix')], overloaded=True), | ||
4922 | + StdMethod(HRESULT, 'SetTransform', [(ObjPointer(IDCompositionTransform), 'transform')], overloaded=True), | ||
4923 | + StdMethod(HRESULT, 'SetTransformParent', [(ObjPointer(IDCompositionVisual), 'visual')]), | ||
4924 | + StdMethod(HRESULT, 'SetEffect', [(ObjPointer(IDCompositionEffect), 'effect')]), | ||
4925 | + StdMethod(HRESULT, 'SetBitmapInterpolationMode', [(DCOMPOSITION_BITMAP_INTERPOLATION_MODE, 'interpolationMode')]), | ||
4926 | + StdMethod(HRESULT, 'SetBorderMode', [(DCOMPOSITION_BORDER_MODE, 'borderMode')]), | ||
4927 | + StdMethod(HRESULT, 'SetClip', [(Reference(Const(D2D_RECT_F)), 'rect')], overloaded=True), | ||
4928 | + StdMethod(HRESULT, 'SetClip', [(ObjPointer(IDCompositionClip), 'clip')], overloaded=True), | ||
4929 | + StdMethod(HRESULT, 'SetContent', [(ObjPointer(IUnknown), 'content')]), | ||
4930 | + StdMethod(HRESULT, 'AddVisual', [(ObjPointer(IDCompositionVisual), 'visual'), (BOOL, 'insertAbove'), (ObjPointer(IDCompositionVisual), 'referenceVisual')]), | ||
4931 | + StdMethod(HRESULT, 'RemoveVisual', [(ObjPointer(IDCompositionVisual), 'visual')]), | ||
4932 | + StdMethod(HRESULT, 'RemoveAllVisuals', []), | ||
4933 | + StdMethod(HRESULT, 'SetCompositeMode', [(DCOMPOSITION_COMPOSITE_MODE, 'compositeMode')]), | ||
4934 | +] | ||
4935 | + | ||
4936 | +IDCompositionTransform.methods += [ | ||
4937 | +] | ||
4938 | + | ||
4939 | +IDCompositionTransform3D.methods += [ | ||
4940 | +] | ||
4941 | + | ||
4942 | +IDCompositionTranslateTransform.methods += [ | ||
4943 | + StdMethod(HRESULT, 'SetOffsetX', [(Float, 'offsetX')], overloaded=True), | ||
4944 | + StdMethod(HRESULT, 'SetOffsetX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4945 | + StdMethod(HRESULT, 'SetOffsetY', [(Float, 'offsetY')], overloaded=True), | ||
4946 | + StdMethod(HRESULT, 'SetOffsetY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4947 | +] | ||
4948 | + | ||
4949 | +IDCompositionTranslateTransform3D.methods += [ | ||
4950 | + StdMethod(HRESULT, 'SetOffsetX', [(Float, 'offsetX')], overloaded=True), | ||
4951 | + StdMethod(HRESULT, 'SetOffsetX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4952 | + StdMethod(HRESULT, 'SetOffsetY', [(Float, 'offsetY')], overloaded=True), | ||
4953 | + StdMethod(HRESULT, 'SetOffsetY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4954 | + StdMethod(HRESULT, 'SetOffsetZ', [(Float, 'offsetZ')], overloaded=True), | ||
4955 | + StdMethod(HRESULT, 'SetOffsetZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4956 | +] | ||
4957 | + | ||
4958 | +IDCompositionScaleTransform.methods += [ | ||
4959 | + StdMethod(HRESULT, 'SetScaleX', [(Float, 'scaleX')], overloaded=True), | ||
4960 | + StdMethod(HRESULT, 'SetScaleX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4961 | + StdMethod(HRESULT, 'SetScaleY', [(Float, 'scaleY')], overloaded=True), | ||
4962 | + StdMethod(HRESULT, 'SetScaleY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4963 | + StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), | ||
4964 | + StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4965 | + StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), | ||
4966 | + StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4967 | +] | ||
4968 | + | ||
4969 | +IDCompositionScaleTransform3D.methods += [ | ||
4970 | + StdMethod(HRESULT, 'SetScaleX', [(Float, 'scaleX')], overloaded=True), | ||
4971 | + StdMethod(HRESULT, 'SetScaleX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4972 | + StdMethod(HRESULT, 'SetScaleY', [(Float, 'scaleY')], overloaded=True), | ||
4973 | + StdMethod(HRESULT, 'SetScaleY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4974 | + StdMethod(HRESULT, 'SetScaleZ', [(Float, 'scaleZ')], overloaded=True), | ||
4975 | + StdMethod(HRESULT, 'SetScaleZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4976 | + StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), | ||
4977 | + StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4978 | + StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), | ||
4979 | + StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4980 | + StdMethod(HRESULT, 'SetCenterZ', [(Float, 'centerZ')], overloaded=True), | ||
4981 | + StdMethod(HRESULT, 'SetCenterZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4982 | +] | ||
4983 | + | ||
4984 | +IDCompositionRotateTransform.methods += [ | ||
4985 | + StdMethod(HRESULT, 'SetAngle', [(Float, 'angle')], overloaded=True), | ||
4986 | + StdMethod(HRESULT, 'SetAngle', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4987 | + StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), | ||
4988 | + StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4989 | + StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), | ||
4990 | + StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4991 | +] | ||
4992 | + | ||
4993 | +IDCompositionRotateTransform3D.methods += [ | ||
4994 | + StdMethod(HRESULT, 'SetAngle', [(Float, 'angle')], overloaded=True), | ||
4995 | + StdMethod(HRESULT, 'SetAngle', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4996 | + StdMethod(HRESULT, 'SetAxisX', [(Float, 'axisX')], overloaded=True), | ||
4997 | + StdMethod(HRESULT, 'SetAxisX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
4998 | + StdMethod(HRESULT, 'SetAxisY', [(Float, 'axisY')], overloaded=True), | ||
4999 | + StdMethod(HRESULT, 'SetAxisY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5000 | + StdMethod(HRESULT, 'SetAxisZ', [(Float, 'axisZ')], overloaded=True), | ||
5001 | + StdMethod(HRESULT, 'SetAxisZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5002 | + StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), | ||
5003 | + StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5004 | + StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), | ||
5005 | + StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5006 | + StdMethod(HRESULT, 'SetCenterZ', [(Float, 'centerZ')], overloaded=True), | ||
5007 | + StdMethod(HRESULT, 'SetCenterZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5008 | +] | ||
5009 | + | ||
5010 | +IDCompositionSkewTransform.methods += [ | ||
5011 | + StdMethod(HRESULT, 'SetAngleX', [(Float, 'angleX')], overloaded=True), | ||
5012 | + StdMethod(HRESULT, 'SetAngleX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5013 | + StdMethod(HRESULT, 'SetAngleY', [(Float, 'angleY')], overloaded=True), | ||
5014 | + StdMethod(HRESULT, 'SetAngleY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5015 | + StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), | ||
5016 | + StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5017 | + StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), | ||
5018 | + StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5019 | +] | ||
5020 | + | ||
5021 | +IDCompositionMatrixTransform.methods += [ | ||
5022 | + StdMethod(HRESULT, 'SetMatrix', [(Reference(Const(D2D_MATRIX_3X2_F)), 'matrix')]), | ||
5023 | + StdMethod(HRESULT, 'SetMatrixElement', [(Int, 'row'), (Int, 'column'), (Float, 'value')], overloaded=True), | ||
5024 | + StdMethod(HRESULT, 'SetMatrixElement', [(Int, 'row'), (Int, 'column'), (ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5025 | +] | ||
5026 | + | ||
5027 | +IDCompositionMatrixTransform3D.methods += [ | ||
5028 | + StdMethod(HRESULT, 'SetMatrix', [(Reference(Const(D3DMATRIX)), 'matrix')]), | ||
5029 | + StdMethod(HRESULT, 'SetMatrixElement', [(Int, 'row'), (Int, 'column'), (Float, 'value')], overloaded=True), | ||
5030 | + StdMethod(HRESULT, 'SetMatrixElement', [(Int, 'row'), (Int, 'column'), (ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5031 | +] | ||
5032 | + | ||
5033 | +IDCompositionEffect.methods += [ | ||
5034 | +] | ||
5035 | + | ||
5036 | +IDCompositionEffectGroup.methods += [ | ||
5037 | + StdMethod(HRESULT, 'SetOpacity', [(Float, 'opacity')], overloaded=True), | ||
5038 | + StdMethod(HRESULT, 'SetOpacity', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5039 | + StdMethod(HRESULT, 'SetTransform3D', [(ObjPointer(IDCompositionTransform3D), 'transform3D')]), | ||
5040 | +] | ||
5041 | + | ||
5042 | +IDCompositionClip.methods += [ | ||
5043 | +] | ||
5044 | + | ||
5045 | +IDCompositionRectangleClip.methods += [ | ||
5046 | + StdMethod(HRESULT, 'SetLeft', [(Float, 'left')], overloaded=True), | ||
5047 | + StdMethod(HRESULT, 'SetLeft', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5048 | + StdMethod(HRESULT, 'SetTop', [(Float, 'top')], overloaded=True), | ||
5049 | + StdMethod(HRESULT, 'SetTop', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5050 | + StdMethod(HRESULT, 'SetRight', [(Float, 'right')], overloaded=True), | ||
5051 | + StdMethod(HRESULT, 'SetRight', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5052 | + StdMethod(HRESULT, 'SetBottom', [(Float, 'bottom')], overloaded=True), | ||
5053 | + StdMethod(HRESULT, 'SetBottom', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5054 | + StdMethod(HRESULT, 'SetTopLeftRadiusX', [(Float, 'radius')], overloaded=True), | ||
5055 | + StdMethod(HRESULT, 'SetTopLeftRadiusX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5056 | + StdMethod(HRESULT, 'SetTopLeftRadiusY', [(Float, 'radius')], overloaded=True), | ||
5057 | + StdMethod(HRESULT, 'SetTopLeftRadiusY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5058 | + StdMethod(HRESULT, 'SetTopRightRadiusX', [(Float, 'radius')], overloaded=True), | ||
5059 | + StdMethod(HRESULT, 'SetTopRightRadiusX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5060 | + StdMethod(HRESULT, 'SetTopRightRadiusY', [(Float, 'radius')], overloaded=True), | ||
5061 | + StdMethod(HRESULT, 'SetTopRightRadiusY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5062 | + StdMethod(HRESULT, 'SetBottomLeftRadiusX', [(Float, 'radius')], overloaded=True), | ||
5063 | + StdMethod(HRESULT, 'SetBottomLeftRadiusX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5064 | + StdMethod(HRESULT, 'SetBottomLeftRadiusY', [(Float, 'radius')], overloaded=True), | ||
5065 | + StdMethod(HRESULT, 'SetBottomLeftRadiusY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5066 | + StdMethod(HRESULT, 'SetBottomRightRadiusX', [(Float, 'radius')], overloaded=True), | ||
5067 | + StdMethod(HRESULT, 'SetBottomRightRadiusX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5068 | + StdMethod(HRESULT, 'SetBottomRightRadiusY', [(Float, 'radius')], overloaded=True), | ||
5069 | + StdMethod(HRESULT, 'SetBottomRightRadiusY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), | ||
5070 | +] | ||
5071 | + | ||
5072 | +IDCompositionSurface.methods += [ | ||
5073 | + # XXX: riid might be ID2D1DeviceContext | ||
5074 | + StdMethod(HRESULT, 'BeginDraw', [(Pointer(Const(RECT)), 'updateRect'), (REFIID, 'iid'), Out(Pointer(ObjPointer(Void)), 'updateObject'), Out(Pointer(POINT), 'updateOffset')]), | ||
5075 | + StdMethod(HRESULT, 'EndDraw', []), | ||
5076 | + StdMethod(HRESULT, 'SuspendDraw', []), | ||
5077 | + StdMethod(HRESULT, 'ResumeDraw', []), | ||
5078 | + StdMethod(HRESULT, 'Scroll', [(Pointer(Const(RECT)), 'scrollRect'), (Pointer(Const(RECT)), 'clipRect'), (Int, 'offsetX'), (Int, 'offsetY')]), | ||
5079 | +] | ||
5080 | + | ||
5081 | +IDCompositionVirtualSurface.methods += [ | ||
5082 | + StdMethod(HRESULT, 'Resize', [(UINT, 'width'), (UINT, 'height')]), | ||
5083 | + StdMethod(HRESULT, 'Trim', [(Array(Const(RECT), 'count'), 'rectangles'), (UINT, 'count')]), | ||
5084 | +] | ||
5085 | + | ||
5086 | +dcomp = Module('dcomp') | ||
5087 | +dcomp.addFunctions([ | ||
5088 | + StdFunction(HRESULT, 'DCompositionCreateDevice', [(ObjPointer(IDXGIDevice), 'dxgiDevice'), (REFIID, 'iid'), Out(Pointer(ObjPointer(Void)), 'dcompositionDevice')]), | ||
5089 | + StdFunction(HRESULT, 'DCompositionCreateSurfaceHandle', [(COMPOSITIONOBJECT, 'desiredAccess'), (Pointer(SECURITY_ATTRIBUTES), 'securityAttributes'), Out(Pointer(HANDLE), 'surfaceHandle')]), | ||
5090 | +]) | ||
5091 | +dcomp.addInterfaces([ | ||
5092 | + IDCompositionDevice, | ||
5093 | +]) | ||
5094 | diff --git a/specs/ddraw.py b/specs/ddraw.py | ||
5095 | index 99f542fe..5df48be0 100644 | ||
5096 | --- a/specs/ddraw.py | ||
5097 | +++ b/specs/ddraw.py | ||
5098 | @@ -25,7 +25,7 @@ | ||
5099 | |||
5100 | """ddraw.h""" | ||
5101 | |||
5102 | -from winapi import * | ||
5103 | +from .winapi import * | ||
5104 | |||
5105 | DirectDrawOptSurfaceDescFlags = Flags(DWORD, [ | ||
5106 | "DDOSD_GUID", | ||
5107 | diff --git a/specs/debug.py b/specs/debug.py | ||
5108 | index 0a004741..6ef80f64 100644 | ||
5109 | --- a/specs/debug.py | ||
5110 | +++ b/specs/debug.py | ||
5111 | @@ -49,7 +49,7 @@ def excepthook(type, value, tb): | ||
5112 | import traceback, pdb | ||
5113 | # we are NOT in interactive mode, print the exception... | ||
5114 | traceback.print_exception(type, value, tb) | ||
5115 | |||
5116 | + print() | ||
5117 | # ...then start the debugger in post-mortem mode. | ||
5118 | pdb.pm() | ||
5119 | |||
5120 | diff --git a/specs/dwrite.py b/specs/dwrite.py | ||
5121 | index 60e5034c..be273f81 100644 | ||
5122 | --- a/specs/dwrite.py | ||
5123 | +++ b/specs/dwrite.py | ||
5124 | @@ -24,8 +24,8 @@ | ||
5125 | ##########################################################################/ | ||
5126 | |||
5127 | |||
5128 | -from winapi import * | ||
5129 | -from dcommon import * | ||
5130 | +from .winapi import * | ||
5131 | +from .dcommon import * | ||
5132 | |||
5133 | |||
5134 | ID2D1SimplifiedGeometrySink = Interface("ID2D1SimplifiedGeometrySink", IUnknown) | ||
5135 | diff --git a/specs/dxgi.py b/specs/dxgi.py | ||
5136 | index 0e880548..040f3bc4 100644 | ||
5137 | --- a/specs/dxgi.py | ||
5138 | +++ b/specs/dxgi.py | ||
5139 | @@ -25,7 +25,7 @@ | ||
5140 | ##########################################################################/ | ||
5141 | |||
5142 | |||
5143 | -from winapi import * | ||
5144 | +from .winapi import * | ||
5145 | |||
5146 | |||
5147 | DXGI_FORMAT = Enum("DXGI_FORMAT", [ | ||
5148 | diff --git a/specs/dxva2.py b/specs/dxva2.py | ||
5149 | index 3936afac..65f5f0c0 100644 | ||
5150 | --- a/specs/dxva2.py | ||
5151 | +++ b/specs/dxva2.py | ||
5152 | @@ -24,7 +24,7 @@ | ||
5153 | ##########################################################################/ | ||
5154 | |||
5155 | |||
5156 | -from d3d9 import * | ||
5157 | +from .d3d9 import * | ||
5158 | |||
5159 | |||
5160 | HRESULT = MAKE_HRESULT(errors = [ | ||
5161 | diff --git a/specs/eglapi.py b/specs/eglapi.py | ||
5162 | index 8379e45e..e1edff06 100644 | ||
5163 | --- a/specs/eglapi.py | ||
5164 | +++ b/specs/eglapi.py | ||
5165 | @@ -26,9 +26,9 @@ | ||
5166 | """EGL API description.""" | ||
5167 | |||
5168 | |||
5169 | -from stdapi import * | ||
5170 | -from gltypes import * | ||
5171 | -from eglenum import * | ||
5172 | +from .stdapi import * | ||
5173 | +from .gltypes import * | ||
5174 | +from .eglenum import * | ||
5175 | |||
5176 | EGLNativeDisplayType = Opaque("EGLNativeDisplayType") | ||
5177 | EGLNativeWindowType = Opaque("EGLNativeWindowType") | ||
5178 | diff --git a/specs/eglenum.py b/specs/eglenum.py | ||
5179 | index 8b10868d..e6290fb2 100644 | ||
5180 | --- a/specs/eglenum.py | ||
5181 | +++ b/specs/eglenum.py | ||
5182 | @@ -28,7 +28,7 @@ | ||
5183 | """EGL enum description""" | ||
5184 | |||
5185 | |||
5186 | -from stdapi import * | ||
5187 | +from .stdapi import * | ||
5188 | |||
5189 | # Most of the following content was produced in a semi-automated fashion by | ||
5190 | # the scripts/eglenum.sed sed script. | ||
5191 | diff --git a/specs/glapi.py b/specs/glapi.py | ||
5192 | index c0e92b3c..8d20052e 100644 | ||
5193 | --- a/specs/glapi.py | ||
5194 | +++ b/specs/glapi.py | ||
5195 | @@ -34,9 +34,9 @@ corner cases correctly. | ||
5196 | """ | ||
5197 | |||
5198 | |||
5199 | -from stdapi import * | ||
5200 | -from gltypes import * | ||
5201 | -import glparams | ||
5202 | +from .stdapi import * | ||
5203 | +from .gltypes import * | ||
5204 | +from . import glparams | ||
5205 | |||
5206 | |||
5207 | def GlFunction(*args, **kwargs): | ||
5208 | diff --git a/specs/glparams.py b/specs/glparams.py | ||
5209 | index 1bed8a6b..5a036975 100644 | ||
5210 | --- a/specs/glparams.py | ||
5211 | +++ b/specs/glparams.py | ||
5212 | @@ -27,9 +27,9 @@ | ||
5213 | '''Describe GL parameters.''' | ||
5214 | |||
5215 | |||
5216 | -from stdapi import * | ||
5217 | +from .stdapi import * | ||
5218 | |||
5219 | -from gltypes import * | ||
5220 | +from .gltypes import * | ||
5221 | |||
5222 | |||
5223 | # Shorthands for the types | ||
5224 | diff --git a/specs/gltypes.py b/specs/gltypes.py | ||
5225 | index a9ffc4a1..631eb868 100644 | ||
5226 | --- a/specs/gltypes.py | ||
5227 | +++ b/specs/gltypes.py | ||
5228 | @@ -29,7 +29,7 @@ | ||
5229 | |||
5230 | import platform | ||
5231 | |||
5232 | -from stdapi import * | ||
5233 | +from .stdapi import * | ||
5234 | |||
5235 | |||
5236 | GLboolean = Enum("GLboolean", [ | ||
5237 | diff --git a/specs/glxapi.py b/specs/glxapi.py | ||
5238 | index 0d3cd969..f4182799 100644 | ||
5239 | --- a/specs/glxapi.py | ||
5240 | +++ b/specs/glxapi.py | ||
5241 | @@ -26,8 +26,8 @@ | ||
5242 | """GLX API description.""" | ||
5243 | |||
5244 | |||
5245 | -from stdapi import * | ||
5246 | -from glapi import * | ||
5247 | +from .stdapi import * | ||
5248 | +from .glapi import * | ||
5249 | |||
5250 | VisualID = Alias("VisualID", UInt32) | ||
5251 | Display = Opaque("Display *") | ||
5252 | diff --git a/specs/scripts/c2api.py b/specs/scripts/c2api.py | ||
5253 | index 7deb2955..b8aaa81d 100755 | ||
5254 | --- a/specs/scripts/c2api.py | ||
5255 | +++ b/specs/scripts/c2api.py | ||
5256 | @@ -122,7 +122,7 @@ class DeclParser: | ||
5257 | self.consume() | ||
5258 | type = 'Pointer(%s)' % type | ||
5259 | name = self.consume() | ||
5260 | - print '%s = Alias("%s", %s)' % (name, name, type) | ||
5261 | + print('%s = Alias("%s", %s)' % (name, name, type)) | ||
5262 | if self.match(','): | ||
5263 | self.consume() | ||
5264 | else: | ||
5265 | @@ -136,7 +136,7 @@ class DeclParser: | ||
5266 | name = self.consume() | ||
5267 | self.consume('{') | ||
5268 | |||
5269 | - print '%s = Enum("%s", [' % (name, name) | ||
5270 | + print('%s = Enum("%s", [' % (name, name)) | ||
5271 | |||
5272 | #value = 0 | ||
5273 | while self.lookahead() != '}': | ||
5274 | @@ -148,12 +148,12 @@ class DeclParser: | ||
5275 | self.consume(',') | ||
5276 | tags = self.parse_tags() | ||
5277 | #print ' "%s",\t# %s' % (name, value) | ||
5278 | - print ' "%s",' % (name,) | ||
5279 | + print(' "%s",' % (name,)) | ||
5280 | #value += 1 | ||
5281 | self.consume('}') | ||
5282 | |||
5283 | - print '])' | ||
5284 | |||
5285 | + print('])') | ||
5286 | + print() | ||
5287 | |||
5288 | def parse_value(self, ref_token, constructor): | ||
5289 | self.consume(ref_token) | ||
5290 | @@ -161,14 +161,14 @@ class DeclParser: | ||
5291 | name = self.consume() | ||
5292 | self.consume('{') | ||
5293 | |||
5294 | - print '%s = %s(%s, [' % (name, constructor, type) | ||
5295 | + print('%s = %s(%s, [' % (name, constructor, type)) | ||
5296 | |||
5297 | while self.lookahead() != '}': | ||
5298 | name, value = self.parse_define() | ||
5299 | self.consume('}') | ||
5300 | |||
5301 | - print '])' | ||
5302 | |||
5303 | + print('])') | ||
5304 | + print() | ||
5305 | |||
5306 | def parse_define(self): | ||
5307 | self.consume('#') | ||
5308 | @@ -176,18 +176,18 @@ class DeclParser: | ||
5309 | name = self.consume() | ||
5310 | value = self.consume() | ||
5311 | #print ' "%s",\t# %s' % (name, value) | ||
5312 | - print ' "%s",' % (name,) | ||
5313 | + print(' "%s",' % (name,)) | ||
5314 | return name, value | ||
5315 | |||
5316 | def parse_struct(self): | ||
5317 | self.consume('struct') | ||
5318 | name = self.consume() | ||
5319 | |||
5320 | - print '%s = Struct("%s", [' % (name, name) | ||
5321 | + print('%s = Struct("%s", [' % (name, name)) | ||
5322 | for type, name in self.parse_members(): | ||
5323 | - print ' (%s, "%s"),' % (type, name) | ||
5324 | - print '])' | ||
5325 | |||
5326 | + print(' (%s, "%s"),' % (type, name)) | ||
5327 | + print('])') | ||
5328 | + print() | ||
5329 | |||
5330 | def parse_union(self): | ||
5331 | self.consume('union') | ||
5332 | @@ -226,8 +226,8 @@ class DeclParser: | ||
5333 | base = self.consume() | ||
5334 | self.consume('{') | ||
5335 | |||
5336 | - print '%s = Interface("%s", %s)' % (name, name, base) | ||
5337 | - print '%s.methods += [' % (name,) | ||
5338 | + print('%s = Interface("%s", %s)' % (name, name, base)) | ||
5339 | + print('%s.methods += [' % (name,)) | ||
5340 | |||
5341 | while self.lookahead() != '}': | ||
5342 | if self.lookahead() in ('public', 'private'): | ||
5343 | @@ -238,8 +238,8 @@ class DeclParser: | ||
5344 | self.consume(';') | ||
5345 | self.consume('}') | ||
5346 | |||
5347 | - print ']' | ||
5348 | |||
5349 | + print(']') | ||
5350 | + print() | ||
5351 | |||
5352 | def parse_prototype(self, creator = 'Function'): | ||
5353 | if self.match('extern', 'virtual'): | ||
5354 | @@ -275,7 +275,7 @@ class DeclParser: | ||
5355 | self.consume() | ||
5356 | self.consume('0') | ||
5357 | |||
5358 | - print ' %s(%s, "%s", [%s]%s),' % (creator, ret, name, ', '.join(args), extra) | ||
5359 | + print(' %s(%s, "%s", [%s]%s),' % (creator, ret, name, ', '.join(args), extra)) | ||
5360 | |||
5361 | def parse_arg(self): | ||
5362 | tags = self.parse_tags() | ||
5363 | @@ -404,8 +404,8 @@ class DeclParser: | ||
5364 | type = 'S' + type | ||
5365 | elif short: | ||
5366 | type = 'Short' | ||
5367 | - elif long: | ||
5368 | - type = 'Long' * long | ||
5369 | + elif int: | ||
5370 | + type = 'Long' * int | ||
5371 | else: | ||
5372 | type = 'Int' | ||
5373 | if unsigned: | ||
5374 | diff --git a/specs/scripts/cxx2api.py b/specs/scripts/cxx2api.py | ||
5375 | new file mode 100755 | ||
5376 | index 00000000..9720615d | ||
5377 | --- /dev/null | ||
5378 | +++ b/specs/scripts/cxx2api.py | ||
5379 | @@ -0,0 +1,488 @@ | ||
5380 | +#!/usr/bin/env python | ||
5381 | + | ||
5382 | + | ||
5383 | + | ||
5384 | +copyright = ''' | ||
5385 | +########################################################################## | ||
5386 | +# | ||
5387 | +# Copyright 2009-2016 VMware, Inc. | ||
5388 | +# All Rights Reserved. | ||
5389 | +# | ||
5390 | +# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
5391 | +# of this software and associated documentation files (the "Software"), to deal | ||
5392 | +# in the Software without restriction, including without limitation the rights | ||
5393 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
5394 | +# copies of the Software, and to permit persons to whom the Software is | ||
5395 | +# furnished to do so, subject to the following conditions: | ||
5396 | +# | ||
5397 | +# The above copyright notice and this permission notice shall be included in | ||
5398 | +# all copies or substantial portions of the Software. | ||
5399 | +# | ||
5400 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
5401 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
5402 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
5403 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
5404 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
5405 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
5406 | +# THE SOFTWARE. | ||
5407 | +# | ||
5408 | +##########################################################################/ | ||
5409 | +''' | ||
5410 | + | ||
5411 | + | ||
5412 | +# | ||
5413 | +# Generates API specs from headers using castxml/pygccxml. | ||
5414 | +# | ||
5415 | +# Usage: | ||
5416 | +# | ||
5417 | +# sudo apt-get install castxml mingw-w64-i686-dev | ||
5418 | +# pip install 'pygccxml==1.9.1' | ||
5419 | +# python specs/scripts/cxx2api.py -Idxsdk/Include -DD2D_USE_C_DEFINITIONS dcomp.h dcomptypes.h dcompanimation.h | ||
5420 | +# | ||
5421 | +# See also: | ||
5422 | +# - http://pygccxml.readthedocs.org/en/develop/index.html | ||
5423 | +# - https://github.com/CastXML/CastXML/blob/master/doc/manual/castxml.1.rst | ||
5424 | +# | ||
5425 | + | ||
5426 | +import os.path | ||
5427 | +import sys | ||
5428 | +import io as StringIO | ||
5429 | +import subprocess | ||
5430 | + | ||
5431 | +from pygccxml import utils | ||
5432 | +from pygccxml import parser | ||
5433 | +from pygccxml import declarations | ||
5434 | + | ||
5435 | +from pygccxml.declarations import algorithm | ||
5436 | +from pygccxml.declarations import decl_visitor | ||
5437 | +from pygccxml.declarations import type_traits | ||
5438 | +from pygccxml.declarations import type_visitor | ||
5439 | + | ||
5440 | + | ||
5441 | +class decl_dumper_t(decl_visitor.decl_visitor_t): | ||
5442 | + | ||
5443 | + def __init__(self, decl = None): | ||
5444 | + decl_visitor.decl_visitor_t.__init__(self) | ||
5445 | + self.decl = decl | ||
5446 | + self.result = None | ||
5447 | + | ||
5448 | + def clone(self): | ||
5449 | + return decl_dumper_t(self.decl) | ||
5450 | + | ||
5451 | + def visit_class(self): | ||
5452 | + class_ = self.decl | ||
5453 | + assert class_.class_type in ('struct', 'union') | ||
5454 | + self.result = class_.name | ||
5455 | + | ||
5456 | + def visit_class_declaration(self): | ||
5457 | + class_ = self.decl | ||
5458 | + self.result = class_.name | ||
5459 | + | ||
5460 | + def visit_typedef(self): | ||
5461 | + typedef = self.decl | ||
5462 | + self.result = typedef.name | ||
5463 | + | ||
5464 | + def visit_enumeration(self): | ||
5465 | + self.result = self.decl.name | ||
5466 | + | ||
5467 | + | ||
5468 | +def dump_decl(decl): | ||
5469 | + visitor = decl_dumper_t(decl) | ||
5470 | + algorithm.apply_visitor(visitor, decl) | ||
5471 | + return visitor.result | ||
5472 | + | ||
5473 | + | ||
5474 | +class type_dumper_t(type_visitor.type_visitor_t): | ||
5475 | + | ||
5476 | + def __init__(self, type): | ||
5477 | + type_visitor.type_visitor_t.__init__(self) | ||
5478 | + self.type = type | ||
5479 | + self.result = None | ||
5480 | + | ||
5481 | + def clone(self): | ||
5482 | + return type_dumper_t(self.type) | ||
5483 | + | ||
5484 | + def visit_void(self): | ||
5485 | + self.result = 'Void' | ||
5486 | + | ||
5487 | + def visit_char(self): | ||
5488 | + self.result = 'Char' | ||
5489 | + | ||
5490 | + def visit_unsigned_char(self): | ||
5491 | + self.result = 'UChar' | ||
5492 | + | ||
5493 | + def visit_signed_char(self): | ||
5494 | + self.result = 'SChar' | ||
5495 | + | ||
5496 | + def visit_wchar(self): | ||
5497 | + raise NotImplementedError | ||
5498 | + | ||
5499 | + def visit_short_int(self): | ||
5500 | + self.result = 'Short' | ||
5501 | + | ||
5502 | + def visit_short_unsigned_int(self): | ||
5503 | + self.result = 'UShort' | ||
5504 | + | ||
5505 | + def visit_bool(self): | ||
5506 | + raise NotImplementedError | ||
5507 | + | ||
5508 | + def visit_int(self): | ||
5509 | + self.result = 'Int' | ||
5510 | + | ||
5511 | + def visit_unsigned_int(self): | ||
5512 | + self.result = 'UInt' | ||
5513 | + | ||
5514 | + def visit_long_int(self): | ||
5515 | + self.result = 'Long' | ||
5516 | + | ||
5517 | + def visit_long_unsigned_int(self): | ||
5518 | + self.result = 'ULong' | ||
5519 | + | ||
5520 | + def visit_long_long_int(self): | ||
5521 | + self.result = 'LongLong' | ||
5522 | + | ||
5523 | + def visit_long_long_unsigned_int(self): | ||
5524 | + self.result = 'ULongLong' | ||
5525 | + | ||
5526 | + def visit_float(self): | ||
5527 | + self.result = "Float" | ||
5528 | + | ||
5529 | + def visit_double(self): | ||
5530 | + self.result = "Double" | ||
5531 | + | ||
5532 | + def visit_array(self): | ||
5533 | + base_type = dump_type(self.type.base) | ||
5534 | + length = self.type.size | ||
5535 | + try: | ||
5536 | + int(length) | ||
5537 | + except ValueError: | ||
5538 | + length = '"%s"' % length | ||
5539 | + self.result = 'Array(%s, %s)' % (base_type, length) | ||
5540 | + | ||
5541 | + def visit_pointer(self): | ||
5542 | + base_type = dump_type(self.type.base) | ||
5543 | + # TODO: Use ObjPointer where appropriate | ||
5544 | + #if isinstance(self.type.base, declarations.cpptypes.declarated_t): | ||
5545 | + # decl = self.type.base.declaration | ||
5546 | + # if isinstance(decl, declarations.typedef.typedef_t): | ||
5547 | + # print(decl.type, type(decl.type)) | ||
5548 | + # if isinstance(decl, declarations.class_declaration.class_t): | ||
5549 | + # if decl.public_members: | ||
5550 | + # self.result = 'ObjPointer(%s)' % decl.name | ||
5551 | + # return | ||
5552 | + # if isinstance(decl, declarations.class_declaration.class_declaration_t): | ||
5553 | + # if decl.public_members: | ||
5554 | + # self.result = 'ObjPointer(%s)' % decl.name | ||
5555 | + # return | ||
5556 | + if base_type.startswith('IDComposition') or \ | ||
5557 | + base_type.startswith('IDXGI') or \ | ||
5558 | + base_type == 'IUnknown': | ||
5559 | + self.result = 'ObjPointer(%s)' % base_type | ||
5560 | + return | ||
5561 | + self.result = 'Pointer(%s)' % base_type | ||
5562 | + | ||
5563 | + def visit_reference(self): | ||
5564 | + base_type = dump_type(self.type.base) | ||
5565 | + if base_type == 'Const(IID)': | ||
5566 | + self.result = 'REFIID' | ||
5567 | + elif base_type == 'Const(GUID)': | ||
5568 | + self.result = 'REFGUID' | ||
5569 | + else: | ||
5570 | + self.result = 'Reference(%s)' % base_type | ||
5571 | + | ||
5572 | + def visit_const(self): | ||
5573 | + self.result = 'Const(%s)' % dump_type(self.type.base) | ||
5574 | + | ||
5575 | + def visit_declarated(self): | ||
5576 | + decl = self.type.declaration | ||
5577 | + self.result = dump_decl(decl) | ||
5578 | + | ||
5579 | + def visit_free_function_type(self): | ||
5580 | + self.result = 'Opaque("%s")' % self.type | ||
5581 | + | ||
5582 | + | ||
5583 | +def dump_type(type): | ||
5584 | + visitor = type_dumper_t(type) | ||
5585 | + algorithm.apply_visitor(visitor, type) | ||
5586 | + # XXX: RECT becomes tagRECT somehow | ||
5587 | + if visitor.result == 'tagRECT': | ||
5588 | + return 'RECT' | ||
5589 | + return visitor.result | ||
5590 | + | ||
5591 | + | ||
5592 | +def is_interface(class_): | ||
5593 | + if not class_.name.startswith('I'): | ||
5594 | + return | ||
5595 | + if len(class_.bases) != 1: | ||
5596 | + return False | ||
5597 | + # TODO: Ensure interface derives from IUnknown | ||
5598 | + return True | ||
5599 | + | ||
5600 | + | ||
5601 | +class decl2_dumper_t(decl_visitor.decl_visitor_t): | ||
5602 | + | ||
5603 | + def __init__(self, name): | ||
5604 | + decl_visitor.decl_visitor_t.__init__(self) | ||
5605 | + | ||
5606 | + self.name = name | ||
5607 | + | ||
5608 | + # The current declaration | ||
5609 | + self.decl = None | ||
5610 | + | ||
5611 | + self.interfaces = StringIO.StringIO() | ||
5612 | + self.methods = StringIO.StringIO() | ||
5613 | + self.functions = StringIO.StringIO() | ||
5614 | + | ||
5615 | + def start(self): | ||
5616 | + print(copyright.strip()) | ||
5617 | + print() | ||
5618 | + print() | ||
5619 | + print(r'from winapi import *') | ||
5620 | + print() | ||
5621 | + | ||
5622 | + def finish(self): | ||
5623 | + sys.stdout.write(self.interfaces.getvalue()) | ||
5624 | + sys.stdout.write('\n') | ||
5625 | + sys.stdout.write(self.methods.getvalue()) | ||
5626 | + | ||
5627 | + name = self.name | ||
5628 | + sys.stdout.write('%s = Module(%r)\n' % (name, name)) | ||
5629 | + sys.stdout.write('%s.addFunctions([\n' % (name,)) | ||
5630 | + sys.stdout.write(self.functions.getvalue()) | ||
5631 | + sys.stdout.write('])\n\n') | ||
5632 | + | ||
5633 | + def clone(self): | ||
5634 | + return decl_dumper_t(self.decl) | ||
5635 | + | ||
5636 | + def visit_class(self): | ||
5637 | + class_ = self.decl | ||
5638 | + assert class_.class_type in ('struct', 'union') | ||
5639 | + | ||
5640 | + if is_interface(class_): | ||
5641 | + self.visit_interface() | ||
5642 | + elif class_.name != '': | ||
5643 | + self.visit_struct(class_.name, class_) | ||
5644 | + | ||
5645 | + def visit_struct(self, decl_name, decl): | ||
5646 | + struct = decl | ||
5647 | + print(r'%s = Struct(%r, [' % (decl_name, decl_name)) | ||
5648 | + for variable in struct.variables(allow_empty=True): | ||
5649 | + var_type = dump_type(variable.decl_type) | ||
5650 | + print(r' (%s, %r),' % (var_type, variable.name)) | ||
5651 | + print(r'])') | ||
5652 | + print() | ||
5653 | + | ||
5654 | + def visit_interface(self): | ||
5655 | + class_ = self.decl | ||
5656 | + assert len(class_.bases) == 1 | ||
5657 | + base = class_.bases[0] | ||
5658 | + | ||
5659 | + s = self.interfaces | ||
5660 | + s.write('%s = Interface(%r, %s)\n' % (class_.name, class_.name, base.related_class.name)) | ||
5661 | + | ||
5662 | + s = self.methods | ||
5663 | + s.write('%s.methods += [\n' % (class_.name,)) | ||
5664 | + for member in class_.public_members: | ||
5665 | + if member.virtuality != 'pure virtual': | ||
5666 | + continue | ||
5667 | + ret_type = dump_type(member.return_type) | ||
5668 | + arg_types = self.convert_args(member.arguments) | ||
5669 | + s.write(' StdMethod(%s, %r, [%s]),\n' % (ret_type, member.name, arg_types)) | ||
5670 | + s.write(']\n\n') | ||
5671 | + | ||
5672 | + def convert_args(self, args): | ||
5673 | + # TODO: use __attribute__ ((annotate ("out"))) | ||
5674 | + # See also: | ||
5675 | + # - https://github.com/CastXML/CastXML/issues/25 | ||
5676 | + # XXX: Requires a castxml version newer than the one in Ubuntu 15.10 | ||
5677 | + arg_types = [] | ||
5678 | + for arg in args: | ||
5679 | + if arg.attributes is not None: | ||
5680 | + sys.stderr.write('warning: found %s attribute %r\n' % (arg.name, arg.attributes)) | ||
5681 | + res_arg_type = dump_type(arg.decl_type) | ||
5682 | + res_arg = '(%s, %r)' % (res_arg_type, arg.name) | ||
5683 | + | ||
5684 | + # Infer output arguments | ||
5685 | + if res_arg_type.startswith('Pointer(') and \ | ||
5686 | + not res_arg_type.startswith('Pointer(Const('): | ||
5687 | + res_arg = 'Out' + res_arg | ||
5688 | + | ||
5689 | + arg_types.append(res_arg) | ||
5690 | + | ||
5691 | + arg_types = ', '.join(arg_types) | ||
5692 | + return arg_types | ||
5693 | + | ||
5694 | + def visit_class_declaration(self): | ||
5695 | + pass | ||
5696 | + | ||
5697 | + def visit_typedef(self): | ||
5698 | + typedef = self.decl | ||
5699 | + base_type = dump_type(typedef.decl_type) | ||
5700 | + if base_type == typedef.name: | ||
5701 | + # Ignore `typedef struct Foo Foo;` | ||
5702 | + return | ||
5703 | + if base_type == '': | ||
5704 | + if isinstance(typedef.decl_type, declarations.cpptypes.declarated_t): | ||
5705 | + base_decl = typedef.decl_type.declaration | ||
5706 | + self.visit_struct(typedef.name, base_decl) | ||
5707 | + return | ||
5708 | + print(r'%s = Alias(%r, %s)' % (typedef.name, typedef.name, base_type)) | ||
5709 | + print() | ||
5710 | + | ||
5711 | + def visit_enumeration(self): | ||
5712 | + enum = self.decl | ||
5713 | + print(r'%s = Enum(%r, [' % (enum.name, enum.name)) | ||
5714 | + for name, value in enum.values: | ||
5715 | + print(r' %r,' % (name,)) | ||
5716 | + print(r'])') | ||
5717 | + print() | ||
5718 | + | ||
5719 | + def visit_variable(self): | ||
5720 | + pass | ||
5721 | + | ||
5722 | + def visit_free_function(self): | ||
5723 | + function = self.decl | ||
5724 | + if function.has_inline: | ||
5725 | + return | ||
5726 | + | ||
5727 | + s = self.functions | ||
5728 | + ret_type = dump_type(function.return_type) | ||
5729 | + arg_types = self.convert_args(function.arguments) | ||
5730 | + s.write(' StdFunction(%s, %r, [%s]),\n' % (ret_type, function.name, arg_types)) | ||
5731 | + | ||
5732 | + def visit_free_operator(self): | ||
5733 | + pass | ||
5734 | + | ||
5735 | + | ||
5736 | +def main(): | ||
5737 | + defines = [] | ||
5738 | + includes = [] | ||
5739 | + cxxflags = [ | ||
5740 | + '-Wno-unknown-attributes', | ||
5741 | + '-Wno-unused-value', | ||
5742 | + '-Wno-macro-redefined', | ||
5743 | + ] | ||
5744 | + compiler = 'g++' | ||
5745 | + | ||
5746 | + args = sys.argv[1:] | ||
5747 | + while args and args[0].startswith('-'): | ||
5748 | + arg = args.pop(0) | ||
5749 | + if arg.startswith('-I'): | ||
5750 | + include = arg[2:] | ||
5751 | + includes.append(include) | ||
5752 | + elif arg.startswith('-D'): | ||
5753 | + define = arg[2:] | ||
5754 | + defines.append(define) | ||
5755 | + else: | ||
5756 | + sys.stderr.write('error: unknown option %r\n' % arg) | ||
5757 | + sys.exit(1) | ||
5758 | + | ||
5759 | + winsdk = True | ||
5760 | + if winsdk: | ||
5761 | + # Set up Clang compiler flags to use MinGW runtime | ||
5762 | + # http://stackoverflow.com/a/19839946 | ||
5763 | + p = subprocess.Popen( | ||
5764 | + ["x86_64-w64-mingw32-g++", "-x", "c++", "-E", "-Wp,-v", '-', '-fsyntax-only'], | ||
5765 | + stdin=open(os.devnull, 'rt'), | ||
5766 | + stdout=open(os.devnull, 'wt'), | ||
5767 | + stderr=subprocess.PIPE) | ||
5768 | + includes.append('/usr/share/castxml/clang/include') | ||
5769 | + for line in p.stderr: | ||
5770 | + if line.startswith(' '): | ||
5771 | + include = line.strip() | ||
5772 | + if os.path.isdir(include): | ||
5773 | + if os.path.exists(os.path.join(include, 'ia32intrin.h')): | ||
5774 | + # XXX: We must use Clang's intrinsic headers | ||
5775 | + continue | ||
5776 | + includes.append(os.path.normpath(include)) | ||
5777 | + | ||
5778 | + winver = 0x0602 | ||
5779 | + | ||
5780 | + defines += [ | ||
5781 | + # emulate MinGW | ||
5782 | + '__MINGW32__', | ||
5783 | + '_WIN32', | ||
5784 | + '_WIN64', | ||
5785 | + '__declspec(x)=', | ||
5786 | + # Avoid namespace pollution when including windows.h | ||
5787 | + # http://support.microsoft.com/kb/166474 | ||
5788 | + 'WIN32_LEAN_AND_MEAN', | ||
5789 | + # Set Windows version to 8.1 | ||
5790 | + '_WIN32_WINNT=0x%04X' % winver, | ||
5791 | + 'WINVER=0x%04X' % winver, | ||
5792 | + 'NTDDI_VERSION=0x%04X0000' % winver, | ||
5793 | + # Prevent headers from requiring a rpcndr.h version beyond MinGW's | ||
5794 | + '__REQUIRED_RPCNDR_H_VERSION__=475', | ||
5795 | + # Avoid C++ helper classes | ||
5796 | + 'D3D10_NO_HELPERS', | ||
5797 | + 'D3D11_NO_HELPERS', | ||
5798 | + 'D3D11_VIDEO_NO_HELPERS', | ||
5799 | + ] | ||
5800 | + | ||
5801 | + # XXX: Change compiler? | ||
5802 | + #compiler = 'cl' | ||
5803 | + | ||
5804 | + # XXX: This doesn't seem to work well | ||
5805 | + cxxflags += [ | ||
5806 | + #'-m32', | ||
5807 | + #'-target', 'x86_64-pc-mingw32', | ||
5808 | + ] | ||
5809 | + | ||
5810 | + sys.stderr.write('Include path:\n') | ||
5811 | + for include in includes: | ||
5812 | + sys.stderr.write(' %s\n' % include) | ||
5813 | + sys.stderr.write('Definitions:\n') | ||
5814 | + for define in defines: | ||
5815 | + sys.stderr.write(' %s\n' % define) | ||
5816 | + | ||
5817 | + import logging | ||
5818 | + utils.loggers.set_level(logging.DEBUG) | ||
5819 | + | ||
5820 | + # Find the location of the xml generator (castxml or gccxml) | ||
5821 | + generator_path, generator_name = utils.find_xml_generator("castxml") | ||
5822 | + | ||
5823 | + # Configure the xml generator | ||
5824 | + config = parser.xml_generator_configuration_t( | ||
5825 | + xml_generator_path=generator_path, | ||
5826 | + xml_generator=generator_name, | ||
5827 | + define_symbols = defines, | ||
5828 | + include_paths = includes, | ||
5829 | + cflags = ' '.join(cxxflags), | ||
5830 | + compiler = compiler, | ||
5831 | + #keep_xml = True, | ||
5832 | + ) | ||
5833 | + | ||
5834 | + script_dir = os.path.dirname(__file__) | ||
5835 | + headers = [ | ||
5836 | + os.path.join(script_dir, '..', '..', 'compat', 'winsdk_compat.h'), | ||
5837 | + os.path.join(script_dir, 'cxx2api.h'), | ||
5838 | + ] | ||
5839 | + main_header = args[0] | ||
5840 | + headers.append(main_header) | ||
5841 | + | ||
5842 | + decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE) | ||
5843 | + global_ns = declarations.get_global_namespace(decls) | ||
5844 | + | ||
5845 | + def decl_filter(decl): | ||
5846 | + location = decl.location | ||
5847 | + if location is None: | ||
5848 | + return False | ||
5849 | + return os.path.basename(location.file_name) in list(map(os.path.basename, args)) | ||
5850 | + | ||
5851 | + module, _ = os.path.splitext(main_header) | ||
5852 | + visitor = decl2_dumper_t(module) | ||
5853 | + visitor.start() | ||
5854 | + for decl in global_ns.declarations: | ||
5855 | + if not decl_filter(decl): | ||
5856 | + continue | ||
5857 | + | ||
5858 | + if sys.stdout.isatty(): | ||
5859 | + print('# ' + str(decl)) | ||
5860 | + | ||
5861 | + visitor.decl = decl | ||
5862 | + algorithm.apply_visitor(visitor, decl) | ||
5863 | + visitor.finish() | ||
5864 | + | ||
5865 | + | ||
5866 | +if __name__ == '__main__': | ||
5867 | + main() | ||
5868 | diff --git a/specs/scripts/spec2api.py b/specs/scripts/spec2api.py | ||
5869 | index f21b08d5..7fb395a4 100755 | ||
5870 | --- a/specs/scripts/spec2api.py | ||
5871 | +++ b/specs/scripts/spec2api.py | ||
5872 | @@ -181,8 +181,8 @@ class SpecParser(LineParser): | ||
5873 | category = self.prefix.upper() + '_' + category | ||
5874 | if category != self.category: | ||
5875 | if self.category is not None: | ||
5876 | |||
5877 | - print ' # %s' % category | ||
5878 | + print() | ||
5879 | + print(' # %s' % category) | ||
5880 | self.category = category | ||
5881 | |||
5882 | if self.prefix == 'wgl': | ||
5883 | @@ -190,7 +190,7 @@ class SpecParser(LineParser): | ||
5884 | else: | ||
5885 | constructor = 'GlFunction' | ||
5886 | |||
5887 | - print ' %s(%s, "%s", [%s]%s),' % (constructor, ret_type, function_name, ', '.join(args), extra) | ||
5888 | + print(' %s(%s, "%s", [%s]%s),' % (constructor, ret_type, function_name, ', '.join(args), extra)) | ||
5889 | |||
5890 | array_re = re.compile(r'^array\s+\[(.*)\]$') | ||
5891 | |||
5892 | diff --git a/specs/scripts/txt2api.py b/specs/scripts/txt2api.py | ||
5893 | index 6cd99dd9..e9469d3c 100755 | ||
5894 | --- a/specs/scripts/txt2api.py | ||
5895 | +++ b/specs/scripts/txt2api.py | ||
5896 | @@ -31,7 +31,7 @@ | ||
5897 | import sys | ||
5898 | import re | ||
5899 | import optparse | ||
5900 | -from urllib2 import urlopen | ||
5901 | +from urllib.request import urlopen | ||
5902 | |||
5903 | |||
5904 | def stderr(x): | ||
5905 | @@ -116,7 +116,7 @@ class TxtParser(LineParser): | ||
5906 | self.consume() | ||
5907 | line = self.consume() | ||
5908 | self.parse_section(line) | ||
5909 | |||
5910 | + print() | ||
5911 | |||
5912 | def parse_section(self, name): | ||
5913 | if name == 'Name Strings': | ||
5914 | @@ -136,7 +136,7 @@ class TxtParser(LineParser): | ||
5915 | name = line.strip() | ||
5916 | if name.startswith('EGL_'): | ||
5917 | self.prefix = '' | ||
5918 | - print ' # %s' % name | ||
5919 | + print(' # %s' % name) | ||
5920 | |||
5921 | def skip_c_comments(self): | ||
5922 | while not self.eof(): | ||
5923 | @@ -192,7 +192,7 @@ class TxtParser(LineParser): | ||
5924 | args.append(arg) | ||
5925 | if self.tokens[0] == ',': | ||
5926 | self.tokens.pop(0) | ||
5927 | - print ' GlFunction(%s, "%s", [%s]%s),' % (ret, name, ', '.join(args), extra) | ||
5928 | + print(' GlFunction(%s, "%s", [%s]%s),' % (ret, name, ', '.join(args), extra)) | ||
5929 | |||
5930 | def parse_arg(self): | ||
5931 | type = self.parse_type() | ||
5932 | diff --git a/specs/scripts/xml2api.py b/specs/scripts/xml2api.py | ||
5933 | index e3820e09..f09fe0bf 100755 | ||
5934 | --- a/specs/scripts/xml2api.py | ||
5935 | +++ b/specs/scripts/xml2api.py | ||
5936 | @@ -126,7 +126,7 @@ def processRequire(node, filterName): | ||
5937 | |||
5938 | |||
5939 | def printPrototypes(prototypes, extensionName, functionNames, skip=set()): | ||
5940 | - print ' # %s' % extensionName | ||
5941 | + print(' # %s' % extensionName) | ||
5942 | |||
5943 | if extensionName == 'GL_EXT_direct_state_access': | ||
5944 | functionNames.sort() | ||
5945 | @@ -134,9 +134,9 @@ def printPrototypes(prototypes, extensionName, functionNames, skip=set()): | ||
5946 | for functionName in functionNames: | ||
5947 | if functionName not in skip: | ||
5948 | prototype = prototypes[functionName] | ||
5949 | - print ' %s,' % prototype | ||
5950 | + print(' %s,' % prototype) | ||
5951 | |||
5952 | |||
5953 | + print() | ||
5954 | |||
5955 | |||
5956 | def main(): | ||
5957 | diff --git a/specs/scripts/xml2enum.py b/specs/scripts/xml2enum.py | ||
5958 | index 6d49e11c..cb2c4ae9 100755 | ||
5959 | --- a/specs/scripts/xml2enum.py | ||
5960 | +++ b/specs/scripts/xml2enum.py | ||
5961 | @@ -58,8 +58,8 @@ for arg in sys.argv[1:]: | ||
5962 | params.setdefault(value, name) | ||
5963 | |||
5964 | |||
5965 | - values = params.keys() | ||
5966 | + values = list(params.keys()) | ||
5967 | values.sort() | ||
5968 | for value in values: | ||
5969 | name = params[value] | ||
5970 | - print ' "%s",\t\t# 0x%04X' % (name, value) | ||
5971 | + print(' "%s",\t\t# 0x%04X' % (name, value)) | ||
5972 | diff --git a/specs/scripts/xml2glparams.py b/specs/scripts/xml2glparams.py | ||
5973 | index 7e2bc351..805aac86 100755 | ||
5974 | --- a/specs/scripts/xml2glparams.py | ||
5975 | +++ b/specs/scripts/xml2glparams.py | ||
5976 | @@ -58,8 +58,8 @@ for arg in sys.argv[1:]: | ||
5977 | params.setdefault(value, name) | ||
5978 | |||
5979 | |||
5980 | - values = params.keys() | ||
5981 | + values = list(params.keys()) | ||
5982 | values.sort() | ||
5983 | for value in values: | ||
5984 | name = params[value] | ||
5985 | - print ' ("",\tX,\t1,\t"%s"),\t# 0x%04X' % (name, value) | ||
5986 | + print(' ("",\tX,\t1,\t"%s"),\t# 0x%04X' % (name, value)) | ||
5987 | diff --git a/specs/stdapi.py b/specs/stdapi.py | ||
5988 | index c72c264b..487b6c1e 100644 | ||
5989 | --- a/specs/stdapi.py | ||
5990 | +++ b/specs/stdapi.py | ||
5991 | @@ -26,7 +26,9 @@ | ||
5992 | """C basic types""" | ||
5993 | |||
5994 | |||
5995 | -import debug | ||
5996 | +import sys | ||
5997 | + | ||
5998 | +from . import debug | ||
5999 | |||
6000 | |||
6001 | class Type: | ||
6002 | @@ -266,6 +268,10 @@ class Bitmask(Type): | ||
6003 | Flags = Bitmask | ||
6004 | |||
6005 | |||
6006 | +def EnumFlags(name, values): | ||
6007 | + return Flags(Alias(name, UInt), values) | ||
6008 | + | ||
6009 | + | ||
6010 | class Array(Type): | ||
6011 | |||
6012 | def __init__(self, type_, length): | ||
6013 | @@ -273,7 +279,7 @@ class Array(Type): | ||
6014 | self.type = type_ | ||
6015 | self.length = length | ||
6016 | if not isinstance(length, int): | ||
6017 | - assert isinstance(length, basestring) | ||
6018 | + assert isinstance(length, str) | ||
6019 | # Check if length is actually a valid constant expression | ||
6020 | try: | ||
6021 | eval(length, {}, {}) | ||
6022 | @@ -329,6 +335,10 @@ class Struct(Type): | ||
6023 | def visit(self, visitor, *args, **kwargs): | ||
6024 | return visitor.visitStruct(self, *args, **kwargs) | ||
6025 | |||
6026 | + def getMemberByName(self, name): | ||
6027 | + memberNames = [memberName for memberType, memberName in self.members] | ||
6028 | + return memberNames.index(name) | ||
6029 | + | ||
6030 | |||
6031 | def Union(kindExpr, kindTypes, contextLess=True): | ||
6032 | switchTypes = [] | ||
6033 | @@ -372,7 +382,7 @@ def InOut(type, name): | ||
6034 | |||
6035 | class Function: | ||
6036 | |||
6037 | - def __init__(self, type, name, args, call = '', fail = None, sideeffects=True, internal=False): | ||
6038 | + def __init__(self, type, name, args, call = '', fail = None, sideeffects=True, internal=False, overloaded=False): | ||
6039 | self.type = type | ||
6040 | self.name = name | ||
6041 | |||
6042 | @@ -394,6 +404,7 @@ class Function: | ||
6043 | self.fail = fail | ||
6044 | self.sideeffects = sideeffects | ||
6045 | self.internal = internal | ||
6046 | + self.overloaded = overloaded | ||
6047 | |||
6048 | def prototype(self, name=None): | ||
6049 | if name is not None: | ||
6050 | @@ -414,6 +425,17 @@ class Function: | ||
6051 | s += ")" | ||
6052 | return s | ||
6053 | |||
6054 | + def sigName(self): | ||
6055 | + name = self.name | ||
6056 | + if self.overloaded: | ||
6057 | + # suffix used to make overloaded functions/methods unique | ||
6058 | + suffix = ','.join([str(arg.type) for arg in self.args]) | ||
6059 | + suffix = suffix.replace(' *', '*') | ||
6060 | + suffix = suffix.replace(' &', '&') | ||
6061 | + suffix = '(' + suffix + ')' | ||
6062 | + name += suffix | ||
6063 | + return name | ||
6064 | + | ||
6065 | def argNames(self): | ||
6066 | return [arg.name for arg in self.args] | ||
6067 | |||
6068 | @@ -463,14 +485,12 @@ class Interface(Type): | ||
6069 | yield method | ||
6070 | for method in self.methods: | ||
6071 | yield method | ||
6072 | - raise StopIteration | ||
6073 | |||
6074 | def iterBases(self): | ||
6075 | iface = self | ||
6076 | while iface is not None: | ||
6077 | yield iface | ||
6078 | iface = iface.base | ||
6079 | - raise StopIteration | ||
6080 | |||
6081 | def hasBase(self, *bases): | ||
6082 | for iface in self.iterBases(): | ||
6083 | @@ -484,14 +504,13 @@ class Interface(Type): | ||
6084 | yield iface, method | ||
6085 | for method in self.methods: | ||
6086 | yield self, method | ||
6087 | - raise StopIteration | ||
6088 | |||
6089 | |||
6090 | class Method(Function): | ||
6091 | |||
6092 | - def __init__(self, type, name, args, call = '', const=False, sideeffects=True): | ||
6093 | + def __init__(self, type, name, args, call = '', const=False, sideeffects=True, overloaded=False): | ||
6094 | assert call == '__stdcall' | ||
6095 | - Function.__init__(self, type, name, args, call = call, sideeffects=sideeffects) | ||
6096 | + Function.__init__(self, type, name, args, call = call, sideeffects=sideeffects, overloaded=overloaded) | ||
6097 | for index in range(len(self.args)): | ||
6098 | self.args[index].index = index + 1 | ||
6099 | self.const = const | ||
6100 | @@ -576,7 +595,7 @@ class Polymorphic(Type): | ||
6101 | else: | ||
6102 | cases[i].append(case) | ||
6103 | |||
6104 | - return zip(cases, types) | ||
6105 | + return list(zip(cases, types)) | ||
6106 | |||
6107 | |||
6108 | def EnumPolymorphic(enumName, switchExpr, switchTypes, defaultType, contextLess=True): | ||
6109 | @@ -734,7 +753,7 @@ class Rebuilder(Visitor): | ||
6110 | if pointer_type is pointer.type: | ||
6111 | return pointer | ||
6112 | else: | ||
6113 | - return LinearPointer(pointer_type) | ||
6114 | + return LinearPointer(pointer_type, self.size) | ||
6115 | |||
6116 | def visitReference(self, reference): | ||
6117 | reference_type = self.visit(reference.type) | ||
6118 | @@ -792,7 +811,7 @@ class MutableRebuilder(Rebuilder): | ||
6119 | |||
6120 | def visitReference(self, reference): | ||
6121 | # Strip out references | ||
6122 | - return reference.type | ||
6123 | + return self.visit(reference.type) | ||
6124 | |||
6125 | |||
6126 | class Traverser(Visitor): | ||
6127 | @@ -894,7 +913,7 @@ class ExpanderMixin: | ||
6128 | |||
6129 | def expand(self, expr): | ||
6130 | # Expand a C expression, replacing certain variables | ||
6131 | - if not isinstance(expr, basestring): | ||
6132 | + if not isinstance(expr, str): | ||
6133 | return expr | ||
6134 | variables = {} | ||
6135 | |||
6136 | diff --git a/specs/wglapi.py b/specs/wglapi.py | ||
6137 | index f24a8d21..563f0269 100644 | ||
6138 | --- a/specs/wglapi.py | ||
6139 | +++ b/specs/wglapi.py | ||
6140 | @@ -27,9 +27,9 @@ | ||
6141 | """WGL API description""" | ||
6142 | |||
6143 | |||
6144 | -from glapi import * | ||
6145 | -from winapi import * | ||
6146 | -from wglenum import * | ||
6147 | +from .glapi import * | ||
6148 | +from .winapi import * | ||
6149 | +from .wglenum import * | ||
6150 | |||
6151 | |||
6152 | wglapi = Module("WGL") | ||
6153 | diff --git a/specs/wglenum.py b/specs/wglenum.py | ||
6154 | index ad9bbccf..6bc4e74d 100644 | ||
6155 | --- a/specs/wglenum.py | ||
6156 | +++ b/specs/wglenum.py | ||
6157 | @@ -27,7 +27,7 @@ | ||
6158 | """WGL enum description""" | ||
6159 | |||
6160 | |||
6161 | -from stdapi import * | ||
6162 | +from .stdapi import * | ||
6163 | |||
6164 | WGLenum = FakeEnum(Int, [ | ||
6165 | "WGL_GPU_VENDOR_AMD", # 0x1F00 | ||
6166 | diff --git a/specs/winapi.py b/specs/winapi.py | ||
6167 | index 445039ff..e66d063a 100644 | ||
6168 | --- a/specs/winapi.py | ||
6169 | +++ b/specs/winapi.py | ||
6170 | @@ -26,7 +26,7 @@ | ||
6171 | """Win32 API type description.""" | ||
6172 | |||
6173 | |||
6174 | -from stdapi import * | ||
6175 | +from .stdapi import * | ||
6176 | |||
6177 | |||
6178 | SHORT = Alias("SHORT", Short) | ||
6179 | diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt | ||
6180 | index 2ceac332..7a452ed4 100644 | ||
6181 | --- a/wrappers/CMakeLists.txt | ||
6182 | +++ b/wrappers/CMakeLists.txt | ||
6183 | @@ -79,7 +79,7 @@ if (WIN32) | ||
6184 | include_directories (BEFORE SYSTEM ${DirectX_D3D_INCLUDE_DIR}) | ||
6185 | add_custom_command ( | ||
6186 | OUTPUT ddrawtrace.cpp | ||
6187 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp | ||
6188 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp | ||
6189 | DEPENDS | ||
6190 | ddrawtrace.py | ||
6191 | dlltrace.py | ||
6192 | @@ -109,7 +109,7 @@ if (WIN32) | ||
6193 | include_directories (BEFORE SYSTEM ${DirectX_D3D9_INCLUDE_DIR} ${DirectX_D3D8_INCLUDE_DIR}) | ||
6194 | add_custom_command ( | ||
6195 | OUTPUT d3d8trace.cpp | ||
6196 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp | ||
6197 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp | ||
6198 | DEPENDS | ||
6199 | d3d8trace.py | ||
6200 | dlltrace.py | ||
6201 | @@ -143,7 +143,7 @@ if (WIN32) | ||
6202 | include_directories (BEFORE SYSTEM ${DirectX_D3D9_INCLUDE_DIR}) | ||
6203 | add_custom_command ( | ||
6204 | OUTPUT d3d9trace.cpp | ||
6205 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp | ||
6206 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp | ||
6207 | DEPENDS | ||
6208 | d3d9trace.py | ||
6209 | dlltrace.py | ||
6210 | @@ -179,7 +179,7 @@ if (WIN32) | ||
6211 | |||
6212 | add_custom_command ( | ||
6213 | OUTPUT dxgitrace.cpp | ||
6214 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgitrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dxgitrace.cpp | ||
6215 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgitrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dxgitrace.cpp | ||
6216 | DEPENDS | ||
6217 | dxgitrace.py | ||
6218 | dlltrace.py | ||
6219 | @@ -216,7 +216,7 @@ if (WIN32) | ||
6220 | |||
6221 | add_custom_command ( | ||
6222 | OUTPUT d2d1trace.cpp | ||
6223 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp | ||
6224 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp | ||
6225 | DEPENDS | ||
6226 | d2d1trace.py | ||
6227 | trace.py | ||
6228 | @@ -241,7 +241,7 @@ if (WIN32) | ||
6229 | # opengl32.dll | ||
6230 | add_custom_command ( | ||
6231 | OUTPUT wgltrace.cpp | ||
6232 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp | ||
6233 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp | ||
6234 | DEPENDS | ||
6235 | wgltrace.py | ||
6236 | gltrace.py | ||
6237 | @@ -278,7 +278,7 @@ elseif (APPLE) | ||
6238 | # OpenGL framework | ||
6239 | add_custom_command ( | ||
6240 | OUTPUT cgltrace.cpp | ||
6241 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp | ||
6242 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp | ||
6243 | DEPENDS | ||
6244 | cgltrace.py | ||
6245 | gltrace.py | ||
6246 | @@ -322,7 +322,7 @@ elseif (X11_FOUND) | ||
6247 | # libGL.so | ||
6248 | add_custom_command ( | ||
6249 | OUTPUT glxtrace.cpp | ||
6250 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp | ||
6251 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp | ||
6252 | DEPENDS | ||
6253 | glxtrace.py | ||
6254 | gltrace.py | ||
6255 | @@ -372,7 +372,7 @@ if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE) | ||
6256 | # libEGL.so/libGL.so | ||
6257 | add_custom_command ( | ||
6258 | OUTPUT egltrace.cpp | ||
6259 | - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp | ||
6260 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp | ||
6261 | DEPENDS | ||
6262 | egltrace.py | ||
6263 | gltrace.py | ||
6264 | diff --git a/wrappers/cgltrace.py b/wrappers/cgltrace.py | ||
6265 | index 6c72f696..02b3c518 100644 | ||
6266 | --- a/wrappers/cgltrace.py | ||
6267 | +++ b/wrappers/cgltrace.py | ||
6268 | @@ -43,55 +43,55 @@ class CglTracer(GlTracer): | ||
6269 | if function.name == 'CGLReleaseContext': | ||
6270 | # Unlike other GL APIs like EGL or GLX, CGL will make the context | ||
6271 | # not current if it's the current context. | ||
6272 | - print ' if (_CGLGetContextRetainCount(ctx) == 1) {' | ||
6273 | - print ' if (gltrace::releaseContext((uintptr_t)ctx)) {' | ||
6274 | - print ' if (_CGLGetCurrentContext() == ctx) {' | ||
6275 | - print ' gltrace::clearContext();' | ||
6276 | - print ' }' | ||
6277 | - print ' }' | ||
6278 | - print ' }' | ||
6279 | + print(' if (_CGLGetContextRetainCount(ctx) == 1) {') | ||
6280 | + print(' if (gltrace::releaseContext((uintptr_t)ctx)) {') | ||
6281 | + print(' if (_CGLGetCurrentContext() == ctx) {') | ||
6282 | + print(' gltrace::clearContext();') | ||
6283 | + print(' }') | ||
6284 | + print(' }') | ||
6285 | + print(' }') | ||
6286 | |||
6287 | if function.name == 'CGLDestroyContext': | ||
6288 | # The same rule applies here about the as for CGLReleaseContext. | ||
6289 | - print ' if (gltrace::releaseContext((uintptr_t)ctx)) {' | ||
6290 | - print ' if (_CGLGetCurrentContext() == ctx) {' | ||
6291 | - print ' gltrace::clearContext();' | ||
6292 | - print ' }' | ||
6293 | - print ' }' | ||
6294 | + print(' if (gltrace::releaseContext((uintptr_t)ctx)) {') | ||
6295 | + print(' if (_CGLGetCurrentContext() == ctx) {') | ||
6296 | + print(' gltrace::clearContext();') | ||
6297 | + print(' }') | ||
6298 | + print(' }') | ||
6299 | |||
6300 | GlTracer.traceFunctionImplBody(self, function) | ||
6301 | |||
6302 | if function.name == 'CGLCreateContext': | ||
6303 | - print ' if (_result == kCGLNoError) {' | ||
6304 | - print ' gltrace::createContext((uintptr_t)*ctx);' | ||
6305 | - print ' }' | ||
6306 | + print(' if (_result == kCGLNoError) {') | ||
6307 | + print(' gltrace::createContext((uintptr_t)*ctx);') | ||
6308 | + print(' }') | ||
6309 | |||
6310 | if function.name == 'CGLSetCurrentContext': | ||
6311 | - print ' if (_result == kCGLNoError) {' | ||
6312 | - print ' if (ctx != NULL) {' | ||
6313 | - print ' gltrace::setContext((uintptr_t)ctx);' | ||
6314 | - print ' } else {' | ||
6315 | - print ' gltrace::clearContext();' | ||
6316 | - print ' }' | ||
6317 | - print ' }' | ||
6318 | + print(' if (_result == kCGLNoError) {') | ||
6319 | + print(' if (ctx != NULL) {') | ||
6320 | + print(' gltrace::setContext((uintptr_t)ctx);') | ||
6321 | + print(' } else {') | ||
6322 | + print(' gltrace::clearContext();') | ||
6323 | + print(' }') | ||
6324 | + print(' }') | ||
6325 | |||
6326 | if function.name == 'CGLRetainContext': | ||
6327 | - print ' gltrace::retainContext((uintptr_t)ctx);' | ||
6328 | + print(' gltrace::retainContext((uintptr_t)ctx);') | ||
6329 | |||
6330 | |||
6331 | if __name__ == '__main__': | ||
6332 | |||
6333 | - print '#include <stdlib.h>' | ||
6334 | - print '#include <string.h>' | ||
6335 | |||
6336 | - print '#include "trace_writer_local.hpp"' | ||
6337 | |||
6338 | - print '// To validate our prototypes' | ||
6339 | - print '#define GL_GLEXT_PROTOTYPES' | ||
6340 | |||
6341 | - print '#include "glproc.hpp"' | ||
6342 | - print '#include "glsize.hpp"' | ||
6343 | |||
6344 | + print() | ||
6345 | + print('#include <stdlib.h>') | ||
6346 | + print('#include <string.h>') | ||
6347 | + print() | ||
6348 | + print('#include "trace_writer_local.hpp"') | ||
6349 | + print() | ||
6350 | + print('// To validate our prototypes') | ||
6351 | + print('#define GL_GLEXT_PROTOTYPES') | ||
6352 | + print() | ||
6353 | + print('#include "glproc.hpp"') | ||
6354 | + print('#include "glsize.hpp"') | ||
6355 | + print() | ||
6356 | |||
6357 | module = Module() | ||
6358 | module.mergeModule(cglapi) | ||
6359 | @@ -101,7 +101,7 @@ if __name__ == '__main__': | ||
6360 | tracer = CglTracer() | ||
6361 | tracer.traceApi(api) | ||
6362 | |||
6363 | - print r''' | ||
6364 | + print(r''' | ||
6365 | |||
6366 | PUBLIC | ||
6367 | void * gll_noop = 0; | ||
6368 | @@ -130,4 +130,4 @@ _init(void) { | ||
6369 | setenv("SDL_OPENGL_LIBRARY", "/System/Library/Frameworks/OpenGL.framework/OpenGL", 1); | ||
6370 | } | ||
6371 | |||
6372 | -''' | ||
6373 | +''') | ||
6374 | diff --git a/wrappers/d2d1trace.py b/wrappers/d2d1trace.py | ||
6375 | index 26223005..2176341f 100644 | ||
6376 | --- a/wrappers/d2d1trace.py | ||
6377 | +++ b/wrappers/d2d1trace.py | ||
6378 | @@ -31,15 +31,15 @@ from specs.d2d1 import d2d1 | ||
6379 | |||
6380 | |||
6381 | if __name__ == '__main__': | ||
6382 | - print '#include "guids_defs.hpp"' | ||
6383 | |||
6384 | - print '#include "trace_writer_local.hpp"' | ||
6385 | - print '#include "os.hpp"' | ||
6386 | |||
6387 | - print '#define DWRITE_EXPORT WINAPI' | ||
6388 | |||
6389 | - print '#include "d2dimports.hpp"' | ||
6390 | |||
6391 | + print('#include "guids_defs.hpp"') | ||
6392 | + print() | ||
6393 | + print('#include "trace_writer_local.hpp"') | ||
6394 | + print('#include "os.hpp"') | ||
6395 | + print() | ||
6396 | + print('#define DWRITE_EXPORT WINAPI') | ||
6397 | + print() | ||
6398 | + print('#include "d2dimports.hpp"') | ||
6399 | + print() | ||
6400 | |||
6401 | api = API() | ||
6402 | api.addModule(d2d1) | ||
6403 | diff --git a/wrappers/d3d8trace.py b/wrappers/d3d8trace.py | ||
6404 | index 2903c48f..11afbca5 100644 | ||
6405 | --- a/wrappers/d3d8trace.py | ||
6406 | +++ b/wrappers/d3d8trace.py | ||
6407 | @@ -34,7 +34,7 @@ class D3D8Tracer(DllTracer): | ||
6408 | def serializeArgValue(self, function, arg): | ||
6409 | # Dump shaders as strings | ||
6410 | if arg.type is D3DSHADER8: | ||
6411 | - print ' DumpShader(trace::localWriter, %s);' % (arg.name) | ||
6412 | + print(' DumpShader(trace::localWriter, %s);' % (arg.name)) | ||
6413 | return | ||
6414 | |||
6415 | DllTracer.serializeArgValue(self, function, arg) | ||
6416 | @@ -55,32 +55,32 @@ class D3D8Tracer(DllTracer): | ||
6417 | |||
6418 | def implementWrapperInterfaceMethodBody(self, interface, base, method): | ||
6419 | if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): | ||
6420 | - print ' if (_MappedSize && m_pbData) {' | ||
6421 | + print(' if (_MappedSize && m_pbData) {') | ||
6422 | self.emit_memcpy('(LPBYTE)m_pbData', '_MappedSize') | ||
6423 | - print ' }' | ||
6424 | + print(' }') | ||
6425 | |||
6426 | DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) | ||
6427 | |||
6428 | if method.name in ('Lock', 'LockRect', 'LockBox'): | ||
6429 | # FIXME: handle recursive locks | ||
6430 | - print ' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {' | ||
6431 | - print ' _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1]) | ||
6432 | - print ' } else {' | ||
6433 | - print ' m_pbData = NULL;' | ||
6434 | - print ' _MappedSize = 0;' | ||
6435 | - print ' }' | ||
6436 | + print(' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {') | ||
6437 | + print(' _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1])) | ||
6438 | + print(' } else {') | ||
6439 | + print(' m_pbData = NULL;') | ||
6440 | + print(' _MappedSize = 0;') | ||
6441 | + print(' }') | ||
6442 | |||
6443 | |||
6444 | if __name__ == '__main__': | ||
6445 | - print '#define INITGUID' | ||
6446 | |||
6447 | - print '#include "trace_writer_local.hpp"' | ||
6448 | - print '#include "os.hpp"' | ||
6449 | |||
6450 | - print '#include "d3d8imports.hpp"' | ||
6451 | - print '#include "d3d8size.hpp"' | ||
6452 | - print '#include "d3d9shader.hpp"' | ||
6453 | |||
6454 | + print('#define INITGUID') | ||
6455 | + print() | ||
6456 | + print('#include "trace_writer_local.hpp"') | ||
6457 | + print('#include "os.hpp"') | ||
6458 | + print() | ||
6459 | + print('#include "d3d8imports.hpp"') | ||
6460 | + print('#include "d3d8size.hpp"') | ||
6461 | + print('#include "d3d9shader.hpp"') | ||
6462 | + print() | ||
6463 | |||
6464 | api = API() | ||
6465 | api.addModule(d3d8) | ||
6466 | diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py | ||
6467 | index 0850ba3e..53d5152f 100644 | ||
6468 | --- a/wrappers/d3d9trace.py | ||
6469 | +++ b/wrappers/d3d9trace.py | ||
6470 | @@ -35,7 +35,7 @@ class D3D9Tracer(DllTracer): | ||
6471 | def serializeArgValue(self, function, arg): | ||
6472 | # Dump shaders as strings | ||
6473 | if arg.type is D3DSHADER9: | ||
6474 | - print ' DumpShader(trace::localWriter, %s);' % (arg.name) | ||
6475 | + print(' DumpShader(trace::localWriter, %s);' % (arg.name)) | ||
6476 | return | ||
6477 | |||
6478 | DllTracer.serializeArgValue(self, function, arg) | ||
6479 | @@ -72,49 +72,49 @@ class D3D9Tracer(DllTracer): | ||
6480 | def implementWrapperInterfaceMethodBody(self, interface, base, method): | ||
6481 | if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): | ||
6482 | if interface.name in ['IDirect3DTexture9']: | ||
6483 | - print ' std::map<UINT, std::pair<size_t, VOID *> >::iterator it = _MappedData.find(Level);' | ||
6484 | - print ' if (it != _MappedData.end()) {' | ||
6485 | + print(' std::map<UINT, std::pair<size_t, VOID *> >::iterator it = _MappedData.find(Level);') | ||
6486 | + print(' if (it != _MappedData.end()) {') | ||
6487 | self.emit_memcpy('(LPBYTE)it->second.second', 'it->second.first') | ||
6488 | - print ' _MappedData.erase(it);' | ||
6489 | - print ' }' | ||
6490 | + print(' _MappedData.erase(it);') | ||
6491 | + print(' }') | ||
6492 | else: | ||
6493 | - print ' if (_MappedSize && m_pbData) {' | ||
6494 | + print(' if (_MappedSize && m_pbData) {') | ||
6495 | self.emit_memcpy('(LPBYTE)m_pbData', '_MappedSize') | ||
6496 | - print ' }' | ||
6497 | + print(' }') | ||
6498 | |||
6499 | DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) | ||
6500 | |||
6501 | if method.name in ('Lock', 'LockRect', 'LockBox'): | ||
6502 | if interface.name in ['IDirect3DTexture9']: | ||
6503 | - print ' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {' | ||
6504 | - print ' size_t mappedSize;' | ||
6505 | - print ' VOID * pbData;' | ||
6506 | - print ' _getMapInfo(_this, %s, pbData, mappedSize);' % ', '.join(method.argNames()[:-1]) | ||
6507 | - print ' _MappedData[Level] = std::make_pair(mappedSize, pbData);' | ||
6508 | - print ' } else {' | ||
6509 | - print ' _MappedData.erase(Level);' | ||
6510 | - print ' }' | ||
6511 | + print(' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {') | ||
6512 | + print(' size_t mappedSize;') | ||
6513 | + print(' VOID * pbData;') | ||
6514 | + print(' _getMapInfo(_this, %s, pbData, mappedSize);' % ', '.join(method.argNames()[:-1])) | ||
6515 | + print(' _MappedData[Level] = std::make_pair(mappedSize, pbData);') | ||
6516 | + print(' } else {') | ||
6517 | + print(' _MappedData.erase(Level);') | ||
6518 | + print(' }') | ||
6519 | else: | ||
6520 | # FIXME: handle recursive locks | ||
6521 | - print ' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {' | ||
6522 | - print ' _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1]) | ||
6523 | - print ' } else {' | ||
6524 | - print ' m_pbData = NULL;' | ||
6525 | - print ' _MappedSize = 0;' | ||
6526 | - print ' }' | ||
6527 | + print(' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {') | ||
6528 | + print(' _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1])) | ||
6529 | + print(' } else {') | ||
6530 | + print(' m_pbData = NULL;') | ||
6531 | + print(' _MappedSize = 0;') | ||
6532 | + print(' }') | ||
6533 | |||
6534 | |||
6535 | if __name__ == '__main__': | ||
6536 | - print '#define INITGUID' | ||
6537 | |||
6538 | - print '#include "trace_writer_local.hpp"' | ||
6539 | - print '#include "os.hpp"' | ||
6540 | |||
6541 | - print '#include "d3d9imports.hpp"' | ||
6542 | - print '#include "d3d9size.hpp"' | ||
6543 | - print '#include "d3d9shader.hpp"' | ||
6544 | - print '#include "dxva2imports.hpp"' | ||
6545 | |||
6546 | + print('#define INITGUID') | ||
6547 | + print() | ||
6548 | + print('#include "trace_writer_local.hpp"') | ||
6549 | + print('#include "os.hpp"') | ||
6550 | + print() | ||
6551 | + print('#include "d3d9imports.hpp"') | ||
6552 | + print('#include "d3d9size.hpp"') | ||
6553 | + print('#include "d3d9shader.hpp"') | ||
6554 | + print('#include "dxva2imports.hpp"') | ||
6555 | + print() | ||
6556 | |||
6557 | d3d9.mergeModule(d3dperf) | ||
6558 | |||
6559 | diff --git a/wrappers/ddrawtrace.py b/wrappers/ddrawtrace.py | ||
6560 | index 96602d21..da7ffbe7 100644 | ||
6561 | --- a/wrappers/ddrawtrace.py | ||
6562 | +++ b/wrappers/ddrawtrace.py | ||
6563 | @@ -41,12 +41,12 @@ class DDrawTracer(DllTracer): | ||
6564 | |||
6565 | |||
6566 | if __name__ == '__main__': | ||
6567 | - print '#define INITGUID' | ||
6568 | - print '#include "d3dimports.hpp"' | ||
6569 | - print '#include "trace_writer_local.hpp"' | ||
6570 | - print '#include "d3d7size.hpp"' | ||
6571 | - print '#include "os.hpp"' | ||
6572 | |||
6573 | + print('#define INITGUID') | ||
6574 | + print('#include "d3dimports.hpp"') | ||
6575 | + print('#include "trace_writer_local.hpp"') | ||
6576 | + print('#include "d3d7size.hpp"') | ||
6577 | + print('#include "os.hpp"') | ||
6578 | + print() | ||
6579 | |||
6580 | api = API() | ||
6581 | api.addModule(ddraw) | ||
6582 | diff --git a/wrappers/dlltrace.py b/wrappers/dlltrace.py | ||
6583 | index 26962216..8ac18b0c 100644 | ||
6584 | --- a/wrappers/dlltrace.py | ||
6585 | +++ b/wrappers/dlltrace.py | ||
6586 | @@ -37,24 +37,24 @@ class DllDispatcher(Dispatcher): | ||
6587 | |||
6588 | def dispatchModule(self, module): | ||
6589 | tag = module.name.upper() | ||
6590 | - print r'HMODULE g_h%sModule = NULL;' % (tag,) | ||
6591 | - print r'' | ||
6592 | - print r'static PROC' | ||
6593 | - print r'_get%sProcAddress(LPCSTR lpProcName) {' % tag | ||
6594 | - print r' if (!g_h%sModule) {' % tag | ||
6595 | - print r' char szDll[MAX_PATH] = {0};' | ||
6596 | - print r' if (!GetSystemDirectoryA(szDll, MAX_PATH)) {' | ||
6597 | - print r' return NULL;' | ||
6598 | - print r' }' | ||
6599 | - print r' strcat(szDll, "\\%s.dll");' % module.name | ||
6600 | - print r' g_h%sModule = LoadLibraryA(szDll);' % tag | ||
6601 | - print r' if (!g_h%sModule) {' % tag | ||
6602 | - print r' return NULL;' | ||
6603 | - print r' }' | ||
6604 | - print r' }' | ||
6605 | - print r' return GetProcAddress(g_h%sModule, lpProcName);' % tag | ||
6606 | - print r'}' | ||
6607 | - print r'' | ||
6608 | + print(r'HMODULE g_h%sModule = NULL;' % (tag,)) | ||
6609 | + print(r'') | ||
6610 | + print(r'static PROC') | ||
6611 | + print(r'_get%sProcAddress(LPCSTR lpProcName) {' % tag) | ||
6612 | + print(r' if (!g_h%sModule) {' % tag) | ||
6613 | + print(r' char szDll[MAX_PATH] = {0};') | ||
6614 | + print(r' if (!GetSystemDirectoryA(szDll, MAX_PATH)) {') | ||
6615 | + print(r' return NULL;') | ||
6616 | + print(r' }') | ||
6617 | + print(r' strcat(szDll, "\\%s.dll");' % module.name) | ||
6618 | + print(r' g_h%sModule = LoadLibraryA(szDll);' % tag) | ||
6619 | + print(r' if (!g_h%sModule) {' % tag) | ||
6620 | + print(r' return NULL;') | ||
6621 | + print(r' }') | ||
6622 | + print(r' }') | ||
6623 | + print(r' return GetProcAddress(g_h%sModule, lpProcName);' % tag) | ||
6624 | + print(r'}') | ||
6625 | + print(r'') | ||
6626 | |||
6627 | Dispatcher.dispatchModule(self, module) | ||
6628 | |||
6629 | diff --git a/wrappers/dxgitrace.py b/wrappers/dxgitrace.py | ||
6630 | index 3edda2c2..134f45d7 100644 | ||
6631 | --- a/wrappers/dxgitrace.py | ||
6632 | +++ b/wrappers/dxgitrace.py | ||
6633 | @@ -40,47 +40,47 @@ class D3DCommonTracer(DllTracer): | ||
6634 | def serializeArgValue(self, function, arg): | ||
6635 | # Dump shaders as strings | ||
6636 | if isinstance(arg.type, stdapi.Blob) and arg.name.startswith('pShaderBytecode'): | ||
6637 | - print ' DumpShader(trace::localWriter, %s, %s);' % (arg.name, arg.type.size) | ||
6638 | + print(' DumpShader(trace::localWriter, %s, %s);' % (arg.name, arg.type.size)) | ||
6639 | return | ||
6640 | |||
6641 | # Serialize the swapchain dimensions | ||
6642 | if function.name == 'CreateSwapChain' and arg.name == 'pDesc' \ | ||
6643 | or arg.name == 'pSwapChainDesc': | ||
6644 | - print r' DXGI_SWAP_CHAIN_DESC *_pSwapChainDesc = NULL;' | ||
6645 | - print r' DXGI_SWAP_CHAIN_DESC _SwapChainDesc;' | ||
6646 | - print r' if (%s) {' % arg.name | ||
6647 | - print r' _SwapChainDesc = *%s;' % arg.name | ||
6648 | + print(r' DXGI_SWAP_CHAIN_DESC *_pSwapChainDesc = NULL;') | ||
6649 | + print(r' DXGI_SWAP_CHAIN_DESC _SwapChainDesc;') | ||
6650 | + print(r' if (%s) {' % arg.name) | ||
6651 | + print(r' _SwapChainDesc = *%s;' % arg.name) | ||
6652 | if function.name != 'CreateSwapChain' or not self.interface.name.endswith('DWM'): | ||
6653 | # Obtain size from the window | ||
6654 | - print r' RECT _rect;' | ||
6655 | - print r' if (GetClientRect(%s->OutputWindow, &_rect)) {' % arg.name | ||
6656 | - print r' if (%s->BufferDesc.Width == 0) {' % arg.name | ||
6657 | - print r' _SwapChainDesc.BufferDesc.Width = _rect.right - _rect.left;' | ||
6658 | - print r' }' | ||
6659 | - print r' if (%s->BufferDesc.Height == 0) {' % arg.name | ||
6660 | - print r' _SwapChainDesc.BufferDesc.Height = _rect.bottom - _rect.top;' | ||
6661 | - print r' }' | ||
6662 | - print r' }' | ||
6663 | + print(r' RECT _rect;') | ||
6664 | + print(r' if (GetClientRect(%s->OutputWindow, &_rect)) {' % arg.name) | ||
6665 | + print(r' if (%s->BufferDesc.Width == 0) {' % arg.name) | ||
6666 | + print(r' _SwapChainDesc.BufferDesc.Width = _rect.right - _rect.left;') | ||
6667 | + print(r' }') | ||
6668 | + print(r' if (%s->BufferDesc.Height == 0) {' % arg.name) | ||
6669 | + print(r' _SwapChainDesc.BufferDesc.Height = _rect.bottom - _rect.top;') | ||
6670 | + print(r' }') | ||
6671 | + print(r' }') | ||
6672 | else: | ||
6673 | # Obtain size from the output | ||
6674 | - print r' DXGI_OUTPUT_DESC _OutputDesc;' | ||
6675 | - print r' if (SUCCEEDED(pOutput->GetDesc(&_OutputDesc))) {' | ||
6676 | - print r' _SwapChainDesc.BufferDesc.Width = _OutputDesc.DesktopCoordinates.right - _OutputDesc.DesktopCoordinates.left;' | ||
6677 | - print r' _SwapChainDesc.BufferDesc.Height = _OutputDesc.DesktopCoordinates.bottom - _OutputDesc.DesktopCoordinates.top;' | ||
6678 | - print r' }' | ||
6679 | - print r' _pSwapChainDesc = &_SwapChainDesc;' | ||
6680 | - print r' }' | ||
6681 | + print(r' DXGI_OUTPUT_DESC _OutputDesc;') | ||
6682 | + print(r' if (SUCCEEDED(pOutput->GetDesc(&_OutputDesc))) {') | ||
6683 | + print(r' _SwapChainDesc.BufferDesc.Width = _OutputDesc.DesktopCoordinates.right - _OutputDesc.DesktopCoordinates.left;') | ||
6684 | + print(r' _SwapChainDesc.BufferDesc.Height = _OutputDesc.DesktopCoordinates.bottom - _OutputDesc.DesktopCoordinates.top;') | ||
6685 | + print(r' }') | ||
6686 | + print(r' _pSwapChainDesc = &_SwapChainDesc;') | ||
6687 | + print(r' }') | ||
6688 | self.serializeValue(arg.type, '_pSwapChainDesc') | ||
6689 | return | ||
6690 | |||
6691 | # Serialize object names | ||
6692 | if function.name == 'SetPrivateData' and arg.name == 'pData': | ||
6693 | iid = function.args[0].name | ||
6694 | - print r' if (%s == WKPDID_D3DDebugObjectName) {' % iid | ||
6695 | - print r' trace::localWriter.writeString(static_cast<const char *>(pData), DataSize);' | ||
6696 | - print r' } else {' | ||
6697 | + print(r' if (%s == WKPDID_D3DDebugObjectName) {' % iid) | ||
6698 | + print(r' trace::localWriter.writeString(static_cast<const char *>(pData), DataSize);') | ||
6699 | + print(r' } else {') | ||
6700 | DllTracer.serializeArgValue(self, function, arg) | ||
6701 | - print r' }' | ||
6702 | + print(r' }') | ||
6703 | return | ||
6704 | |||
6705 | DllTracer.serializeArgValue(self, function, arg) | ||
6706 | @@ -110,47 +110,47 @@ class D3DCommonTracer(DllTracer): | ||
6707 | if method.getArgByName('pInitialData'): | ||
6708 | pDesc1 = method.getArgByName('pDesc1') | ||
6709 | if pDesc1 is not None: | ||
6710 | - print r' %s pDesc = pDesc1;' % (pDesc1.type,) | ||
6711 | + print(r' %s pDesc = pDesc1;' % (pDesc1.type,)) | ||
6712 | |||
6713 | if method.name in ('Map', 'Unmap'): | ||
6714 | # On D3D11 Map/Unmap is not a resource method, but a context method instead. | ||
6715 | resourceArg = method.getArgByName('pResource') | ||
6716 | if resourceArg is None: | ||
6717 | - print ' _MAP_DESC & _MapDesc = m_MapDesc;' | ||
6718 | + print(' _MAP_DESC & _MapDesc = m_MapDesc;') | ||
6719 | else: | ||
6720 | - print ' _MAP_DESC & _MapDesc = m_MapDescs[std::pair<%s, UINT>(pResource, Subresource)];' % resourceArg.type | ||
6721 | + print(' _MAP_DESC & _MapDesc = m_MapDescs[std::pair<%s, UINT>(pResource, Subresource)];' % resourceArg.type) | ||
6722 | |||
6723 | if method.name == 'Unmap': | ||
6724 | - print ' if (_MapDesc.Size && _MapDesc.pData) {' | ||
6725 | + print(' if (_MapDesc.Size && _MapDesc.pData) {') | ||
6726 | self.emit_memcpy('_MapDesc.pData', '_MapDesc.Size') | ||
6727 | - print ' }' | ||
6728 | + print(' }') | ||
6729 | |||
6730 | DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) | ||
6731 | |||
6732 | if method.name == 'Map': | ||
6733 | # NOTE: recursive locks are explicitely forbidden | ||
6734 | - print ' if (SUCCEEDED(_result)) {' | ||
6735 | - print ' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames()) | ||
6736 | - print ' } else {' | ||
6737 | - print ' _MapDesc.pData = NULL;' | ||
6738 | - print ' _MapDesc.Size = 0;' | ||
6739 | - print ' }' | ||
6740 | + print(' if (SUCCEEDED(_result)) {') | ||
6741 | + print(' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames())) | ||
6742 | + print(' } else {') | ||
6743 | + print(' _MapDesc.pData = NULL;') | ||
6744 | + print(' _MapDesc.Size = 0;') | ||
6745 | + print(' }') | ||
6746 | |||
6747 | |||
6748 | if __name__ == '__main__': | ||
6749 | - print r'#define INITGUID' | ||
6750 | |||
6751 | - print r'#include "trace_writer_local.hpp"' | ||
6752 | - print r'#include "os.hpp"' | ||
6753 | |||
6754 | - print r'#include "d3dcommonshader.hpp"' | ||
6755 | |||
6756 | - print r'#include "d3d10imports.hpp"' | ||
6757 | - print r'#include "d3d10size.hpp"' | ||
6758 | - print r'#include "d3d11imports.hpp"' | ||
6759 | - print r'#include "d3d11size.hpp"' | ||
6760 | - print r'#include "d3d9imports.hpp" // D3DPERF_*' | ||
6761 | |||
6762 | + print(r'#define INITGUID') | ||
6763 | + print() | ||
6764 | + print(r'#include "trace_writer_local.hpp"') | ||
6765 | + print(r'#include "os.hpp"') | ||
6766 | + print() | ||
6767 | + print(r'#include "d3dcommonshader.hpp"') | ||
6768 | + print() | ||
6769 | + print(r'#include "d3d10imports.hpp"') | ||
6770 | + print(r'#include "d3d10size.hpp"') | ||
6771 | + print(r'#include "d3d11imports.hpp"') | ||
6772 | + print(r'#include "d3d11size.hpp"') | ||
6773 | + print(r'#include "d3d9imports.hpp" // D3DPERF_*') | ||
6774 | + print() | ||
6775 | |||
6776 | api = API() | ||
6777 | api.addModule(dxgi.dxgi) | ||
6778 | diff --git a/wrappers/egltrace.py b/wrappers/egltrace.py | ||
6779 | index 1fcb0fd6..f5b61c0c 100644 | ||
6780 | --- a/wrappers/egltrace.py | ||
6781 | +++ b/wrappers/egltrace.py | ||
6782 | @@ -50,239 +50,239 @@ class EglTracer(GlTracer): | ||
6783 | |||
6784 | def traceFunctionImplBody(self, function): | ||
6785 | if function.name == 'glTexDirectMapVIV': | ||
6786 | - print ' // prevent loop call' | ||
6787 | - print ' glTexDirectVIVMap(target, width, height, format, Logical, Physical);' | ||
6788 | + print(' // prevent loop call') | ||
6789 | + print(' glTexDirectVIVMap(target, width, height, format, Logical, Physical);') | ||
6790 | return | ||
6791 | |||
6792 | if function.name == 'glTexDirectInvalidateVIV': | ||
6793 | - print ' // get current texture' | ||
6794 | - print ' GLint tex = 0;' | ||
6795 | - print ' int32_t size = 0;' | ||
6796 | - print ' int32_t ysize = 0;' | ||
6797 | - print ' int32_t usize = 0;' | ||
6798 | - print ' int32_t vsize = 0;' | ||
6799 | - print ' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);' | ||
6800 | - print ' if(tex == 0)' | ||
6801 | - print ' {' | ||
6802 | - print ' return;' | ||
6803 | - print ' }' | ||
6804 | - print ' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];' | ||
6805 | - print ' switch(data.format){' | ||
6806 | - print ' case GL_VIV_YV12:' | ||
6807 | - print ' case GL_VIV_I420:' | ||
6808 | - print ' ysize=data.width * data.height;' | ||
6809 | - print ' usize=ysize/4;' | ||
6810 | - print ' vsize=usize;' | ||
6811 | - print ' break;' | ||
6812 | - print ' case GL_VIV_NV12:' | ||
6813 | - print ' case GL_VIV_NV21:' | ||
6814 | - print ' ysize=data.width * data.height;' | ||
6815 | - print ' usize=ysize/2;' | ||
6816 | - print ' vsize=0;' | ||
6817 | - print ' break;' | ||
6818 | - print ' case GL_RGBA:' | ||
6819 | - print ' case GL_BGRA_EXT:' | ||
6820 | - print ' ysize=data.width * data.height *4;' | ||
6821 | - print ' usize=0;' | ||
6822 | - print ' vsize=0;' | ||
6823 | - print ' break;' | ||
6824 | - print ' case GL_RGB:' | ||
6825 | - print ' ysize=data.width * data.height *3;' | ||
6826 | - print ' usize=0;' | ||
6827 | - print ' vsize=0;' | ||
6828 | - print ' break;' | ||
6829 | - print ' case GL_VIV_YUY2:' | ||
6830 | - print ' case GL_VIV_UYVY:' | ||
6831 | - print ' case GL_RGB565_OES:' | ||
6832 | - print ' case GL_LUMINANCE8_ALPHA8_EXT:' | ||
6833 | - print ' ysize=data.width * data.height *2;' | ||
6834 | - print ' usize=0;' | ||
6835 | - print ' vsize=0;' | ||
6836 | - print ' break;' | ||
6837 | - print ' case GL_ALPHA:' | ||
6838 | - print ' ysize=data.width * data.height;' | ||
6839 | - print ' usize=0;' | ||
6840 | - print ' vsize=0;' | ||
6841 | - print ' break;' | ||
6842 | - print ' default:' | ||
6843 | - print ' return;' | ||
6844 | - print ' }' | ||
6845 | - print ' if (NULL==(GLvoid*)data.logical) {' | ||
6846 | - print ' if (ysize > 0) {' | ||
6847 | + print(' // get current texture') | ||
6848 | + print(' GLint tex = 0;') | ||
6849 | + print(' int32_t size = 0;') | ||
6850 | + print(' int32_t ysize = 0;') | ||
6851 | + print(' int32_t usize = 0;') | ||
6852 | + print(' int32_t vsize = 0;') | ||
6853 | + print(' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);') | ||
6854 | + print(' if(tex == 0)') | ||
6855 | + print(' {') | ||
6856 | + print(' return;') | ||
6857 | + print(' }') | ||
6858 | + print(' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];') | ||
6859 | + print(' switch(data.format){') | ||
6860 | + print(' case GL_VIV_YV12:') | ||
6861 | + print(' case GL_VIV_I420:') | ||
6862 | + print(' ysize=data.width * data.height;') | ||
6863 | + print(' usize=ysize/4;') | ||
6864 | + print(' vsize=usize;') | ||
6865 | + print(' break;') | ||
6866 | + print(' case GL_VIV_NV12:') | ||
6867 | + print(' case GL_VIV_NV21:') | ||
6868 | + print(' ysize=data.width * data.height;') | ||
6869 | + print(' usize=ysize/2;') | ||
6870 | + print(' vsize=0;') | ||
6871 | + print(' break;') | ||
6872 | + print(' case GL_RGBA:') | ||
6873 | + print(' case GL_BGRA_EXT:') | ||
6874 | + print(' ysize=data.width * data.height *4;') | ||
6875 | + print(' usize=0;') | ||
6876 | + print(' vsize=0;') | ||
6877 | + print(' break;') | ||
6878 | + print(' case GL_RGB:') | ||
6879 | + print(' ysize=data.width * data.height *3;') | ||
6880 | + print(' usize=0;') | ||
6881 | + print(' vsize=0;') | ||
6882 | + print(' break;') | ||
6883 | + print(' case GL_VIV_YUY2:') | ||
6884 | + print(' case GL_VIV_UYVY:') | ||
6885 | + print(' case GL_RGB565_OES:') | ||
6886 | + print(' case GL_LUMINANCE8_ALPHA8_EXT:') | ||
6887 | + print(' ysize=data.width * data.height *2;') | ||
6888 | + print(' usize=0;') | ||
6889 | + print(' vsize=0;') | ||
6890 | + print(' break;') | ||
6891 | + print(' case GL_ALPHA:') | ||
6892 | + print(' ysize=data.width * data.height;') | ||
6893 | + print(' usize=0;') | ||
6894 | + print(' vsize=0;') | ||
6895 | + print(' break;') | ||
6896 | + print(' default:') | ||
6897 | + print(' return;') | ||
6898 | + print(' }') | ||
6899 | + print(' if (NULL==(GLvoid*)data.logical) {') | ||
6900 | + print(' if (ysize > 0) {') | ||
6901 | self.emit_memcpy_opt('(GLvoid*)data.planes[0]', 'ysize') | ||
6902 | - print ' }' | ||
6903 | - print ' if (usize > 0) {' | ||
6904 | + print(' }') | ||
6905 | + print(' if (usize > 0) {') | ||
6906 | self.emit_memcpy_opt('(GLvoid*)data.planes[1]', 'usize') | ||
6907 | - print ' }' | ||
6908 | - print ' if (vsize > 0) {' | ||
6909 | + print(' }') | ||
6910 | + print(' if (vsize > 0) {') | ||
6911 | self.emit_memcpy_opt('(GLvoid*)data.planes[2]', 'vsize') | ||
6912 | - print ' }' | ||
6913 | - print ' } else {' | ||
6914 | - print ' size = ysize + usize + vsize;' | ||
6915 | - print ' if (size > 0) {' | ||
6916 | + print(' }') | ||
6917 | + print(' } else {') | ||
6918 | + print(' size = ysize + usize + vsize;') | ||
6919 | + print(' if (size > 0) {') | ||
6920 | self.emit_memcpy_opt('(GLvoid*)data.logical', 'size') | ||
6921 | - print ' }' | ||
6922 | - print ' }' | ||
6923 | + print(' }') | ||
6924 | + print(' }') | ||
6925 | |||
6926 | if function.name == 'eglGetProcAddress': | ||
6927 | - print ' procname = __get_alias_func_name(procname);' | ||
6928 | + print(' procname = __get_alias_func_name(procname);') | ||
6929 | |||
6930 | GlTracer.traceFunctionImplBody(self, function) | ||
6931 | |||
6932 | if function.name == 'glTexDirectVIV': | ||
6933 | - print ' // get current texture' | ||
6934 | - print ' GLint tex = 0;' | ||
6935 | - print ' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);' | ||
6936 | - print ' if(tex != 0)' | ||
6937 | - print ' {' | ||
6938 | - print ' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];' | ||
6939 | - print ' data.width = width;' | ||
6940 | - print ' data.height = height;' | ||
6941 | - print ' data.format = format;' | ||
6942 | - print ' data.planes[0] = pixels[0];' | ||
6943 | - print ' data.planes[1] = pixels[1];' | ||
6944 | - print ' data.planes[2] = pixels[2];' | ||
6945 | - print ' }' | ||
6946 | + print(' // get current texture') | ||
6947 | + print(' GLint tex = 0;') | ||
6948 | + print(' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);') | ||
6949 | + print(' if(tex != 0)') | ||
6950 | + print(' {') | ||
6951 | + print(' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];') | ||
6952 | + print(' data.width = width;') | ||
6953 | + print(' data.height = height;') | ||
6954 | + print(' data.format = format;') | ||
6955 | + print(' data.planes[0] = pixels[0];') | ||
6956 | + print(' data.planes[1] = pixels[1];') | ||
6957 | + print(' data.planes[2] = pixels[2];') | ||
6958 | + print(' }') | ||
6959 | |||
6960 | if function.name == 'glTexDirectVIVMap' or function.name == 'glTexDirectTiledMapVIV': | ||
6961 | - print ' // get current texture' | ||
6962 | - print ' GLint tex = 0;' | ||
6963 | - print ' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);' | ||
6964 | - print ' if(tex != 0)' | ||
6965 | - print ' {' | ||
6966 | - print ' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];' | ||
6967 | - print ' data.width = width;' | ||
6968 | - print ' data.height = height;' | ||
6969 | - print ' data.format = format;' | ||
6970 | - print ' data.logical = *Logical; // Logical != NULL' | ||
6971 | - print ' data.physical = *Physical;' | ||
6972 | - print ' }' | ||
6973 | + print(' // get current texture') | ||
6974 | + print(' GLint tex = 0;') | ||
6975 | + print(' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);') | ||
6976 | + print(' if(tex != 0)') | ||
6977 | + print(' {') | ||
6978 | + print(' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];') | ||
6979 | + print(' data.width = width;') | ||
6980 | + print(' data.height = height;') | ||
6981 | + print(' data.format = format;') | ||
6982 | + print(' data.logical = *Logical; // Logical != NULL') | ||
6983 | + print(' data.physical = *Physical;') | ||
6984 | + print(' }') | ||
6985 | |||
6986 | if function.name == 'eglCreateContext': | ||
6987 | - print ' if (_result != EGL_NO_CONTEXT)' | ||
6988 | - print ' gltrace::createContext((uintptr_t)_result);' | ||
6989 | + print(' if (_result != EGL_NO_CONTEXT)') | ||
6990 | + print(' gltrace::createContext((uintptr_t)_result);') | ||
6991 | |||
6992 | if function.name == 'eglMakeCurrent': | ||
6993 | - print r' if (_result) {' | ||
6994 | - print r' // update the profile' | ||
6995 | - print r' if (ctx != EGL_NO_CONTEXT) {' | ||
6996 | - print r' gltrace::setContext((uintptr_t)ctx);' | ||
6997 | - print r' gltrace::Context *tr = gltrace::getContext();' | ||
6998 | - print r' EGLint api = EGL_OPENGL_ES_API;' | ||
6999 | - print r' _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);' | ||
7000 | - print r' if (api == EGL_OPENGL_API) {' | ||
7001 | - print r' assert(tr->profile.api == glprofile::API_GL);' | ||
7002 | - print r' } else if (api == EGL_OPENGL_ES_API) {' | ||
7003 | - print r' EGLint client_version = 1;' | ||
7004 | - print r' _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &client_version);' | ||
7005 | - print r' if (tr->profile.api != glprofile::API_GLES ||' | ||
7006 | - print r' tr->profile.major < client_version) {' | ||
7007 | - print r' std::string version = tr->profile.str();' | ||
7008 | - print r' os::log("apitrace: warning: eglMakeCurrent: expected OpenGL ES %i.x context, but got %s\n",' | ||
7009 | - print r' client_version, version.c_str());' | ||
7010 | - print r' }' | ||
7011 | - print r' } else {' | ||
7012 | - print r' assert(0);' | ||
7013 | - print r' }' | ||
7014 | - print r' } else {' | ||
7015 | - print r' gltrace::clearContext();' | ||
7016 | - print r' }' | ||
7017 | - print r' }' | ||
7018 | + print(r' if (_result) {') | ||
7019 | + print(r' // update the profile') | ||
7020 | + print(r' if (ctx != EGL_NO_CONTEXT) {') | ||
7021 | + print(r' gltrace::setContext((uintptr_t)ctx);') | ||
7022 | + print(r' gltrace::Context *tr = gltrace::getContext();') | ||
7023 | + print(r' EGLint api = EGL_OPENGL_ES_API;') | ||
7024 | + print(r' _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);') | ||
7025 | + print(r' if (api == EGL_OPENGL_API) {') | ||
7026 | + print(r' assert(tr->profile.api == glprofile::API_GL);') | ||
7027 | + print(r' } else if (api == EGL_OPENGL_ES_API) {') | ||
7028 | + print(r' EGLint client_version = 1;') | ||
7029 | + print(r' _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &client_version);') | ||
7030 | + print(r' if (tr->profile.api != glprofile::API_GLES ||') | ||
7031 | + print(r' tr->profile.major < client_version) {') | ||
7032 | + print(r' std::string version = tr->profile.str();') | ||
7033 | + print(r' os::log("apitrace: warning: eglMakeCurrent: expected OpenGL ES %i.x context, but got %s\n",') | ||
7034 | + print(r' client_version, version.c_str());') | ||
7035 | + print(r' }') | ||
7036 | + print(r' } else {') | ||
7037 | + print(r' assert(0);') | ||
7038 | + print(r' }') | ||
7039 | + print(r' } else {') | ||
7040 | + print(r' gltrace::clearContext();') | ||
7041 | + print(r' }') | ||
7042 | + print(r' }') | ||
7043 | |||
7044 | if function.name == 'eglDestroyContext': | ||
7045 | - print ' if (_result) {' | ||
7046 | - print ' gltrace::releaseContext((uintptr_t)ctx);' | ||
7047 | - print ' }' | ||
7048 | + print(' if (_result) {') | ||
7049 | + print(' gltrace::releaseContext((uintptr_t)ctx);') | ||
7050 | + print(' }') | ||
7051 | |||
7052 | if function.name == 'glEGLImageTargetTexture2DOES': | ||
7053 | - print ' image_info *info = _EGLImageKHR_get_image_info(target, image);' | ||
7054 | - print ' if (info) {' | ||
7055 | - print ' GLint level = 0;' | ||
7056 | - print ' GLint internalformat = info->internalformat;' | ||
7057 | - print ' GLsizei width = info->width;' | ||
7058 | - print ' GLsizei height = info->height;' | ||
7059 | - print ' GLint border = 0;' | ||
7060 | - print ' GLenum format = info->format;' | ||
7061 | - print ' GLenum type = info->type;' | ||
7062 | - print ' const GLvoid * pixels = info->pixels;' | ||
7063 | + print(' image_info *info = _EGLImageKHR_get_image_info(target, image);') | ||
7064 | + print(' if (info) {') | ||
7065 | + print(' GLint level = 0;') | ||
7066 | + print(' GLint internalformat = info->internalformat;') | ||
7067 | + print(' GLsizei width = info->width;') | ||
7068 | + print(' GLsizei height = info->height;') | ||
7069 | + print(' GLint border = 0;') | ||
7070 | + print(' GLenum format = info->format;') | ||
7071 | + print(' GLenum type = info->type;') | ||
7072 | + print(' const GLvoid * pixels = info->pixels;') | ||
7073 | self.emitFakeTexture2D() | ||
7074 | - print ' _EGLImageKHR_free_image_info(info);' | ||
7075 | - print ' }' | ||
7076 | + print(' _EGLImageKHR_free_image_info(info);') | ||
7077 | + print(' }') | ||
7078 | |||
7079 | |||
7080 | if __name__ == '__main__': | ||
7081 | - print '#include <stdlib.h>' | ||
7082 | - print '#include <string.h>' | ||
7083 | |||
7084 | - print '#include "trace_writer_local.hpp"' | ||
7085 | |||
7086 | - print '// To validate our prototypes' | ||
7087 | - print '#define GL_GLEXT_PROTOTYPES' | ||
7088 | - print '#define EGL_EGLEXT_PROTOTYPES' | ||
7089 | |||
7090 | - print '#include "dlopen.hpp"' | ||
7091 | - print '#include "glproc.hpp"' | ||
7092 | - print '#include "glsize.hpp"' | ||
7093 | - print '#include "eglsize.hpp"' | ||
7094 | |||
7095 | - print 'static const char *__get_alias_func_name(const char *origFunName)' | ||
7096 | - print '{' | ||
7097 | - print ' /* Vivante driver uses alias name for following OES/EXT functions, that means dlsym for thoese functions will fail */' | ||
7098 | - print ' static const char * __glExtProcAlias[][2] =' | ||
7099 | - print ' {' | ||
7100 | - print ' /* Extension API alias for GL_OES_texture_3D */' | ||
7101 | - print ' {"glTexImage3DOES", "glTexImage3D"},' | ||
7102 | - print ' {"glTexSubImage3DOES", "glTexSubImage3D"},' | ||
7103 | - print ' {"glCopyTexSubImage3DOES", "glCopyTexSubImage3D"},' | ||
7104 | - print ' {"glCompressedTexImage3DOES", "glCompressedTexImage3D"},' | ||
7105 | - print ' {"glCompressedTexSubImage3DOES", "glCompressedTexSubImage3D"},' | ||
7106 | |||
7107 | - print ' /* Extension API alias for GL_OES_get_program_binary */' | ||
7108 | - print ' {"glGetProgramBinaryOES", "glGetProgramBinary"},' | ||
7109 | - print ' {"glProgramBinaryOES", "glProgramBinary"},' | ||
7110 | |||
7111 | - print ' /* Extension API alias for GL_OES_vertex_array_object */' | ||
7112 | - print ' {"glBindVertexArrayOES", "glBindVertexArray"},' | ||
7113 | - print ' {"glDeleteVertexArraysOES", "glDeleteVertexArrays"},' | ||
7114 | - print ' {"glGenVertexArraysOES", "glGenVertexArrays"},' | ||
7115 | - print ' {"glIsVertexArrayOES", "glIsVertexArray"},' | ||
7116 | |||
7117 | - print ' /* Extension API alias for GL_OES_blend_minmax */' | ||
7118 | - print ' {"glBlendEquationEXT", "glBlendEquation"}' | ||
7119 | - print ' };' | ||
7120 | |||
7121 | - print ' int count = sizeof(__glExtProcAlias) / sizeof(__glExtProcAlias[0]);' | ||
7122 | - print ' int i;' | ||
7123 | |||
7124 | - print ' for(i=0; i<count; i++)' | ||
7125 | - print ' {' | ||
7126 | - print ' if(strcmp(__glExtProcAlias[i][0], origFunName) == 0)' | ||
7127 | - print ' return __glExtProcAlias[i][1];' | ||
7128 | - print ' }' | ||
7129 | |||
7130 | - print ' return origFunName;' | ||
7131 | - print '}' | ||
7132 | - | ||
7133 | |||
7134 | - print 'typedef struct TexDirectVivData' | ||
7135 | - print '{' | ||
7136 | - print ' int width;' | ||
7137 | - print ' int height;' | ||
7138 | - print ' GLenum format;' | ||
7139 | - print ' GLvoid*planes[3]; // used for glTexDirectVIV' | ||
7140 | - print ' GLvoid*logical; // used for glTexDirectVIVMap/glTexDirectMapVIV/glTexDirectTiledMapVIV' | ||
7141 | - print ' GLuint physical;' | ||
7142 | - print '}TEXDIRECTVIVDATA;' | ||
7143 | |||
7144 | - print 'static std::map<GLint, TEXDIRECTVIVDATA> _directTextureDataMap;' | ||
7145 | |||
7146 | - print '#define GL_VIV_YV12 0x8FC0' | ||
7147 | - print '#define GL_VIV_NV12 0x8FC1' | ||
7148 | - print '#define GL_VIV_YUY2 0x8FC2' | ||
7149 | - print '#define GL_VIV_UYVY 0x8FC3' | ||
7150 | - print '#define GL_VIV_NV21 0x8FC4' | ||
7151 | - print '#define GL_VIV_I420 0x8FC5' | ||
7152 | |||
7153 | + print('#include <stdlib.h>') | ||
7154 | + print('#include <string.h>') | ||
7155 | + print() | ||
7156 | + print('#include "trace_writer_local.hpp"') | ||
7157 | + print() | ||
7158 | + print('// To validate our prototypes') | ||
7159 | + print('#define GL_GLEXT_PROTOTYPES') | ||
7160 | + print('#define EGL_EGLEXT_PROTOTYPES') | ||
7161 | + print() | ||
7162 | + print('#include "dlopen.hpp"') | ||
7163 | + print('#include "glproc.hpp"') | ||
7164 | + print('#include "glsize.hpp"') | ||
7165 | + print('#include "eglsize.hpp"') | ||
7166 | + print() | ||
7167 | + print('static const char *__get_alias_func_name(const char *origFunName)') | ||
7168 | + print('{') | ||
7169 | + print(' /* Vivante driver uses alias name for following OES/EXT functions, that means dlsym for thoese functions will fail */') | ||
7170 | + print(' static const char * __glExtProcAlias[][2] =') | ||
7171 | + print(' {') | ||
7172 | + print(' /* Extension API alias for GL_OES_texture_3D */') | ||
7173 | + print(' {"glTexImage3DOES", "glTexImage3D"},') | ||
7174 | + print(' {"glTexSubImage3DOES", "glTexSubImage3D"},') | ||
7175 | + print(' {"glCopyTexSubImage3DOES", "glCopyTexSubImage3D"},') | ||
7176 | + print(' {"glCompressedTexImage3DOES", "glCompressedTexImage3D"},') | ||
7177 | + print(' {"glCompressedTexSubImage3DOES", "glCompressedTexSubImage3D"},') | ||
7178 | + print() | ||
7179 | + print(' /* Extension API alias for GL_OES_get_program_binary */') | ||
7180 | + print(' {"glGetProgramBinaryOES", "glGetProgramBinary"},') | ||
7181 | + print(' {"glProgramBinaryOES", "glProgramBinary"},') | ||
7182 | + print() | ||
7183 | + print(' /* Extension API alias for GL_OES_vertex_array_object */') | ||
7184 | + print(' {"glBindVertexArrayOES", "glBindVertexArray"},') | ||
7185 | + print(' {"glDeleteVertexArraysOES", "glDeleteVertexArrays"},') | ||
7186 | + print(' {"glGenVertexArraysOES", "glGenVertexArrays"},') | ||
7187 | + print(' {"glIsVertexArrayOES", "glIsVertexArray"},') | ||
7188 | + print() | ||
7189 | + print(' /* Extension API alias for GL_OES_blend_minmax */') | ||
7190 | + print(' {"glBlendEquationEXT", "glBlendEquation"}') | ||
7191 | + print(' };') | ||
7192 | + print() | ||
7193 | + print(' int count = sizeof(__glExtProcAlias) / sizeof(__glExtProcAlias[0]);') | ||
7194 | + print(' int i;') | ||
7195 | + print() | ||
7196 | + print(' for(i=0; i<count; i++)') | ||
7197 | + print(' {') | ||
7198 | + print(' if(strcmp(__glExtProcAlias[i][0], origFunName) == 0)') | ||
7199 | + print(' return __glExtProcAlias[i][1];') | ||
7200 | + print(' }') | ||
7201 | + print() | ||
7202 | + print(' return origFunName;') | ||
7203 | + print('}') | ||
7204 | + | ||
7205 | + print() | ||
7206 | + print('typedef struct TexDirectVivData') | ||
7207 | + print('{') | ||
7208 | + print(' int width;') | ||
7209 | + print(' int height;') | ||
7210 | + print(' GLenum format;') | ||
7211 | + print(' GLvoid*planes[3]; // used for glTexDirectVIV') | ||
7212 | + print(' GLvoid*logical; // used for glTexDirectVIVMap/glTexDirectMapVIV/glTexDirectTiledMapVIV') | ||
7213 | + print(' GLuint physical;') | ||
7214 | + print('}TEXDIRECTVIVDATA;') | ||
7215 | + print() | ||
7216 | + print('static std::map<GLint, TEXDIRECTVIVDATA> _directTextureDataMap;') | ||
7217 | + print() | ||
7218 | + print('#define GL_VIV_YV12 0x8FC0') | ||
7219 | + print('#define GL_VIV_NV12 0x8FC1') | ||
7220 | + print('#define GL_VIV_YUY2 0x8FC2') | ||
7221 | + print('#define GL_VIV_UYVY 0x8FC3') | ||
7222 | + print('#define GL_VIV_NV21 0x8FC4') | ||
7223 | + print('#define GL_VIV_I420 0x8FC5') | ||
7224 | + print() | ||
7225 | |||
7226 | module = Module() | ||
7227 | module.mergeModule(eglapi) | ||
7228 | @@ -292,7 +292,7 @@ if __name__ == '__main__': | ||
7229 | tracer = EglTracer() | ||
7230 | tracer.traceApi(api) | ||
7231 | |||
7232 | - print r''' | ||
7233 | + print(r''' | ||
7234 | |||
7235 | |||
7236 | |||
7237 | @@ -453,8 +453,8 @@ void APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, GLsizei stride, | ||
7238 | #endif /* ANDROID */ | ||
7239 | |||
7240 | |||
7241 | -''' | ||
7242 | - print r''' | ||
7243 | +''') | ||
7244 | + print(r''' | ||
7245 | /* | ||
7246 | * let the GPU driver know that we are in apitrace | ||
7247 | */ | ||
7248 | @@ -464,4 +464,4 @@ int APIENTRY ApiTraceEnabled(void) { | ||
7249 | return 1; | ||
7250 | } | ||
7251 | |||
7252 | -''' | ||
7253 | +''') | ||
7254 | diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py | ||
7255 | index cf13ae18..02504148 100644 | ||
7256 | --- a/wrappers/gltrace.py | ||
7257 | +++ b/wrappers/gltrace.py | ||
7258 | @@ -79,7 +79,7 @@ class TypeGetter(stdapi.Visitor): | ||
7259 | suffix = 'iv' | ||
7260 | arg_type = 'GLint' | ||
7261 | else: | ||
7262 | - print alias.expr | ||
7263 | + print(alias.expr) | ||
7264 | assert False | ||
7265 | function_name = self.prefix + suffix + self.ext_suffix | ||
7266 | return function_name, arg_type | ||
7267 | @@ -114,48 +114,48 @@ class GlTracer(Tracer): | ||
7268 | def header(self, api): | ||
7269 | Tracer.header(self, api) | ||
7270 | |||
7271 | - print '#include <algorithm>' | ||
7272 | |||
7273 | - print '#include "gltrace.hpp"' | ||
7274 | |||
7275 | + print('#include <algorithm>') | ||
7276 | + print() | ||
7277 | + print('#include "gltrace.hpp"') | ||
7278 | + print() | ||
7279 | |||
7280 | # Which glVertexAttrib* variant to use | ||
7281 | - print 'enum vertex_attrib {' | ||
7282 | - print ' VERTEX_ATTRIB,' | ||
7283 | - print ' VERTEX_ATTRIB_NV,' | ||
7284 | - print '};' | ||
7285 | |||
7286 | - print 'static vertex_attrib _get_vertex_attrib(void) {' | ||
7287 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
7288 | - print ' if (ctx->user_arrays_nv) {' | ||
7289 | - print ' GLboolean _vertex_program = GL_FALSE;' | ||
7290 | - print ' _glGetBooleanv(GL_VERTEX_PROGRAM_ARB, &_vertex_program);' | ||
7291 | - print ' if (_vertex_program) {' | ||
7292 | - print ' if (ctx->user_arrays_nv) {' | ||
7293 | - print ' GLint _vertex_program_binding_nv = _glGetInteger(GL_VERTEX_PROGRAM_BINDING_NV);' | ||
7294 | - print ' if (_vertex_program_binding_nv) {' | ||
7295 | - print ' return VERTEX_ATTRIB_NV;' | ||
7296 | - print ' }' | ||
7297 | - print ' }' | ||
7298 | - print ' }' | ||
7299 | - print ' }' | ||
7300 | - print ' return VERTEX_ATTRIB;' | ||
7301 | - print '}' | ||
7302 | |||
7303 | + print('enum vertex_attrib {') | ||
7304 | + print(' VERTEX_ATTRIB,') | ||
7305 | + print(' VERTEX_ATTRIB_NV,') | ||
7306 | + print('};') | ||
7307 | + print() | ||
7308 | + print('static vertex_attrib _get_vertex_attrib(void) {') | ||
7309 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
7310 | + print(' if (ctx->user_arrays_nv) {') | ||
7311 | + print(' GLboolean _vertex_program = GL_FALSE;') | ||
7312 | + print(' _glGetBooleanv(GL_VERTEX_PROGRAM_ARB, &_vertex_program);') | ||
7313 | + print(' if (_vertex_program) {') | ||
7314 | + print(' if (ctx->user_arrays_nv) {') | ||
7315 | + print(' GLint _vertex_program_binding_nv = _glGetInteger(GL_VERTEX_PROGRAM_BINDING_NV);') | ||
7316 | + print(' if (_vertex_program_binding_nv) {') | ||
7317 | + print(' return VERTEX_ATTRIB_NV;') | ||
7318 | + print(' }') | ||
7319 | + print(' }') | ||
7320 | + print(' }') | ||
7321 | + print(' }') | ||
7322 | + print(' return VERTEX_ATTRIB;') | ||
7323 | + print('}') | ||
7324 | + print() | ||
7325 | |||
7326 | self.defineShadowBufferHelper() | ||
7327 | |||
7328 | # Whether we need user arrays | ||
7329 | - print 'static inline bool _need_user_arrays(void)' | ||
7330 | - print '{' | ||
7331 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
7332 | - print ' if (!ctx->user_arrays) {' | ||
7333 | - print ' return false;' | ||
7334 | - print ' }' | ||
7335 | |||
7336 | - print ' glprofile::Profile profile = ctx->profile;' | ||
7337 | - print ' bool es1 = profile.es() && profile.major == 1;' | ||
7338 | |||
7339 | + print('static inline bool _need_user_arrays(void)') | ||
7340 | + print('{') | ||
7341 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
7342 | + print(' if (!ctx->user_arrays) {') | ||
7343 | + print(' return false;') | ||
7344 | + print(' }') | ||
7345 | + print() | ||
7346 | + print(' glprofile::Profile profile = ctx->profile;') | ||
7347 | + print(' bool es1 = profile.es() && profile.major == 1;') | ||
7348 | + print() | ||
7349 | |||
7350 | for camelcase_name, uppercase_name in self.arrays: | ||
7351 | # in which profile is the array available? | ||
7352 | @@ -166,120 +166,120 @@ class GlTracer(Tracer): | ||
7353 | function_name = 'gl%sPointer' % camelcase_name | ||
7354 | enable_name = 'GL_%s_ARRAY' % uppercase_name | ||
7355 | binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name | ||
7356 | - print ' // %s' % function_name | ||
7357 | - print ' if (%s) {' % profile_check | ||
7358 | + print(' // %s' % function_name) | ||
7359 | + print(' if (%s) {' % profile_check) | ||
7360 | self.array_prolog(api, uppercase_name) | ||
7361 | - print ' if (_glIsEnabled(%s) &&' % enable_name | ||
7362 | - print ' _glGetInteger(%s) == 0) {' % binding_name | ||
7363 | + print(' if (_glIsEnabled(%s) &&' % enable_name) | ||
7364 | + print(' _glGetInteger(%s) == 0) {' % binding_name) | ||
7365 | self.array_cleanup(api, uppercase_name) | ||
7366 | - print ' return true;' | ||
7367 | - print ' }' | ||
7368 | + print(' return true;') | ||
7369 | + print(' }') | ||
7370 | self.array_epilog(api, uppercase_name) | ||
7371 | - print ' }' | ||
7372 | |||
7373 | - | ||
7374 | - print ' // ES1 does not support generic vertex attributes' | ||
7375 | - print ' if (es1)' | ||
7376 | - print ' return false;' | ||
7377 | |||
7378 | - print ' vertex_attrib _vertex_attrib = _get_vertex_attrib();' | ||
7379 | |||
7380 | - print ' // glVertexAttribPointer' | ||
7381 | - print ' if (_vertex_attrib == VERTEX_ATTRIB) {' | ||
7382 | - print ' GLint _max_vertex_attribs = _glGetInteger(GL_MAX_VERTEX_ATTRIBS);' | ||
7383 | - print ' for (GLint index = 0; index < _max_vertex_attribs; ++index) {' | ||
7384 | - print ' if (_glGetVertexAttribi(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED) &&' | ||
7385 | - print ' _glGetVertexAttribi(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING) == 0) {' | ||
7386 | - print ' return true;' | ||
7387 | - print ' }' | ||
7388 | - print ' }' | ||
7389 | - print ' }' | ||
7390 | |||
7391 | - print ' // glVertexAttribPointerNV' | ||
7392 | - print ' if (_vertex_attrib == VERTEX_ATTRIB_NV) {' | ||
7393 | - print ' for (GLint index = 0; index < 16; ++index) {' | ||
7394 | - print ' if (_glIsEnabled(GL_VERTEX_ATTRIB_ARRAY0_NV + index)) {' | ||
7395 | - print ' return true;' | ||
7396 | - print ' }' | ||
7397 | - print ' }' | ||
7398 | - print ' }' | ||
7399 | |||
7400 | - | ||
7401 | - print ' return false;' | ||
7402 | - print '}' | ||
7403 | |||
7404 | - | ||
7405 | - print 'static void _trace_user_arrays(GLuint count);' | ||
7406 | |||
7407 | - | ||
7408 | - print '// whether glLockArraysEXT() has ever been called' | ||
7409 | - print 'static bool _checkLockArraysEXT = false;' | ||
7410 | |||
7411 | + print(' }') | ||
7412 | + print() | ||
7413 | + | ||
7414 | + print(' // ES1 does not support generic vertex attributes') | ||
7415 | + print(' if (es1)') | ||
7416 | + print(' return false;') | ||
7417 | + print() | ||
7418 | + print(' vertex_attrib _vertex_attrib = _get_vertex_attrib();') | ||
7419 | + print() | ||
7420 | + print(' // glVertexAttribPointer') | ||
7421 | + print(' if (_vertex_attrib == VERTEX_ATTRIB) {') | ||
7422 | + print(' GLint _max_vertex_attribs = _glGetInteger(GL_MAX_VERTEX_ATTRIBS);') | ||
7423 | + print(' for (GLint index = 0; index < _max_vertex_attribs; ++index) {') | ||
7424 | + print(' if (_glGetVertexAttribi(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED) &&') | ||
7425 | + print(' _glGetVertexAttribi(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING) == 0) {') | ||
7426 | + print(' return true;') | ||
7427 | + print(' }') | ||
7428 | + print(' }') | ||
7429 | + print(' }') | ||
7430 | + print() | ||
7431 | + print(' // glVertexAttribPointerNV') | ||
7432 | + print(' if (_vertex_attrib == VERTEX_ATTRIB_NV) {') | ||
7433 | + print(' for (GLint index = 0; index < 16; ++index) {') | ||
7434 | + print(' if (_glIsEnabled(GL_VERTEX_ATTRIB_ARRAY0_NV + index)) {') | ||
7435 | + print(' return true;') | ||
7436 | + print(' }') | ||
7437 | + print(' }') | ||
7438 | + print(' }') | ||
7439 | + print() | ||
7440 | + | ||
7441 | + print(' return false;') | ||
7442 | + print('}') | ||
7443 | + print() | ||
7444 | + | ||
7445 | + print('static void _trace_user_arrays(GLuint count);') | ||
7446 | + print() | ||
7447 | + | ||
7448 | + print('// whether glLockArraysEXT() has ever been called') | ||
7449 | + print('static bool _checkLockArraysEXT = false;') | ||
7450 | + print() | ||
7451 | |||
7452 | # Buffer mappings | ||
7453 | - print '// whether glMapBufferRange(GL_MAP_WRITE_BIT) has ever been called' | ||
7454 | - print 'static bool _checkBufferMapRange = false;' | ||
7455 | |||
7456 | - print '// whether glBufferParameteriAPPLE(GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE) has ever been called' | ||
7457 | - print 'static bool _checkBufferFlushingUnmapAPPLE = false;' | ||
7458 | |||
7459 | + print('// whether glMapBufferRange(GL_MAP_WRITE_BIT) has ever been called') | ||
7460 | + print('static bool _checkBufferMapRange = false;') | ||
7461 | + print() | ||
7462 | + print('// whether glBufferParameteriAPPLE(GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE) has ever been called') | ||
7463 | + print('static bool _checkBufferFlushingUnmapAPPLE = false;') | ||
7464 | + print() | ||
7465 | |||
7466 | # Generate a helper function to determine whether a parameter name | ||
7467 | # refers to a symbolic value or not | ||
7468 | - print 'static bool' | ||
7469 | - print 'is_symbolic_pname(GLenum pname) {' | ||
7470 | - print ' switch (pname) {' | ||
7471 | + print('static bool') | ||
7472 | + print('is_symbolic_pname(GLenum pname) {') | ||
7473 | + print(' switch (pname) {') | ||
7474 | for function, type, count, name in glparams.parameters: | ||
7475 | if type is glapi.GLenum: | ||
7476 | - print ' case %s:' % name | ||
7477 | - print ' return true;' | ||
7478 | - print ' default:' | ||
7479 | - print ' return false;' | ||
7480 | - print ' }' | ||
7481 | - print '}' | ||
7482 | |||
7483 | + print(' case %s:' % name) | ||
7484 | + print(' return true;') | ||
7485 | + print(' default:') | ||
7486 | + print(' return false;') | ||
7487 | + print(' }') | ||
7488 | + print('}') | ||
7489 | + print() | ||
7490 | |||
7491 | # Generate a helper function to determine whether a parameter value is | ||
7492 | # potentially symbolic or not; i.e., if the value can be represented in | ||
7493 | # an enum or not | ||
7494 | - print 'template<class T>' | ||
7495 | - print 'static inline bool' | ||
7496 | - print 'is_symbolic_param(T param) {' | ||
7497 | - print ' return static_cast<T>(static_cast<GLenum>(param)) == param;' | ||
7498 | - print '}' | ||
7499 | |||
7500 | + print('template<class T>') | ||
7501 | + print('static inline bool') | ||
7502 | + print('is_symbolic_param(T param) {') | ||
7503 | + print(' return static_cast<T>(static_cast<GLenum>(param)) == param;') | ||
7504 | + print('}') | ||
7505 | + print() | ||
7506 | |||
7507 | # Generate a helper function to know how many elements a parameter has | ||
7508 | - print 'static size_t' | ||
7509 | - print '_gl_param_size(GLenum pname) {' | ||
7510 | - print ' switch (pname) {' | ||
7511 | + print('static size_t') | ||
7512 | + print('_gl_param_size(GLenum pname) {') | ||
7513 | + print(' switch (pname) {') | ||
7514 | for function, type, count, name in glparams.parameters: | ||
7515 | if name == 'GL_PROGRAM_BINARY_FORMATS': | ||
7516 | count = 0 | ||
7517 | if type is not None: | ||
7518 | - print ' case %s: return %s;' % (name, count) | ||
7519 | - print ' default:' | ||
7520 | - print r' os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);' | ||
7521 | - print ' return 1;' | ||
7522 | - print ' }' | ||
7523 | - print '}' | ||
7524 | |||
7525 | + print(' case %s: return %s;' % (name, count)) | ||
7526 | + print(' default:') | ||
7527 | + print(r' os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);') | ||
7528 | + print(' return 1;') | ||
7529 | + print(' }') | ||
7530 | + print('}') | ||
7531 | + print() | ||
7532 | |||
7533 | # states such as GL_UNPACK_ROW_LENGTH are not available in GLES | ||
7534 | - print 'static inline bool' | ||
7535 | - print 'can_unpack_subimage(void) {' | ||
7536 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
7537 | - print ' return ctx->profile.desktop();' | ||
7538 | - print '}' | ||
7539 | |||
7540 | + print('static inline bool') | ||
7541 | + print('can_unpack_subimage(void) {') | ||
7542 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
7543 | + print(' return ctx->profile.desktop();') | ||
7544 | + print('}') | ||
7545 | + print() | ||
7546 | |||
7547 | # VMWX_map_buffer_debug | ||
7548 | - print r'extern "C" PUBLIC' | ||
7549 | - print r'void APIENTRY' | ||
7550 | - print r'glNotifyMappedBufferRangeVMWX(const void * start, GLsizeiptr length) {' | ||
7551 | + print(r'extern "C" PUBLIC') | ||
7552 | + print(r'void APIENTRY') | ||
7553 | + print(r'glNotifyMappedBufferRangeVMWX(const void * start, GLsizeiptr length) {') | ||
7554 | self.emit_memcpy('start', 'length') | ||
7555 | - print r'}' | ||
7556 | |||
7557 | + print(r'}') | ||
7558 | + print() | ||
7559 | |||
7560 | getProcAddressFunctionNames = [] | ||
7561 | |||
7562 | @@ -290,70 +290,70 @@ class GlTracer(Tracer): | ||
7563 | argType = getProcAddressFunction.args[0].type | ||
7564 | retType = getProcAddressFunction.type | ||
7565 | |||
7566 | - print 'static %s _wrapProcAddress(%s procName, %s procPtr);' % (retType, argType, retType) | ||
7567 | |||
7568 | + print('static %s _wrapProcAddress(%s procName, %s procPtr);' % (retType, argType, retType)) | ||
7569 | + print() | ||
7570 | |||
7571 | Tracer.traceApi(self, api) | ||
7572 | |||
7573 | - print 'static %s _wrapProcAddress(%s procName, %s procPtr) {' % (retType, argType, retType) | ||
7574 | + print('static %s _wrapProcAddress(%s procName, %s procPtr) {' % (retType, argType, retType)) | ||
7575 | |||
7576 | # Provide fallback functions to missing debug functions | ||
7577 | - print ' if (!procPtr) {' | ||
7578 | + print(' if (!procPtr) {') | ||
7579 | else_ = '' | ||
7580 | for function_name in self.debug_functions: | ||
7581 | if self.api.getFunctionByName(function_name): | ||
7582 | - print ' %sif (strcmp("%s", (const char *)procName) == 0) {' % (else_, function_name) | ||
7583 | - print ' return (%s)&%s;' % (retType, function_name) | ||
7584 | - print ' }' | ||
7585 | + print(' %sif (strcmp("%s", (const char *)procName) == 0) {' % (else_, function_name)) | ||
7586 | + print(' return (%s)&%s;' % (retType, function_name)) | ||
7587 | + print(' }') | ||
7588 | else_ = 'else ' | ||
7589 | - print ' %s{' % else_ | ||
7590 | - print ' return NULL;' | ||
7591 | - print ' }' | ||
7592 | - print ' }' | ||
7593 | + print(' %s{' % else_) | ||
7594 | + print(' return NULL;') | ||
7595 | + print(' }') | ||
7596 | + print(' }') | ||
7597 | |||
7598 | for function in api.getAllFunctions(): | ||
7599 | ptype = function_pointer_type(function) | ||
7600 | pvalue = function_pointer_value(function) | ||
7601 | - print ' if (strcmp("%s", (const char *)procName) == 0) {' % function.name | ||
7602 | - print ' assert(procPtr != (%s)&%s);' % (retType, function.name) | ||
7603 | - print ' %s = (%s)procPtr;' % (pvalue, ptype) | ||
7604 | - print ' return (%s)&%s;' % (retType, function.name,) | ||
7605 | - print ' }' | ||
7606 | - print ' os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);' | ||
7607 | - print ' return procPtr;' | ||
7608 | - print '}' | ||
7609 | |||
7610 | + print(' if (strcmp("%s", (const char *)procName) == 0) {' % function.name) | ||
7611 | + print(' assert(procPtr != (%s)&%s);' % (retType, function.name)) | ||
7612 | + print(' %s = (%s)procPtr;' % (pvalue, ptype)) | ||
7613 | + print(' return (%s)&%s;' % (retType, function.name,)) | ||
7614 | + print(' }') | ||
7615 | + print(' os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);') | ||
7616 | + print(' return procPtr;') | ||
7617 | + print('}') | ||
7618 | + print() | ||
7619 | else: | ||
7620 | Tracer.traceApi(self, api) | ||
7621 | |||
7622 | def defineShadowBufferHelper(self): | ||
7623 | - print 'void _shadow_glGetBufferSubData(GLenum target, GLintptr offset,' | ||
7624 | - print ' GLsizeiptr size, GLvoid *data)' | ||
7625 | - print '{' | ||
7626 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
7627 | - print ' if (!ctx->needsShadowBuffers() || target != GL_ELEMENT_ARRAY_BUFFER) {' | ||
7628 | - print ' _glGetBufferSubData(target, offset, size, data);' | ||
7629 | - print ' return;' | ||
7630 | - print ' }' | ||
7631 | |||
7632 | - print ' GLint buffer_binding = _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);' | ||
7633 | - print ' if (buffer_binding > 0) {' | ||
7634 | - print ' gltrace::Buffer & buf = ctx->buffers[buffer_binding];' | ||
7635 | - print ' buf.getSubData(offset, size, data);' | ||
7636 | - print ' }' | ||
7637 | - print '}' | ||
7638 | + print('void _shadow_glGetBufferSubData(GLenum target, GLintptr offset,') | ||
7639 | + print(' GLsizeiptr size, GLvoid *data)') | ||
7640 | + print('{') | ||
7641 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
7642 | + print(' if (!ctx->needsShadowBuffers() || target != GL_ELEMENT_ARRAY_BUFFER) {') | ||
7643 | + print(' _glGetBufferSubData(target, offset, size, data);') | ||
7644 | + print(' return;') | ||
7645 | + print(' }') | ||
7646 | + print() | ||
7647 | + print(' GLint buffer_binding = _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);') | ||
7648 | + print(' if (buffer_binding > 0) {') | ||
7649 | + print(' gltrace::Buffer & buf = ctx->buffers[buffer_binding];') | ||
7650 | + print(' buf.getSubData(offset, size, data);') | ||
7651 | + print(' }') | ||
7652 | + print('}') | ||
7653 | |||
7654 | def shadowBufferMethod(self, method): | ||
7655 | # Emit code to fetch the shadow buffer, and invoke a method | ||
7656 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
7657 | - print ' if (ctx->needsShadowBuffers() && target == GL_ELEMENT_ARRAY_BUFFER) {' | ||
7658 | - print ' GLint buffer_binding = _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);' | ||
7659 | - print ' if (buffer_binding > 0) {' | ||
7660 | - print ' gltrace::Buffer & buf = ctx->buffers[buffer_binding];' | ||
7661 | - print ' buf.' + method + ';' | ||
7662 | - print ' }' | ||
7663 | - print ' }' | ||
7664 | |||
7665 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
7666 | + print(' if (ctx->needsShadowBuffers() && target == GL_ELEMENT_ARRAY_BUFFER) {') | ||
7667 | + print(' GLint buffer_binding = _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);') | ||
7668 | + print(' if (buffer_binding > 0) {') | ||
7669 | + print(' gltrace::Buffer & buf = ctx->buffers[buffer_binding];') | ||
7670 | + print(' buf.' + method + ';') | ||
7671 | + print(' }') | ||
7672 | + print(' }') | ||
7673 | + print() | ||
7674 | |||
7675 | def shadowBufferProlog(self, function): | ||
7676 | if function.name == 'glBufferData': | ||
7677 | @@ -363,12 +363,12 @@ class GlTracer(Tracer): | ||
7678 | self.shadowBufferMethod('bufferSubData(offset, size, data)') | ||
7679 | |||
7680 | if function.name == 'glDeleteBuffers': | ||
7681 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
7682 | - print ' if (ctx->needsShadowBuffers()) {' | ||
7683 | - print ' for (GLsizei i = 0; i < n; i++) {' | ||
7684 | - print ' ctx->buffers.erase(buffer[i]);' | ||
7685 | - print ' }' | ||
7686 | - print ' }' | ||
7687 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
7688 | + print(' if (ctx->needsShadowBuffers()) {') | ||
7689 | + print(' for (GLsizei i = 0; i < n; i++) {') | ||
7690 | + print(' ctx->buffers.erase(buffer[i]);') | ||
7691 | + print(' }') | ||
7692 | + print(' }') | ||
7693 | |||
7694 | array_pointer_function_names = set(( | ||
7695 | "glVertexPointer", | ||
7696 | @@ -426,42 +426,42 @@ class GlTracer(Tracer): | ||
7697 | def traceFunctionImplBody(self, function): | ||
7698 | # Defer tracing of user array pointers... | ||
7699 | if function.name in self.array_pointer_function_names: | ||
7700 | - print ' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);' | ||
7701 | - print ' if (!_array_buffer) {' | ||
7702 | - print ' static bool warned = false;' | ||
7703 | - print ' if (!warned) {' | ||
7704 | - print ' warned = true;' | ||
7705 | - print ' os::log("apitrace: warning: %s: call will be faked due to pointer to user memory (https://github.com/apitrace/apitrace/blob/master/docs/BUGS.markdown#tracing)\\n", __FUNCTION__);' | ||
7706 | - print ' }' | ||
7707 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
7708 | - print ' ctx->user_arrays = true;' | ||
7709 | + print(' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);') | ||
7710 | + print(' if (!_array_buffer) {') | ||
7711 | + print(' static bool warned = false;') | ||
7712 | + print(' if (!warned) {') | ||
7713 | + print(' warned = true;') | ||
7714 | + print(' os::log("apitrace: warning: %s: call will be faked due to pointer to user memory (https://github.com/apitrace/apitrace/blob/master/docs/BUGS.markdown#tracing)\\n", __FUNCTION__);') | ||
7715 | + print(' }') | ||
7716 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
7717 | + print(' ctx->user_arrays = true;') | ||
7718 | if function.name == "glVertexAttribPointerNV": | ||
7719 | - print ' ctx->user_arrays_nv = true;' | ||
7720 | + print(' ctx->user_arrays_nv = true;') | ||
7721 | self.invokeFunction(function) | ||
7722 | |||
7723 | # And also break down glInterleavedArrays into the individual calls | ||
7724 | if function.name == 'glInterleavedArrays': | ||
7725 | |||
7726 | + print() | ||
7727 | |||
7728 | # Initialize the enable flags | ||
7729 | for camelcase_name, uppercase_name in self.arrays: | ||
7730 | flag_name = '_' + uppercase_name.lower() | ||
7731 | - print ' GLboolean %s = GL_FALSE;' % flag_name | ||
7732 | |||
7733 | + print(' GLboolean %s = GL_FALSE;' % flag_name) | ||
7734 | + print() | ||
7735 | |||
7736 | # Switch for the interleaved formats | ||
7737 | - print ' switch (format) {' | ||
7738 | + print(' switch (format) {') | ||
7739 | for format in self.interleaved_formats: | ||
7740 | - print ' case %s:' % format | ||
7741 | + print(' case %s:' % format) | ||
7742 | for camelcase_name, uppercase_name in self.arrays: | ||
7743 | flag_name = '_' + uppercase_name.lower() | ||
7744 | if format.find('_' + uppercase_name[0]) >= 0: | ||
7745 | - print ' %s = GL_TRUE;' % flag_name | ||
7746 | - print ' break;' | ||
7747 | - print ' default:' | ||
7748 | - print ' return;' | ||
7749 | - print ' }' | ||
7750 | |||
7751 | + print(' %s = GL_TRUE;' % flag_name) | ||
7752 | + print(' break;') | ||
7753 | + print(' default:') | ||
7754 | + print(' return;') | ||
7755 | + print(' }') | ||
7756 | + print() | ||
7757 | |||
7758 | # Emit fake glEnableClientState/glDisableClientState flags | ||
7759 | for camelcase_name, uppercase_name in self.arrays: | ||
7760 | @@ -469,16 +469,16 @@ class GlTracer(Tracer): | ||
7761 | enable_name = 'GL_%s_ARRAY' % uppercase_name | ||
7762 | |||
7763 | # Emit a fake function | ||
7764 | - print ' {' | ||
7765 | - print ' static const trace::FunctionSig &_sig = %s ? _glEnableClientState_sig : _glDisableClientState_sig;' % flag_name | ||
7766 | - print ' unsigned _call = trace::localWriter.beginEnter(&_sig, true);' | ||
7767 | - print ' trace::localWriter.beginArg(0);' | ||
7768 | + print(' {') | ||
7769 | + print(' static const trace::FunctionSig &_sig = %s ? _glEnableClientState_sig : _glDisableClientState_sig;' % flag_name) | ||
7770 | + print(' unsigned _call = trace::localWriter.beginEnter(&_sig, true);') | ||
7771 | + print(' trace::localWriter.beginArg(0);') | ||
7772 | self.serializeValue(glapi.GLenum, enable_name) | ||
7773 | - print ' trace::localWriter.endArg();' | ||
7774 | - print ' trace::localWriter.endEnter();' | ||
7775 | - print ' trace::localWriter.beginLeave(_call);' | ||
7776 | - print ' trace::localWriter.endLeave();' | ||
7777 | - print ' }' | ||
7778 | + print(' trace::localWriter.endArg();') | ||
7779 | + print(' trace::localWriter.endEnter();') | ||
7780 | + print(' trace::localWriter.beginLeave(_call);') | ||
7781 | + print(' trace::localWriter.endLeave();') | ||
7782 | + print(' }') | ||
7783 | |||
7784 | # Warn about buggy glGet(GL_*ARRAY_SIZE) not returning GL_BGRA | ||
7785 | buggyFunctions = { | ||
7786 | @@ -489,224 +489,224 @@ class GlTracer(Tracer): | ||
7787 | } | ||
7788 | if function.name in buggyFunctions: | ||
7789 | getter, extraArg, pname = buggyFunctions[function.name] | ||
7790 | - print r' static bool _checked = false;' | ||
7791 | - print r' if (!_checked && size == GL_BGRA) {' | ||
7792 | - print r' GLint _size = 0;' | ||
7793 | - print r' _%s(%s%s, &_size);' % (getter, extraArg, pname) | ||
7794 | - print r' if (_size != GL_BGRA) {' | ||
7795 | - print r' os::log("apitrace: warning: %s(%s) does not return GL_BGRA; trace will be incorrect (https://github.com/apitrace/apitrace/issues/261)\n");' % (getter, pname) | ||
7796 | - print r' }' | ||
7797 | - print r' _checked = true;' | ||
7798 | - print r' }' | ||
7799 | - | ||
7800 | - print ' return;' | ||
7801 | - print ' }' | ||
7802 | + print(r' static bool _checked = false;') | ||
7803 | + print(r' if (!_checked && size == GL_BGRA) {') | ||
7804 | + print(r' GLint _size = 0;') | ||
7805 | + print(r' _%s(%s%s, &_size);' % (getter, extraArg, pname)) | ||
7806 | + print(r' if (_size != GL_BGRA) {') | ||
7807 | + print(r' os::log("apitrace: warning: %s(%s) does not return GL_BGRA; trace will be incorrect (https://github.com/apitrace/apitrace/issues/261)\n");' % (getter, pname)) | ||
7808 | + print(r' }') | ||
7809 | + print(r' _checked = true;') | ||
7810 | + print(r' }') | ||
7811 | + | ||
7812 | + print(' return;') | ||
7813 | + print(' }') | ||
7814 | |||
7815 | # ... to the draw calls | ||
7816 | if self.draw_function_regex.match(function.name): | ||
7817 | if not self.multi_draw_function_regex.match(function.name): | ||
7818 | - print ' if (trace::localWriter.isIgnored()) {' | ||
7819 | + print(' if (trace::localWriter.isIgnored()) {') | ||
7820 | self.invokeFunction(function) | ||
7821 | - print ' return;' | ||
7822 | - print ' }' | ||
7823 | - print ' if (_need_user_arrays()) {' | ||
7824 | + print(' return;') | ||
7825 | + print(' }') | ||
7826 | + print(' if (_need_user_arrays()) {') | ||
7827 | if 'Indirect' in function.name: | ||
7828 | - print r' os::log("apitrace: warning: %s: indirect user arrays not supported\n");' % (function.name,) | ||
7829 | + print(r' os::log("apitrace: warning: %s: indirect user arrays not supported\n");' % (function.name,)) | ||
7830 | else: | ||
7831 | arg_names = ', '.join([arg.name for arg in function.args[1:]]) | ||
7832 | - print ' GLuint _count = _%s_count(%s);' % (function.name, arg_names) | ||
7833 | + print(' GLuint _count = _%s_count(%s);' % (function.name, arg_names)) | ||
7834 | # Some apps, in particular Quake3, can tell the driver to lock more | ||
7835 | # vertices than those actually required for the draw call. | ||
7836 | - print ' if (_checkLockArraysEXT) {' | ||
7837 | - print ' GLuint _locked_count = _glGetInteger(GL_ARRAY_ELEMENT_LOCK_FIRST_EXT)' | ||
7838 | - print ' + _glGetInteger(GL_ARRAY_ELEMENT_LOCK_COUNT_EXT);' | ||
7839 | - print ' _count = std::max(_count, _locked_count);' | ||
7840 | - print ' }' | ||
7841 | - print ' _trace_user_arrays(_count);' | ||
7842 | - print ' }' | ||
7843 | + print(' if (_checkLockArraysEXT) {') | ||
7844 | + print(' GLuint _locked_count = _glGetInteger(GL_ARRAY_ELEMENT_LOCK_FIRST_EXT)') | ||
7845 | + print(' + _glGetInteger(GL_ARRAY_ELEMENT_LOCK_COUNT_EXT);') | ||
7846 | + print(' _count = std::max(_count, _locked_count);') | ||
7847 | + print(' }') | ||
7848 | + print(' _trace_user_arrays(_count);') | ||
7849 | + print(' }') | ||
7850 | if function.name == 'glLockArraysEXT': | ||
7851 | - print ' _checkLockArraysEXT = true;' | ||
7852 | + print(' _checkLockArraysEXT = true;') | ||
7853 | |||
7854 | # Warn if user arrays are used with glBegin/glArrayElement/glEnd. | ||
7855 | if function.name == 'glBegin': | ||
7856 | - print r' gltrace::Context *ctx = gltrace::getContext();' | ||
7857 | - print r' ctx->userArraysOnBegin = _need_user_arrays();' | ||
7858 | + print(r' gltrace::Context *ctx = gltrace::getContext();') | ||
7859 | + print(r' ctx->userArraysOnBegin = _need_user_arrays();') | ||
7860 | if function.name.startswith('glArrayElement'): | ||
7861 | - print r' gltrace::Context *ctx = gltrace::getContext();' | ||
7862 | - print r' if (ctx->userArraysOnBegin) {' | ||
7863 | - print r' os::log("apitrace: warning: user arrays with glArrayElement not supported (https://github.com/apitrace/apitrace/issues/276)\n");' | ||
7864 | - print r' ctx->userArraysOnBegin = false;' | ||
7865 | - print r' }' | ||
7866 | + print(r' gltrace::Context *ctx = gltrace::getContext();') | ||
7867 | + print(r' if (ctx->userArraysOnBegin) {') | ||
7868 | + print(r' os::log("apitrace: warning: user arrays with glArrayElement not supported (https://github.com/apitrace/apitrace/issues/276)\n");') | ||
7869 | + print(r' ctx->userArraysOnBegin = false;') | ||
7870 | + print(r' }') | ||
7871 | |||
7872 | # Emit a fake memcpy on buffer uploads | ||
7873 | if function.name == 'glBufferParameteriAPPLE': | ||
7874 | - print ' if (pname == GL_BUFFER_FLUSHING_UNMAP_APPLE && param == GL_FALSE) {' | ||
7875 | - print ' _checkBufferFlushingUnmapAPPLE = true;' | ||
7876 | - print ' }' | ||
7877 | + print(' if (pname == GL_BUFFER_FLUSHING_UNMAP_APPLE && param == GL_FALSE) {') | ||
7878 | + print(' _checkBufferFlushingUnmapAPPLE = true;') | ||
7879 | + print(' }') | ||
7880 | if function.name in ('glUnmapBuffer', 'glUnmapBufferARB'): | ||
7881 | if function.name.endswith('ARB'): | ||
7882 | suffix = 'ARB' | ||
7883 | else: | ||
7884 | suffix = '' | ||
7885 | - print ' GLint access_flags = 0;' | ||
7886 | - print ' GLint access = 0;' | ||
7887 | - print ' bool flush;' | ||
7888 | - print ' // GLES3 does not have GL_BUFFER_ACCESS;' | ||
7889 | - print ' if (_checkBufferMapRange) {' | ||
7890 | - print ' _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);' % suffix | ||
7891 | - print ' flush = (access_flags & GL_MAP_WRITE_BIT) && !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT));' | ||
7892 | - print ' } else {' | ||
7893 | - print ' _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS, &access);' % suffix | ||
7894 | - print ' flush = access != GL_READ_ONLY;' | ||
7895 | - print ' }' | ||
7896 | - print ' if (flush) {' | ||
7897 | - print ' GLvoid *map = NULL;' | ||
7898 | - print ' _glGetBufferPointerv%s(target, GL_BUFFER_MAP_POINTER, &map);' % suffix | ||
7899 | - print ' if (map) {' | ||
7900 | - print ' GLint length = -1;' | ||
7901 | - print ' if (_checkBufferMapRange) {' | ||
7902 | - print ' _glGetBufferParameteriv%s(target, GL_BUFFER_MAP_LENGTH, &length);' % suffix | ||
7903 | - print ' if (length == -1) {' | ||
7904 | - print ' // Mesa drivers refuse GL_BUFFER_MAP_LENGTH without GL 3.0 up-to' | ||
7905 | - print ' // http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffee498fb848b253a7833373fe5430f8c7ca0c5f' | ||
7906 | - print ' static bool warned = false;' | ||
7907 | - print ' if (!warned) {' | ||
7908 | - print ' os::log("apitrace: warning: glGetBufferParameteriv%s(GL_BUFFER_MAP_LENGTH) failed\\n");' % suffix | ||
7909 | - print ' warned = true;' | ||
7910 | - print ' }' | ||
7911 | - print ' }' | ||
7912 | - print ' } else {' | ||
7913 | - print ' length = 0;' | ||
7914 | - print ' _glGetBufferParameteriv%s(target, GL_BUFFER_SIZE, &length);' % suffix | ||
7915 | - print ' }' | ||
7916 | - print ' if (_checkBufferFlushingUnmapAPPLE) {' | ||
7917 | - print ' GLint flushing_unmap = GL_TRUE;' | ||
7918 | - print ' _glGetBufferParameteriv%s(target, GL_BUFFER_FLUSHING_UNMAP_APPLE, &flushing_unmap);' % suffix | ||
7919 | - print ' flush = flush && flushing_unmap;' | ||
7920 | - print ' }' | ||
7921 | - print ' if (flush && length > 0) {' | ||
7922 | + print(' GLint access_flags = 0;') | ||
7923 | + print(' GLint access = 0;') | ||
7924 | + print(' bool flush;') | ||
7925 | + print(' // GLES3 does not have GL_BUFFER_ACCESS;') | ||
7926 | + print(' if (_checkBufferMapRange) {') | ||
7927 | + print(' _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);' % suffix) | ||
7928 | + print(' flush = (access_flags & GL_MAP_WRITE_BIT) && !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT));') | ||
7929 | + print(' } else {') | ||
7930 | + print(' _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS, &access);' % suffix) | ||
7931 | + print(' flush = access != GL_READ_ONLY;') | ||
7932 | + print(' }') | ||
7933 | + print(' if (flush) {') | ||
7934 | + print(' GLvoid *map = NULL;') | ||
7935 | + print(' _glGetBufferPointerv%s(target, GL_BUFFER_MAP_POINTER, &map);' % suffix) | ||
7936 | + print(' if (map) {') | ||
7937 | + print(' GLint length = -1;') | ||
7938 | + print(' if (_checkBufferMapRange) {') | ||
7939 | + print(' _glGetBufferParameteriv%s(target, GL_BUFFER_MAP_LENGTH, &length);' % suffix) | ||
7940 | + print(' if (length == -1) {') | ||
7941 | + print(' // Mesa drivers refuse GL_BUFFER_MAP_LENGTH without GL 3.0 up-to') | ||
7942 | + print(' // http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffee498fb848b253a7833373fe5430f8c7ca0c5f') | ||
7943 | + print(' static bool warned = false;') | ||
7944 | + print(' if (!warned) {') | ||
7945 | + print(' os::log("apitrace: warning: glGetBufferParameteriv%s(GL_BUFFER_MAP_LENGTH) failed\\n");' % suffix) | ||
7946 | + print(' warned = true;') | ||
7947 | + print(' }') | ||
7948 | + print(' }') | ||
7949 | + print(' } else {') | ||
7950 | + print(' length = 0;') | ||
7951 | + print(' _glGetBufferParameteriv%s(target, GL_BUFFER_SIZE, &length);' % suffix) | ||
7952 | + print(' }') | ||
7953 | + print(' if (_checkBufferFlushingUnmapAPPLE) {') | ||
7954 | + print(' GLint flushing_unmap = GL_TRUE;') | ||
7955 | + print(' _glGetBufferParameteriv%s(target, GL_BUFFER_FLUSHING_UNMAP_APPLE, &flushing_unmap);' % suffix) | ||
7956 | + print(' flush = flush && flushing_unmap;') | ||
7957 | + print(' }') | ||
7958 | + print(' if (flush && length > 0) {') | ||
7959 | self.emit_memcpy('map', 'length') | ||
7960 | - print ' }' | ||
7961 | - print ' }' | ||
7962 | - print ' }' | ||
7963 | + print(' }') | ||
7964 | + print(' }') | ||
7965 | + print(' }') | ||
7966 | if function.name == 'glUnmapBufferOES': | ||
7967 | - print ' GLint access_flags = 0;' | ||
7968 | - print ' GLint access = 0;' | ||
7969 | - print ' bool flush;' | ||
7970 | - print ' // GLES3 does not have GL_BUFFER_ACCESS;' | ||
7971 | - print ' if (_checkBufferMapRange) {' | ||
7972 | - print ' _glGetBufferParameteriv(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);' | ||
7973 | - print ' flush = (access_flags & GL_MAP_WRITE_BIT) && !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT));' | ||
7974 | - print ' } else {' | ||
7975 | - print ' _glGetBufferParameteriv(target, GL_BUFFER_ACCESS, &access);' | ||
7976 | - print ' flush = access != GL_READ_ONLY;' | ||
7977 | - print ' }' | ||
7978 | - print ' if (flush) {' | ||
7979 | - print ' GLvoid *map = NULL;' | ||
7980 | - print ' _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER, &map);' | ||
7981 | - print ' if (map) {' | ||
7982 | - print ' GLint length = 0;' | ||
7983 | - print ' GLint offset = 0;' | ||
7984 | - print ' if (_checkBufferMapRange) {' | ||
7985 | - print ' _glGetBufferParameteriv(target, GL_BUFFER_MAP_LENGTH, &length);' | ||
7986 | - print ' _glGetBufferParameteriv(target, GL_BUFFER_MAP_OFFSET, &offset);' | ||
7987 | - print ' } else {' | ||
7988 | - print ' _glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);' | ||
7989 | - print ' }' | ||
7990 | - print ' if (flush && length > 0) {' | ||
7991 | + print(' GLint access_flags = 0;') | ||
7992 | + print(' GLint access = 0;') | ||
7993 | + print(' bool flush;') | ||
7994 | + print(' // GLES3 does not have GL_BUFFER_ACCESS;') | ||
7995 | + print(' if (_checkBufferMapRange) {') | ||
7996 | + print(' _glGetBufferParameteriv(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);') | ||
7997 | + print(' flush = (access_flags & GL_MAP_WRITE_BIT) && !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT));') | ||
7998 | + print(' } else {') | ||
7999 | + print(' _glGetBufferParameteriv(target, GL_BUFFER_ACCESS, &access);') | ||
8000 | + print(' flush = access != GL_READ_ONLY;') | ||
8001 | + print(' }') | ||
8002 | + print(' if (flush) {') | ||
8003 | + print(' GLvoid *map = NULL;') | ||
8004 | + print(' _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER, &map);') | ||
8005 | + print(' if (map) {') | ||
8006 | + print(' GLint length = 0;') | ||
8007 | + print(' GLint offset = 0;') | ||
8008 | + print(' if (_checkBufferMapRange) {') | ||
8009 | + print(' _glGetBufferParameteriv(target, GL_BUFFER_MAP_LENGTH, &length);') | ||
8010 | + print(' _glGetBufferParameteriv(target, GL_BUFFER_MAP_OFFSET, &offset);') | ||
8011 | + print(' } else {') | ||
8012 | + print(' _glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);') | ||
8013 | + print(' }') | ||
8014 | + print(' if (flush && length > 0) {') | ||
8015 | self.emit_memcpy('map', 'length') | ||
8016 | self.shadowBufferMethod('bufferSubData(offset, length, map)') | ||
8017 | - print ' }' | ||
8018 | - print ' }' | ||
8019 | - print ' }' | ||
8020 | + print(' }') | ||
8021 | + print(' }') | ||
8022 | + print(' }') | ||
8023 | if function.name == 'glUnmapNamedBuffer': | ||
8024 | - print ' GLint access_flags = 0;' | ||
8025 | - print ' _glGetNamedBufferParameteriv(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);' | ||
8026 | - print ' if ((access_flags & GL_MAP_WRITE_BIT) &&' | ||
8027 | - print ' !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT))) {' | ||
8028 | - print ' GLvoid *map = NULL;' | ||
8029 | - print ' _glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &map);' | ||
8030 | - print ' GLint length = 0;' | ||
8031 | - print ' _glGetNamedBufferParameteriv(buffer, GL_BUFFER_MAP_LENGTH, &length);' | ||
8032 | - print ' if (map && length > 0) {' | ||
8033 | + print(' GLint access_flags = 0;') | ||
8034 | + print(' _glGetNamedBufferParameteriv(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);') | ||
8035 | + print(' if ((access_flags & GL_MAP_WRITE_BIT) &&') | ||
8036 | + print(' !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT))) {') | ||
8037 | + print(' GLvoid *map = NULL;') | ||
8038 | + print(' _glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &map);') | ||
8039 | + print(' GLint length = 0;') | ||
8040 | + print(' _glGetNamedBufferParameteriv(buffer, GL_BUFFER_MAP_LENGTH, &length);') | ||
8041 | + print(' if (map && length > 0) {') | ||
8042 | self.emit_memcpy('map', 'length') | ||
8043 | - print ' }' | ||
8044 | - print ' }' | ||
8045 | + print(' }') | ||
8046 | + print(' }') | ||
8047 | if function.name == 'glUnmapNamedBufferEXT': | ||
8048 | - print ' GLint access_flags = 0;' | ||
8049 | - print ' _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);' | ||
8050 | - print ' if ((access_flags & GL_MAP_WRITE_BIT) &&' | ||
8051 | - print ' !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT))) {' | ||
8052 | - print ' GLvoid *map = NULL;' | ||
8053 | - print ' _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);' | ||
8054 | - print ' GLint length = 0;' | ||
8055 | - print ' _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_MAP_LENGTH, &length);' | ||
8056 | - print ' if (map && length > 0) {' | ||
8057 | + print(' GLint access_flags = 0;') | ||
8058 | + print(' _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);') | ||
8059 | + print(' if ((access_flags & GL_MAP_WRITE_BIT) &&') | ||
8060 | + print(' !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT))) {') | ||
8061 | + print(' GLvoid *map = NULL;') | ||
8062 | + print(' _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);') | ||
8063 | + print(' GLint length = 0;') | ||
8064 | + print(' _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_MAP_LENGTH, &length);') | ||
8065 | + print(' if (map && length > 0) {') | ||
8066 | self.emit_memcpy('map', 'length') | ||
8067 | - print ' }' | ||
8068 | - print ' }' | ||
8069 | + print(' }') | ||
8070 | + print(' }') | ||
8071 | if function.name == 'glFlushMappedBufferRange': | ||
8072 | - print ' GLvoid *map = NULL;' | ||
8073 | - print ' _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);' | ||
8074 | - print ' if (map && length > 0) {' | ||
8075 | + print(' GLvoid *map = NULL;') | ||
8076 | + print(' _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);') | ||
8077 | + print(' if (map && length > 0) {') | ||
8078 | self.emit_memcpy('(const char *)map + offset', 'length') | ||
8079 | - print ' }' | ||
8080 | + print(' }') | ||
8081 | if function.name == 'glFlushMappedBufferRangeEXT': | ||
8082 | - print ' GLvoid *map = NULL;' | ||
8083 | - print ' _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &map);' | ||
8084 | - print ' if (map && length > 0) {' | ||
8085 | + print(' GLvoid *map = NULL;') | ||
8086 | + print(' _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &map);') | ||
8087 | + print(' if (map && length > 0) {') | ||
8088 | self.emit_memcpy('(const char *)map + offset', 'length') | ||
8089 | - print ' }' | ||
8090 | + print(' }') | ||
8091 | if function.name == 'glFlushMappedBufferRangeAPPLE': | ||
8092 | - print ' GLvoid *map = NULL;' | ||
8093 | - print ' _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);' | ||
8094 | - print ' if (map && size > 0) {' | ||
8095 | + print(' GLvoid *map = NULL;') | ||
8096 | + print(' _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);') | ||
8097 | + print(' if (map && size > 0) {') | ||
8098 | self.emit_memcpy('(const char *)map + offset', 'size') | ||
8099 | - print ' }' | ||
8100 | + print(' }') | ||
8101 | if function.name == 'glFlushMappedNamedBufferRange': | ||
8102 | - print ' GLvoid *map = NULL;' | ||
8103 | - print ' _glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &map);' | ||
8104 | - print ' if (map && length > 0) {' | ||
8105 | + print(' GLvoid *map = NULL;') | ||
8106 | + print(' _glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &map);') | ||
8107 | + print(' if (map && length > 0) {') | ||
8108 | self.emit_memcpy('(const char *)map + offset', 'length') | ||
8109 | - print ' }' | ||
8110 | + print(' }') | ||
8111 | if function.name == 'glFlushMappedNamedBufferRangeEXT': | ||
8112 | - print ' GLvoid *map = NULL;' | ||
8113 | - print ' _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);' | ||
8114 | - print ' if (map && length > 0) {' | ||
8115 | + print(' GLvoid *map = NULL;') | ||
8116 | + print(' _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);') | ||
8117 | + print(' if (map && length > 0) {') | ||
8118 | self.emit_memcpy('(const char *)map + offset', 'length') | ||
8119 | - print ' }' | ||
8120 | + print(' }') | ||
8121 | |||
8122 | # FIXME: We don't support coherent/pinned memory mappings | ||
8123 | if function.name in ('glBufferStorage', 'glNamedBufferStorage', 'glNamedBufferStorageEXT'): | ||
8124 | - print r' if (!(flags & GL_MAP_PERSISTENT_BIT)) {' | ||
8125 | - print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);' | ||
8126 | - print r' }' | ||
8127 | - print r' flags &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;' | ||
8128 | + print(r' if (!(flags & GL_MAP_PERSISTENT_BIT)) {') | ||
8129 | + print(r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);') | ||
8130 | + print(r' }') | ||
8131 | + print(r' flags &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;') | ||
8132 | if function.name in ('glMapBufferRange', 'glMapBufferRangeEXT', 'glMapNamedBufferRange', 'glMapNamedBufferRangeEXT'): | ||
8133 | - print r' if (access & GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX) {' | ||
8134 | - print r' if (!(access & GL_MAP_PERSISTENT_BIT)) {' | ||
8135 | - print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);' | ||
8136 | - print r' }' | ||
8137 | - print r' if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {' | ||
8138 | - print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/ MAP_FLUSH_EXPLICIT_BIT\n", __FUNCTION__);' | ||
8139 | - print r' }' | ||
8140 | - print r' access &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;' | ||
8141 | - print r' } else if (access & GL_MAP_COHERENT_BIT) {' | ||
8142 | - print r' os::log("apitrace: warning: %s: MAP_COHERENT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);' | ||
8143 | - print r' } else if ((access & GL_MAP_PERSISTENT_BIT) &&' | ||
8144 | - print r' !(access & GL_MAP_FLUSH_EXPLICIT_BIT)) {' | ||
8145 | - print r' os::log("apitrace: warning: %s: MAP_PERSISTENT_BIT w/o FLUSH_EXPLICIT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);' | ||
8146 | - print r' }' | ||
8147 | + print(r' if (access & GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX) {') | ||
8148 | + print(r' if (!(access & GL_MAP_PERSISTENT_BIT)) {') | ||
8149 | + print(r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);') | ||
8150 | + print(r' }') | ||
8151 | + print(r' if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {') | ||
8152 | + print(r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/ MAP_FLUSH_EXPLICIT_BIT\n", __FUNCTION__);') | ||
8153 | + print(r' }') | ||
8154 | + print(r' access &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;') | ||
8155 | + print(r' } else if (access & GL_MAP_COHERENT_BIT) {') | ||
8156 | + print(r' os::log("apitrace: warning: %s: MAP_COHERENT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);') | ||
8157 | + print(r' } else if ((access & GL_MAP_PERSISTENT_BIT) &&') | ||
8158 | + print(r' !(access & GL_MAP_FLUSH_EXPLICIT_BIT)) {') | ||
8159 | + print(r' os::log("apitrace: warning: %s: MAP_PERSISTENT_BIT w/o FLUSH_EXPLICIT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);') | ||
8160 | + print(r' }') | ||
8161 | if function.name in ('glBufferData', 'glBufferDataARB'): | ||
8162 | - print r' if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {' | ||
8163 | - print r' os::log("apitrace: warning: GL_AMD_pinned_memory not fully supported\n");' | ||
8164 | - print r' }' | ||
8165 | + print(r' if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {') | ||
8166 | + print(r' os::log("apitrace: warning: GL_AMD_pinned_memory not fully supported\n");') | ||
8167 | + print(r' }') | ||
8168 | |||
8169 | # TODO: We don't track GL_INTEL_map_texture mappings | ||
8170 | if function.name == 'glMapTexture2DINTEL': | ||
8171 | - print r' if (access & GL_MAP_WRITE_BIT) {' | ||
8172 | - print r' os::log("apitrace: warning: GL_INTEL_map_texture not fully supported\n");' | ||
8173 | - print r' }' | ||
8174 | + print(r' if (access & GL_MAP_WRITE_BIT) {') | ||
8175 | + print(r' os::log("apitrace: warning: GL_INTEL_map_texture not fully supported\n");') | ||
8176 | + print(r' }') | ||
8177 | |||
8178 | # Don't leave vertex attrib locations to chance. Instead emit fake | ||
8179 | # glBindAttribLocation calls to ensure that the same locations will be | ||
8180 | @@ -715,40 +715,40 @@ class GlTracer(Tracer): | ||
8181 | # many entry-points, including non-shader related ones. | ||
8182 | if function.name == 'glLinkProgram': | ||
8183 | Tracer.invokeFunction(self, function) | ||
8184 | - print ' GLint active_attributes = 0;' | ||
8185 | - print ' _glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active_attributes);' | ||
8186 | - print ' for (GLint attrib = 0; attrib < active_attributes; ++attrib) {' | ||
8187 | - print ' GLint size = 0;' | ||
8188 | - print ' GLenum type = 0;' | ||
8189 | - print ' GLchar name[256];' | ||
8190 | + print(' GLint active_attributes = 0;') | ||
8191 | + print(' _glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active_attributes);') | ||
8192 | + print(' for (GLint attrib = 0; attrib < active_attributes; ++attrib) {') | ||
8193 | + print(' GLint size = 0;') | ||
8194 | + print(' GLenum type = 0;') | ||
8195 | + print(' GLchar name[256];') | ||
8196 | # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256 | ||
8197 | - print ' _glGetActiveAttrib(program, attrib, sizeof name, NULL, &size, &type, name);' | ||
8198 | - print " if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {" | ||
8199 | - print ' GLint location = _glGetAttribLocation(program, name);' | ||
8200 | - print ' if (location >= 0) {' | ||
8201 | + print(' _glGetActiveAttrib(program, attrib, sizeof name, NULL, &size, &type, name);') | ||
8202 | + print(" if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {") | ||
8203 | + print(' GLint location = _glGetAttribLocation(program, name);') | ||
8204 | + print(' if (location >= 0) {') | ||
8205 | bind_function = glapi.glapi.getFunctionByName('glBindAttribLocation') | ||
8206 | self.fake_call(bind_function, ['program', 'location', 'name']) | ||
8207 | - print ' }' | ||
8208 | - print ' }' | ||
8209 | - print ' }' | ||
8210 | + print(' }') | ||
8211 | + print(' }') | ||
8212 | + print(' }') | ||
8213 | if function.name == 'glLinkProgramARB': | ||
8214 | Tracer.invokeFunction(self, function) | ||
8215 | - print ' GLint active_attributes = 0;' | ||
8216 | - print ' _glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &active_attributes);' | ||
8217 | - print ' for (GLint attrib = 0; attrib < active_attributes; ++attrib) {' | ||
8218 | - print ' GLint size = 0;' | ||
8219 | - print ' GLenum type = 0;' | ||
8220 | - print ' GLcharARB name[256];' | ||
8221 | + print(' GLint active_attributes = 0;') | ||
8222 | + print(' _glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &active_attributes);') | ||
8223 | + print(' for (GLint attrib = 0; attrib < active_attributes; ++attrib) {') | ||
8224 | + print(' GLint size = 0;') | ||
8225 | + print(' GLenum type = 0;') | ||
8226 | + print(' GLcharARB name[256];') | ||
8227 | # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256 | ||
8228 | - print ' _glGetActiveAttribARB(programObj, attrib, sizeof name, NULL, &size, &type, name);' | ||
8229 | - print " if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {" | ||
8230 | - print ' GLint location = _glGetAttribLocationARB(programObj, name);' | ||
8231 | - print ' if (location >= 0) {' | ||
8232 | + print(' _glGetActiveAttribARB(programObj, attrib, sizeof name, NULL, &size, &type, name);') | ||
8233 | + print(" if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {") | ||
8234 | + print(' GLint location = _glGetAttribLocationARB(programObj, name);') | ||
8235 | + print(' if (location >= 0) {') | ||
8236 | bind_function = glapi.glapi.getFunctionByName('glBindAttribLocationARB') | ||
8237 | self.fake_call(bind_function, ['programObj', 'location', 'name']) | ||
8238 | - print ' }' | ||
8239 | - print ' }' | ||
8240 | - print ' }' | ||
8241 | + print(' }') | ||
8242 | + print(' }') | ||
8243 | + print(' }') | ||
8244 | |||
8245 | self.shadowBufferProlog(function) | ||
8246 | |||
8247 | @@ -815,9 +815,9 @@ class GlTracer(Tracer): | ||
8248 | # Force glProgramBinary to fail. Per ARB_get_program_binary this | ||
8249 | # should signal the app that it needs to recompile. | ||
8250 | if function.name in ('glProgramBinary', 'glProgramBinaryOES'): | ||
8251 | - print r' binaryFormat = 0xDEADDEAD;' | ||
8252 | - print r' binary = &binaryFormat;' | ||
8253 | - print r' length = sizeof binaryFormat;' | ||
8254 | + print(r' binaryFormat = 0xDEADDEAD;') | ||
8255 | + print(r' binary = &binaryFormat;') | ||
8256 | + print(r' length = sizeof binaryFormat;') | ||
8257 | |||
8258 | Tracer.invokeFunction(self, function) | ||
8259 | |||
8260 | @@ -838,25 +838,25 @@ class GlTracer(Tracer): | ||
8261 | # We may be faking KHR_debug, so ensure the pointer queries result is | ||
8262 | # always zeroed to prevent dereference of unitialized pointers | ||
8263 | if function.name == 'glGetPointerv': | ||
8264 | - print ' if (params &&' | ||
8265 | - print ' (pname == GL_DEBUG_CALLBACK_FUNCTION ||' | ||
8266 | - print ' pname == GL_DEBUG_CALLBACK_USER_PARAM)) {' | ||
8267 | - print ' *params = NULL;' | ||
8268 | - print ' }' | ||
8269 | + print(' if (params &&') | ||
8270 | + print(' (pname == GL_DEBUG_CALLBACK_FUNCTION ||') | ||
8271 | + print(' pname == GL_DEBUG_CALLBACK_USER_PARAM)) {') | ||
8272 | + print(' *params = NULL;') | ||
8273 | + print(' }') | ||
8274 | |||
8275 | if function.name in self.getProcAddressFunctionNames: | ||
8276 | nameArg = function.args[0].name | ||
8277 | - print ' if (strcmp("glNotifyMappedBufferRangeVMWX", (const char *)%s) == 0) {' % (nameArg,) | ||
8278 | - print ' _result = (%s)&glNotifyMappedBufferRangeVMWX;' % (function.type,) | ||
8279 | - print ' } else if (strcmp("glTexDirectVIV", (const char *)%s) == 0) {' % (nameArg,) | ||
8280 | - print ' _result = (%s)&glTexDirectVIV;' % (function.type,) | ||
8281 | - print ' } else if (strcmp("glTexDirectInvalidateVIV", (const char *)%s) == 0) {' % (nameArg,) | ||
8282 | - print ' _result = (%s)&glTexDirectInvalidateVIV;' % (function.type,) | ||
8283 | + print(' if (strcmp("glNotifyMappedBufferRangeVMWX", (const char *)%s) == 0) {' % (nameArg,)) | ||
8284 | + print(' _result = (%s)&glNotifyMappedBufferRangeVMWX;' % (function.type,)) | ||
8285 | + print(' } else if (strcmp("glTexDirectVIV", (const char *)%s) == 0) {' % (nameArg,)) | ||
8286 | + print(' _result = (%s)&glTexDirectVIV;' % (function.type,)) | ||
8287 | + print(' } else if (strcmp("glTexDirectInvalidateVIV", (const char *)%s) == 0) {' % (nameArg,)) | ||
8288 | + print(' _result = (%s)&glTexDirectInvalidateVIV;' % (function.type,)) | ||
8289 | for marker_function in self.marker_functions: | ||
8290 | if self.api.getFunctionByName(marker_function): | ||
8291 | - print ' } else if (strcmp("%s", (const char *)%s) == 0) {' % (marker_function, nameArg) | ||
8292 | - print ' _result = (%s)&%s;' % (function.type, marker_function) | ||
8293 | - print ' } else {' | ||
8294 | + print(' } else if (strcmp("%s", (const char *)%s) == 0) {' % (marker_function, nameArg)) | ||
8295 | + print(' _result = (%s)&%s;' % (function.type, marker_function)) | ||
8296 | + print(' } else {') | ||
8297 | Tracer.doInvokeFunction(self, function) | ||
8298 | |||
8299 | # Replace function addresses with ours | ||
8300 | @@ -864,24 +864,24 @@ class GlTracer(Tracer): | ||
8301 | # contain the addresses of the wrapper functions, and not the real | ||
8302 | # functions, but in practice this should make no difference. | ||
8303 | if function.name in self.getProcAddressFunctionNames: | ||
8304 | - print ' _result = _wrapProcAddress(%s, _result);' % (nameArg,) | ||
8305 | + print(' _result = _wrapProcAddress(%s, _result);' % (nameArg,)) | ||
8306 | |||
8307 | - print ' }' | ||
8308 | + print(' }') | ||
8309 | return | ||
8310 | |||
8311 | if function.name in ('glGetProgramBinary', 'glGetProgramBinaryOES'): | ||
8312 | - print r' bufSize = 0;' | ||
8313 | + print(r' bufSize = 0;') | ||
8314 | |||
8315 | Tracer.doInvokeFunction(self, function) | ||
8316 | |||
8317 | if function.name == 'glGetProgramiv': | ||
8318 | - print r' if (params && pname == GL_PROGRAM_BINARY_LENGTH) {' | ||
8319 | - print r' *params = 0;' | ||
8320 | - print r' }' | ||
8321 | + print(r' if (params && pname == GL_PROGRAM_BINARY_LENGTH) {') | ||
8322 | + print(r' *params = 0;') | ||
8323 | + print(r' }') | ||
8324 | if function.name in ('glGetProgramBinary', 'glGetProgramBinaryOES'): | ||
8325 | - print r' if (length) {' | ||
8326 | - print r' *length = 0;' | ||
8327 | - print r' }' | ||
8328 | + print(r' if (length) {') | ||
8329 | + print(r' *length = 0;') | ||
8330 | + print(r' }') | ||
8331 | |||
8332 | buffer_targets = [ | ||
8333 | 'ARRAY_BUFFER', | ||
8334 | @@ -902,9 +902,9 @@ class GlTracer(Tracer): | ||
8335 | |||
8336 | # Keep track of buffer mappings | ||
8337 | if function.name in ('glMapBufferRange', 'glMapBufferRangeEXT'): | ||
8338 | - print ' if (access & GL_MAP_WRITE_BIT) {' | ||
8339 | - print ' _checkBufferMapRange = true;' | ||
8340 | - print ' }' | ||
8341 | + print(' if (access & GL_MAP_WRITE_BIT) {') | ||
8342 | + print(' _checkBufferMapRange = true;') | ||
8343 | + print(' }') | ||
8344 | |||
8345 | boolean_names = [ | ||
8346 | 'GL_FALSE', | ||
8347 | @@ -932,17 +932,17 @@ class GlTracer(Tracer): | ||
8348 | and (isinstance(arg.type, stdapi.Blob) \ | ||
8349 | or (isinstance(arg.type, stdapi.Const) \ | ||
8350 | and isinstance(arg.type.type, stdapi.Blob))): | ||
8351 | - print ' {' | ||
8352 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
8353 | - print ' GLint _unpack_buffer = 0;' | ||
8354 | - print ' if (ctx->profile.desktop())' | ||
8355 | - print ' _glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &_unpack_buffer);' | ||
8356 | - print ' if (_unpack_buffer) {' | ||
8357 | - print ' trace::localWriter.writePointer((uintptr_t)%s);' % arg.name | ||
8358 | - print ' } else {' | ||
8359 | + print(' {') | ||
8360 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
8361 | + print(' GLint _unpack_buffer = 0;') | ||
8362 | + print(' if (ctx->profile.desktop())') | ||
8363 | + print(' _glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &_unpack_buffer);') | ||
8364 | + print(' if (_unpack_buffer) {') | ||
8365 | + print(' trace::localWriter.writePointer((uintptr_t)%s);' % arg.name) | ||
8366 | + print(' } else {') | ||
8367 | Tracer.serializeArgValue(self, function, arg) | ||
8368 | - print ' }' | ||
8369 | - print ' }' | ||
8370 | + print(' }') | ||
8371 | + print(' }') | ||
8372 | return | ||
8373 | |||
8374 | # Several GL state functions take GLenum symbolic names as | ||
8375 | @@ -953,11 +953,11 @@ class GlTracer(Tracer): | ||
8376 | assert arg.index > 0 | ||
8377 | assert function.args[arg.index - 1].name == 'pname' | ||
8378 | assert function.args[arg.index - 1].type == glapi.GLenum | ||
8379 | - print ' if (is_symbolic_pname(pname) && is_symbolic_param(%s)) {' % arg.name | ||
8380 | + print(' if (is_symbolic_pname(pname) && is_symbolic_param(%s)) {' % arg.name) | ||
8381 | self.serializeValue(glapi.GLenum, arg.name) | ||
8382 | - print ' } else {' | ||
8383 | + print(' } else {') | ||
8384 | Tracer.serializeArgValue(self, function, arg) | ||
8385 | - print ' }' | ||
8386 | + print(' }') | ||
8387 | return | ||
8388 | |||
8389 | Tracer.serializeArgValue(self, function, arg) | ||
8390 | @@ -967,20 +967,20 @@ class GlTracer(Tracer): | ||
8391 | |||
8392 | # A simple state tracker to track the pointer values | ||
8393 | # update the state | ||
8394 | - print 'static void _trace_user_arrays(GLuint count)' | ||
8395 | - print '{' | ||
8396 | - print ' gltrace::Context *ctx = gltrace::getContext();' | ||
8397 | |||
8398 | - print ' glprofile::Profile profile = ctx->profile;' | ||
8399 | - print ' bool es1 = profile.es() && profile.major == 1;' | ||
8400 | |||
8401 | + print('static void _trace_user_arrays(GLuint count)') | ||
8402 | + print('{') | ||
8403 | + print(' gltrace::Context *ctx = gltrace::getContext();') | ||
8404 | + print() | ||
8405 | + print(' glprofile::Profile profile = ctx->profile;') | ||
8406 | + print(' bool es1 = profile.es() && profile.major == 1;') | ||
8407 | + print() | ||
8408 | |||
8409 | # Temporarily unbind the array buffer | ||
8410 | - print ' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);' | ||
8411 | - print ' if (_array_buffer) {' | ||
8412 | + print(' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);') | ||
8413 | + print(' if (_array_buffer) {') | ||
8414 | self.fake_glBindBuffer(api, 'GL_ARRAY_BUFFER', '0') | ||
8415 | - print ' }' | ||
8416 | |||
8417 | + print(' }') | ||
8418 | + print() | ||
8419 | |||
8420 | for camelcase_name, uppercase_name in self.arrays: | ||
8421 | # in which profile is the array available? | ||
8422 | @@ -993,45 +993,45 @@ class GlTracer(Tracer): | ||
8423 | binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name | ||
8424 | function = api.getFunctionByName(function_name) | ||
8425 | |||
8426 | - print ' // %s' % function.prototype() | ||
8427 | - print ' if (%s) {' % profile_check | ||
8428 | + print(' // %s' % function.prototype()) | ||
8429 | + print(' if (%s) {' % profile_check) | ||
8430 | self.array_trace_prolog(api, uppercase_name) | ||
8431 | self.array_prolog(api, uppercase_name) | ||
8432 | - print ' if (_glIsEnabled(%s)) {' % enable_name | ||
8433 | - print ' GLint _binding = _glGetInteger(%s);' % binding_name | ||
8434 | - print ' if (!_binding) {' | ||
8435 | + print(' if (_glIsEnabled(%s)) {' % enable_name) | ||
8436 | + print(' GLint _binding = _glGetInteger(%s);' % binding_name) | ||
8437 | + print(' if (!_binding) {') | ||
8438 | |||
8439 | # Get the arguments via glGet* | ||
8440 | for arg in function.args: | ||
8441 | arg_get_enum = 'GL_%s_ARRAY_%s' % (uppercase_name, arg.name.upper()) | ||
8442 | arg_get_function, arg_type = TypeGetter().visit(arg.type) | ||
8443 | - print ' %s %s = 0;' % (arg_type, arg.name) | ||
8444 | - print ' _%s(%s, &%s);' % (arg_get_function, arg_get_enum, arg.name) | ||
8445 | + print(' %s %s = 0;' % (arg_type, arg.name)) | ||
8446 | + print(' _%s(%s, &%s);' % (arg_get_function, arg_get_enum, arg.name)) | ||
8447 | |||
8448 | arg_names = ', '.join([arg.name for arg in function.args[:-1]]) | ||
8449 | - print ' size_t _size = _%s_size(%s, count);' % (function.name, arg_names) | ||
8450 | + print(' size_t _size = _%s_size(%s, count);' % (function.name, arg_names)) | ||
8451 | |||
8452 | # Emit a fake function | ||
8453 | self.array_trace_intermezzo(api, uppercase_name) | ||
8454 | - print ' unsigned _call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) | ||
8455 | + print(' unsigned _call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)) | ||
8456 | for arg in function.args: | ||
8457 | assert not arg.output | ||
8458 | - print ' trace::localWriter.beginArg(%u);' % (arg.index,) | ||
8459 | + print(' trace::localWriter.beginArg(%u);' % (arg.index,)) | ||
8460 | if arg.name != 'pointer': | ||
8461 | self.serializeValue(arg.type, arg.name) | ||
8462 | else: | ||
8463 | - print ' trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name) | ||
8464 | - print ' trace::localWriter.endArg();' | ||
8465 | + print(' trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name)) | ||
8466 | + print(' trace::localWriter.endArg();') | ||
8467 | |||
8468 | - print ' trace::localWriter.endEnter();' | ||
8469 | - print ' trace::localWriter.beginLeave(_call);' | ||
8470 | - print ' trace::localWriter.endLeave();' | ||
8471 | - print ' }' | ||
8472 | - print ' }' | ||
8473 | + print(' trace::localWriter.endEnter();') | ||
8474 | + print(' trace::localWriter.beginLeave(_call);') | ||
8475 | + print(' trace::localWriter.endLeave();') | ||
8476 | + print(' }') | ||
8477 | + print(' }') | ||
8478 | self.array_epilog(api, uppercase_name) | ||
8479 | self.array_trace_epilog(api, uppercase_name) | ||
8480 | - print ' }' | ||
8481 | |||
8482 | + print(' }') | ||
8483 | + print() | ||
8484 | |||
8485 | # Samething, but for glVertexAttribPointer* | ||
8486 | # | ||
8487 | @@ -1043,12 +1043,12 @@ class GlTracer(Tracer): | ||
8488 | # This means that the implementations of these functions do not always | ||
8489 | # alias, and they need to be considered independently. | ||
8490 | # | ||
8491 | - print ' // ES1 does not support generic vertex attributes' | ||
8492 | - print ' if (es1)' | ||
8493 | - print ' return;' | ||
8494 | |||
8495 | - print ' vertex_attrib _vertex_attrib = _get_vertex_attrib();' | ||
8496 | |||
8497 | + print(' // ES1 does not support generic vertex attributes') | ||
8498 | + print(' if (es1)') | ||
8499 | + print(' return;') | ||
8500 | + print() | ||
8501 | + print(' vertex_attrib _vertex_attrib = _get_vertex_attrib();') | ||
8502 | + print() | ||
8503 | for suffix in ['', 'NV']: | ||
8504 | if suffix: | ||
8505 | SUFFIX = '_' + suffix | ||
8506 | @@ -1057,24 +1057,24 @@ class GlTracer(Tracer): | ||
8507 | function_name = 'glVertexAttribPointer' + suffix | ||
8508 | function = api.getFunctionByName(function_name) | ||
8509 | |||
8510 | - print ' // %s' % function.prototype() | ||
8511 | - print ' if (_vertex_attrib == VERTEX_ATTRIB%s) {' % SUFFIX | ||
8512 | + print(' // %s' % function.prototype()) | ||
8513 | + print(' if (_vertex_attrib == VERTEX_ATTRIB%s) {' % SUFFIX) | ||
8514 | if suffix == 'NV': | ||
8515 | - print ' GLint _max_vertex_attribs = 16;' | ||
8516 | + print(' GLint _max_vertex_attribs = 16;') | ||
8517 | else: | ||
8518 | - print ' GLint _max_vertex_attribs = _glGetInteger(GL_MAX_VERTEX_ATTRIBS);' | ||
8519 | - print ' for (GLint index = 0; index < _max_vertex_attribs; ++index) {' | ||
8520 | - print ' GLint _enabled = 0;' | ||
8521 | + print(' GLint _max_vertex_attribs = _glGetInteger(GL_MAX_VERTEX_ATTRIBS);') | ||
8522 | + print(' for (GLint index = 0; index < _max_vertex_attribs; ++index) {') | ||
8523 | + print(' GLint _enabled = 0;') | ||
8524 | if suffix == 'NV': | ||
8525 | - print ' _glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &_enabled);' | ||
8526 | + print(' _glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &_enabled);') | ||
8527 | else: | ||
8528 | - print ' _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED%s, &_enabled);' % (suffix, SUFFIX) | ||
8529 | - print ' if (_enabled) {' | ||
8530 | - print ' GLint _binding = 0;' | ||
8531 | + print(' _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED%s, &_enabled);' % (suffix, SUFFIX)) | ||
8532 | + print(' if (_enabled) {') | ||
8533 | + print(' GLint _binding = 0;') | ||
8534 | if suffix != 'NV': | ||
8535 | # It doesn't seem possible to use VBOs with NV_vertex_program. | ||
8536 | - print ' _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING%s, &_binding);' % (suffix, SUFFIX) | ||
8537 | - print ' if (!_binding) {' | ||
8538 | + print(' _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING%s, &_binding);' % (suffix, SUFFIX)) | ||
8539 | + print(' if (!_binding) {') | ||
8540 | |||
8541 | # Get the arguments via glGet* | ||
8542 | for arg in function.args[1:]: | ||
8543 | @@ -1083,40 +1083,40 @@ class GlTracer(Tracer): | ||
8544 | else: | ||
8545 | arg_get_enum = 'GL_VERTEX_ATTRIB_ARRAY_%s%s' % (arg.name.upper(), SUFFIX) | ||
8546 | arg_get_function, arg_type = TypeGetter('glGetVertexAttrib', False, suffix).visit(arg.type) | ||
8547 | - print ' %s %s = 0;' % (arg_type, arg.name) | ||
8548 | - print ' _%s(index, %s, &%s);' % (arg_get_function, arg_get_enum, arg.name) | ||
8549 | + print(' %s %s = 0;' % (arg_type, arg.name)) | ||
8550 | + print(' _%s(index, %s, &%s);' % (arg_get_function, arg_get_enum, arg.name)) | ||
8551 | |||
8552 | arg_names = ', '.join([arg.name for arg in function.args[1:-1]]) | ||
8553 | - print ' size_t _size = _%s_size(%s, count);' % (function.name, arg_names) | ||
8554 | + print(' size_t _size = _%s_size(%s, count);' % (function.name, arg_names)) | ||
8555 | |||
8556 | # Emit a fake function | ||
8557 | - print ' unsigned _call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) | ||
8558 | + print(' unsigned _call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)) | ||
8559 | for arg in function.args: | ||
8560 | assert not arg.output | ||
8561 | - print ' trace::localWriter.beginArg(%u);' % (arg.index,) | ||
8562 | + print(' trace::localWriter.beginArg(%u);' % (arg.index,)) | ||
8563 | if arg.name != 'pointer': | ||
8564 | self.serializeValue(arg.type, arg.name) | ||
8565 | else: | ||
8566 | - print ' trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name) | ||
8567 | - print ' trace::localWriter.endArg();' | ||
8568 | + print(' trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name)) | ||
8569 | + print(' trace::localWriter.endArg();') | ||
8570 | |||
8571 | - print ' trace::localWriter.endEnter();' | ||
8572 | - print ' trace::localWriter.beginLeave(_call);' | ||
8573 | - print ' trace::localWriter.endLeave();' | ||
8574 | - print ' }' | ||
8575 | - print ' }' | ||
8576 | - print ' }' | ||
8577 | - print ' }' | ||
8578 | |||
8579 | + print(' trace::localWriter.endEnter();') | ||
8580 | + print(' trace::localWriter.beginLeave(_call);') | ||
8581 | + print(' trace::localWriter.endLeave();') | ||
8582 | + print(' }') | ||
8583 | + print(' }') | ||
8584 | + print(' }') | ||
8585 | + print(' }') | ||
8586 | + print() | ||
8587 | |||
8588 | # Restore the original array_buffer | ||
8589 | - print ' if (_array_buffer) {' | ||
8590 | + print(' if (_array_buffer) {') | ||
8591 | self.fake_glBindBuffer(api, 'GL_ARRAY_BUFFER', '_array_buffer') | ||
8592 | - print ' }' | ||
8593 | |||
8594 | + print(' }') | ||
8595 | + print() | ||
8596 | |||
8597 | - print '}' | ||
8598 | |||
8599 | + print('}') | ||
8600 | + print() | ||
8601 | |||
8602 | # | ||
8603 | # Hooks for glTexCoordPointer, which is identical to the other array | ||
8604 | @@ -1125,49 +1125,49 @@ class GlTracer(Tracer): | ||
8605 | |||
8606 | def array_prolog(self, api, uppercase_name): | ||
8607 | if uppercase_name == 'TEXTURE_COORD': | ||
8608 | - print ' GLint max_units = 0;' | ||
8609 | - print ' if (ctx->profile.desktop())' | ||
8610 | - print ' _glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_units);' | ||
8611 | - print ' else' | ||
8612 | - print ' _glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_units);' | ||
8613 | - print ' GLint client_active_texture = GL_TEXTURE0;' | ||
8614 | - print ' if (max_units > 0) {' | ||
8615 | - print ' _glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &client_active_texture);' | ||
8616 | - print ' }' | ||
8617 | - print ' GLint unit = 0;' | ||
8618 | - print ' do {' | ||
8619 | - print ' GLint texture = GL_TEXTURE0 + unit;' | ||
8620 | - print ' if (max_units > 0) {' | ||
8621 | - print ' _glClientActiveTexture(texture);' | ||
8622 | - print ' }' | ||
8623 | + print(' GLint max_units = 0;') | ||
8624 | + print(' if (ctx->profile.desktop())') | ||
8625 | + print(' _glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_units);') | ||
8626 | + print(' else') | ||
8627 | + print(' _glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_units);') | ||
8628 | + print(' GLint client_active_texture = GL_TEXTURE0;') | ||
8629 | + print(' if (max_units > 0) {') | ||
8630 | + print(' _glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &client_active_texture);') | ||
8631 | + print(' }') | ||
8632 | + print(' GLint unit = 0;') | ||
8633 | + print(' do {') | ||
8634 | + print(' GLint texture = GL_TEXTURE0 + unit;') | ||
8635 | + print(' if (max_units > 0) {') | ||
8636 | + print(' _glClientActiveTexture(texture);') | ||
8637 | + print(' }') | ||
8638 | |||
8639 | def array_trace_prolog(self, api, uppercase_name): | ||
8640 | if uppercase_name == 'TEXTURE_COORD': | ||
8641 | - print ' bool client_active_texture_dirty = false;' | ||
8642 | + print(' bool client_active_texture_dirty = false;') | ||
8643 | |||
8644 | def array_epilog(self, api, uppercase_name): | ||
8645 | if uppercase_name == 'TEXTURE_COORD': | ||
8646 | - print ' } while (++unit < max_units);' | ||
8647 | + print(' } while (++unit < max_units);') | ||
8648 | self.array_cleanup(api, uppercase_name) | ||
8649 | |||
8650 | def array_cleanup(self, api, uppercase_name): | ||
8651 | if uppercase_name == 'TEXTURE_COORD': | ||
8652 | - print ' if (max_units > 0) {' | ||
8653 | - print ' _glClientActiveTexture(client_active_texture);' | ||
8654 | - print ' }' | ||
8655 | + print(' if (max_units > 0) {') | ||
8656 | + print(' _glClientActiveTexture(client_active_texture);') | ||
8657 | + print(' }') | ||
8658 | |||
8659 | def array_trace_intermezzo(self, api, uppercase_name): | ||
8660 | if uppercase_name == 'TEXTURE_COORD': | ||
8661 | - print ' if (texture != client_active_texture || client_active_texture_dirty) {' | ||
8662 | - print ' client_active_texture_dirty = true;' | ||
8663 | + print(' if (texture != client_active_texture || client_active_texture_dirty) {') | ||
8664 | + print(' client_active_texture_dirty = true;') | ||
8665 | self.fake_glClientActiveTexture_call(api, "texture"); | ||
8666 | - print ' }' | ||
8667 | + print(' }') | ||
8668 | |||
8669 | def array_trace_epilog(self, api, uppercase_name): | ||
8670 | if uppercase_name == 'TEXTURE_COORD': | ||
8671 | - print ' if (client_active_texture_dirty) {' | ||
8672 | + print(' if (client_active_texture_dirty) {') | ||
8673 | self.fake_glClientActiveTexture_call(api, "client_active_texture"); | ||
8674 | - print ' }' | ||
8675 | + print(' }') | ||
8676 | |||
8677 | def fake_glBindBuffer(self, api, target, buffer): | ||
8678 | function = api.getFunctionByName('glBindBuffer') | ||
8679 | @@ -1180,13 +1180,13 @@ class GlTracer(Tracer): | ||
8680 | def emitFakeTexture2D(self): | ||
8681 | function = glapi.glapi.getFunctionByName('glTexImage2D') | ||
8682 | instances = function.argNames() | ||
8683 | - print ' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) | ||
8684 | + print(' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)) | ||
8685 | for arg in function.args: | ||
8686 | assert not arg.output | ||
8687 | self.serializeArg(function, arg) | ||
8688 | - print ' trace::localWriter.endEnter();' | ||
8689 | - print ' trace::localWriter.beginLeave(_fake_call);' | ||
8690 | - print ' trace::localWriter.endLeave();' | ||
8691 | + print(' trace::localWriter.endEnter();') | ||
8692 | + print(' trace::localWriter.beginLeave(_fake_call);') | ||
8693 | + print(' trace::localWriter.endLeave();') | ||
8694 | |||
8695 | |||
8696 | |||
8697 | diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py | ||
8698 | index f35d1fe9..b05028e2 100644 | ||
8699 | --- a/wrappers/glxtrace.py | ||
8700 | +++ b/wrappers/glxtrace.py | ||
8701 | @@ -64,7 +64,7 @@ class GlxTracer(GlTracer): | ||
8702 | |||
8703 | def traceFunctionImplBody(self, function): | ||
8704 | if function.name in self.destroyContextFunctionNames: | ||
8705 | - print ' gltrace::releaseContext((uintptr_t)ctx);' | ||
8706 | + print(' gltrace::releaseContext((uintptr_t)ctx);') | ||
8707 | |||
8708 | if function.name == 'glXGetCurrentDisplay': | ||
8709 | print ' if(_glXGetCurrentDisplay == &glXGetCurrentDisplay ){' | ||
8710 | @@ -74,16 +74,16 @@ class GlxTracer(GlTracer): | ||
8711 | GlTracer.traceFunctionImplBody(self, function) | ||
8712 | |||
8713 | if function.name in self.createContextFunctionNames: | ||
8714 | - print ' if (_result != NULL)' | ||
8715 | - print ' gltrace::createContext((uintptr_t)_result);' | ||
8716 | + print(' if (_result != NULL)') | ||
8717 | + print(' gltrace::createContext((uintptr_t)_result);') | ||
8718 | |||
8719 | if function.name in self.makeCurrentFunctionNames: | ||
8720 | - print ' if (_result) {' | ||
8721 | - print ' if (ctx != NULL)' | ||
8722 | - print ' gltrace::setContext((uintptr_t)ctx);' | ||
8723 | - print ' else' | ||
8724 | - print ' gltrace::clearContext();' | ||
8725 | - print ' }' | ||
8726 | + print(' if (_result) {') | ||
8727 | + print(' if (ctx != NULL)') | ||
8728 | + print(' gltrace::setContext((uintptr_t)ctx);') | ||
8729 | + print(' else') | ||
8730 | + print(' gltrace::clearContext();') | ||
8731 | + print(' }') | ||
8732 | |||
8733 | if function.name == 'glXBindTexImageEXT': | ||
8734 | # FIXME: glXBindTexImageEXT gets called frequently, so we should | ||
8735 | @@ -92,7 +92,7 @@ class GlxTracer(GlTracer): | ||
8736 | # emit emitFakeTexture2D when it changes | ||
8737 | # - keep a global hash of the pixels | ||
8738 | # FIXME: Handle mipmaps | ||
8739 | - print r''' | ||
8740 | + print(r''' | ||
8741 | unsigned glx_target = 0; | ||
8742 | _glXQueryDrawable(display, drawable, GLX_TEXTURE_TARGET_EXT, &glx_target); | ||
8743 | GLenum target; | ||
8744 | @@ -152,29 +152,29 @@ class GlxTracer(GlTracer): | ||
8745 | GLint row_stride = _align(width * 4, alignment); | ||
8746 | GLvoid * pixels = malloc(height * row_stride); | ||
8747 | _glGetTexImage(target, level, format, type, pixels); | ||
8748 | - ''' | ||
8749 | + ''') | ||
8750 | self.emitFakeTexture2D() | ||
8751 | - print r''' | ||
8752 | + print(r''' | ||
8753 | free(pixels); | ||
8754 | } | ||
8755 | - ''' | ||
8756 | + ''') | ||
8757 | |||
8758 | |||
8759 | if __name__ == '__main__': | ||
8760 | |||
8761 | - print '#include <stdlib.h>' | ||
8762 | - print '#include <string.h>' | ||
8763 | |||
8764 | - print '#include "trace_writer_local.hpp"' | ||
8765 | |||
8766 | - print '// To validate our prototypes' | ||
8767 | - print '#define GL_GLEXT_PROTOTYPES' | ||
8768 | - print '#define GLX_GLXEXT_PROTOTYPES' | ||
8769 | |||
8770 | - print '#include "dlopen.hpp"' | ||
8771 | - print '#include "glproc.hpp"' | ||
8772 | - print '#include "glsize.hpp"' | ||
8773 | |||
8774 | + print() | ||
8775 | + print('#include <stdlib.h>') | ||
8776 | + print('#include <string.h>') | ||
8777 | + print() | ||
8778 | + print('#include "trace_writer_local.hpp"') | ||
8779 | + print() | ||
8780 | + print('// To validate our prototypes') | ||
8781 | + print('#define GL_GLEXT_PROTOTYPES') | ||
8782 | + print('#define GLX_GLXEXT_PROTOTYPES') | ||
8783 | + print() | ||
8784 | + print('#include "dlopen.hpp"') | ||
8785 | + print('#include "glproc.hpp"') | ||
8786 | + print('#include "glsize.hpp"') | ||
8787 | + print() | ||
8788 | |||
8789 | module = Module() | ||
8790 | module.mergeModule(glxapi) | ||
8791 | diff --git a/wrappers/trace.py b/wrappers/trace.py | ||
8792 | index 7d1baa10..318f0990 100644 | ||
8793 | --- a/wrappers/trace.py | ||
8794 | +++ b/wrappers/trace.py | ||
8795 | @@ -69,21 +69,21 @@ class ComplexValueSerializer(stdapi.OnceVisitor): | ||
8796 | |||
8797 | def visitStruct(self, struct): | ||
8798 | # Ensure member array has nonzero length to avoid MSVC error C2466 | ||
8799 | - print 'static const char * _struct%s_members[%u] = {' % (struct.tag, max(len(struct.members), 1)) | ||
8800 | + print('static const char * _struct%s_members[%u] = {' % (struct.tag, max(len(struct.members), 1))) | ||
8801 | for type, name, in struct.members: | ||
8802 | if name is None: | ||
8803 | - print ' "",' | ||
8804 | + print(' "",') | ||
8805 | else: | ||
8806 | - print ' "%s",' % (name,) | ||
8807 | - print '};' | ||
8808 | - print 'static const trace::StructSig _struct%s_sig = {' % (struct.tag,) | ||
8809 | + print(' "%s",' % (name,)) | ||
8810 | + print('};') | ||
8811 | + print('static const trace::StructSig _struct%s_sig = {' % (struct.tag,)) | ||
8812 | if struct.name is None: | ||
8813 | structName = '""' | ||
8814 | else: | ||
8815 | structName = '"%s"' % struct.name | ||
8816 | - print ' %u, %s, %u, _struct%s_members' % (struct.id, structName, len(struct.members), struct.tag) | ||
8817 | - print '};' | ||
8818 | |||
8819 | + print(' %u, %s, %u, _struct%s_members' % (struct.id, structName, len(struct.members), struct.tag)) | ||
8820 | + print('};') | ||
8821 | + print() | ||
8822 | |||
8823 | def visitArray(self, array): | ||
8824 | self.visit(array.type) | ||
8825 | @@ -95,26 +95,26 @@ class ComplexValueSerializer(stdapi.OnceVisitor): | ||
8826 | pass | ||
8827 | |||
8828 | def visitEnum(self, enum): | ||
8829 | - print 'static const trace::EnumValue _enum%s_values[] = {' % (enum.tag) | ||
8830 | + print('static const trace::EnumValue _enum%s_values[] = {' % (enum.tag)) | ||
8831 | for value in enum.values: | ||
8832 | - print ' {"%s", %s},' % (value, value) | ||
8833 | - print '};' | ||
8834 | |||
8835 | - print 'static const trace::EnumSig _enum%s_sig = {' % (enum.tag) | ||
8836 | - print ' %u, %u, _enum%s_values' % (enum.id, len(enum.values), enum.tag) | ||
8837 | - print '};' | ||
8838 | |||
8839 | + print(' {"%s", %s},' % (value, value)) | ||
8840 | + print('};') | ||
8841 | + print() | ||
8842 | + print('static const trace::EnumSig _enum%s_sig = {' % (enum.tag)) | ||
8843 | + print(' %u, %u, _enum%s_values' % (enum.id, len(enum.values), enum.tag)) | ||
8844 | + print('};') | ||
8845 | + print() | ||
8846 | |||
8847 | def visitBitmask(self, bitmask): | ||
8848 | - print 'static const trace::BitmaskFlag _bitmask%s_flags[] = {' % (bitmask.tag) | ||
8849 | + print('static const trace::BitmaskFlag _bitmask%s_flags[] = {' % (bitmask.tag)) | ||
8850 | for value in bitmask.values: | ||
8851 | - print ' {"%s", %s},' % (value, value) | ||
8852 | - print '};' | ||
8853 | |||
8854 | - print 'static const trace::BitmaskSig _bitmask%s_sig = {' % (bitmask.tag) | ||
8855 | - print ' %u, %u, _bitmask%s_flags' % (bitmask.id, len(bitmask.values), bitmask.tag) | ||
8856 | - print '};' | ||
8857 | |||
8858 | + print(' {"%s", %s},' % (value, value)) | ||
8859 | + print('};') | ||
8860 | + print() | ||
8861 | + print('static const trace::BitmaskSig _bitmask%s_sig = {' % (bitmask.tag)) | ||
8862 | + print(' %u, %u, _bitmask%s_flags' % (bitmask.id, len(bitmask.values), bitmask.tag)) | ||
8863 | + print('};') | ||
8864 | + print() | ||
8865 | |||
8866 | def visitPointer(self, pointer): | ||
8867 | self.visit(pointer.type) | ||
8868 | @@ -146,16 +146,16 @@ class ComplexValueSerializer(stdapi.OnceVisitor): | ||
8869 | def visitPolymorphic(self, polymorphic): | ||
8870 | if not polymorphic.contextLess: | ||
8871 | return | ||
8872 | - print 'static void _write__%s(int selector, %s const & value) {' % (polymorphic.tag, polymorphic.expr) | ||
8873 | - print ' switch (selector) {' | ||
8874 | + print('static void _write__%s(int selector, %s const & value) {' % (polymorphic.tag, polymorphic.expr)) | ||
8875 | + print(' switch (selector) {') | ||
8876 | for cases, type in polymorphic.iterSwitch(): | ||
8877 | for case in cases: | ||
8878 | - print ' %s:' % case | ||
8879 | + print(' %s:' % case) | ||
8880 | self.serializer.visit(type, '(%s)(value)' % (type,)) | ||
8881 | - print ' break;' | ||
8882 | - print ' }' | ||
8883 | - print '}' | ||
8884 | |||
8885 | + print(' break;') | ||
8886 | + print(' }') | ||
8887 | + print('}') | ||
8888 | + print() | ||
8889 | |||
8890 | |||
8891 | class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
8892 | @@ -167,7 +167,7 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
8893 | ''' | ||
8894 | |||
8895 | def visitLiteral(self, literal, instance): | ||
8896 | - print ' trace::localWriter.write%s(%s);' % (literal.kind, instance) | ||
8897 | + print(' trace::localWriter.write%s(%s);' % (literal.kind, instance)) | ||
8898 | |||
8899 | def visitString(self, string, instance): | ||
8900 | if not string.wide: | ||
8901 | @@ -183,33 +183,33 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
8902 | length = ', %s' % self.expand(string.length) | ||
8903 | else: | ||
8904 | length = '' | ||
8905 | - print ' trace::localWriter.write%s(%s%s);' % (suffix, instance, length) | ||
8906 | + print(' trace::localWriter.write%s(%s%s);' % (suffix, instance, length)) | ||
8907 | |||
8908 | def visitConst(self, const, instance): | ||
8909 | self.visit(const.type, instance) | ||
8910 | |||
8911 | def visitStruct(self, struct, instance): | ||
8912 | - print ' trace::localWriter.beginStruct(&_struct%s_sig);' % (struct.tag,) | ||
8913 | + print(' trace::localWriter.beginStruct(&_struct%s_sig);' % (struct.tag,)) | ||
8914 | for member in struct.members: | ||
8915 | self.visitMember(member, instance) | ||
8916 | - print ' trace::localWriter.endStruct();' | ||
8917 | + print(' trace::localWriter.endStruct();') | ||
8918 | |||
8919 | def visitArray(self, array, instance): | ||
8920 | length = '_c' + array.type.tag | ||
8921 | index = '_i' + array.type.tag | ||
8922 | array_length = self.expand(array.length) | ||
8923 | - print ' if (%s) {' % instance | ||
8924 | - print ' size_t %s = %s > 0 ? %s : 0;' % (length, array_length, array_length) | ||
8925 | - print ' trace::localWriter.beginArray(%s);' % length | ||
8926 | - print ' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index) | ||
8927 | - print ' trace::localWriter.beginElement();' | ||
8928 | + print(' if (%s) {' % instance) | ||
8929 | + print(' size_t %s = %s > 0 ? %s : 0;' % (length, array_length, array_length)) | ||
8930 | + print(' trace::localWriter.beginArray(%s);' % length) | ||
8931 | + print(' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index)) | ||
8932 | + print(' trace::localWriter.beginElement();') | ||
8933 | self.visitElement(index, array.type, '(%s)[%s]' % (instance, index)) | ||
8934 | - print ' trace::localWriter.endElement();' | ||
8935 | - print ' }' | ||
8936 | - print ' trace::localWriter.endArray();' | ||
8937 | - print ' } else {' | ||
8938 | - print ' trace::localWriter.writeNull();' | ||
8939 | - print ' }' | ||
8940 | + print(' trace::localWriter.endElement();') | ||
8941 | + print(' }') | ||
8942 | + print(' trace::localWriter.endArray();') | ||
8943 | + print(' } else {') | ||
8944 | + print(' trace::localWriter.writeNull();') | ||
8945 | + print(' }') | ||
8946 | |||
8947 | def visitAttribArray(self, array, instance): | ||
8948 | # For each element, decide if it is a key or a value (which depends on the previous key). | ||
8949 | @@ -218,90 +218,90 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
8950 | |||
8951 | # determine the array length which must be passed to writeArray() up front | ||
8952 | count = '_c' + array.baseType.tag | ||
8953 | - print ' {' | ||
8954 | - print ' int %s;' % count | ||
8955 | - print ' for (%(c)s = 0; %(array)s && %(array)s[%(c)s] != %(terminator)s; %(c)s += 2) {' \ | ||
8956 | - % {'c': count, 'array': instance, 'terminator': array.terminator} | ||
8957 | + print(' {') | ||
8958 | + print(' int %s;' % count) | ||
8959 | + print(' for (%(c)s = 0; %(array)s && %(array)s[%(c)s] != %(terminator)s; %(c)s += 2) {' \ | ||
8960 | + % {'c': count, 'array': instance, 'terminator': array.terminator}) | ||
8961 | if array.hasKeysWithoutValues: | ||
8962 | - print ' switch (int(%(array)s[%(c)s])) {' % {'array': instance, 'c': count} | ||
8963 | + print(' switch (int(%(array)s[%(c)s])) {' % {'array': instance, 'c': count}) | ||
8964 | for key, valueType in array.valueTypes: | ||
8965 | if valueType is None: | ||
8966 | - print ' case %s:' % key | ||
8967 | - print ' %s--;' % count # the next value is a key again and checked if it's the terminator | ||
8968 | - print ' break;' | ||
8969 | - print ' }' | ||
8970 | - print ' }' | ||
8971 | - print ' %(c)s += %(array)s ? 1 : 0;' % {'c': count, 'array': instance} | ||
8972 | - print ' trace::localWriter.beginArray(%s);' % count | ||
8973 | + print(' case %s:' % key) | ||
8974 | + print(' %s--;' % count) # the next value is a key again and checked if it's the terminator | ||
8975 | + print(' break;') | ||
8976 | + print(' }') | ||
8977 | + print(' }') | ||
8978 | + print(' %(c)s += %(array)s ? 1 : 0;' % {'c': count, 'array': instance}) | ||
8979 | + print(' trace::localWriter.beginArray(%s);' % count) | ||
8980 | |||
8981 | # for each key / key-value pair write the key and the value, if the key requires one | ||
8982 | |||
8983 | index = '_i' + array.baseType.tag | ||
8984 | - print ' for (int %(i)s = 0; %(i)s < %(count)s; %(i)s++) {' % {'i': index, 'count': count} | ||
8985 | - print ' trace::localWriter.beginElement();' | ||
8986 | + print(' for (int %(i)s = 0; %(i)s < %(count)s; %(i)s++) {' % {'i': index, 'count': count}) | ||
8987 | + print(' trace::localWriter.beginElement();') | ||
8988 | self.visit(array.baseType, "%(array)s[%(i)s]" % {'array': instance, 'i': index}) | ||
8989 | - print ' trace::localWriter.endElement();' | ||
8990 | - print ' if (%(i)s + 1 >= %(count)s) {' % {'i': index, 'count': count} | ||
8991 | - print ' break;' | ||
8992 | - print ' }' | ||
8993 | - print ' switch (int(%(array)s[%(i)s++])) {' % {'array': instance, 'i': index} | ||
8994 | + print(' trace::localWriter.endElement();') | ||
8995 | + print(' if (%(i)s + 1 >= %(count)s) {' % {'i': index, 'count': count}) | ||
8996 | + print(' break;') | ||
8997 | + print(' }') | ||
8998 | + print(' switch (int(%(array)s[%(i)s++])) {' % {'array': instance, 'i': index}) | ||
8999 | # write generic value the usual way | ||
9000 | for key, valueType in array.valueTypes: | ||
9001 | if valueType is not None: | ||
9002 | - print ' case %s:' % key | ||
9003 | - print ' trace::localWriter.beginElement();' | ||
9004 | + print(' case %s:' % key) | ||
9005 | + print(' trace::localWriter.beginElement();') | ||
9006 | self.visitElement(index, valueType, '(%(array)s)[%(i)s]' % {'array': instance, 'i': index}) | ||
9007 | - print ' trace::localWriter.endElement();' | ||
9008 | - print ' break;' | ||
9009 | + print(' trace::localWriter.endElement();') | ||
9010 | + print(' break;') | ||
9011 | # known key with no value, just decrease the index so we treat the next value as a key | ||
9012 | if array.hasKeysWithoutValues: | ||
9013 | for key, valueType in array.valueTypes: | ||
9014 | if valueType is None: | ||
9015 | - print ' case %s:' % key | ||
9016 | - print ' %s--;' % index | ||
9017 | - print ' break;' | ||
9018 | + print(' case %s:' % key) | ||
9019 | + print(' %s--;' % index) | ||
9020 | + print(' break;') | ||
9021 | # unknown key, write an int value | ||
9022 | - print ' default:' | ||
9023 | - print ' trace::localWriter.beginElement();' | ||
9024 | - print ' os::log("apitrace: warning: %s: unknown key 0x%04X, interpreting value as int\\n", ' + \ | ||
9025 | - '__FUNCTION__, int(%(array)s[%(i)s - 1]));' % {'array': instance, 'i': index} | ||
9026 | - print ' trace::localWriter.writeSInt(%(array)s[%(i)s]);' % {'array': instance, 'i': index} | ||
9027 | - print ' trace::localWriter.endElement();' | ||
9028 | - print ' break;' | ||
9029 | - print ' }' | ||
9030 | - print ' }' | ||
9031 | - print ' trace::localWriter.endArray();' | ||
9032 | - print ' }' | ||
9033 | + print(' default:') | ||
9034 | + print(' trace::localWriter.beginElement();') | ||
9035 | + print(' os::log("apitrace: warning: %s: unknown key 0x%04X, interpreting value as int\\n", ' + \ | ||
9036 | + '__FUNCTION__, int(%(array)s[%(i)s - 1]));' % {'array': instance, 'i': index}) | ||
9037 | + print(' trace::localWriter.writeSInt(%(array)s[%(i)s]);' % {'array': instance, 'i': index}) | ||
9038 | + print(' trace::localWriter.endElement();') | ||
9039 | + print(' break;') | ||
9040 | + print(' }') | ||
9041 | + print(' }') | ||
9042 | + print(' trace::localWriter.endArray();') | ||
9043 | + print(' }') | ||
9044 | |||
9045 | |||
9046 | def visitBlob(self, blob, instance): | ||
9047 | - print ' trace::localWriter.writeBlob(%s, %s);' % (instance, self.expand(blob.size)) | ||
9048 | + print(' trace::localWriter.writeBlob(%s, %s);' % (instance, self.expand(blob.size))) | ||
9049 | |||
9050 | def visitEnum(self, enum, instance): | ||
9051 | - print ' trace::localWriter.writeEnum(&_enum%s_sig, %s);' % (enum.tag, instance) | ||
9052 | + print(' trace::localWriter.writeEnum(&_enum%s_sig, %s);' % (enum.tag, instance)) | ||
9053 | |||
9054 | def visitBitmask(self, bitmask, instance): | ||
9055 | - print ' trace::localWriter.writeBitmask(&_bitmask%s_sig, %s);' % (bitmask.tag, instance) | ||
9056 | + print(' trace::localWriter.writeBitmask(&_bitmask%s_sig, %s);' % (bitmask.tag, instance)) | ||
9057 | |||
9058 | def visitPointer(self, pointer, instance): | ||
9059 | - print ' if (%s) {' % instance | ||
9060 | - print ' trace::localWriter.beginArray(1);' | ||
9061 | - print ' trace::localWriter.beginElement();' | ||
9062 | + print(' if (%s) {' % instance) | ||
9063 | + print(' trace::localWriter.beginArray(1);') | ||
9064 | + print(' trace::localWriter.beginElement();') | ||
9065 | self.visit(pointer.type, "*" + instance) | ||
9066 | - print ' trace::localWriter.endElement();' | ||
9067 | - print ' trace::localWriter.endArray();' | ||
9068 | - print ' } else {' | ||
9069 | - print ' trace::localWriter.writeNull();' | ||
9070 | - print ' }' | ||
9071 | + print(' trace::localWriter.endElement();') | ||
9072 | + print(' trace::localWriter.endArray();') | ||
9073 | + print(' } else {') | ||
9074 | + print(' trace::localWriter.writeNull();') | ||
9075 | + print(' }') | ||
9076 | |||
9077 | def visitIntPointer(self, pointer, instance): | ||
9078 | - print ' trace::localWriter.writePointer((uintptr_t)%s);' % instance | ||
9079 | + print(' trace::localWriter.writePointer((uintptr_t)%s);' % instance) | ||
9080 | |||
9081 | def visitObjPointer(self, pointer, instance): | ||
9082 | - print ' trace::localWriter.writePointer((uintptr_t)%s);' % instance | ||
9083 | + print(' trace::localWriter.writePointer((uintptr_t)%s);' % instance) | ||
9084 | |||
9085 | def visitLinearPointer(self, pointer, instance): | ||
9086 | - print ' trace::localWriter.writePointer((uintptr_t)%s);' % instance | ||
9087 | + print(' trace::localWriter.writePointer((uintptr_t)%s);' % instance) | ||
9088 | |||
9089 | def visitReference(self, reference, instance): | ||
9090 | self.visit(reference.type, instance) | ||
9091 | @@ -313,31 +313,31 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): | ||
9092 | self.visit(alias.type, instance) | ||
9093 | |||
9094 | def visitOpaque(self, opaque, instance): | ||
9095 | - print ' trace::localWriter.writePointer((uintptr_t)%s);' % instance | ||
9096 | + print(' trace::localWriter.writePointer((uintptr_t)%s);' % instance) | ||
9097 | |||
9098 | def visitInterface(self, interface, instance): | ||
9099 | assert False | ||
9100 | |||
9101 | def visitPolymorphic(self, polymorphic, instance): | ||
9102 | if polymorphic.contextLess: | ||
9103 | - print ' _write__%s(%s, %s);' % (polymorphic.tag, polymorphic.switchExpr, instance) | ||
9104 | + print(' _write__%s(%s, %s);' % (polymorphic.tag, polymorphic.switchExpr, instance)) | ||
9105 | else: | ||
9106 | switchExpr = self.expand(polymorphic.switchExpr) | ||
9107 | - print ' switch (%s) {' % switchExpr | ||
9108 | + print(' switch (%s) {' % switchExpr) | ||
9109 | for cases, type in polymorphic.iterSwitch(): | ||
9110 | for case in cases: | ||
9111 | - print ' %s:' % case | ||
9112 | + print(' %s:' % case) | ||
9113 | caseInstance = instance | ||
9114 | if type.expr is not None: | ||
9115 | caseInstance = 'static_cast<%s>(%s)' % (type, caseInstance) | ||
9116 | self.visit(type, caseInstance) | ||
9117 | - print ' break;' | ||
9118 | + print(' break;') | ||
9119 | if polymorphic.defaultType is None: | ||
9120 | - print r' default:' | ||
9121 | - print r' os::log("apitrace: warning: %%s: unexpected polymorphic case %%i\n", __FUNCTION__, (int)%s);' % (switchExpr,) | ||
9122 | - print r' trace::localWriter.writeNull();' | ||
9123 | - print r' break;' | ||
9124 | - print ' }' | ||
9125 | + print(r' default:') | ||
9126 | + print(r' os::log("apitrace: warning: %%s: unexpected polymorphic case %%i\n", __FUNCTION__, (int)%s);' % (switchExpr,)) | ||
9127 | + print(r' trace::localWriter.writeNull();') | ||
9128 | + print(r' break;') | ||
9129 | + print(' }') | ||
9130 | |||
9131 | |||
9132 | class WrapDecider(stdapi.Traverser): | ||
9133 | @@ -369,16 +369,16 @@ class ValueWrapper(stdapi.Traverser, stdapi.ExpanderMixin): | ||
9134 | |||
9135 | def visitArray(self, array, instance): | ||
9136 | array_length = self.expand(array.length) | ||
9137 | - print " if (%s) {" % instance | ||
9138 | - print " for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array_length | ||
9139 | + print(" if (%s) {" % instance) | ||
9140 | + print(" for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array_length) | ||
9141 | self.visitElement('_i', array.type, instance + "[_i]") | ||
9142 | - print " }" | ||
9143 | - print " }" | ||
9144 | + print(" }") | ||
9145 | + print(" }") | ||
9146 | |||
9147 | def visitPointer(self, pointer, instance): | ||
9148 | - print " if (%s) {" % instance | ||
9149 | + print(" if (%s) {" % instance) | ||
9150 | self.visit(pointer.type, "*" + instance) | ||
9151 | - print " }" | ||
9152 | + print(" }") | ||
9153 | |||
9154 | def visitObjPointer(self, pointer, instance): | ||
9155 | elem_type = pointer.type.mutable() | ||
9156 | @@ -388,13 +388,13 @@ class ValueWrapper(stdapi.Traverser, stdapi.ExpanderMixin): | ||
9157 | self.visitInterfacePointer(elem_type.type, instance) | ||
9158 | else: | ||
9159 | # All interfaces should at least implement IUnknown | ||
9160 | - print " WrapIUnknown::_wrap(__FUNCTION__, (IUnknown **) &%s);" % (instance,) | ||
9161 | + print(" WrapIUnknown::_wrap(__FUNCTION__, (IUnknown **) &%s);" % (instance,)) | ||
9162 | |||
9163 | def visitInterface(self, interface, instance): | ||
9164 | raise NotImplementedError | ||
9165 | |||
9166 | def visitInterfacePointer(self, interface, instance): | ||
9167 | - print " Wrap%s::_wrap(__FUNCTION__, &%s);" % (interface.name, instance) | ||
9168 | + print(" Wrap%s::_wrap(__FUNCTION__, &%s);" % (interface.name, instance)) | ||
9169 | |||
9170 | def visitPolymorphic(self, type, instance): | ||
9171 | # XXX: There might be polymorphic values that need wrapping in the future | ||
9172 | @@ -409,17 +409,17 @@ class ValueUnwrapper(ValueWrapper): | ||
9173 | def visitStruct(self, struct, instance): | ||
9174 | if not self.allocated: | ||
9175 | # Argument is constant. We need to create a non const | ||
9176 | - print ' {' | ||
9177 | - print " %s * _t = static_cast<%s *>(alloca(sizeof *_t));" % (struct, struct) | ||
9178 | - print ' *_t = %s;' % (instance,) | ||
9179 | + print(' {') | ||
9180 | + print(" %s * _t = static_cast<%s *>(alloca(sizeof *_t));" % (struct, struct)) | ||
9181 | + print(' *_t = %s;' % (instance,)) | ||
9182 | assert instance.startswith('*') | ||
9183 | - print ' %s = _t;' % (instance[1:],) | ||
9184 | + print(' %s = _t;' % (instance[1:],)) | ||
9185 | instance = '*_t' | ||
9186 | self.allocated = True | ||
9187 | try: | ||
9188 | return ValueWrapper.visitStruct(self, struct, instance) | ||
9189 | finally: | ||
9190 | - print ' }' | ||
9191 | + print(' }') | ||
9192 | else: | ||
9193 | return ValueWrapper.visitStruct(self, struct, instance) | ||
9194 | |||
9195 | @@ -428,18 +428,18 @@ class ValueUnwrapper(ValueWrapper): | ||
9196 | return ValueWrapper.visitArray(self, array, instance) | ||
9197 | array_length = self.expand(array.length) | ||
9198 | elem_type = array.type.mutable() | ||
9199 | - print " if (%s && %s) {" % (instance, array_length) | ||
9200 | - print " %s * _t = static_cast<%s *>(alloca(%s * sizeof *_t));" % (elem_type, elem_type, array_length) | ||
9201 | - print " for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array_length | ||
9202 | - print " _t[_i] = %s[_i];" % instance | ||
9203 | + print(" if (%s && %s) {" % (instance, array_length)) | ||
9204 | + print(" %s * _t = static_cast<%s *>(alloca(%s * sizeof *_t));" % (elem_type, elem_type, array_length)) | ||
9205 | + print(" for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array_length) | ||
9206 | + print(" _t[_i] = %s[_i];" % instance) | ||
9207 | self.allocated = True | ||
9208 | self.visit(array.type, "_t[_i]") | ||
9209 | - print " }" | ||
9210 | - print " %s = _t;" % instance | ||
9211 | - print " }" | ||
9212 | + print(" }") | ||
9213 | + print(" %s = _t;" % instance) | ||
9214 | + print(" }") | ||
9215 | |||
9216 | def visitInterfacePointer(self, interface, instance): | ||
9217 | - print r' Wrap%s::_unwrap(__FUNCTION__, &%s);' % (interface.name, instance) | ||
9218 | + print(r' Wrap%s::_unwrap(__FUNCTION__, &%s);' % (interface.name, instance)) | ||
9219 | |||
9220 | |||
9221 | def _getInterfaceHierarchy(allIfaces, baseIface, result): | ||
9222 | @@ -479,14 +479,17 @@ class Tracer: | ||
9223 | # Includes | ||
9224 | for module in api.modules: | ||
9225 | for header in module.headers: | ||
9226 | - print header | ||
9227 | |||
9228 | + print(header) | ||
9229 | + print() | ||
9230 | |||
9231 | # Generate the serializer functions | ||
9232 | types = api.getAllTypes() | ||
9233 | visitor = ComplexValueSerializer(self.serializerFactory()) | ||
9234 | - map(visitor.visit, types) | ||
9235 | |||
9236 | + | ||
9237 | + for tp in types: | ||
9238 | + visitor.visit(tp) | ||
9239 | + | ||
9240 | + print() | ||
9241 | |||
9242 | # Interfaces wrapers | ||
9243 | self.traceInterfaces(api) | ||
9244 | @@ -498,22 +501,22 @@ class Tracer: | ||
9245 | self.traceFunctionDecl(function) | ||
9246 | for function in api.getAllFunctions(): | ||
9247 | self.traceFunctionImpl(function) | ||
9248 | |||
9249 | + print() | ||
9250 | |||
9251 | self.footer(api) | ||
9252 | |||
9253 | def header(self, api): | ||
9254 | - print '#ifdef _WIN32' | ||
9255 | - print '# include <malloc.h> // alloca' | ||
9256 | - print '# ifndef alloca' | ||
9257 | - print '# define alloca _alloca' | ||
9258 | - print '# endif' | ||
9259 | - print '#else' | ||
9260 | - print '# include <alloca.h> // alloca' | ||
9261 | - print '#endif' | ||
9262 | |||
9263 | |||
9264 | - print 'static std::map<void *, void *> g_WrappedObjects;' | ||
9265 | + print('#ifdef _WIN32') | ||
9266 | + print('# include <malloc.h> // alloca') | ||
9267 | + print('# ifndef alloca') | ||
9268 | + print('# define alloca _alloca') | ||
9269 | + print('# endif') | ||
9270 | + print('#else') | ||
9271 | + print('# include <alloca.h> // alloca') | ||
9272 | + print('#endif') | ||
9273 | + print() | ||
9274 | + print() | ||
9275 | + print('static std::map<void *, void *> g_WrappedObjects;') | ||
9276 | |||
9277 | def footer(self, api): | ||
9278 | pass | ||
9279 | @@ -523,11 +526,11 @@ class Tracer: | ||
9280 | |||
9281 | if not function.internal: | ||
9282 | if function.args: | ||
9283 | - print 'static const char * _%s_args[%u] = {%s};' % (function.name, len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args])) | ||
9284 | + print('static const char * _%s_args[%u] = {%s};' % (function.name, len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args]))) | ||
9285 | else: | ||
9286 | - print 'static const char ** _%s_args = NULL;' % (function.name,) | ||
9287 | - print 'static const trace::FunctionSig _%s_sig = {%u, "%s", %u, _%s_args};' % (function.name, self.getFunctionSigId(), function.name, len(function.args), function.name) | ||
9288 | |||
9289 | + print('static const char ** _%s_args = NULL;' % (function.name,)) | ||
9290 | + print('static const trace::FunctionSig _%s_sig = {%u, "%s", %u, _%s_args};' % (function.name, self.getFunctionSigId(), function.sigName(), len(function.args), function.name)) | ||
9291 | + print() | ||
9292 | |||
9293 | def getFunctionSigId(self): | ||
9294 | id = Tracer.__id | ||
9295 | @@ -539,12 +542,12 @@ class Tracer: | ||
9296 | |||
9297 | def traceFunctionImpl(self, function): | ||
9298 | if self.isFunctionPublic(function): | ||
9299 | - print 'extern "C" PUBLIC' | ||
9300 | + print('extern "C" PUBLIC') | ||
9301 | else: | ||
9302 | - print 'extern "C" PRIVATE' | ||
9303 | - print function.prototype() + ' {' | ||
9304 | + print('extern "C" PRIVATE') | ||
9305 | + print(function.prototype() + ' {') | ||
9306 | if function.type is not stdapi.Void: | ||
9307 | - print ' %s _result;' % function.type | ||
9308 | + print(' %s _result;' % function.type) | ||
9309 | |||
9310 | for arg in function.args: | ||
9311 | if not arg.output: | ||
9312 | @@ -555,43 +558,43 @@ class Tracer: | ||
9313 | # XXX: wrapping should go here, but before we can do that we'll need to protect g_WrappedObjects with its own mutex | ||
9314 | |||
9315 | if function.type is not stdapi.Void: | ||
9316 | - print ' return _result;' | ||
9317 | + print(' return _result;') | ||
9318 | |||
9319 | - print '}' | ||
9320 | |||
9321 | + print('}') | ||
9322 | + print() | ||
9323 | |||
9324 | def traceFunctionImplBody(self, function): | ||
9325 | multi_draw_function_regex = re.compile(r'^glMultiDraw(Arrays|Elements)([A-Z][a-zA-Z]*)?$' ) | ||
9326 | if not function.internal: | ||
9327 | - print ' unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,) | ||
9328 | + print(' unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)) | ||
9329 | for arg in function.args: | ||
9330 | if not arg.output: | ||
9331 | self.serializeArg(function, arg) | ||
9332 | - print ' trace::localWriter.endEnter();' | ||
9333 | + print(' trace::localWriter.endEnter();') | ||
9334 | |||
9335 | if self.multi_draw_function_regex.match(function.name): | ||
9336 | - print ' trace::localWriter.beginIgnore();' | ||
9337 | - print ' trace::localWriter.endIgnore();' | ||
9338 | + print(' trace::localWriter.beginIgnore();') | ||
9339 | + print(' trace::localWriter.endEnter();') | ||
9340 | |||
9341 | self.invokeFunction(function) | ||
9342 | |||
9343 | if self.multi_draw_function_regex.match(function.name): | ||
9344 | - print ' trace::localWriter.beginTrace();' | ||
9345 | - print ' trace::localWriter.endTrace();' | ||
9346 | + print(' trace::localWriter.beginTrace();') | ||
9347 | + print(' trace::localWriter.endTrace();') | ||
9348 | |||
9349 | if not function.internal: | ||
9350 | - print ' trace::localWriter.beginLeave(_call);' | ||
9351 | - print ' if (%s) {' % self.wasFunctionSuccessful(function) | ||
9352 | + print(' trace::localWriter.beginLeave(_call);') | ||
9353 | + print(' if (%s) {' % self.wasFunctionSuccessful(function)) | ||
9354 | for arg in function.args: | ||
9355 | if arg.output: | ||
9356 | self.serializeArg(function, arg) | ||
9357 | self.wrapArg(function, arg) | ||
9358 | - print ' }' | ||
9359 | + print(' }') | ||
9360 | if function.type is not stdapi.Void: | ||
9361 | self.serializeRet(function, "_result") | ||
9362 | if function.type is not stdapi.Void: | ||
9363 | self.wrapRet(function, "_result") | ||
9364 | - print ' trace::localWriter.endLeave();' | ||
9365 | + print(' trace::localWriter.endLeave();') | ||
9366 | |||
9367 | def invokeFunction(self, function): | ||
9368 | self.doInvokeFunction(function) | ||
9369 | @@ -603,7 +606,7 @@ class Tracer: | ||
9370 | else: | ||
9371 | result = '_result = ' | ||
9372 | dispatch = prefix + function.name + suffix | ||
9373 | - print ' %s%s(%s);' % (result, dispatch, ', '.join([str(arg.name) for arg in function.args])) | ||
9374 | + print(' %s%s(%s);' % (result, dispatch, ', '.join([str(arg.name) for arg in function.args]))) | ||
9375 | |||
9376 | def wasFunctionSuccessful(self, function): | ||
9377 | if function.type is stdapi.Void: | ||
9378 | @@ -613,9 +616,9 @@ class Tracer: | ||
9379 | return 'true' | ||
9380 | |||
9381 | def serializeArg(self, function, arg): | ||
9382 | - print ' trace::localWriter.beginArg(%u);' % (arg.index,) | ||
9383 | + print(' trace::localWriter.beginArg(%u);' % (arg.index,)) | ||
9384 | self.serializeArgValue(function, arg) | ||
9385 | - print ' trace::localWriter.endArg();' | ||
9386 | + print(' trace::localWriter.endArg();') | ||
9387 | |||
9388 | def serializeArgValue(self, function, arg): | ||
9389 | self.serializeValue(arg.type, arg.name) | ||
9390 | @@ -641,9 +644,9 @@ class Tracer: | ||
9391 | self.unwrapValue(arg.type, arg.name) | ||
9392 | |||
9393 | def serializeRet(self, function, instance): | ||
9394 | - print ' trace::localWriter.beginReturn();' | ||
9395 | + print(' trace::localWriter.beginReturn();') | ||
9396 | self.serializeValue(function.type, instance) | ||
9397 | - print ' trace::localWriter.endReturn();' | ||
9398 | + print(' trace::localWriter.endReturn();') | ||
9399 | |||
9400 | def serializeValue(self, type, instance): | ||
9401 | serializer = self.serializerFactory() | ||
9402 | @@ -672,70 +675,72 @@ class Tracer: | ||
9403 | if not interfaces: | ||
9404 | return | ||
9405 | |||
9406 | - print r'#include "guids.hpp"' | ||
9407 | |||
9408 | + print(r'#include "guids.hpp"') | ||
9409 | + print() | ||
9410 | |||
9411 | map(self.declareWrapperInterface, interfaces) | ||
9412 | |||
9413 | # Helper functions to wrap/unwrap interface pointers | ||
9414 | - print r'static inline bool' | ||
9415 | - print r'hasChildInterface(REFIID riid, IUnknown *pUnknown) {' | ||
9416 | - print r' IUnknown *pObj = NULL;' | ||
9417 | - print r' HRESULT hr = pUnknown->QueryInterface(riid, (VOID **)&pObj);' | ||
9418 | - print r' if (FAILED(hr)) {' | ||
9419 | - print r' return false;' | ||
9420 | - print r' }' | ||
9421 | - print r' assert(pObj);' | ||
9422 | - print r' pObj->Release();' | ||
9423 | - print r' return pUnknown == pObj;' | ||
9424 | - print r'}' | ||
9425 | |||
9426 | - print r'static inline const void *' | ||
9427 | - print r'getVtbl(const void *pvObj) {' | ||
9428 | - print r' return pvObj ? *(const void **)pvObj : NULL;' | ||
9429 | - print r'}' | ||
9430 | |||
9431 | + print(r'static inline bool') | ||
9432 | + print(r'hasChildInterface(REFIID riid, IUnknown *pUnknown) {') | ||
9433 | + print(r' IUnknown *pObj = NULL;') | ||
9434 | + print(r' HRESULT hr = pUnknown->QueryInterface(riid, (VOID **)&pObj);') | ||
9435 | + print(r' if (FAILED(hr)) {') | ||
9436 | + print(r' return false;') | ||
9437 | + print(r' }') | ||
9438 | + print(r' assert(pObj);') | ||
9439 | + print(r' pObj->Release();') | ||
9440 | + print(r' return pUnknown == pObj;') | ||
9441 | + print(r'}') | ||
9442 | + print() | ||
9443 | + print(r'static inline const void *') | ||
9444 | + print(r'getVtbl(const void *pvObj) {') | ||
9445 | + print(r' return pvObj ? *(const void **)pvObj : NULL;') | ||
9446 | + print(r'}') | ||
9447 | + print() | ||
9448 | |||
9449 | self.implementIidWrapper(api) | ||
9450 | |||
9451 | - map(self.implementWrapperInterface, interfaces) | ||
9452 | |||
9453 | + for iface in interfaces: | ||
9454 | + self.implementWrapperInterface(iface) | ||
9455 | + | ||
9456 | + print() | ||
9457 | |||
9458 | def declareWrapperInterface(self, interface): | ||
9459 | wrapperInterfaceName = getWrapperInterfaceName(interface) | ||
9460 | - print "class %s : public %s " % (wrapperInterfaceName, interface.name) | ||
9461 | - print "{" | ||
9462 | - print "private:" | ||
9463 | - print " %s(%s * pInstance);" % (wrapperInterfaceName, interface.name) | ||
9464 | - print " virtual ~%s();" % wrapperInterfaceName | ||
9465 | - print "public:" | ||
9466 | - print " static %s* _create(const char *entryName, %s * pInstance);" % (wrapperInterfaceName, interface.name) | ||
9467 | - print " static void _wrap(const char *entryName, %s ** ppInstance);" % (interface.name,) | ||
9468 | - print " static void _unwrap(const char *entryName, %s ** pInstance);" % (interface.name,) | ||
9469 | |||
9470 | + print("class %s : public %s " % (wrapperInterfaceName, interface.name)) | ||
9471 | + print("{") | ||
9472 | + print("private:") | ||
9473 | + print(" %s(%s * pInstance);" % (wrapperInterfaceName, interface.name)) | ||
9474 | + print(" virtual ~%s();" % wrapperInterfaceName) | ||
9475 | + print("public:") | ||
9476 | + print(" static %s* _create(const char *entryName, %s * pInstance);" % (wrapperInterfaceName, interface.name)) | ||
9477 | + print(" static void _wrap(const char *entryName, %s ** ppInstance);" % (interface.name,)) | ||
9478 | + print(" static void _unwrap(const char *entryName, %s ** pInstance);" % (interface.name,)) | ||
9479 | + print() | ||
9480 | |||
9481 | methods = list(interface.iterMethods()) | ||
9482 | for method in methods: | ||
9483 | - print " " + method.prototype() + ";" | ||
9484 | + print(" " + method.prototype() + ";") | ||
9485 | |||
9486 | |||
9487 | for type, name, value in self.enumWrapperInterfaceVariables(interface): | ||
9488 | - print ' %s %s;' % (type, name) | ||
9489 | |||
9490 | - | ||
9491 | - print r'private:' | ||
9492 | - print r' void _dummy(unsigned i) const {' | ||
9493 | - print r' os::log("error: %%s: unexpected virtual method %%i of instance pWrapper=%%p pvObj=%%p pVtbl=%%p\n", "%s", i, this, m_pInstance, m_pVtbl);' % interface.name | ||
9494 | - print r' trace::localWriter.flush();' | ||
9495 | - print r' os::abort();' | ||
9496 | - print r' }' | ||
9497 | |||
9498 | + print(' %s %s;' % (type, name)) | ||
9499 | + print() | ||
9500 | + | ||
9501 | + print(r'private:') | ||
9502 | + print(r' void _dummy(unsigned i) const {') | ||
9503 | + print(r' os::log("error: %%s: unexpected virtual method %%i of instance pWrapper=%%p pvObj=%%p pVtbl=%%p\n", "%s", i, this, m_pInstance, m_pVtbl);' % interface.name) | ||
9504 | + print(r' trace::localWriter.flush();') | ||
9505 | + print(r' os::abort();') | ||
9506 | + print(r' }') | ||
9507 | + print() | ||
9508 | for i in range(len(methods), 64): | ||
9509 | - print r' virtual void _dummy%i(void) const { _dummy(%i); }' % (i, i) | ||
9510 | |||
9511 | + print(r' virtual void _dummy%i(void) const { _dummy(%i); }' % (i, i)) | ||
9512 | + print() | ||
9513 | |||
9514 | - print "};" | ||
9515 | |||
9516 | + print("};") | ||
9517 | + print() | ||
9518 | |||
9519 | def enumWrapperInterfaceVariables(self, interface): | ||
9520 | return [ | ||
9521 | @@ -751,101 +756,101 @@ class Tracer: | ||
9522 | wrapperInterfaceName = getWrapperInterfaceName(iface) | ||
9523 | |||
9524 | # Private constructor | ||
9525 | - print '%s::%s(%s * pInstance) {' % (wrapperInterfaceName, wrapperInterfaceName, iface.name) | ||
9526 | + print('%s::%s(%s * pInstance) {' % (wrapperInterfaceName, wrapperInterfaceName, iface.name)) | ||
9527 | for type, name, value in self.enumWrapperInterfaceVariables(iface): | ||
9528 | if value is not None: | ||
9529 | - print ' %s = %s;' % (name, value) | ||
9530 | - print '}' | ||
9531 | |||
9532 | + print(' %s = %s;' % (name, value)) | ||
9533 | + print('}') | ||
9534 | + print() | ||
9535 | |||
9536 | # Public constructor | ||
9537 | - print '%s *%s::_create(const char *entryName, %s * pInstance) {' % (wrapperInterfaceName, wrapperInterfaceName, iface.name) | ||
9538 | - print r' Wrap%s *pWrapper = new Wrap%s(pInstance);' % (iface.name, iface.name) | ||
9539 | + print('%s *%s::_create(const char *entryName, %s * pInstance) {' % (wrapperInterfaceName, wrapperInterfaceName, iface.name)) | ||
9540 | + print(r' Wrap%s *pWrapper = new Wrap%s(pInstance);' % (iface.name, iface.name)) | ||
9541 | if debug: | ||
9542 | - print r' os::log("%%s: created %s pvObj=%%p pWrapper=%%p pVtbl=%%p\n", entryName, pInstance, pWrapper, pWrapper->m_pVtbl);' % iface.name | ||
9543 | - print r' g_WrappedObjects[pInstance] = pWrapper;' | ||
9544 | - print r' return pWrapper;' | ||
9545 | - print '}' | ||
9546 | |||
9547 | + print(r' os::log("%%s: created %s pvObj=%%p pWrapper=%%p pVtbl=%%p\n", entryName, pInstance, pWrapper, pWrapper->m_pVtbl);' % iface.name) | ||
9548 | + print(r' g_WrappedObjects[pInstance] = pWrapper;') | ||
9549 | + print(r' return pWrapper;') | ||
9550 | + print('}') | ||
9551 | + print() | ||
9552 | |||
9553 | # Destructor | ||
9554 | - print '%s::~%s() {' % (wrapperInterfaceName, wrapperInterfaceName) | ||
9555 | + print('%s::~%s() {' % (wrapperInterfaceName, wrapperInterfaceName)) | ||
9556 | if debug: | ||
9557 | - print r' os::log("%s::Release: deleted pvObj=%%p pWrapper=%%p pVtbl=%%p\n", m_pInstance, this, m_pVtbl);' % iface.name | ||
9558 | - print r' g_WrappedObjects.erase(m_pInstance);' | ||
9559 | - print '}' | ||
9560 | |||
9561 | + print(r' os::log("%s::Release: deleted pvObj=%%p pWrapper=%%p pVtbl=%%p\n", m_pInstance, this, m_pVtbl);' % iface.name) | ||
9562 | + print(r' g_WrappedObjects.erase(m_pInstance);') | ||
9563 | + print('}') | ||
9564 | + print() | ||
9565 | |||
9566 | baseMethods = list(iface.iterBaseMethods()) | ||
9567 | for base, method in baseMethods: | ||
9568 | self.base = base | ||
9569 | self.implementWrapperInterfaceMethod(iface, base, method) | ||
9570 | |||
9571 | |||
9572 | + print() | ||
9573 | |||
9574 | # Wrap pointer | ||
9575 | ifaces = self.api.getAllInterfaces() | ||
9576 | - print r'void' | ||
9577 | - print r'%s::_wrap(const char *entryName, %s **ppObj) {' % (wrapperInterfaceName, iface.name) | ||
9578 | - print r' if (!ppObj) {' | ||
9579 | - print r' return;' | ||
9580 | - print r' }' | ||
9581 | - print r' %s *pObj = *ppObj;' % (iface.name,) | ||
9582 | - print r' if (!pObj) {' | ||
9583 | - print r' return;' | ||
9584 | - print r' }' | ||
9585 | - print r' assert(hasChildInterface(IID_%s, pObj));' % iface.name | ||
9586 | - print r' std::map<void *, void *>::const_iterator it = g_WrappedObjects.find(pObj);' | ||
9587 | - print r' if (it != g_WrappedObjects.end()) {' | ||
9588 | - print r' Wrap%s *pWrapper = (Wrap%s *)it->second;' % (iface.name, iface.name) | ||
9589 | - print r' assert(pWrapper);' | ||
9590 | - print r' assert(pWrapper->m_dwMagic == 0xd8365d6c);' | ||
9591 | - print r' assert(pWrapper->m_pInstance == pObj);' | ||
9592 | - print r' if (pWrapper->m_pVtbl == getVtbl(pObj) &&' | ||
9593 | - print r' pWrapper->m_NumMethods >= %s) {' % len(baseMethods) | ||
9594 | + print(r'void') | ||
9595 | + print(r'%s::_wrap(const char *entryName, %s **ppObj) {' % (wrapperInterfaceName, iface.name)) | ||
9596 | + print(r' if (!ppObj) {') | ||
9597 | + print(r' return;') | ||
9598 | + print(r' }') | ||
9599 | + print(r' %s *pObj = *ppObj;' % (iface.name,)) | ||
9600 | + print(r' if (!pObj) {') | ||
9601 | + print(r' return;') | ||
9602 | + print(r' }') | ||
9603 | + print(r' assert(hasChildInterface(IID_%s, pObj));' % iface.name) | ||
9604 | + print(r' std::map<void *, void *>::const_iterator it = g_WrappedObjects.find(pObj);') | ||
9605 | + print(r' if (it != g_WrappedObjects.end()) {') | ||
9606 | + print(r' Wrap%s *pWrapper = (Wrap%s *)it->second;' % (iface.name, iface.name)) | ||
9607 | + print(r' assert(pWrapper);') | ||
9608 | + print(r' assert(pWrapper->m_dwMagic == 0xd8365d6c);') | ||
9609 | + print(r' assert(pWrapper->m_pInstance == pObj);') | ||
9610 | + print(r' if (pWrapper->m_pVtbl == getVtbl(pObj) &&') | ||
9611 | + print(r' pWrapper->m_NumMethods >= %s) {' % len(baseMethods)) | ||
9612 | if debug: | ||
9613 | - print r' os::log("%s: fetched pvObj=%p pWrapper=%p pVtbl=%p\n", entryName, pObj, pWrapper, pWrapper->m_pVtbl);' | ||
9614 | - print r' *ppObj = pWrapper;' | ||
9615 | - print r' return;' | ||
9616 | - print r' }' | ||
9617 | - print r' }' | ||
9618 | + print(r' os::log("%s: fetched pvObj=%p pWrapper=%p pVtbl=%p\n", entryName, pObj, pWrapper, pWrapper->m_pVtbl);') | ||
9619 | + print(r' *ppObj = pWrapper;') | ||
9620 | + print(r' return;') | ||
9621 | + print(r' }') | ||
9622 | + print(r' }') | ||
9623 | for childIface in getInterfaceHierarchy(ifaces, iface): | ||
9624 | - print r' if (hasChildInterface(IID_%s, pObj)) {' % (childIface.name,) | ||
9625 | - print r' *ppObj = Wrap%s::_create(entryName, static_cast<%s *>(pObj));' % (childIface.name, childIface.name) | ||
9626 | - print r' return;' | ||
9627 | - print r' }' | ||
9628 | - print r' *ppObj = Wrap%s::_create(entryName, pObj);' % iface.name | ||
9629 | - print r'}' | ||
9630 | |||
9631 | + print(r' if (hasChildInterface(IID_%s, pObj)) {' % (childIface.name,)) | ||
9632 | + print(r' *ppObj = Wrap%s::_create(entryName, static_cast<%s *>(pObj));' % (childIface.name, childIface.name)) | ||
9633 | + print(r' return;') | ||
9634 | + print(r' }') | ||
9635 | + print(r' *ppObj = Wrap%s::_create(entryName, pObj);' % iface.name) | ||
9636 | + print(r'}') | ||
9637 | + print() | ||
9638 | |||
9639 | # Unwrap pointer | ||
9640 | - print r'void' | ||
9641 | - print r'%s::_unwrap(const char *entryName, %s **ppObj) {' % (wrapperInterfaceName, iface.name) | ||
9642 | - print r' if (!ppObj || !*ppObj) {' | ||
9643 | - print r' return;' | ||
9644 | - print r' }' | ||
9645 | - print r' const %s *pWrapper = static_cast<const %s*>(*ppObj);' % (wrapperInterfaceName, getWrapperInterfaceName(iface)) | ||
9646 | - print r' if (pWrapper && pWrapper->m_dwMagic == 0xd8365d6c) {' | ||
9647 | - print r' *ppObj = pWrapper->m_pInstance;' | ||
9648 | - print r' } else {' | ||
9649 | - print r' os::log("apitrace: warning: %%s: unexpected %%s pointer %%p\n", entryName, "%s", *ppObj);' % iface.name | ||
9650 | - print r' trace::localWriter.flush();' | ||
9651 | - print r' }' | ||
9652 | - print r'}' | ||
9653 | |||
9654 | + print(r'void') | ||
9655 | + print(r'%s::_unwrap(const char *entryName, %s **ppObj) {' % (wrapperInterfaceName, iface.name)) | ||
9656 | + print(r' if (!ppObj || !*ppObj) {') | ||
9657 | + print(r' return;') | ||
9658 | + print(r' }') | ||
9659 | + print(r' const %s *pWrapper = static_cast<const %s*>(*ppObj);' % (wrapperInterfaceName, getWrapperInterfaceName(iface))) | ||
9660 | + print(r' if (pWrapper && pWrapper->m_dwMagic == 0xd8365d6c) {') | ||
9661 | + print(r' *ppObj = pWrapper->m_pInstance;') | ||
9662 | + print(r' } else {') | ||
9663 | + print(r' os::log("apitrace: warning: %%s: unexpected %%s pointer %%p\n", entryName, "%s", *ppObj);' % iface.name) | ||
9664 | + print(r' trace::localWriter.flush();') | ||
9665 | + print(r' }') | ||
9666 | + print(r'}') | ||
9667 | + print() | ||
9668 | |||
9669 | def implementWrapperInterfaceMethod(self, interface, base, method): | ||
9670 | wrapperInterfaceName = getWrapperInterfaceName(interface) | ||
9671 | |||
9672 | - print method.prototype(wrapperInterfaceName + '::' + method.name) + ' {' | ||
9673 | + print(method.prototype(wrapperInterfaceName + '::' + method.name) + ' {') | ||
9674 | |||
9675 | if False: | ||
9676 | - print r' os::log("%%s(%%p -> %%p)\n", "%s", this, m_pInstance);' % (wrapperInterfaceName + '::' + method.name) | ||
9677 | + print(r' os::log("%%s(%%p -> %%p)\n", "%s", this, m_pInstance);' % (wrapperInterfaceName + '::' + method.name)) | ||
9678 | |||
9679 | if method.type is not stdapi.Void: | ||
9680 | - print ' %s _result;' % method.type | ||
9681 | + print(' %s _result;' % method.type) | ||
9682 | |||
9683 | - print ' %s *_this = static_cast<%s *>(m_pInstance);' % (base, base) | ||
9684 | + print(' %s *_this = static_cast<%s *>(m_pInstance);' % (base, base)) | ||
9685 | for arg in method.args: | ||
9686 | if not arg.output: | ||
9687 | self.unwrapArg(method, arg) | ||
9688 | @@ -855,36 +860,36 @@ class Tracer: | ||
9689 | # XXX: wrapping should go here, but before we can do that we'll need to protect g_WrappedObjects with its own mutex | ||
9690 | |||
9691 | if method.type is not stdapi.Void: | ||
9692 | - print ' return _result;' | ||
9693 | + print(' return _result;') | ||
9694 | |||
9695 | - print '}' | ||
9696 | |||
9697 | + print('}') | ||
9698 | + print() | ||
9699 | |||
9700 | def implementWrapperInterfaceMethodBody(self, interface, base, method): | ||
9701 | assert not method.internal | ||
9702 | |||
9703 | - print ' static const char * _args[%u] = {%s};' % (len(method.args) + 1, ', '.join(['"this"'] + ['"%s"' % arg.name for arg in method.args])) | ||
9704 | - print ' static const trace::FunctionSig _sig = {%u, "%s", %u, _args};' % (self.getFunctionSigId(), interface.name + '::' + method.name, len(method.args) + 1) | ||
9705 | + print(' static const char * _args[%u] = {%s};' % (len(method.args) + 1, ', '.join(['"this"'] + ['"%s"' % arg.name for arg in method.args]))) | ||
9706 | + print(' static const trace::FunctionSig _sig = {%u, "%s", %u, _args};' % (self.getFunctionSigId(), interface.name + '::' + method.name, len(method.args) + 1)) | ||
9707 | |||
9708 | - print ' unsigned _call = trace::localWriter.beginEnter(&_sig);' | ||
9709 | - print ' trace::localWriter.beginArg(0);' | ||
9710 | - print ' trace::localWriter.writePointer((uintptr_t)m_pInstance);' | ||
9711 | - print ' trace::localWriter.endArg();' | ||
9712 | + print(' unsigned _call = trace::localWriter.beginEnter(&_sig);') | ||
9713 | + print(' trace::localWriter.beginArg(0);') | ||
9714 | + print(' trace::localWriter.writePointer((uintptr_t)m_pInstance);') | ||
9715 | + print(' trace::localWriter.endArg();') | ||
9716 | for arg in method.args: | ||
9717 | if not arg.output: | ||
9718 | self.serializeArg(method, arg) | ||
9719 | - print ' trace::localWriter.endEnter();' | ||
9720 | + print(' trace::localWriter.endEnter();') | ||
9721 | |||
9722 | self.invokeMethod(interface, base, method) | ||
9723 | |||
9724 | - print ' trace::localWriter.beginLeave(_call);' | ||
9725 | + print(' trace::localWriter.beginLeave(_call);') | ||
9726 | |||
9727 | - print ' if (%s) {' % self.wasFunctionSuccessful(method) | ||
9728 | + print(' if (%s) {' % self.wasFunctionSuccessful(method)) | ||
9729 | for arg in method.args: | ||
9730 | if arg.output: | ||
9731 | self.serializeArg(method, arg) | ||
9732 | self.wrapArg(method, arg) | ||
9733 | - print ' }' | ||
9734 | + print(' }') | ||
9735 | |||
9736 | if method.type is not stdapi.Void: | ||
9737 | self.serializeRet(method, '_result') | ||
9738 | @@ -893,51 +898,51 @@ class Tracer: | ||
9739 | |||
9740 | if method.name == 'Release': | ||
9741 | assert method.type is not stdapi.Void | ||
9742 | - print r' if (!_result) {' | ||
9743 | - print r' delete this;' | ||
9744 | - print r' }' | ||
9745 | + print(r' if (!_result) {') | ||
9746 | + print(r' delete this;') | ||
9747 | + print(r' }') | ||
9748 | |||
9749 | - print ' trace::localWriter.endLeave();' | ||
9750 | + print(' trace::localWriter.endLeave();') | ||
9751 | |||
9752 | def implementIidWrapper(self, api): | ||
9753 | ifaces = api.getAllInterfaces() | ||
9754 | |||
9755 | - print r'static void' | ||
9756 | - print r'warnIID(const char *entryName, REFIID riid, void *pvObj, const char *reason) {' | ||
9757 | - print r' os::log("apitrace: warning: %s: %s IID %s\n",' | ||
9758 | - print r' entryName, reason,' | ||
9759 | - print r' getGuidName(riid));' | ||
9760 | - print r' void * pVtbl = *(void **)pvObj;' | ||
9761 | - print r' HMODULE hModule = 0;' | ||
9762 | - print r' BOOL bRet = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |' | ||
9763 | - print r' GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,' | ||
9764 | - print r' (LPCTSTR)pVtbl,' | ||
9765 | - print r' &hModule);' | ||
9766 | - print r' assert(bRet);' | ||
9767 | - print r' if (bRet) {' | ||
9768 | - print r' char szModule[MAX_PATH];' | ||
9769 | - print r' DWORD dwRet = GetModuleFileNameA(hModule, szModule, sizeof szModule);' | ||
9770 | - print r' assert(dwRet);' | ||
9771 | - print r' if (dwRet) {' | ||
9772 | - print r' DWORD dwOffset = (UINT_PTR)pVtbl - (UINT_PTR)hModule;' | ||
9773 | - print r' os::log("apitrace: warning: pVtbl = %p (%s!+0x%0lx)\n", pVtbl, szModule, dwOffset);' | ||
9774 | - print r' }' | ||
9775 | - print r' }' | ||
9776 | - print r'}' | ||
9777 | |||
9778 | - print r'static void' | ||
9779 | - print r'wrapIID(const char *entryName, REFIID riid, void * * ppvObj) {' | ||
9780 | - print r' if (!ppvObj || !*ppvObj) {' | ||
9781 | - print r' return;' | ||
9782 | - print r' }' | ||
9783 | + print(r'static void') | ||
9784 | + print(r'warnIID(const char *entryName, REFIID riid, void *pvObj, const char *reason) {') | ||
9785 | + print(r' os::log("apitrace: warning: %s: %s IID %s\n",') | ||
9786 | + print(r' entryName, reason,') | ||
9787 | + print(r' getGuidName(riid));') | ||
9788 | + print(r' void * pVtbl = *(void **)pvObj;') | ||
9789 | + print(r' HMODULE hModule = 0;') | ||
9790 | + print(r' BOOL bRet = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |') | ||
9791 | + print(r' GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,') | ||
9792 | + print(r' (LPCTSTR)pVtbl,') | ||
9793 | + print(r' &hModule);') | ||
9794 | + print(r' assert(bRet);') | ||
9795 | + print(r' if (bRet) {') | ||
9796 | + print(r' char szModule[MAX_PATH];') | ||
9797 | + print(r' DWORD dwRet = GetModuleFileNameA(hModule, szModule, sizeof szModule);') | ||
9798 | + print(r' assert(dwRet);') | ||
9799 | + print(r' if (dwRet) {') | ||
9800 | + print(r' DWORD dwOffset = (UINT_PTR)pVtbl - (UINT_PTR)hModule;') | ||
9801 | + print(r' os::log("apitrace: warning: pVtbl = %p (%s!+0x%0lx)\n", pVtbl, szModule, dwOffset);') | ||
9802 | + print(r' }') | ||
9803 | + print(r' }') | ||
9804 | + print(r'}') | ||
9805 | + print() | ||
9806 | + print(r'static void') | ||
9807 | + print(r'wrapIID(const char *entryName, REFIID riid, void * * ppvObj) {') | ||
9808 | + print(r' if (!ppvObj || !*ppvObj) {') | ||
9809 | + print(r' return;') | ||
9810 | + print(r' }') | ||
9811 | for iface in ifaces: | ||
9812 | - print r' if (riid == IID_%s) {' % (iface.name,) | ||
9813 | - print r' Wrap%s::_wrap(entryName, (%s **) ppvObj);' % (iface.name, iface.name) | ||
9814 | - print r' return;' | ||
9815 | - print r' }' | ||
9816 | - print r' warnIID(entryName, riid, *ppvObj, "unsupported");' | ||
9817 | - print r'}' | ||
9818 | |||
9819 | + print(r' if (riid == IID_%s) {' % (iface.name,)) | ||
9820 | + print(r' Wrap%s::_wrap(entryName, (%s **) ppvObj);' % (iface.name, iface.name)) | ||
9821 | + print(r' return;') | ||
9822 | + print(r' }') | ||
9823 | + print(r' warnIID(entryName, riid, *ppvObj, "unsupported");') | ||
9824 | + print(r'}') | ||
9825 | + print() | ||
9826 | |||
9827 | def wrapIid(self, function, riid, out): | ||
9828 | # Cast output arg to `void **` if necessary | ||
9829 | @@ -947,42 +952,42 @@ class Tracer: | ||
9830 | assert isinstance(obj_type, stdapi.Interface) | ||
9831 | out_name = 'reinterpret_cast<void * *>(%s)' % out_name | ||
9832 | |||
9833 | - print r' if (%s && *%s) {' % (out.name, out.name) | ||
9834 | + print(r' if (%s && *%s) {' % (out.name, out.name)) | ||
9835 | functionName = function.name | ||
9836 | else_ = '' | ||
9837 | if self.interface is not None: | ||
9838 | functionName = self.interface.name + '::' + functionName | ||
9839 | - print r' if (*%s == m_pInstance &&' % (out_name,) | ||
9840 | - print r' (%s)) {' % ' || '.join('%s == IID_%s' % (riid.name, iface.name) for iface in self.interface.iterBases()) | ||
9841 | - print r' *%s = this;' % (out_name,) | ||
9842 | - print r' }' | ||
9843 | + print(r' if (*%s == m_pInstance &&' % (out_name,)) | ||
9844 | + print(r' (%s)) {' % ' || '.join('%s == IID_%s' % (riid.name, iface.name) for iface in self.interface.iterBases())) | ||
9845 | + print(r' *%s = this;' % (out_name,)) | ||
9846 | + print(r' }') | ||
9847 | else_ = 'else ' | ||
9848 | - print r' %s{' % else_ | ||
9849 | - print r' wrapIID("%s", %s, %s);' % (functionName, riid.name, out_name) | ||
9850 | - print r' }' | ||
9851 | - print r' }' | ||
9852 | + print(r' %s{' % else_) | ||
9853 | + print(r' wrapIID("%s", %s, %s);' % (functionName, riid.name, out_name)) | ||
9854 | + print(r' }') | ||
9855 | + print(r' }') | ||
9856 | |||
9857 | def invokeMethod(self, interface, base, method): | ||
9858 | if method.type is stdapi.Void: | ||
9859 | result = '' | ||
9860 | else: | ||
9861 | result = '_result = ' | ||
9862 | - print ' %s_this->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args])) | ||
9863 | + print(' %s_this->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args]))) | ||
9864 | |||
9865 | def emit_memcpy(self, ptr, size): | ||
9866 | - print ' trace::fakeMemcpy(%s, %s);' % (ptr, size) | ||
9867 | + print(' trace::fakeMemcpy(%s, %s);' % (ptr, size)) | ||
9868 | |||
9869 | def emit_memcpy_opt(self, ptr, size): | ||
9870 | - print ' trace::fakeMemcpyOpt(%s, %s);' % (ptr, size) | ||
9871 | + print(' trace::fakeMemcpyOpt(%s, %s);' % (ptr, size)) | ||
9872 | |||
9873 | def fake_call(self, function, args): | ||
9874 | - print ' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) | ||
9875 | + print(' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)) | ||
9876 | for arg, instance in zip(function.args, args): | ||
9877 | assert not arg.output | ||
9878 | - print ' trace::localWriter.beginArg(%u);' % (arg.index,) | ||
9879 | + print(' trace::localWriter.beginArg(%u);' % (arg.index,)) | ||
9880 | self.serializeValue(arg.type, instance) | ||
9881 | - print ' trace::localWriter.endArg();' | ||
9882 | - print ' trace::localWriter.endEnter();' | ||
9883 | - print ' trace::localWriter.beginLeave(_fake_call);' | ||
9884 | - print ' trace::localWriter.endLeave();' | ||
9885 | + print(' trace::localWriter.endArg();') | ||
9886 | + print(' trace::localWriter.endEnter();') | ||
9887 | + print(' trace::localWriter.beginLeave(_fake_call);') | ||
9888 | + print(' trace::localWriter.endLeave();') | ||
9889 | |||
9890 | diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py | ||
9891 | index bc79d774..be86c36e 100644 | ||
9892 | --- a/wrappers/wgltrace.py | ||
9893 | +++ b/wrappers/wgltrace.py | ||
9894 | @@ -66,63 +66,65 @@ class WglTracer(GlTracer): | ||
9895 | # wglCreateContext/wglCreateLayerContext to obtain a HGLRC that's | ||
9896 | # recognizable by OPENGL32.DLL. Therefore we need to detect and | ||
9897 | # dispatch internal calls, without further ado. | ||
9898 | - print r' if (_reentrant) {' | ||
9899 | + print(r' if (_reentrant) {') | ||
9900 | self.invokeFunction(function) | ||
9901 | if function.type is not Void: | ||
9902 | - print ' return _result;' | ||
9903 | - print r' }' | ||
9904 | - print r' ReentryScope _reentry;' | ||
9905 | - print r' (void)_reentry;' | ||
9906 | |||
9907 | + print(' return _result;') | ||
9908 | + print(r' }') | ||
9909 | + print(r' ReentryScope _reentry;') | ||
9910 | + print(r' (void)_reentry;') | ||
9911 | + print() | ||
9912 | |||
9913 | if function.name in self.destroyContextFunctionNames: | ||
9914 | # Unlike other GL APIs like EGL or GLX, WGL will make the context | ||
9915 | # inactive if it's currently the active context. | ||
9916 | - print ' if (_wglGetCurrentContext() == hglrc) {' | ||
9917 | - print ' gltrace::clearContext();' | ||
9918 | - print ' }' | ||
9919 | - print ' gltrace::releaseContext((uintptr_t)hglrc);' | ||
9920 | + print(' if (_wglGetCurrentContext() == hglrc) {') | ||
9921 | + print(' gltrace::clearContext();') | ||
9922 | + print(' }') | ||
9923 | + print(' gltrace::releaseContext((uintptr_t)hglrc);') | ||
9924 | |||
9925 | GlTracer.traceFunctionImplBody(self, function) | ||
9926 | |||
9927 | if function.name in self.createContextFunctionNames: | ||
9928 | - print ' if (_result)' | ||
9929 | - print ' gltrace::createContext((uintptr_t)_result);' | ||
9930 | + print(' if (_result)') | ||
9931 | + print(' gltrace::createContext((uintptr_t)_result);') | ||
9932 | |||
9933 | if function.name in self.makeCurrentFunctionNames: | ||
9934 | - print ' if (_result) {' | ||
9935 | - print ' if (hglrc != NULL)' | ||
9936 | - print ' gltrace::setContext((uintptr_t)hglrc);' | ||
9937 | - print ' else' | ||
9938 | - print ' gltrace::clearContext();' | ||
9939 | - print ' }' | ||
9940 | + print(' if (_result) {') | ||
9941 | + print(' if (hglrc != NULL)') | ||
9942 | + print(' gltrace::setContext((uintptr_t)hglrc);') | ||
9943 | + print(' else') | ||
9944 | + print(' gltrace::clearContext();') | ||
9945 | + print(' }') | ||
9946 | |||
9947 | |||
9948 | if __name__ == '__main__': | ||
9949 | |||
9950 | - print '#define _GDI32_' | ||
9951 | |||
9952 | - print '#include <string.h>' | ||
9953 | - print '#include <windows.h>' | ||
9954 | |||
9955 | - print '#include "trace_writer_local.hpp"' | ||
9956 | - print '#include "os.hpp"' | ||
9957 | |||
9958 | - print '// To validate our prototypes' | ||
9959 | - print '#define GL_GLEXT_PROTOTYPES' | ||
9960 | - print '#define WGL_GLXEXT_PROTOTYPES' | ||
9961 | |||
9962 | - print '#include "glproc.hpp"' | ||
9963 | - print '#include "glsize.hpp"' | ||
9964 | |||
9965 | - print 'static OS_THREAD_SPECIFIC(uintptr_t) _reentrant;' | ||
9966 | |||
9967 | - print '// Helper class to track reentries in function scope.' | ||
9968 | - print 'struct ReentryScope {' | ||
9969 | - print 'inline ReentryScope() { _reentrant = 1; }' | ||
9970 | - print 'inline ~ReentryScope() { _reentrant = 0; }' | ||
9971 | - print '};' | ||
9972 | |||
9973 | + print() | ||
9974 | + print('#define _GDI32_') | ||
9975 | + print() | ||
9976 | + print('#include <string.h>') | ||
9977 | + print('#include <windows.h>') | ||
9978 | + print() | ||
9979 | + print('#include <sstream>') | ||
9980 | + print() | ||
9981 | + print('#include "trace_writer_local.hpp"') | ||
9982 | + print('#include "os.hpp"') | ||
9983 | + print() | ||
9984 | + print('// To validate our prototypes') | ||
9985 | + print('#define GL_GLEXT_PROTOTYPES') | ||
9986 | + print('#define WGL_GLXEXT_PROTOTYPES') | ||
9987 | + print() | ||
9988 | + print('#include "glproc.hpp"') | ||
9989 | + print('#include "glsize.hpp"') | ||
9990 | + print() | ||
9991 | + print('static OS_THREAD_LOCAL uintptr_t _reentrant;') | ||
9992 | + print() | ||
9993 | + print('// Helper class to track reentries in function scope.') | ||
9994 | + print('struct ReentryScope {') | ||
9995 | + print('inline ReentryScope() { _reentrant = 1; }') | ||
9996 | + print('inline ~ReentryScope() { _reentrant = 0; }') | ||
9997 | + print('};') | ||
9998 | + print() | ||
9999 | module = Module() | ||
10000 | module.mergeModule(glapi) | ||
10001 | module.mergeModule(wglapi) | ||
10002 | -- | ||
10003 | 2.17.1 | ||
10004 | |||
diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0002-specs-Tie-Python-2-3-conversion-loose-ends.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0002-specs-Tie-Python-2-3-conversion-loose-ends.patch deleted file mode 100644 index 25141602..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0002-specs-Tie-Python-2-3-conversion-loose-ends.patch +++ /dev/null | |||
@@ -1,169 +0,0 @@ | |||
1 | From a8791e3dca61500a382be84dc96973639b8bd182 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jose Fonseca <jfonseca@vmware.com> | ||
3 | Date: Sun, 28 Apr 2019 14:13:01 +0100 | ||
4 | Subject: [PATCH 2/4] specs: Tie Python 2 ->3 conversion loose ends. | ||
5 | |||
6 | Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/5b3c68cafaddc82c0f34bea8127582eee07ac3be] | ||
7 | |||
8 | (cherry picked from commit 5b3c68cafaddc82c0f34bea8127582eee07ac3be) | ||
9 | Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> | ||
10 | --- | ||
11 | specs/scripts/Makefile | 16 ++++++++-------- | ||
12 | specs/scripts/c2api.py | 6 +++--- | ||
13 | specs/scripts/cxx2api.py | 2 +- | ||
14 | specs/scripts/spec2api.py | 2 +- | ||
15 | specs/scripts/txt2api.py | 8 +++++--- | ||
16 | specs/scripts/xml2api.py | 2 +- | ||
17 | specs/scripts/xml2enum.py | 2 +- | ||
18 | specs/scripts/xml2glparams.py | 2 +- | ||
19 | 8 files changed, 21 insertions(+), 19 deletions(-) | ||
20 | |||
21 | diff --git a/specs/scripts/Makefile b/specs/scripts/Makefile | ||
22 | index 714a3deb..f03f36eb 100644 | ||
23 | --- a/specs/scripts/Makefile | ||
24 | +++ b/specs/scripts/Makefile | ||
25 | @@ -37,28 +37,28 @@ download: \ | ||
26 | wget -N https://www.opengl.org/registry/oldspecs/$@ | ||
27 | |||
28 | glapi.py: xml2api.py gl.xml | ||
29 | - python $^ > $@ | ||
30 | + python3 $^ > $@ | ||
31 | |||
32 | glxapi.py: xml2api.py glx.xml | ||
33 | - python $^ > $@ | ||
34 | + python3 $^ > $@ | ||
35 | |||
36 | wglapi.py: xml2api.py wgl.xml | ||
37 | - python $^ > $@ | ||
38 | + python3 $^ > $@ | ||
39 | |||
40 | eglapi.py: xml2api.py egl.xml | ||
41 | - python $^ > $@ | ||
42 | + python3 $^ > $@ | ||
43 | |||
44 | glparams.py: xml2glparams.py gl.xml | ||
45 | - python $^ > $@ | ||
46 | + python3 $^ > $@ | ||
47 | |||
48 | glxenum.py: xml2enum.py glx.xml | ||
49 | - python $^ > $@ | ||
50 | + python3 $^ > $@ | ||
51 | |||
52 | wglenum.py: xml2enum.py wgl.xml | ||
53 | - python $^ > $@ | ||
54 | + python3 $^ > $@ | ||
55 | |||
56 | eglenum.py: xml2enum.py egl.xml | ||
57 | - python $^ > $@ | ||
58 | + python3 $^ > $@ | ||
59 | |||
60 | clean: | ||
61 | rm -f \ | ||
62 | diff --git a/specs/scripts/c2api.py b/specs/scripts/c2api.py | ||
63 | index b8aaa81d..208169d2 100755 | ||
64 | --- a/specs/scripts/c2api.py | ||
65 | +++ b/specs/scripts/c2api.py | ||
66 | @@ -1,4 +1,4 @@ | ||
67 | -#!/usr/bin/env python | ||
68 | +#!/usr/bin/env python3 | ||
69 | ########################################################################## | ||
70 | # | ||
71 | # Copyright 2011 Jose Fonseca | ||
72 | @@ -404,8 +404,8 @@ class DeclParser: | ||
73 | type = 'S' + type | ||
74 | elif short: | ||
75 | type = 'Short' | ||
76 | - elif int: | ||
77 | - type = 'Long' * int | ||
78 | + elif long: | ||
79 | + type = 'Long' * long | ||
80 | else: | ||
81 | type = 'Int' | ||
82 | if unsigned: | ||
83 | diff --git a/specs/scripts/cxx2api.py b/specs/scripts/cxx2api.py | ||
84 | index 9720615d..8056de47 100755 | ||
85 | --- a/specs/scripts/cxx2api.py | ||
86 | +++ b/specs/scripts/cxx2api.py | ||
87 | @@ -1,4 +1,4 @@ | ||
88 | -#!/usr/bin/env python | ||
89 | +#!/usr/bin/env python3 | ||
90 | |||
91 | |||
92 | |||
93 | diff --git a/specs/scripts/spec2api.py b/specs/scripts/spec2api.py | ||
94 | index 7fb395a4..33a8d058 100755 | ||
95 | --- a/specs/scripts/spec2api.py | ||
96 | +++ b/specs/scripts/spec2api.py | ||
97 | @@ -1,4 +1,4 @@ | ||
98 | -#!/usr/bin/env python | ||
99 | +#!/usr/bin/env python3 | ||
100 | ########################################################################## | ||
101 | # | ||
102 | # Copyright 2010 VMware, Inc. | ||
103 | diff --git a/specs/scripts/txt2api.py b/specs/scripts/txt2api.py | ||
104 | index e9469d3c..a32ca658 100755 | ||
105 | --- a/specs/scripts/txt2api.py | ||
106 | +++ b/specs/scripts/txt2api.py | ||
107 | @@ -1,4 +1,4 @@ | ||
108 | -#!/usr/bin/env python | ||
109 | +#!/usr/bin/env python3 | ||
110 | ########################################################################## | ||
111 | # | ||
112 | # Copyright 2010 VMware, Inc. | ||
113 | @@ -28,6 +28,7 @@ | ||
114 | """Parser for OpenGL .txt extensions specification.""" | ||
115 | |||
116 | |||
117 | +import io | ||
118 | import sys | ||
119 | import re | ||
120 | import optparse | ||
121 | @@ -233,12 +234,13 @@ def main(): | ||
122 | |||
123 | for arg in args: | ||
124 | if arg.startswith('http://') or arg.startswith('https://'): | ||
125 | - stream = urlopen(arg, 'rt') | ||
126 | + stream = urlopen(arg) | ||
127 | + stream = io.TextIOWrapper(stream, encoding='ascii') | ||
128 | else: | ||
129 | stream = open(arg, 'rt') | ||
130 | parser = TxtParser(stream, prefix = options.prefix) | ||
131 | parser.parse() | ||
132 | - | ||
133 | + | ||
134 | |||
135 | if __name__ == '__main__': | ||
136 | main() | ||
137 | diff --git a/specs/scripts/xml2api.py b/specs/scripts/xml2api.py | ||
138 | index f09fe0bf..6b4ec3b7 100755 | ||
139 | --- a/specs/scripts/xml2api.py | ||
140 | +++ b/specs/scripts/xml2api.py | ||
141 | @@ -1,4 +1,4 @@ | ||
142 | -#!/usr/bin/env python | ||
143 | +#!/usr/bin/env python3 | ||
144 | ########################################################################## | ||
145 | # | ||
146 | # Copyright 2014 VMware, Inc | ||
147 | diff --git a/specs/scripts/xml2enum.py b/specs/scripts/xml2enum.py | ||
148 | index cb2c4ae9..f799b7b5 100755 | ||
149 | --- a/specs/scripts/xml2enum.py | ||
150 | +++ b/specs/scripts/xml2enum.py | ||
151 | @@ -1,4 +1,4 @@ | ||
152 | -#!/usr/bin/env python | ||
153 | +#!/usr/bin/env python3 | ||
154 | ########################################################################## | ||
155 | # | ||
156 | # Copyright 2014 VMware, Inc | ||
157 | diff --git a/specs/scripts/xml2glparams.py b/specs/scripts/xml2glparams.py | ||
158 | index 805aac86..a651d896 100755 | ||
159 | --- a/specs/scripts/xml2glparams.py | ||
160 | +++ b/specs/scripts/xml2glparams.py | ||
161 | @@ -1,4 +1,4 @@ | ||
162 | -#!/usr/bin/env python | ||
163 | +#!/usr/bin/env python3 | ||
164 | ########################################################################## | ||
165 | # | ||
166 | # Copyright 2014 VMware, Inc | ||
167 | -- | ||
168 | 2.17.1 | ||
169 | |||
diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0003-scripts-Tie-Python-2-3-conversion-loose-ends.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0003-scripts-Tie-Python-2-3-conversion-loose-ends.patch deleted file mode 100644 index e30273d5..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0003-scripts-Tie-Python-2-3-conversion-loose-ends.patch +++ /dev/null | |||
@@ -1,276 +0,0 @@ | |||
1 | From 8ba82a1ef77e60bd614cca1e583e1a0c25b4f281 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jose Fonseca <jfonseca@vmware.com> | ||
3 | Date: Sun, 28 Apr 2019 14:14:44 +0100 | ||
4 | Subject: [PATCH 3/4] scripts: Tie Python 2 -> 3 conversion loose ends. | ||
5 | |||
6 | Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/247e1fa87f4e87b8914662e44a8ecef4d444cc90] | ||
7 | |||
8 | (cherry picked from commit 247e1fa87f4e87b8914662e44a8ecef4d444cc90) | ||
9 | Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> | ||
10 | --- | ||
11 | retrace/glstate_params.py | 2 +- | ||
12 | scripts/convert.py | 2 +- | ||
13 | scripts/highlight.py | 3 ++- | ||
14 | scripts/jsondiff.py | 2 +- | ||
15 | scripts/jsonextractimages.py | 2 +- | ||
16 | scripts/leaks.py | 4 ++-- | ||
17 | scripts/profileshader.py | 2 +- | ||
18 | scripts/retracediff.py | 2 +- | ||
19 | scripts/snapdiff.py | 2 +- | ||
20 | scripts/tracecheck.py | 2 +- | ||
21 | scripts/tracediff.py | 10 +++++----- | ||
22 | scripts/unpickle.py | 19 ++++++++++--------- | ||
23 | 12 files changed, 27 insertions(+), 25 deletions(-) | ||
24 | |||
25 | diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py | ||
26 | index bc90f66b..55f2dbc9 100755 | ||
27 | --- a/retrace/glstate_params.py | ||
28 | +++ b/retrace/glstate_params.py | ||
29 | @@ -1,4 +1,4 @@ | ||
30 | -#!/usr/bin/env python | ||
31 | +#!/usr/bin/env python3 | ||
32 | ########################################################################## | ||
33 | # | ||
34 | # Copyright 2011 Jose Fonseca | ||
35 | diff --git a/scripts/convert.py b/scripts/convert.py | ||
36 | index 83df70ce..1f285a8c 100755 | ||
37 | --- a/scripts/convert.py | ||
38 | +++ b/scripts/convert.py | ||
39 | @@ -1,4 +1,4 @@ | ||
40 | -#!/usr/bin/env python | ||
41 | +#!/usr/bin/env python3 | ||
42 | ########################################################################## | ||
43 | # | ||
44 | # Copyright 2012 VMware Inc. | ||
45 | diff --git a/scripts/highlight.py b/scripts/highlight.py | ||
46 | index ed3b54d4..e494abf4 100644 | ||
47 | --- a/scripts/highlight.py | ||
48 | +++ b/scripts/highlight.py | ||
49 | @@ -221,7 +221,8 @@ def LessHighlighter(): | ||
50 | try: | ||
51 | less = subprocess.Popen( | ||
52 | args = ['less', '-FRXn'], | ||
53 | - stdin = subprocess.PIPE | ||
54 | + stdin = subprocess.PIPE, | ||
55 | + universal_newlines = True | ||
56 | ) | ||
57 | except OSError: | ||
58 | return ColorHighlighter() | ||
59 | diff --git a/scripts/jsondiff.py b/scripts/jsondiff.py | ||
60 | index 25c4840e..d7a18e21 100755 | ||
61 | --- a/scripts/jsondiff.py | ||
62 | +++ b/scripts/jsondiff.py | ||
63 | @@ -1,4 +1,4 @@ | ||
64 | -#!/usr/bin/env python | ||
65 | +#!/usr/bin/env python3 | ||
66 | ########################################################################## | ||
67 | # | ||
68 | # Copyright 2015 VMware, Inc. | ||
69 | diff --git a/scripts/jsonextractimages.py b/scripts/jsonextractimages.py | ||
70 | index 917ee7e4..785e32db 100755 | ||
71 | --- a/scripts/jsonextractimages.py | ||
72 | +++ b/scripts/jsonextractimages.py | ||
73 | @@ -1,4 +1,4 @@ | ||
74 | -#!/usr/bin/env python | ||
75 | +#!/usr/bin/env python3 | ||
76 | ########################################################################## | ||
77 | # | ||
78 | # Copyright 2012 Jose Fonseca | ||
79 | diff --git a/scripts/leaks.py b/scripts/leaks.py | ||
80 | index 325af1e2..706e60a9 100755 | ||
81 | --- a/scripts/leaks.py | ||
82 | +++ b/scripts/leaks.py | ||
83 | @@ -1,4 +1,4 @@ | ||
84 | -#!/usr/bin/env python | ||
85 | +#!/usr/bin/env python3 | ||
86 | ########################################################################## | ||
87 | # | ||
88 | # Copyright 2014-2016 VMware, Inc. | ||
89 | @@ -39,7 +39,7 @@ class LeakDetector(unpickle.Unpickler): | ||
90 | def __init__(self, apitrace, trace): | ||
91 | |||
92 | cmd = [apitrace, 'pickle', '--symbolic', trace] | ||
93 | - p = subprocess.Popen(args = cmd, stdout = subprocess.PIPE) | ||
94 | + p = subprocess.Popen(args = cmd, stdout=subprocess.PIPE) | ||
95 | |||
96 | unpickle.Unpickler.__init__(self, p.stdout) | ||
97 | |||
98 | diff --git a/scripts/profileshader.py b/scripts/profileshader.py | ||
99 | index 5c2a58fb..c6c1c935 100755 | ||
100 | --- a/scripts/profileshader.py | ||
101 | +++ b/scripts/profileshader.py | ||
102 | @@ -1,4 +1,4 @@ | ||
103 | -#!/usr/bin/env python | ||
104 | +#!/usr/bin/env python3 | ||
105 | ########################################################################## | ||
106 | # | ||
107 | # Copyright 2012-2013 VMware, Inc. | ||
108 | diff --git a/scripts/retracediff.py b/scripts/retracediff.py | ||
109 | index 8105f536..967f3a93 100755 | ||
110 | --- a/scripts/retracediff.py | ||
111 | +++ b/scripts/retracediff.py | ||
112 | @@ -1,4 +1,4 @@ | ||
113 | -#!/usr/bin/env python | ||
114 | +#!/usr/bin/env python3 | ||
115 | ########################################################################## | ||
116 | # | ||
117 | # Copyright 2011 Jose Fonseca | ||
118 | diff --git a/scripts/snapdiff.py b/scripts/snapdiff.py | ||
119 | index b0d5f757..58fefe88 100755 | ||
120 | --- a/scripts/snapdiff.py | ||
121 | +++ b/scripts/snapdiff.py | ||
122 | @@ -1,4 +1,4 @@ | ||
123 | -#!/usr/bin/env python | ||
124 | +#!/usr/bin/env python3 | ||
125 | ########################################################################## | ||
126 | # | ||
127 | # Copyright 2011 Jose Fonseca | ||
128 | diff --git a/scripts/tracecheck.py b/scripts/tracecheck.py | ||
129 | index 3a2ec452..38167e89 100755 | ||
130 | --- a/scripts/tracecheck.py | ||
131 | +++ b/scripts/tracecheck.py | ||
132 | @@ -1,4 +1,4 @@ | ||
133 | -#!/usr/bin/env python | ||
134 | +#!/usr/bin/env python3 | ||
135 | ########################################################################## | ||
136 | # | ||
137 | # Copyright 2011 VMware, Inc. | ||
138 | diff --git a/scripts/tracediff.py b/scripts/tracediff.py | ||
139 | index 0cd9c8c6..88e389a3 100755 | ||
140 | --- a/scripts/tracediff.py | ||
141 | +++ b/scripts/tracediff.py | ||
142 | @@ -1,4 +1,4 @@ | ||
143 | -#!/usr/bin/env python | ||
144 | +#!/usr/bin/env python3 | ||
145 | ########################################################################## | ||
146 | # | ||
147 | # Copyright 2011 Jose Fonseca | ||
148 | @@ -173,7 +173,7 @@ class ExternalDiffer(Differ): | ||
149 | try: | ||
150 | less = subprocess.Popen( | ||
151 | args = ['less', '-FRXn'], | ||
152 | - stdin = subprocess.PIPE | ||
153 | + stdin = subprocess.PIPE, | ||
154 | ) | ||
155 | except OSError: | ||
156 | pass | ||
157 | @@ -214,7 +214,7 @@ ignoredFunctionNames = set([ | ||
158 | |||
159 | |||
160 | class Blob: | ||
161 | - '''Data-less proxy for bytearrays, to save memory.''' | ||
162 | + '''Data-less proxy for bytes, to save memory.''' | ||
163 | |||
164 | def __init__(self, size, hash): | ||
165 | self.size = size | ||
166 | @@ -233,7 +233,7 @@ class Blob: | ||
167 | class BlobReplacer(Rebuilder): | ||
168 | '''Replace blobs with proxys.''' | ||
169 | |||
170 | - def visitByteArray(self, obj): | ||
171 | + def visitBytes(self, obj): | ||
172 | return Blob(len(obj), hash(str(obj))) | ||
173 | |||
174 | def visitCall(self, call): | ||
175 | @@ -287,7 +287,7 @@ class PythonDiffer(Differ): | ||
176 | '--calls=' + calls, | ||
177 | trace | ||
178 | ], | ||
179 | - stdout = subprocess.PIPE, | ||
180 | + stdout=subprocess.PIPE, | ||
181 | ) | ||
182 | |||
183 | parser = Loader(p.stdout) | ||
184 | diff --git a/scripts/unpickle.py b/scripts/unpickle.py | ||
185 | index 86891d29..822b8ea8 100755 | ||
186 | --- a/scripts/unpickle.py | ||
187 | +++ b/scripts/unpickle.py | ||
188 | @@ -1,4 +1,4 @@ | ||
189 | -#!/usr/bin/env python | ||
190 | +#!/usr/bin/env python3 | ||
191 | ########################################################################## | ||
192 | # | ||
193 | # Copyright 2012 Jose Fonseca | ||
194 | @@ -34,6 +34,7 @@ Run as: | ||
195 | |||
196 | |||
197 | import itertools | ||
198 | +import operator | ||
199 | import optparse | ||
200 | import sys | ||
201 | import time | ||
202 | @@ -55,7 +56,7 @@ CALL_FLAG_MARKER_PUSH = (1 << 9) | ||
203 | CALL_FLAG_MARKER_POP = (1 << 10) | ||
204 | |||
205 | |||
206 | -class Pointer(long): | ||
207 | +class Pointer(int): | ||
208 | |||
209 | def __str__(self): | ||
210 | if self == 0: | ||
211 | @@ -79,7 +80,7 @@ class Visitor: | ||
212 | self.dispatch[tuple] = self.visitTuple | ||
213 | self.dispatch[list] = self.visitList | ||
214 | self.dispatch[dict] = self.visitDict | ||
215 | - self.dispatch[bytearray] = self.visitByteArray | ||
216 | + self.dispatch[bytes] = self.visitBytes | ||
217 | self.dispatch[Pointer] = self.visitPointer | ||
218 | |||
219 | def visit(self, obj): | ||
220 | @@ -119,7 +120,7 @@ class Visitor: | ||
221 | def visitDict(self, obj): | ||
222 | return self.visitIterable(obj) | ||
223 | |||
224 | - def visitByteArray(self, obj): | ||
225 | + def visitBytes(self, obj): | ||
226 | raise NotImplementedError | ||
227 | |||
228 | def visitPointer(self, obj): | ||
229 | @@ -153,7 +154,7 @@ class Dumper(Visitor): | ||
230 | def visitDict(self, obj): | ||
231 | return '{' + self.visitItems(iter(obj.items())) + '}' | ||
232 | |||
233 | - def visitByteArray(self, obj): | ||
234 | + def visitBytes(self, obj): | ||
235 | return 'blob(%u)' % len(obj) | ||
236 | |||
237 | |||
238 | @@ -169,7 +170,7 @@ class Hasher(Visitor): | ||
239 | def visitIterable(self, obj): | ||
240 | return tuple(map(self.visit, obj)) | ||
241 | |||
242 | - def visitByteArray(self, obj): | ||
243 | + def visitBytes(self, obj): | ||
244 | return str(obj) | ||
245 | |||
246 | |||
247 | @@ -193,7 +194,7 @@ class Rebuilder(Visitor): | ||
248 | else: | ||
249 | return obj | ||
250 | |||
251 | - def visitByteArray(self, obj): | ||
252 | + def visitBytes(self, obj): | ||
253 | return obj | ||
254 | |||
255 | |||
256 | @@ -269,7 +270,7 @@ class Counter(Unpickler): | ||
257 | Unpickler.parse(self) | ||
258 | |||
259 | functionFrequencies = list(self.functionFrequencies.items()) | ||
260 | - functionFrequencies.sort(lambda (name1, freq1), (name2, freq2): cmp(freq1, freq2)) | ||
261 | + functionFrequencies.sort(key=operator.itemgetter(1)) | ||
262 | for name, frequency in functionFrequencies: | ||
263 | sys.stdout.write('%8u %s\n' % (frequency, name)) | ||
264 | |||
265 | @@ -311,7 +312,7 @@ def main(): | ||
266 | msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) | ||
267 | |||
268 | startTime = time.time() | ||
269 | - parser = Counter(sys.stdin, options.verbose) | ||
270 | + parser = Counter(sys.stdin.buffer, options.verbose) | ||
271 | parser.parse() | ||
272 | stopTime = time.time() | ||
273 | duration = stopTime - startTime | ||
274 | -- | ||
275 | 2.17.1 | ||
276 | |||
diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0004-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0004-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch deleted file mode 100644 index 8974e5db..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0004-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | From aa8e341e73c288b77a5187e3676a2bbb6588b705 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jose Fonseca <jfonseca@vmware.com> | ||
3 | Date: Mon, 29 Apr 2019 06:41:49 +0100 | ||
4 | Subject: [PATCH 4/4] scripts: Tie a few more Python 2 to 3 conversion loose | ||
5 | ends. | ||
6 | |||
7 | Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/f527924cca45591966139eae8c2fefb4a9a0f947] | ||
8 | |||
9 | (cherry picked from commit f527924cca45591966139eae8c2fefb4a9a0f947) | ||
10 | Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> | ||
11 | --- | ||
12 | scripts/jsonextractimages.py | 10 +++++----- | ||
13 | scripts/profileshader.py | 2 +- | ||
14 | 2 files changed, 6 insertions(+), 6 deletions(-) | ||
15 | |||
16 | diff --git a/scripts/jsonextractimages.py b/scripts/jsonextractimages.py | ||
17 | index 785e32db..ac20c23d 100755 | ||
18 | --- a/scripts/jsonextractimages.py | ||
19 | +++ b/scripts/jsonextractimages.py | ||
20 | @@ -34,7 +34,7 @@ import base64 | ||
21 | import sys | ||
22 | |||
23 | |||
24 | -pngSignature = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A" | ||
25 | +pngSignature = b"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A" | ||
26 | |||
27 | |||
28 | def dumpSurfaces(state, memberName): | ||
29 | @@ -46,13 +46,13 @@ def dumpSurfaces(state, memberName): | ||
30 | extName = 'png' | ||
31 | else: | ||
32 | magic = data[:2] | ||
33 | - if magic in ('P1', 'P4'): | ||
34 | + if magic in (b'P1', b'P4'): | ||
35 | extName = 'pbm' | ||
36 | - elif magic in ('P2', 'P5'): | ||
37 | + elif magic in (b'P2', b'P5'): | ||
38 | extName = 'pgm' | ||
39 | - elif magic in ('P3', 'P6'): | ||
40 | + elif magic in (b'P3', b'P6'): | ||
41 | extName = 'ppm' | ||
42 | - elif magic in ('Pf', 'PF'): | ||
43 | + elif magic in (b'Pf', b'PF'): | ||
44 | extName = 'pfm' | ||
45 | else: | ||
46 | sys.stderr.write('warning: unsupport Netpbm format %s\n' % magic) | ||
47 | diff --git a/scripts/profileshader.py b/scripts/profileshader.py | ||
48 | index c6c1c935..7e8637eb 100755 | ||
49 | --- a/scripts/profileshader.py | ||
50 | +++ b/scripts/profileshader.py | ||
51 | @@ -92,7 +92,7 @@ def process(stream, groupField): | ||
52 | id = str(group[0]).rjust(maxGroupLen) | ||
53 | draw = str(group[1]['draws']).rjust(12) | ||
54 | dura = str(group[1]['duration']).rjust(18) | ||
55 | - perCall = str(group[1]['duration'] / group[1]['draws']).rjust(12) | ||
56 | + perCall = str(group[1]['duration'] // group[1]['draws']).rjust(12) | ||
57 | longest = str(group[1]['longest']).rjust(11) | ||
58 | print("| %s | %s | %s | %s | %s |" % (id, draw, dura, perCall, longest)) | ||
59 | |||
60 | -- | ||
61 | 2.17.1 | ||
62 | |||
diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0005-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0005-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch deleted file mode 100644 index 6bff7e92..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0005-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | From 8b3afcaeebdd87962f2f3fef36973090621d116b Mon Sep 17 00:00:00 2001 | ||
2 | From: Max Krummenacher <max.krummenacher@toradex.com> | ||
3 | Date: Sun, 29 Mar 2020 15:38:31 +0000 | ||
4 | Subject: [PATCH 5/5] scripts: Tie a few more Python 2 to 3 conversion loose | ||
5 | ends. | ||
6 | |||
7 | Upstream-Status: pending | ||
8 | Note: code exists in NXP's fork only. | ||
9 | |||
10 | Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> | ||
11 | --- | ||
12 | wrappers/glxtrace.py | 14 +++++++------- | ||
13 | 1 file changed, 7 insertions(+), 7 deletions(-) | ||
14 | |||
15 | diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py | ||
16 | index b05028e2..2472560d 100644 | ||
17 | --- a/wrappers/glxtrace.py | ||
18 | +++ b/wrappers/glxtrace.py | ||
19 | @@ -67,9 +67,9 @@ class GlxTracer(GlTracer): | ||
20 | print(' gltrace::releaseContext((uintptr_t)ctx);') | ||
21 | |||
22 | if function.name == 'glXGetCurrentDisplay': | ||
23 | - print ' if(_glXGetCurrentDisplay == &glXGetCurrentDisplay ){' | ||
24 | - print ' _glXGetCurrentDisplay = (PFN_GLXGETCURRENTDISPLAY)_getPublicProcAddress("glXGetCurrentDisplay");' | ||
25 | - print ' }' | ||
26 | + print (' if(_glXGetCurrentDisplay == &glXGetCurrentDisplay ){') | ||
27 | + print (' _glXGetCurrentDisplay = (PFN_GLXGETCURRENTDISPLAY)_getPublicProcAddress("glXGetCurrentDisplay");') | ||
28 | + print (' }') | ||
29 | |||
30 | GlTracer.traceFunctionImplBody(self, function) | ||
31 | |||
32 | @@ -184,7 +184,7 @@ if __name__ == '__main__': | ||
33 | tracer = GlxTracer() | ||
34 | tracer.traceApi(api) | ||
35 | |||
36 | - print r''' | ||
37 | + print (r''' | ||
38 | |||
39 | |||
40 | /* | ||
41 | @@ -247,8 +247,8 @@ void * dlopen(const char *filename, int flag) | ||
42 | |||
43 | |||
44 | |||
45 | -''' | ||
46 | - print r''' | ||
47 | +''') | ||
48 | + print (r''' | ||
49 | /* | ||
50 | * let the GPU driver know that we are in apitrace | ||
51 | */ | ||
52 | @@ -257,4 +257,4 @@ int APIENTRY ApiTraceEnabled(void) { | ||
53 | return 1; | ||
54 | } | ||
55 | |||
56 | -''' | ||
57 | +''') | ||
58 | -- | ||
59 | 2.20.1 | ||
60 | |||
diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_9.0.0.bb b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_9.0.0.bb index 9461a34d..2f8029a4 100644 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_9.0.0.bb +++ b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_9.0.0.bb | |||
@@ -5,17 +5,18 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=aeb969185a143c3c25130bc2c3ef9a50" | |||
5 | DEPENDS = "imx-gpu-viv zlib libpng procps" | 5 | DEPENDS = "imx-gpu-viv zlib libpng procps" |
6 | 6 | ||
7 | SRC_URI = "git://source.codeaurora.org/external/imx/apitrace-imx.git;protocol=https;branch=imx_9.0" | 7 | SRC_URI = "git://source.codeaurora.org/external/imx/apitrace-imx.git;protocol=https;branch=imx_9.0" |
8 | SRCREV = "8636fa989d8e914a7986916b058878761a981a6f" | 8 | SRCREV = "fed74f6f84cb4f48ddace4306c9bf90bf7a9a967" |
9 | 9 | ||
10 | S = "${WORKDIR}/git" | 10 | S = "${WORKDIR}/git" |
11 | 11 | ||
12 | inherit cmake pkgconfig perlnative python3native | 12 | inherit cmake pkgconfig perlnative python3native |
13 | 13 | ||
14 | PACKAGECONFIG ??= "egl waffle" | 14 | PACKAGECONFIG ??= "egl" |
15 | PACKAGECONFIG_append = \ | 15 | PACKAGECONFIG_append = \ |
16 | "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', '', \ | 16 | "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', '', \ |
17 | bb.utils.contains('DISTRO_FEATURES', 'x11', ' x11', \ | 17 | bb.utils.contains('DISTRO_FEATURES', 'x11', ' x11', \ |
18 | '', d), d)}" | 18 | '', d), d)}" |
19 | PACKAGECONFIG_append_mx8 = " waffle" | ||
19 | PACKAGECONFIG_append_imxgpu2d = " vivante" | 20 | PACKAGECONFIG_append_imxgpu2d = " vivante" |
20 | 21 | ||
21 | PACKAGECONFIG[egl] = "-DENABLE_EGL=ON,-DENABLE_EGL=OFF,virtual/egl" | 22 | PACKAGECONFIG[egl] = "-DENABLE_EGL=ON,-DENABLE_EGL=OFF,virtual/egl" |