def load(self, offset, copy): for rtype in floating_types: if self.size == rffi.sizeof(rtype): return Float( rffi.cast(rffi.DOUBLE, rffi.cast(rffi.CArrayPtr(rtype), offset)[0])) else: raise unwind(LTypeError(u"undefined ffi type: %s" % self.repr()))
def load(self, offset, copy): for rtype in signed_types: if self.size == rffi.sizeof(rtype): return Integer( rffi.cast(rffi.LONG, rffi.cast(rffi.CArrayPtr(rtype), offset)[0])) else: raise unwind(LTypeError(u"undefined ffi type: %s" % self.repr()))
def sizeof_a(tp, n): assert isinstance(tp, Type) if tp.size == 0 or tp.align == 0: raise unwind(LTypeError(u"cannot determine size of opaque type")) if tp.parameter is not None: return tp.size + sizeof(tp.parameter) * n else: return tp.size * n
def store(self, pool, offset, value): for rtype in signed_types: if self.size == rffi.sizeof(rtype): pnt = rffi.cast(rffi.CArrayPtr(rtype), offset) pnt[0] = rffi.cast(rtype, to_int(value)) break else: raise unwind(LTypeError(u"undefined ffi type: %s" % self.repr())) return value
def store(self, pool, offset, value): number = to_float(value) for rtype in floating_types: if self.size == rffi.sizeof(rtype): pnt = rffi.cast(rffi.CArrayPtr(rtype), offset) pnt[0] = rffi.cast(rtype, number) break else: raise unwind(LTypeError(u"undefined ffi type: %s" % self.repr())) return value
def cast_to_ffitype(self): for rtype in signed_types: if self.size == rffi.sizeof(rtype): return clibffi.cast_type_to_ffitype(rtype) else: raise unwind(LTypeError(u"undefined ffi type: %s" % self.repr()))
def sizeof(tp): assert isinstance(tp, Type) if tp.size == 0 or tp.align == 0: raise unwind(LTypeError(u"cannot determine size of opaque type")) return tp.size
def store(self, pool, offset, value): raise unwind(LTypeError(u".store method missing"))
def load(self, offset, copy): raise unwind(LTypeError(u".load method missing"))
def cast_to_ffitype(self): raise unwind(LTypeError(u".cast_to_ffitype method missing"))