##########################################################################/
+"""WGL tracing code generator."""
+
+
from wglapi import wglapi
from trace import Tracer
+from codegen import *
public_symbols = set([
def wrap_ret(self, function, instance):
if function.name == "wglGetProcAddress":
print ' if (%s) {' % instance
- else_ = ''
- for f in wglapi.functions:
+
+ func_dict = dict([(f.name, f) for f in wglapi.functions])
+
+ def handle_case(function_name):
+ f = func_dict[function_name]
ptype = self.function_pointer_type(f)
pvalue = self.function_pointer_value(f)
- print ' %sif (!strcmp("%s", lpszProc)) {' % (else_, f.name)
- print ' %s = (%s)%s;' % (pvalue, ptype, instance)
- print ' %s = (%s)&%s;' % (instance, function.type, f.name);
- print ' }'
- else_ = 'else '
- print ' %s{' % (else_,)
- print ' OS::DebugMessage("apitrace: unknown function \\"%s\\"\\n", lpszProc);'
- print ' }'
+ print ' %s = (%s)%s;' % (pvalue, ptype, instance)
+ print ' %s = (%s)&%s;' % (instance, function.type, f.name);
+
+ def handle_default():
+ print ' OS::DebugMessage("apitrace: unknown function \\"%s\\"\\n", lpszProc);'
+
+ string_switch('lpszProc', func_dict.keys(), handle_case, handle_default)
print ' }'
print '#include "os.hpp"'
print '#include "glsize.hpp"'
print
- print '#ifndef PFD_SUPPORT_DIRECTDRAW'
- print '#define PFD_SUPPORT_DIRECTDRAW 0x00002000'
- print '#endif'
- print '#ifndef PFD_SUPPORT_COMPOSITION'
- print '#define PFD_SUPPORT_COMPOSITION 0x00008000'
- print '#endif'
-
- print '#define GLAPIENTRY __stdcall'
- print
- print '#ifdef __MINGW32__'
- print ''
- print 'typedef struct _WGLSWAP'
- print '{'
- print ' HDC hdc;'
- print ' UINT uiFlags;'
- print '} WGLSWAP, *PWGLSWAP, FAR *LPWGLSWAP;'
- print ''
- print '#define WGL_SWAPMULTIPLE_MAX 16'
- print ''
- print '#endif'
- print
print 'extern "C" {'
print '''
static HINSTANCE g_hDll = NULL;