Example #1
0
 def from_memory(self, space, w_obj, w_pycppclass, offset):
     # returned as a long value for the address (INTPTR_T is not proper
     # per se, but rffi does not come with a PTRDIFF_T)
     address = self._get_raw_address(space, w_obj, offset)
     ptrval = rffi.cast(rffi.ULONG, rffi.cast(rffi.VOIDPP, address)[0])
     if ptrval == 0:
         from pypy.module._cppyy import interp_cppyy
         return interp_cppyy.get_nullptr(space)
     arr = space.interp_w(W_Array, letter2tp(space, 'P'))
     return arr.fromaddress(space, ptrval, sys.maxint)
Example #2
0
 def execute(self, space, cppmethod, cppthis, num_args, args):
     if hasattr(space, "fake"):
         raise NotImplementedError
     lresult = capi.c_call_l(space, cppmethod, cppthis, num_args, args)
     ptrval = rffi.cast(rffi.ULONG, lresult)
     arr = space.interp_w(W_Array, unpack_simple_shape(space, space.newtext(self.typecode)))
     if ptrval == 0:
         from pypy.module._cppyy import interp_cppyy
         return interp_cppyy.get_nullptr(space)
     return arr.fromaddress(space, ptrval, sys.maxint)
Example #3
0
 def from_memory(self, space, w_obj, offset):
     # returned as a long value for the address (INTPTR_T is not proper
     # per se, but rffi does not come with a PTRDIFF_T)
     address = self._get_raw_address(space, w_obj, offset)
     ptrval = rffi.cast(rffi.ULONGP, address)[0]
     if ptrval == rffi.cast(rffi.ULONG, 0):
         from pypy.module._cppyy import interp_cppyy
         return interp_cppyy.get_nullptr(space)
     shape = letter2tp(space, 'P')
     return lowlevelviews.W_LowLevelView(space, shape, sys.maxint/shape.size, ptrval)
Example #4
0
 def execute(self, space, cppmethod, cppthis, num_args, args):
     if hasattr(space, "fake"):
         raise NotImplementedError
     lresult = capi.c_call_l(space, cppmethod, cppthis, num_args, args)
     ptrval = rffi.cast(rffi.ULONG, lresult)
     if ptrval == rffi.cast(rffi.ULONG, 0):
         from pypy.module._cppyy import interp_cppyy
         return interp_cppyy.get_nullptr(space)
     shape = letter2tp(space, self.typecode)
     return lowlevelviews.W_LowLevelView(space, shape,
                                         sys.maxint / shape.size, ptrval)
Example #5
0
def is_nullpointer_specialcase(space, w_obj):
    # 0 and nullptr may serve as "NULL"

    # integer 0
    try:
        return space.int_w(w_obj) == 0
    except Exception:
        pass
    # C++-style nullptr
    from pypy.module._cppyy import interp_cppyy
    return space.is_true(space.is_(w_obj, interp_cppyy.get_nullptr(space)))
Example #6
0
 def execute(self, space, cppmethod, cppthis, num_args, args):
     if hasattr(space, "fake"):
         raise NotImplementedError
     address = capi.c_call_r(space, cppmethod, cppthis, num_args, args)
     ipv = rffi.cast(rffi.UINTPTR_T, address)
     if ipv == rffi.cast(rffi.UINTPTR_T, 0):
         from pypy.module._cppyy import interp_cppyy
         return interp_cppyy.get_nullptr(space)
     shape = letter2tp(space, self.typecode)
     return lowlevelviews.W_LowLevelView(space, shape,
                                         sys.maxint / shape.size, ipv)
Example #7
0
def is_nullpointer_specialcase(space, w_obj):
    # 0, None, and nullptr may serve as "NULL", check for any of them

    # integer 0
    try:
        return space.int_w(w_obj) == 0
    except Exception:
        pass
    # None or nullptr
    from pypy.module._cppyy import interp_cppyy
    return space.is_true(space.is_(w_obj, space.w_None)) or \
        space.is_true(space.is_(w_obj, interp_cppyy.get_nullptr(space)))