"""Win32 API type description."""
-from base import *
+from stdapi import *
SHORT = Alias("SHORT", Short)
USHORT = Alias("USHORT", UShort)
)
-class DllFunction(Function):
-
- def get_true_pointer(self):
- ptype = self.pointer_type()
- pvalue = self.pointer_value()
- print ' if(!g_hDll) {'
- print ' g_hDll = LoadLibrary(g_szDll);'
- print ' if(!g_hDll)'
- self.fail_impl()
- print ' }'
- print ' if(!%s) {' % (pvalue,)
- print ' %s = (%s)GetProcAddress(g_hDll, "%s");' % (pvalue, ptype, self.name)
- print ' if(!%s)' % (pvalue,)
- self.fail_impl()
- print ' }'
-
-
-class Dll:
-
- def __init__(self, name):
- self.name = name
- self.functions = []
- if self not in towrap:
- towrap.append(self)
-
- def wrap_name(self):
- return "Wrap" + self.name
-
- def wrap_pre_decl(self):
- pass
-
- def wrap_decl(self):
- print 'static HINSTANCE g_hDll = NULL;'
- print 'static TCHAR g_szDll[MAX_PATH] = {0};'
- print
- print 'BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);'
- print
- for function in self.functions:
- function.wrap_decl()
- print
-
- def wrap_impl(self):
- print r'BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {'
- print r' switch(fdwReason) {'
- print r' case DLL_PROCESS_ATTACH:'
- print r' if(!GetSystemDirectory(g_szDll, MAX_PATH))'
- print r' return FALSE;'
- print r' _tcscat(g_szDll, TEXT("\\%s.dll"));' % self.name
- print r' Log::Open("%s");' % self.name
- print r' case DLL_THREAD_ATTACH:'
- print r' return TRUE;'
- print r' case DLL_THREAD_DETACH:'
- print r' return TRUE;'
- print r' case DLL_PROCESS_DETACH:'
- print r' Log::Close();'
- print r' if(g_hDll) {'
- print r' FreeLibrary(g_hDll);'
- print r' g_hDll = NULL;'
- print r' }'
- print r' return TRUE;'
- print r' }'
- print r' (void)hinstDLL;'
- print r' (void)lpvReserved;'
- print r' return TRUE;'
- print r'}'
- print
- for function in self.functions:
- function.wrap_impl()
- print
-