示例#1
0
def load_backend(space):
    state = space.fromcache(State)
    if state.backend is None:
        from pypy.module._cffi_backend.libraryobj import W_Library
        if os.environ.get('CPPYY_BACKEND_LIBRARY'):
            libname = os.environ['CPPYY_BACKEND_LIBRARY']
            state.backend = W_Library(space, space.newtext(libname), dldflags)
        else:
            # try usual lookups
            try:
                if backend_library[-len(backend_ext):] == backend_ext:
                    fullname = backend_library
                else:
                    fullname = backend_library + backend_ext
                state.backend = W_Library(space, space.newtext(fullname),
                                          dldflags)
            except Exception as e:
                # TODO: where to find the value '.pypy-41'? Note that this only matters for testing.
                state.backend = W_Library(
                    space,
                    space.newtext(backend_library + '.pypy-41' + backend_ext),
                    dldflags)

        if state.backend:
            # fix constants
            state.c_sizeof_farg = _cdata_to_size_t(
                space, call_capi(space, 'function_arg_sizeof', []))
            state.c_offset_farg = _cdata_to_size_t(
                space, call_capi(space, 'function_arg_typeoffset', []))
示例#2
0
def load_backend(space):
    state = space.fromcache(State)
    if state.backend is None:
        from pypy.module._cffi_backend.libraryobj import W_Library
        if os.environ.get('CPPYY_BACKEND_LIBRARY'):
            libname = os.environ['CPPYY_BACKEND_LIBRARY']
            state.backend = W_Library(space, space.newtext(libname), dldflags)
        else:
            # try usual lookups
            try:
                if backend_library[-len(backend_ext):] == backend_ext:
                    fullname = backend_library
                else:
                    fullname = backend_library + backend_ext
                state.backend = W_Library(space, space.newtext(fullname),
                                          dldflags)
            except Exception as e:
                soabi = space.config.objspace.soabi
                if soabi is None:
                    soabi = '.pypy-%d%d' % PYPY_VERSION[:2]
                state.backend = W_Library(
                    space,
                    space.newtext(backend_library + soabi + backend_ext),
                    dldflags)

        if state.backend:
            # fix constants
            state.c_sizeof_farg = _cdata_to_size_t(
                space, call_capi(space, 'function_arg_sizeof', []))
            state.c_offset_farg = _cdata_to_size_t(
                space, call_capi(space, 'function_arg_typeoffset', []))
示例#3
0
def load_backend(space):
    state = space.fromcache(State)
    if state.backend is None:
        from pypy.module._cffi_backend.libraryobj import W_Library
        dldflags = rdynload.RTLD_LOCAL | rdynload.RTLD_LAZY
        if os.environ.get('CPPYY_BACKEND_LIBRARY'):
            libname = os.environ['CPPYY_BACKEND_LIBRARY']
            state.backend = W_Library(space, libname, dldflags)
        else:
            # try usual lookups
            state.backend = W_Library(space, backend_library, dldflags)

        if state.backend:
            # fix constants
            state.c_sizeof_farg = _cdata_to_size_t(
                space, call_capi(space, 'function_arg_sizeof', []))
            state.c_offset_farg = _cdata_to_size_t(
                space, call_capi(space, 'function_arg_typeoffset', []))
示例#4
0
def load_reflection_library(space):
    state = space.fromcache(State)
    if state.library is None:
        from pypy.module._cffi_backend.libraryobj import W_Library
        state.library = W_Library(space, reflection_library,
                                  rdynload.RTLD_LOCAL | rdynload.RTLD_LAZY)
        if state.library:
            # fix constants
            state.c_sizeof_farg = _cdata_to_size_t(
                space, call_capi(space, 'function_arg_sizeof', []))
            state.c_offset_farg = _cdata_to_size_t(
                space, call_capi(space, 'function_arg_typeoffset', []))
    return state.library