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.wrap(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)
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)
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.wrap(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)
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)))