Ejemplo n.º 1
0
 def convert_to_object(self, cdata):
     if self.value_fits_long:
         value = misc.read_raw_long_data(cdata, self.size)
         return self.space.wrap(value)
     else:
         value = misc.read_raw_signed_data(cdata, self.size)
         return self.space.wrap(value)  # r_longlong => on 32-bit, 'long'
Ejemplo n.º 2
0
 def test_it_writes_nothing_and_returns_None(self, space):
     data = lltype.malloc(rffi.CCHARP.TO, 1, flavor='raw')
     misc.write_raw_signed_data(data, 11, 1)
     w_void_type = ffitype.VoidRWStrategy()
     res = w_void_type.write(space, data, 0)
     assert misc.read_raw_signed_data(data, 1) == 11
     assert res is None
     lltype.free(data, flavor='raw')
Ejemplo n.º 3
0
 def test_it_writes_nothing_and_returns_None(self, space):
     data = lltype.malloc(rffi.CCHARP.TO, 1, flavor='raw')
     misc.write_raw_signed_data(data, 11, 1)
     w_void_type = ffitype.VoidRWStrategy()
     res = w_void_type.write(space, data, 0)
     assert misc.read_raw_signed_data(data, 1) == 11
     assert res is None
     lltype.free(data, flavor='raw')
Ejemplo n.º 4
0
 def test_it_writes_signed_types_to_buffer(self, space):
     for t in [
             ffitype.INT8, ffitype.INT16, ffitype.INT32, ffitype.INT64,
             ffitype.LONG
     ]:
         w_signed_type = ffitype.SignedRWStrategy(t)
         size = w_signed_type.typesize
         # make new buffer for every t
         data = lltype.malloc(rffi.CCHARP.TO, size, flavor='raw')
         w_i = space.newint(-18)
         w_signed_type.write(space, data, w_i)
         raw_res = misc.read_raw_signed_data(data, size)
         assert raw_res == -18
         lltype.free(data, flavor='raw')
Ejemplo n.º 5
0
 def test_it_writes_signed_types_to_buffer(self, space):
     for t in [ffitype.INT8,
               ffitype.INT16,
               ffitype.INT32,
               ffitype.INT64,
               ffitype.LONG]:
         w_signed_type = ffitype.SignedRWStrategy(t)
         size = w_signed_type.typesize
         # make new buffer for every t
         data = lltype.malloc(rffi.CCHARP.TO, size, flavor='raw')
         w_i = space.newint(-18)
         w_signed_type.write(space, data, w_i)
         raw_res = misc.read_raw_signed_data(data, size)
         assert raw_res == -18
         lltype.free(data, flavor='raw')
Ejemplo n.º 6
0
 def _convert_to_object_longlong(self, cdata):
     # in its own function: LONGLONG may make the whole function jit-opaque
     value = misc.read_raw_signed_data(cdata, self.size)
     return self.space.wrap(value)    # r_longlong => on 32-bit, 'long'
Ejemplo n.º 7
0
Archivo: type.py Proyecto: mswart/topaz
 def read(self, space, data):
     result = misc.read_raw_signed_data(data, self.typesize)
     return space.newint(intmask(result))
Ejemplo n.º 8
0
Archivo: type.py Proyecto: mswart/topaz
 def read(self, space, data):
     result = bool(misc.read_raw_signed_data(data, self.typesize))
     return space.newbool(result)
Ejemplo n.º 9
0
 def _nonzero_longlong(self, cdata):
     # in its own function: LONGLONG may make the whole function jit-opaque
     value = misc.read_raw_signed_data(cdata, self.size)
     return bool(value)
Ejemplo n.º 10
0
 def _nonzero_longlong(self, cdata):
     # in its own function: LONGLONG may make the whole function jit-opaque
     value = misc.read_raw_signed_data(cdata, self.size)
     return bool(value)