Add API for structure

This commit is contained in:
Siu Kwan Lam 2012-08-03 22:30:54 -07:00
commit 184e4ea1a1
5 changed files with 109 additions and 12 deletions

View file

@ -35,14 +35,18 @@ class CExecutor(object):
else:
self.engine = mod_or_engine
def get_ctype_function(self, fn, typeinfo):
types = [ MAP_CTYPES[s.strip()] for s in typeinfo.split(',') ]
if not types:
retty = None
argtys = []
def get_ctype_function(self, fn, *typeinfo):
if len(typeinfo)==1 and isinstance(typeinfo[0], str):
types = [ MAP_CTYPES[s.strip()] for s in typeinfo[0].split(',') ]
if not types:
retty = None
argtys = []
else:
retty = types[0]
argtys = types[1:]
else:
retty = types[0]
argtys = types[1:]
retty = typeinfo[0]
argtys = typeinfo[1:]
prototype = ct.CFUNCTYPE(retty, *argtys)
fnptr = self.engine.get_pointer_to_function(fn)