def execute(self, space, cppmethod, cppthis, num_args, args): if hasattr(space, "fake"): raise NotImplementedError lresult = capi.c_call_l(cppmethod, cppthis, num_args, args) address = rffi.cast(rffi.ULONG, lresult) arr = space.interp_w(W_Array, unpack_simple_shape(space, space.wrap(self.typecode))) return arr.fromaddress(space, address, sys.maxint)
def __getattr__(self, name): if name.startswith('array_'): typecode = name[len('array_'):] arr = self.space.interp_w(W_Array, unpack_simple_shape(self.space, self.space.wrap(typecode))) setattr(self, name, arr) return arr raise AttributeError(name)
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)
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 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) address = rffi.cast(rffi.ULONG, lresult) arr = space.interp_w(W_Array, unpack_simple_shape(space, space.wrap(self.typecode))) if address == 0: # TODO: fix this hack; fromaddress() will allocate memory if address # is null and there seems to be no way around it (ll_buffer can not # be touched directly) nullarr = arr.fromaddress(space, address, 0) assert isinstance(nullarr, W_ArrayInstance) nullarr.free(space) return nullarr return arr.fromaddress(space, address, sys.maxint)