X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=dispatch%2Fdispatch.py;h=60f95073b76d829c773b3dc653e6fadde895cfb0;hb=48c661ea6c0f2bd9b76a3385cd946b7d07bc9b5f;hp=647454208d0cc75344bf482962cf6c30d8d3fa03;hpb=632a78d5c90941c896fa3c7156131f27c5a58b24;p=apitrace diff --git a/dispatch/dispatch.py b/dispatch/dispatch.py index 6474542..60f9507 100644 --- a/dispatch/dispatch.py +++ b/dispatch/dispatch.py @@ -58,20 +58,20 @@ class Dispatcher: # raise NotImplementedError - def dispatch_api(self, api): - for function in api.functions: - self.invokeFunction(function) + def dispatchModule(self, module): + for function in module.functions: + self.dispatchFunction(module, function) # define standard name aliases for convenience, but only when not # tracing, as that would cause symbol clashing with the tracing # functions print '#ifdef RETRACE' - for function in api.functions: + for function in module.functions: print '#define %s _%s' % (function.name, function.name) print '#endif /* RETRACE */' print - def invokeFunction(self, function): + def dispatchFunction(self, module, function): ptype = function_pointer_type(function) pvalue = function_pointer_value(function) print 'typedef ' + function.prototype('* %s' % ptype) + ';' @@ -83,23 +83,26 @@ class Dispatcher: ret = '' else: ret = 'return ' - self.get_true_pointer(function) + self.invokeGetProcAddress(module, function) print ' %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args])) print '}' print - def isFunctionPublic(self, function): + def isFunctionPublic(self, module, function): return True - def get_true_pointer(self, function): + def getProcAddressName(self, module, function): + if self.isFunctionPublic(module, function): + return '_getPublicProcAddress' + else: + return '_getPrivateProcAddress' + + def invokeGetProcAddress(self, module, function): ptype = function_pointer_type(function) pvalue = function_pointer_value(function) - if self.isFunctionPublic(function): - get_proc_address = '_getPublicProcAddress' - else: - get_proc_address = '_getPrivateProcAddress' + getProcAddressName = self.getProcAddressName(module, function) print ' if (!%s) {' % (pvalue,) - print ' %s = (%s)%s(_name);' % (pvalue, ptype, get_proc_address) + print ' %s = (%s)%s(_name);' % (pvalue, ptype, getProcAddressName) print ' if (!%s) {' % (pvalue,) self.failFunction(function) print ' }'