Beispiel #1
0
    def __init__(self,
                 name,
                 mode=DEFAULT_MODE,
                 handle=None,
                 use_errno=False,
                 use_last_error=False):
        self._name = name
        flags = self._func_flags_
        if use_errno:
            flags |= _FUNCFLAG_USE_ERRNO
        if use_last_error:
            flags |= _FUNCFLAG_USE_LASTERROR

        class _FuncPtr(_CFuncPtr):
            _flags_ = flags
            _restype_ = self._func_restype_

        self._FuncPtr = _FuncPtr

        if handle is None:
            if flags & _FUNCFLAG_CDECL:
                self._handle = _ffi.CDLL(name, mode)
            else:
                self._handle = _ffi.WinDLL(name, mode)
        else:
            self._handle = handle
    def __init__(self, name, mode=DEFAULT_MODE, handle=None,
                 use_errno=False,
                 use_last_error=False):
        self._name = name
        flags = self._func_flags_
        if use_errno:
            flags |= _FUNCFLAG_USE_ERRNO
        if use_last_error:
            flags |= _FUNCFLAG_USE_LASTERROR

        class _FuncPtr(_CFuncPtr):
            _flags_ = flags
            _restype_ = self._func_restype_
        self._FuncPtr = _FuncPtr

        if handle is None:
            handle = 0
        if flags & _FUNCFLAG_CDECL:
            pypy_dll = _ffi.CDLL(name, mode, handle)
        else:
            pypy_dll = _ffi.WinDLL(name, mode, handle)
        self.__pypy_dll__ = pypy_dll
        handle = int(pypy_dll)
        if _sys.maxint > 2 ** 32:
            handle = int(handle)   # long -> int
        self._handle = handle
Beispiel #3
0
    def __init__(self,
                 name,
                 mode=DEFAULT_MODE,
                 handle=None,
                 use_errno=False,
                 use_last_error=False):
        self._name = name
        flags = self._func_flags_
        if use_errno:
            flags |= _FUNCFLAG_USE_ERRNO
        if use_last_error:
            flags |= _FUNCFLAG_USE_LASTERROR
        if _sys.platform.startswith("aix"):
            """When the name contains ".a(" and ends with ")",
               e.g., "libFOO.a(libFOO.so)" - this is taken to be an
               archive(member) syntax for dlopen(), and the mode is adjusted.
               Otherwise, name is presented to dlopen() as a file argument.
            """
            if name and name.endswith(")") and ".a(" in name:
                mode |= (_os.RTLD_MEMBER | _os.RTLD_NOW)

        class _FuncPtr(_CFuncPtr):
            _flags_ = flags
            _restype_ = self._func_restype_

        self._FuncPtr = _FuncPtr

        if handle is None:
            if flags & _FUNCFLAG_CDECL:
                pypy_dll = _ffi.CDLL(name, mode)
            else:
                pypy_dll = _ffi.WinDLL(name, mode)
            self.__pypy_dll__ = pypy_dll
            handle = int(pypy_dll)
        self._handle = handle