def wrap_constructor(func, engine, py_module, rettype): from bitey.bind import map_llvm_to_ctypes args = func.type.pointee.args ret_type = func.type.pointee.return_type ret_ctype = map_llvm_to_ctypes(ret_type, py_module) args_ctypes = [map_llvm_to_ctypes(arg, py_module) for arg in args] functype = ctypes.CFUNCTYPE(rettype, *args_ctypes) addr = engine.get_pointer_to_function(func) return functype(addr)
def wrap_constructor(func, engine, py_module ,rettype): from bitey.bind import map_llvm_to_ctypes args = func.type.pointee.args ret_type = func.type.pointee.return_type ret_ctype = map_llvm_to_ctypes(ret_type, py_module) args_ctypes = [map_llvm_to_ctypes(arg, py_module) for arg in args] functype = ctypes.CFUNCTYPE(rettype, *args_ctypes) addr = engine.get_pointer_to_function(func) return functype(addr)
def debug_ctypes(mod, spine, constructors, rettype=None): from bitey.bind import map_llvm_to_ctypes from imp import new_module engine = ExecutionEngine.new(mod) py = new_module('') if not rettype: map_llvm_to_ctypes(spine, py) rettype = py.maybe else: rettype = rettype return [wrap_constructor(c, engine, py, rettype) for c in constructors]