1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:57:44 +00:00

AK: Rename Stream::read_entire_buffer to Stream::read_until_filled

No functional changes.
This commit is contained in:
Tim Schumacher 2023-03-01 15:27:35 +01:00 committed by Linus Groh
parent d5871f5717
commit a3f73e7d85
31 changed files with 58 additions and 58 deletions

View file

@ -210,7 +210,7 @@ struct ConvertToRaw<float> {
LittleEndian<u32> res;
ReadonlyBytes bytes { &value, sizeof(float) };
FixedMemoryStream stream { bytes };
stream.read_entire_buffer(res.bytes()).release_value_but_fixme_should_propagate_errors();
stream.read_until_filled(res.bytes()).release_value_but_fixme_should_propagate_errors();
return static_cast<u32>(res);
}
};
@ -222,7 +222,7 @@ struct ConvertToRaw<double> {
LittleEndian<u64> res;
ReadonlyBytes bytes { &value, sizeof(double) };
FixedMemoryStream stream { bytes };
stream.read_entire_buffer(res.bytes()).release_value_but_fixme_should_propagate_errors();
stream.read_until_filled(res.bytes()).release_value_but_fixme_should_propagate_errors();
return static_cast<u64>(res);
}
};
@ -260,7 +260,7 @@ T BytecodeInterpreter::read_value(ReadonlyBytes data)
{
LittleEndian<T> value;
FixedMemoryStream stream { data };
auto maybe_error = stream.read_entire_buffer(value.bytes());
auto maybe_error = stream.read_until_filled(value.bytes());
if (maybe_error.is_error()) {
dbgln("Read from {} failed", data.data());
m_trap = Trap { "Read from memory failed" };
@ -273,7 +273,7 @@ float BytecodeInterpreter::read_value<float>(ReadonlyBytes data)
{
LittleEndian<u32> raw_value;
FixedMemoryStream stream { data };
auto maybe_error = stream.read_entire_buffer(raw_value.bytes());
auto maybe_error = stream.read_until_filled(raw_value.bytes());
if (maybe_error.is_error())
m_trap = Trap { "Read from memory failed" };
return bit_cast<float>(static_cast<u32>(raw_value));
@ -284,7 +284,7 @@ double BytecodeInterpreter::read_value<double>(ReadonlyBytes data)
{
LittleEndian<u64> raw_value;
FixedMemoryStream stream { data };
auto maybe_error = stream.read_entire_buffer(raw_value.bytes());
auto maybe_error = stream.read_until_filled(raw_value.bytes());
if (maybe_error.is_error())
m_trap = Trap { "Read from memory failed" };
return bit_cast<double>(static_cast<u64>(raw_value));

View file

@ -89,7 +89,7 @@ void Configuration::dump_stack()
AllocatingMemoryStream memory_stream;
Printer { memory_stream }.print(vs...);
auto buffer = ByteBuffer::create_uninitialized(memory_stream.used_buffer_size()).release_value_but_fixme_should_propagate_errors();
memory_stream.read_entire_buffer(buffer).release_value_but_fixme_should_propagate_errors();
memory_stream.read_until_filled(buffer).release_value_but_fixme_should_propagate_errors();
dbgln(format.view(), StringView(buffer).trim_whitespace());
};
for (auto const& entry : stack().entries()) {

View file

@ -64,7 +64,7 @@ static auto parse_vector(Stream& stream)
if (count > Constants::max_allowed_vector_size)
return ParseResult<Vector<T>> { ParseError::HugeAllocationRequested };
entries.resize(count);
if (stream.read_entire_buffer({ entries.data(), entries.size() }).is_error())
if (stream.read_until_filled({ entries.data(), entries.size() }).is_error())
return ParseResult<Vector<T>> { with_eof_check(stream, ParseError::InvalidInput) };
break; // Note: We read this all in one go!
}
@ -486,7 +486,7 @@ ParseResult<Vector<Instruction>> Instruction::parse(Stream& stream, InstructionP
case Instructions::f32_const.value(): {
// op literal
LittleEndian<u32> value;
if (stream.read_entire_buffer(value.bytes()).is_error())
if (stream.read_until_filled(value.bytes()).is_error())
return with_eof_check(stream, ParseError::ExpectedFloatingImmediate);
auto floating = bit_cast<float>(static_cast<u32>(value));
@ -496,7 +496,7 @@ ParseResult<Vector<Instruction>> Instruction::parse(Stream& stream, InstructionP
case Instructions::f64_const.value(): {
// op literal
LittleEndian<u64> value;
if (stream.read_entire_buffer(value.bytes()).is_error())
if (stream.read_until_filled(value.bytes()).is_error())
return with_eof_check(stream, ParseError::ExpectedFloatingImmediate);
auto floating = bit_cast<double>(static_cast<u64>(value));
@ -1276,12 +1276,12 @@ ParseResult<Module> Module::parse(Stream& stream)
{
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Module"sv);
u8 buf[4];
if (stream.read_entire_buffer({ buf, 4 }).is_error())
if (stream.read_until_filled({ buf, 4 }).is_error())
return with_eof_check(stream, ParseError::InvalidInput);
if (Bytes { buf, 4 } != wasm_magic.span())
return with_eof_check(stream, ParseError::InvalidModuleMagic);
if (stream.read_entire_buffer({ buf, 4 }).is_error())
if (stream.read_until_filled({ buf, 4 }).is_error())
return with_eof_check(stream, ParseError::InvalidInput);
if (Bytes { buf, 4 } != wasm_version.span())
return with_eof_check(stream, ParseError::InvalidModuleVersion);