Example #1
0
 def test_struct_fields_float(self):
     POINT = lltype.Struct('POINT', ('x', rffi.DOUBLE), ('y', rffi.DOUBLE))
     y_ofs = 8
     p = lltype.malloc(POINT, flavor='raw')
     p.x = 123.4
     p.y = 567.8
     addr = rffi.cast(rffi.VOIDP, p)
     assert struct_getfield_float(types.double, addr, 0) == 123.4
     assert struct_getfield_float(types.double, addr, y_ofs) == 567.8
     #
     struct_setfield_float(types.double, addr, 0, 321.0)
     struct_setfield_float(types.double, addr, y_ofs, 876.5)
     assert p.x == 321.0
     assert p.y == 876.5
     #
     lltype.free(p, flavor='raw')
Example #2
0
 def test_struct_fields_float(self):
     POINT = lltype.Struct('POINT',
                           ('x', rffi.DOUBLE),
                           ('y', rffi.DOUBLE)
                           )
     y_ofs = 8
     p = lltype.malloc(POINT, flavor='raw')
     p.x = 123.4
     p.y = 567.8
     addr = rffi.cast(rffi.VOIDP, p)
     assert struct_getfield_float(types.double, addr, 0) == 123.4
     assert struct_getfield_float(types.double, addr, y_ofs) == 567.8
     #
     struct_setfield_float(types.double, addr, 0, 321.0)
     struct_setfield_float(types.double, addr, y_ofs, 876.5)
     assert p.x == 321.0
     assert p.y == 876.5
     #
     lltype.free(p, flavor='raw')
Example #3
0
 def handle_float(self, w_ffitype, w_obj, floatval):
     libffi.struct_setfield_float(w_ffitype.get_ffitype(),
                                  self.rawmem, self.offset, floatval)
Example #4
0
 def handle_float(self, w_ffitype, w_obj, floatval):
     libffi.struct_setfield_float(w_ffitype.get_ffitype(), self.rawmem,
                                  self.offset, floatval)