Example #1
0
 def test_struct_fields_singlefloat(self):
     POINT = lltype.Struct('POINT',
                           ('x', rffi.FLOAT),
                           ('y', rffi.FLOAT)
                           )
     y_ofs = 4
     p = lltype.malloc(POINT, flavor='raw')
     p.x = r_singlefloat(123.4)
     p.y = r_singlefloat(567.8)
     addr = rffi.cast(rffi.VOIDP, p)
     assert struct_getfield_singlefloat(types.double, addr, 0) == r_singlefloat(123.4)
     assert struct_getfield_singlefloat(types.double, addr, y_ofs) == r_singlefloat(567.8)
     #
     struct_setfield_singlefloat(types.double, addr, 0, r_singlefloat(321.0))
     struct_setfield_singlefloat(types.double, addr, y_ofs, r_singlefloat(876.5))
     assert p.x == r_singlefloat(321.0)
     assert p.y == r_singlefloat(876.5)
     #
     lltype.free(p, flavor='raw')
Example #2
0
 def test_struct_fields_singlefloat(self):
     POINT = lltype.Struct('POINT', ('x', rffi.FLOAT), ('y', rffi.FLOAT))
     y_ofs = 4
     p = lltype.malloc(POINT, flavor='raw')
     p.x = r_singlefloat(123.4)
     p.y = r_singlefloat(567.8)
     addr = rffi.cast(rffi.VOIDP, p)
     assert struct_getfield_singlefloat(types.double, addr,
                                        0) == r_singlefloat(123.4)
     assert struct_getfield_singlefloat(types.double, addr,
                                        y_ofs) == r_singlefloat(567.8)
     #
     struct_setfield_singlefloat(types.double, addr, 0,
                                 r_singlefloat(321.0))
     struct_setfield_singlefloat(types.double, addr, y_ofs,
                                 r_singlefloat(876.5))
     assert p.x == r_singlefloat(321.0)
     assert p.y == r_singlefloat(876.5)
     #
     lltype.free(p, flavor='raw')
Example #3
0
 def handle_singlefloat(self, w_ffitype, w_obj, singlefloatval):
     libffi.struct_setfield_singlefloat(w_ffitype.get_ffitype(),
                                        self.rawmem, self.offset, singlefloatval)
Example #4
0
 def handle_singlefloat(self, w_ffitype, w_obj, singlefloatval):
     libffi.struct_setfield_singlefloat(w_ffitype.get_ffitype(),
                                        self.rawmem, self.offset,
                                        singlefloatval)