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

AK: Deprecate the old AK::Stream

This also removes a few cases where the respective header wasn't
actually required to be included.
This commit is contained in:
Tim Schumacher 2023-01-20 14:07:24 +01:00 committed by Andrew Kaster
parent 230cb3b0cb
commit ae64b68717
38 changed files with 116 additions and 120 deletions

View file

@ -8,7 +8,6 @@
#include "Loader.h"
#include "MP3Types.h"
#include <AK/MemoryStream.h>
#include <AK/Tuple.h>
#include <LibCore/BitStream.h>
#include <LibCore/MemoryStream.h>

View file

@ -8,7 +8,6 @@
#pragma once
#include <AK/Function.h>
#include <AK/Stream.h>
#include <LibCore/Forward.h>
#include <LibCore/Object.h>
#include <LibCore/Stream.h>

View file

@ -704,7 +704,7 @@ ErrorOr<int> LocalSocket::release_fd()
return fd;
}
WrappedAKInputStream::WrappedAKInputStream(NonnullOwnPtr<InputStream> stream)
WrappedAKInputStream::WrappedAKInputStream(NonnullOwnPtr<DeprecatedInputStream> stream)
: m_stream(move(stream))
{
}
@ -746,7 +746,7 @@ void WrappedAKInputStream::close()
{
}
WrappedAKOutputStream::WrappedAKOutputStream(NonnullOwnPtr<OutputStream> stream)
WrappedAKOutputStream::WrappedAKOutputStream(NonnullOwnPtr<DeprecatedOutputStream> stream)
: m_stream(move(stream))
{
}

View file

