예제 #1
0
파일: ctypefunc.py 프로젝트: Darriall/pypy
    def __init__(self, space, fargs, fresult, ellipsis):
        extra = self._compute_extra_text(fargs, fresult, ellipsis)
        size = rffi.sizeof(rffi.VOIDP)
        W_CTypePtrBase.__init__(self, space, size, extra, 2, fresult,
                                could_cast_anything=False)
        self.fargs = fargs
        self.ellipsis = bool(ellipsis)
        # fresult is stored in self.ctitem

        if not ellipsis:
            # Functions with '...' varargs are stored without a cif_descr
            # at all.  The cif is computed on every call from the actual
            # types passed in.  For all other functions, the cif_descr
            # is computed here.
            builder = CifDescrBuilder(fargs, fresult)
            try:
                builder.rawallocate(self)
            except OperationError, e:
                if not e.match(space, space.w_NotImplementedError):
                    raise
                # else, eat the NotImplementedError.  We will get the
                # exception if we see an actual call
                if self.cif_descr:   # should not be True, but you never know
                    lltype.free(self.cif_descr, flavor='raw')
                    self.cif_descr = lltype.nullptr(CIF_DESCRIPTION)
예제 #2
0
    def __init__(self, space, fargs, fresult, ellipsis, abi=FFI_DEFAULT_ABI):
        assert isinstance(ellipsis, bool)
        extra, xpos = self._compute_extra_text(fargs, fresult, ellipsis, abi)
        size = rffi.sizeof(rffi.VOIDP)
        W_CTypePtrBase.__init__(self, space, size, extra, xpos, fresult)
        self.fargs = fargs
        self.ellipsis = ellipsis
        self.abi = abi
        # fresult is stored in self.ctitem

        if not ellipsis:
            # Functions with '...' varargs are stored without a cif_descr
            # at all.  The cif is computed on every call from the actual
            # types passed in.  For all other functions, the cif_descr
            # is computed here.
            builder = CifDescrBuilder(fargs, fresult, abi)
            try:
                builder.rawallocate(self)
            except OperationError as e:
                if not e.match(space, space.w_NotImplementedError):
                    raise
                # else, eat the NotImplementedError.  We will get the
                # exception if we see an actual call
                if self.cif_descr:  # should not be True, but you never know
                    lltype.free(self.cif_descr, flavor='raw')
                    self.cif_descr = lltype.nullptr(CIF_DESCRIPTION)
예제 #3
0
파일: ctypefunc.py 프로젝트: kipras/pypy
    def __init__(self, space, fargs, fresult, ellipsis):
        extra = self._compute_extra_text(fargs, fresult, ellipsis)
        size = rffi.sizeof(rffi.VOIDP)
        W_CTypePtrBase.__init__(self, space, size, extra, 2, fresult, could_cast_anything=False)
        self.fargs = fargs
        self.ellipsis = bool(ellipsis)
        # fresult is stored in self.ctitem

        if not ellipsis:
            # Functions with '...' varargs are stored without a cif_descr
            # at all.  The cif is computed on every call from the actual
            # types passed in.  For all other functions, the cif_descr
            # is computed here.
            CifDescrBuilder(fargs, fresult).rawallocate(self)
예제 #4
0
 def _fget(self, attrchar):
     if attrchar == 'a':  # args
         return self.space.newtuple([a for a in self.fargs])
     if attrchar == 'r':  # result
         return self.ctitem
     if attrchar == 'E':  # ellipsis
         return self.space.newbool(self.ellipsis)
     if attrchar == 'A':  # abi
         return self.space.newint(self.abi)
     return W_CTypePtrBase._fget(self, attrchar)
예제 #5
0
파일: ctypefunc.py 프로젝트: kipras/pypy
 def _fget(self, attrchar):
     if attrchar == "a":  # args
         return self.space.newtuple([self.space.wrap(a) for a in self.fargs])
     if attrchar == "r":  # result
         return self.space.wrap(self.ctitem)
     if attrchar == "E":  # ellipsis
         return self.space.wrap(self.ellipsis)
     if attrchar == "A":  # abi
         return self.space.wrap(clibffi.FFI_DEFAULT_ABI)  # XXX
     return W_CTypePtrBase._fget(self, attrchar)
예제 #6
0
 def _fget(self, attrchar):
     if attrchar == 'a':    # args
         return self.space.newtuple([self.space.wrap(a)
                                     for a in self.fargs])
     if attrchar == 'r':    # result
         return self.space.wrap(self.ctitem)
     if attrchar == 'E':    # ellipsis
         return self.space.wrap(self.ellipsis)
     if attrchar == 'A':    # abi
         return self.space.wrap(self.abi)
     return W_CTypePtrBase._fget(self, attrchar)
예제 #7
0
 def _fget(self, attrchar):
     if attrchar == 'a':  # args
         return self.space.newtuple(
             [self.space.wrap(a) for a in self.fargs])
     if attrchar == 'r':  # result
         return self.space.wrap(self.ctitem)
     if attrchar == 'E':  # ellipsis
         return self.space.wrap(self.ellipsis)
     if attrchar == 'A':  # abi
         return self.space.wrap(clibffi.FFI_DEFAULT_ABI)  # XXX
     return W_CTypePtrBase._fget(self, attrchar)