gmp-utils: Convert the read/write methods to using gdb::array_view
This commit changes the interfaces of some of the methods declared in gmp-utils to take a gdb::array_view of gdb_byte instead of a (gdb_byte *, size) couple. This makes these methods' API probably more C++-idiomatic. * gmp-utils.h (gdb_mpz::read): Change buf and len parameters into one single gdb::array_view parameter. (gdb_mpz::write): Likewise. (gdb_mpq::read_fixed_point, gdb_mpq::write_fixed_point): Likewise. * gmp-utils.c (gdb_mpz::read): Change buf and len parameters into one single gdb::array_view parameter. Adjust implementation accordingly. (gdb_mpz::write): Likewise. (gdb_mpq::read_fixed_point, gdb_mpq::write_fixed_point): Likewise. * unittests/gmp-utils-selftests.c: Adapt following changes above. * valarith.c, valops.c, valprint.c, value.c: Likewise.
This commit is contained in:
parent
987b670356
commit
c9f0b43fe4
8 changed files with 68 additions and 43 deletions
10
gdb/valops.c
10
gdb/valops.c
|
@ -357,7 +357,8 @@ value_cast_to_fixed_point (struct type *to_type, struct value *from_val)
|
|||
{
|
||||
gdb_mpz vz;
|
||||
|
||||
vz.read (value_contents (from_val), TYPE_LENGTH (from_type),
|
||||
vz.read (gdb::make_array_view (value_contents (from_val),
|
||||
TYPE_LENGTH (from_type)),
|
||||
type_byte_order (from_type), from_type->is_unsigned ());
|
||||
mpq_set_z (vq.val, vz.val);
|
||||
|
||||
|
@ -378,8 +379,9 @@ value_cast_to_fixed_point (struct type *to_type, struct value *from_val)
|
|||
/* Finally, create the result value, and pack the unscaled value
|
||||
in it. */
|
||||
struct value *result = allocate_value (to_type);
|
||||
unscaled.write (value_contents_raw (result),
|
||||
TYPE_LENGTH (to_type), type_byte_order (to_type),
|
||||
unscaled.write (gdb::make_array_view (value_contents_raw (result),
|
||||
TYPE_LENGTH (to_type)),
|
||||
type_byte_order (to_type),
|
||||
to_type->is_unsigned ());
|
||||
|
||||
return result;
|
||||
|
@ -523,7 +525,7 @@ value_cast (struct type *type, struct value *arg2)
|
|||
gdb_mpq fp_val;
|
||||
|
||||
fp_val.read_fixed_point
|
||||
(value_contents (arg2), TYPE_LENGTH (type2),
|
||||
(gdb::make_array_view (value_contents (arg2), TYPE_LENGTH (type2)),
|
||||
type_byte_order (type2), type2->is_unsigned (),
|
||||
fixed_point_scaling_factor (type2));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue