Exemplo n.º 1
0
    def _call_funcptr(self, funcptr, *newargs):

        if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
            tmp = _rawffi.get_errno()
            _rawffi.set_errno(get_errno())
            set_errno(tmp)
        if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
            tmp = _rawffi.get_last_error()
            _rawffi.set_last_error(get_last_error())
            set_last_error(tmp)
        try:
            result = funcptr(*newargs)
        finally:
            if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
                tmp = _rawffi.get_errno()
                _rawffi.set_errno(get_errno())
                set_errno(tmp)
            if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
                tmp = _rawffi.get_last_error()
                _rawffi.set_last_error(get_last_error())
                set_last_error(tmp)
        #
        try:
            return self._build_result(self._restype_, result)
        finally:
            funcptr.free_temp_buffers()
Exemplo n.º 2
0
 def _call_funcptr(self, funcptr, *newargs):
     if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
         tmp = _rawffi.get_errno()
         _rawffi.set_errno(get_errno())
         set_errno(tmp)
     if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
         tmp = _rawffi.get_last_error()
         _rawffi.set_last_error(get_last_error())
         set_last_error(tmp)
     try:
         result = funcptr(*newargs)
     finally:
         if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
             tmp = _rawffi.get_errno()
             _rawffi.set_errno(get_errno())
             set_errno(tmp)
         if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
             tmp = _rawffi.get_last_error()
             _rawffi.set_last_error(get_last_error())
             set_last_error(tmp)
     #
     try:
         return self._build_result(self._restype_, result)
     finally:
         funcptr.free_temp_buffers()
Exemplo n.º 3
0
 def test_errno(self):
     import _rawffi
     lib = _rawffi.CDLL(self.lib_name)
     A = _rawffi.Array('i')
     f = lib.ptr('check_errno', ['i'], 'i')
     _rawffi.set_errno(42)
     arg = A(1)
     arg[0] = 43
     res = f(arg)
     assert res[0] == 42
     z = _rawffi.get_errno()
     assert z == 43
     arg.free()
Exemplo n.º 4
0
 def test_errno(self):
     import _rawffi
     lib = _rawffi.CDLL(self.lib_name)
     A = _rawffi.Array('i')
     f = lib.ptr('check_errno', ['i'], 'i')
     _rawffi.set_errno(42)
     arg = A(1)
     arg[0] = 43
     res = f(arg)
     assert res[0] == 42
     z = _rawffi.get_errno()
     assert z == 43
     arg.free()