@ -9,6 +9,7 @@
#include <AK/Badge.h>
#include <AK/CircularBuffer.h>
#include <AK/DeprecatedStream.h>
#include <AK/DeprecatedString.h>
#include <AK/EnumBits.h>
#include <AK/Function.h>
@ -1071,7 +1072,7 @@ using ReusableUDPSocket = BasicReusableSocket<UDPSocket>;
// Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
class WrappedAKInputStream final : public Stream {
public:
WrappedAKInputStream(NonnullOwnPtr<InputStream> stream);
WrappedAKInputStream(NonnullOwnPtr<DeprecatedInputStream> stream);
virtual ErrorOr<Bytes> read(Bytes) override;
virtual ErrorOr<void> discard(size_t discarded_bytes) override;
virtual ErrorOr<size_t> write(ReadonlyBytes) override;
@ -1080,13 +1081,13 @@ public:
virtual void close() override;
private:
NonnullOwnPtr<InputStream> m_stream;
NonnullOwnPtr<DeprecatedInputStream> m_stream;
};
// Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
class WrappedAKOutputStream final : public Stream {
public:
WrappedAKOutputStream(NonnullOwnPtr<OutputStream> stream);
WrappedAKOutputStream(NonnullOwnPtr<DeprecatedOutputStream> stream);
virtual ErrorOr<Bytes> read(Bytes) override;
virtual ErrorOr<size_t> write(ReadonlyBytes) override;
virtual bool is_eof() const override;
@ -1094,11 +1095,11 @@ public:
virtual void close() override;
private:
NonnullOwnPtr<OutputStream> m_stream;
NonnullOwnPtr<DeprecatedOutputStream> m_stream;
};
// Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
class WrapInAKInputStream final : public InputStream {
class WrapInAKInputStream final : public DeprecatedInputStream {
public:
WrapInAKInputStream(Core::Stream::Stream& stream);
virtual size_t read(Bytes) override;
@ -1111,7 +1112,7 @@ private:
};
// Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
class WrapInAKOutputStream final : public OutputStream {
class WrapInAKOutputStream final : public DeprecatedOutputStream {
public:
WrapInAKOutputStream(Core::Stream::Stream& stream);
virtual size_t write(ReadonlyBytes) override;

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedStream.h>
#include <AK/Try.h>
#include <AK/Utf8View.h>
#include <LibCrypto/ASN1/DER.h>
@ -223,7 +224,7 @@ Optional<DecodeError> Decoder::leave()
return {};
}
void pretty_print(Decoder& decoder, OutputStream& stream, int indent)
void pretty_print(Decoder& decoder, DeprecatedOutputStream& stream, int indent)
{
while (!decoder.eof()) {
auto tag = decoder.peek();

View file

@ -226,7 +226,7 @@ private:
Optional<Tag> m_current_tag;
};
void pretty_print(Decoder&, OutputStream&, int indent = 0);
void pretty_print(Decoder&, DeprecatedOutputStream&, int indent = 0);
}

View file

@ -6,7 +6,7 @@
#include <AK/ByteReader.h>
#include <AK/Debug.h>
#include <AK/MemoryStream.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/Types.h>
#include <LibCrypto/Authentication/GHash.h>
@ -47,7 +47,7 @@ GHash::TagType GHash::process(ReadonlyBytes aad, ReadonlyBytes cipher)
if (i > buf.size()) {
static u8 buffer[16];
Bytes buffer_bytes { buffer, 16 };
OutputMemoryStream stream { buffer_bytes };
DeprecatedOutputMemoryStream stream { buffer_bytes };
stream.write(buf.slice(i - 16));
stream.fill_to_end(0);

View file

@ -5,7 +5,6 @@
*/
#include "Answer.h"
#include <AK/Stream.h>
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
#include <time.h>

View file

@ -9,7 +9,6 @@
#include "Name.h"
#include "PacketHeader.h"
#include <AK/Debug.h>
#include <AK/MemoryStream.h>
#include <AK/StringBuilder.h>
#include <LibCore/MemoryStream.h>
#include <arpa/inet.h>

View file

@ -7,10 +7,10 @@
#include <AK/Bitmap.h>
#include <AK/Checked.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/Memory.h>
#include <AK/MemoryStream.h>
#include <AK/Optional.h>
#include <AK/Queue.h>
#include <AK/ScopeGuard.h>
@ -212,7 +212,7 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::create_from_serialized_byte_buffer(ByteBu
/// - image data (= actual size * u8)
ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::create_from_serialized_bytes(ReadonlyBytes bytes)
{
InputMemoryStream stream { bytes };
DeprecatedInputMemoryStream stream { bytes };
size_t actual_size;
unsigned width;
unsigned height;
@ -260,7 +260,7 @@ ByteBuffer Bitmap::serialize_to_byte_buffer() const
{
// FIXME: Somehow handle possible OOM situation here.
auto buffer = ByteBuffer::create_uninitialized(sizeof(size_t) + 4 * sizeof(unsigned) + sizeof(BitmapFormat) + sizeof(ARGB32) * palette_size(m_format) + size_in_bytes()).release_value_but_fixme_should_propagate_errors();
OutputMemoryStream stream { buffer };
DeprecatedOutputMemoryStream stream { buffer };
auto write = [&]<typename T>(T value) {
if (stream.write({ &value, sizeof(T) }) != sizeof(T))

View file

@ -5,10 +5,10 @@
*/
#include <AK/Debug.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/DeprecatedString.h>
#include <AK/Endian.h>
#include <AK/Error.h>
#include <AK/MemoryStream.h>
#include <AK/StringBuilder.h>
#include <AK/Try.h>
#include <AK/Vector.h>
@ -454,7 +454,7 @@ static size_t bits_per_pixel(DXGIFormat format)
}
}
static void decode_dx5_alpha_block(InputMemoryStream& stream, DDSLoadingContext& context, u64 bitmap_x, u64 bitmap_y)
static void decode_dx5_alpha_block(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, u64 bitmap_x, u64 bitmap_y)
{
LittleEndian<u8> color0 {}, color1 {};
LittleEndian<u8> code0 {}, code1 {}, code2 {}, code3 {}, code4 {}, code5 {};
@ -517,7 +517,7 @@ static void decode_dx5_alpha_block(InputMemoryStream& stream, DDSLoadingContext&
}
}
static void decode_dx3_alpha_block(InputMemoryStream& stream, DDSLoadingContext& context, u64 bitmap_x, u64 bitmap_y)
static void decode_dx3_alpha_block(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, u64 bitmap_x, u64 bitmap_y)
{
LittleEndian<u8> a0 {}, a1 {}, a2 {}, a3 {}, a4 {}, a5 {}, a6 {}, a7 {};
@ -565,7 +565,7 @@ static void unpack_rbg_565(u32 rgb, u8* output)
output[3] = 255;
}
static void decode_color_block(InputMemoryStream& stream, DDSLoadingContext& context, bool dxt1, u64 bitmap_x, u64 bitmap_y)
static void decode_color_block(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, bool dxt1, u64 bitmap_x, u64 bitmap_y)
{
LittleEndian<u8> c0_low {}, c0_high {}, c1_low {}, c1_high {};
LittleEndian<u8> codes_0 {}, codes_1 {}, codes_2 {}, codes_3 {};
@ -621,7 +621,7 @@ static void decode_color_block(InputMemoryStream& stream, DDSLoadingContext& con
}
}
static void decode_dxt(InputMemoryStream& stream, DDSLoadingContext& context, DXGIFormat format, u64 width, u64 y)
static void decode_dxt(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, DXGIFormat format, u64 width, u64 y)
{
if (format == DXGI_FORMAT_BC1_UNORM) {
for (size_t x = 0; x < width; x += 4) {
@ -643,7 +643,7 @@ static void decode_dxt(InputMemoryStream& stream, DDSLoadingContext& context, DX
}
}
}
static void decode_bitmap(InputMemoryStream& stream, DDSLoadingContext& context, DXGIFormat format, u64 width, u64 height)
static void decode_bitmap(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, DXGIFormat format, u64 width, u64 height)
{
Vector<u32> dxt_formats = { DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC3_UNORM };
if (dxt_formats.contains_slow(format)) {
@ -698,7 +698,7 @@ static size_t get_minimum_bytes_for_mipmap(DXGIFormat format, u64 width, u64 hei
static ErrorOr<void> decode_dds(DDSLoadingContext& context)
{
InputMemoryStream stream({ context.data, context.data_size });
DeprecatedInputMemoryStream stream({ context.data, context.data_size });
// All valid DDS files are at least 128 bytes long.
if (stream.remaining() < 128) {

View file

@ -6,6 +6,7 @@
#pragma once
#include <AK/Endian.h>
#include <AK/Span.h>
#include <AK/Vector.h>
#include <LibGfx/AffineTransform.h>

View file

@ -7,6 +7,7 @@
#include <AK/Array.h>
#include <AK/Debug.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/Error.h>
#include <AK/IntegralMath.h>
#include <AK/Memory.h>

View file

@ -6,7 +6,7 @@
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <AK/MemoryStream.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/Types.h>
#include <LibGfx/BMPLoader.h>
@ -59,7 +59,7 @@ struct ICOLoadingContext {
size_t largest_index;
};
static Optional<size_t> decode_ico_header(InputMemoryStream& stream)
static Optional<size_t> decode_ico_header(DeprecatedInputMemoryStream& stream)
{
ICONDIR header;
stream >> Bytes { &header, sizeof(header) };
@ -71,7 +71,7 @@ static Optional<size_t> decode_ico_header(InputMemoryStream& stream)
return { header.image_count };
}
static Optional<ICOImageDescriptor> decode_ico_direntry(InputMemoryStream& stream)
static Optional<ICOImageDescriptor> decode_ico_direntry(DeprecatedInputMemoryStream& stream)
{
ICONDIRENTRY entry;
stream >> Bytes { &entry, sizeof(entry) };
@ -108,7 +108,7 @@ static size_t find_largest_image(ICOLoadingContext const& context)
static bool load_ico_directory(ICOLoadingContext& context)
{
InputMemoryStream stream { { context.data, context.data_size } };
DeprecatedInputMemoryStream stream { { context.data, context.data_size } };
auto image_count = decode_ico_header(stream);
if (!image_count.has_value() || image_count.value() == 0) {
@ -187,7 +187,7 @@ bool ICOImageDecoderPlugin::load_ico_bitmap(ICOLoadingContext& context, Optional
ErrorOr<bool> ICOImageDecoderPlugin::sniff(ReadonlyBytes data)
{
InputMemoryStream stream { { data.data(), data.size() } };
DeprecatedInputMemoryStream stream { { data.data(), data.size() } };
return decode_ico_header(stream).has_value();
}
@ -237,7 +237,7 @@ bool ICOImageDecoderPlugin::set_nonvolatile(bool& was_purged)
bool ICOImageDecoderPlugin::initialize()
{
InputMemoryStream stream { { m_context->data, m_context->data_size } };
DeprecatedInputMemoryStream stream { { m_context->data, m_context->data_size } };
return decode_ico_header(stream).has_value();
}

View file

@ -6,6 +6,7 @@
#include "QOIWriter.h"
#include <AK/DeprecatedString.h>
#include <AK/Endian.h>
namespace Gfx {

View file

@ -9,7 +9,6 @@
#include <AK/Concepts.h>
#include <AK/DeprecatedString.h>
#include <AK/Forward.h>
#include <AK/MemoryStream.h>
#include <AK/NumericLimits.h>
#include <AK/StdLibExtras.h>
#include <AK/Try.h>

View file

@ -5,7 +5,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/MemoryStream.h>
#include <AK/Tuple.h>
#include <LibCore/BitStream.h>
#include <LibCore/MemoryStream.h>

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Endian.h>
#include <AK/String.h>
#include <LibGfx/Forward.h>
#include <LibPDF/Encoding.h>

View file

@ -10,7 +10,6 @@
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/MemoryStream.h>
#include <AK/RefCounted.h>
#include <AK/WeakPtr.h>
#include <LibCore/MemoryStream.h>

View file

@ -5,8 +5,8 @@
*/
#include <AK/Debug.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/Endian.h>
#include <AK/MemoryStream.h>
#include <LibCore/EventLoop.h>
#include <LibCore/Timer.h>
#include <LibCrypto/PK/Code/EMSA_PSS.h>
@ -141,7 +141,7 @@ void TLSv12::update_packet(ByteBuffer& packet)
// length (2)
u8 aad[13];
Bytes aad_bytes { aad, 13 };
OutputMemoryStream aad_stream { aad_bytes };
DeprecatedOutputMemoryStream aad_stream { aad_bytes };
u64 seq_no = AK::convert_between_host_and_network_endian(m_context.local_sequence_number);
u16 len = AK::convert_between_host_and_network_endian((u16)(packet.size() - header_size));
@ -382,7 +382,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
// length (2)
u8 aad[13];
Bytes aad_bytes { aad, 13 };
OutputMemoryStream aad_stream { aad_bytes };
DeprecatedOutputMemoryStream aad_stream { aad_bytes };
u64 seq_no = AK::convert_between_host_and_network_endian(m_context.remote_sequence_number);
u16 len = AK::convert_between_host_and_network_endian((u16)packet_length);

View file

@ -9,7 +9,7 @@
#include <AK/Badge.h>
#include <AK/DeprecatedString.h>
#include <AK/DistinctNumeric.h>
#include <AK/MemoryStream.h>
#include <AK/LEB128.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/Result.h>
#include <AK/Variant.h>