def inttype(self, name, c_name, signed, **kwds): try: return self.types[name] except KeyError: bits = sizeof_c_type(c_name, **kwds) * 8 inttype = rarithmetic.build_int('r_' + name, signed, bits) tp = lltype.build_number(name, inttype) self.numbertype_to_rclass[tp] = inttype self.types[name] = tp return tp
def setup(): for _name in 'byte short int long longlong'.split(): for name in (_name, 'u' + _name): c_type = getattr(ctypes, 'c_' + name) sign, bits = c_type_size(c_type) inttype = rarithmetic.build_int('rc' + name, sign, bits) globals()['rc'+name] = inttype if name[0] == 'u': llname = 'CU' + name[1:].title() else: llname = 'C' + name.title() globals()[llname] = lltype.build_number(llname, inttype)
def setup(): """ creates necessary c-level types """ from pypy.rpython.lltypesystem.rfficache import platform for name, bits in platform.items(): if name.startswith('unsigned'): name = 'u' + name[9:] signed = False else: signed = True name = name.replace(' ', '') llname = name.upper() inttype = rarithmetic.build_int('r_' + name, signed, bits) globals()['r_' + name] = inttype globals()[llname] = lltype.build_number(llname, inttype)
""" creates necessary c-level types """ names = populate_inttypes() result = [] for name in names: tp = platform.types[name.upper()] globals()['r_' + name] = platform.numbertype_to_rclass[tp] globals()[name.upper()] = tp tpp = lltype.Ptr(lltype.Array(tp, hints={'nolength': True})) globals()[name.upper()+'P'] = tpp result.append(tp) return result NUMBER_TYPES = setup() platform.numbertype_to_rclass[lltype.Signed] = int # avoid "r_long" for common cases r_int_real = rarithmetic.build_int("r_int_real", r_int.SIGN, r_int.BITS, True) INT_real = lltype.build_number("INT", r_int_real) platform.numbertype_to_rclass[INT_real] = r_int_real NUMBER_TYPES.append(INT_real) # ^^^ this creates at least the following names: # -------------------------------------------------------------------- # Type RPython integer class doing wrap-around # -------------------------------------------------------------------- # SIGNEDCHAR r_signedchar # UCHAR r_uchar # SHORT r_short # USHORT r_ushort # INT r_int # UINT r_uint # LONG r_long
def _make_type(self, name, signed, size): inttype = rarithmetic.build_int('r_' + name, signed, size * 8) tp = lltype.build_number(name, inttype) self.numbertype_to_rclass[tp] = inttype self.types[name] = tp return tp
def _make_type(self, name, signed, size): inttype = rarithmetic.build_int('r_' + name, signed, size*8) tp = lltype.build_number(name, inttype) self.numbertype_to_rclass[tp] = inttype self.types[name] = tp return tp