def load_embedded_cffi_module(space, version, init_struct): from pypy.module._cffi_backend.cffi1_module import load_cffi1_module declare_c_function() # translation-time hint only: # declare _cffi_carefully_make_gil() # version = rffi.cast(lltype.Signed, version) if not (EMBED_VERSION_MIN <= version <= EMBED_VERSION_MAX): raise oefmt(space.w_ImportError, "cffi embedded module has got unknown version tag %s", hex(version)) # if space.config.objspace.usemodules.thread: from pypy.module.thread import os_thread os_thread.setup_threads(space) # name = rffi.charp2str(init_struct.name) load_cffi1_module(space, name, None, init_struct.func) code = rffi.charp2str(init_struct.code) compiler = space.createcompiler() pycode = compiler.compile(code, "<init code for '%s'>" % name, 'exec', 0) w_globals = space.newdict(module=True) space.setitem_str(w_globals, "__builtins__", space.builtin) pycode.exec_code(space, w_globals, w_globals)
def load_embedded_cffi_module(space, version, init_struct): from pypy.module._cffi_backend.cffi1_module import load_cffi1_module declare_c_function() # translation-time hint only: # declare _cffi_carefully_make_gil() # version = rffi.cast(lltype.Signed, version) if not (EMBED_VERSION_MIN <= version <= EMBED_VERSION_MAX): raise oefmt(space.w_ImportError, "cffi embedded module has got unknown version tag %s", hex(version)) # if space.config.objspace.usemodules.thread: from pypy.module.thread import os_thread os_thread.setup_threads(space) # name = rffi.charp2str(init_struct.name) load_cffi1_module(space, name, None, init_struct.func) code = rffi.charp2str(init_struct.code) compiler = space.createcompiler() pycode = compiler.compile(code, "<init code for '%s'>" % name, 'exec', 0) w_globals = space.newdict(module=True) space.setitem_str(w_globals, "__builtins__", space.wrap(space.builtin)) pycode.exec_code(space, w_globals, w_globals)
def dummy_prepare_file_argument(space, fileobj): # call load_cffi1_module() too, from a random place like here cffi1_module.load_cffi1_module(space, "foo", "foo", 42) return lltype.nullptr(rffi.CCHARP.TO)