mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Provide a default set of Traits for const
types
This commit is contained in:
parent
a2f60911fe
commit
e9dda2a5f8
Notes:
sideshowbarker
2024-07-17 09:49:48 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/e9dda2a5f8 Pull-request: https://github.com/SerenityOS/serenity/pull/21852
5 changed files with 22 additions and 29 deletions
10
AK/Endian.h
10
AK/Endian.h
|
@ -125,21 +125,11 @@ struct Traits<LittleEndian<T>> : public DefaultTraits<LittleEndian<T>> {
|
|||
static constexpr bool is_trivially_serializable() { return Traits<T>::is_trivially_serializable(); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Traits<LittleEndian<T> const> : public DefaultTraits<LittleEndian<T> const> {
|
||||
static constexpr bool is_trivially_serializable() { return Traits<T>::is_trivially_serializable(); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Traits<BigEndian<T>> : public DefaultTraits<BigEndian<T>> {
|
||||
static constexpr bool is_trivially_serializable() { return Traits<T>::is_trivially_serializable(); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Traits<BigEndian<T> const> : public DefaultTraits<BigEndian<T> const> {
|
||||
static constexpr bool is_trivially_serializable() { return Traits<T>::is_trivially_serializable(); }
|
||||
};
|
||||
|
||||
constexpr u16 bitswap(u16 v)
|
||||
{
|
||||
v = ((v >> 1) & 0x5555) | ((v & 0x5555) << 1); // even & odd bits
|
||||
|
|
|
@ -30,6 +30,11 @@ template<typename T>
|
|||
struct Traits : public DefaultTraits<T> {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Traits<T const> : public Traits<T> {
|
||||
using PeekType = typename Traits<T>::ConstPeekType;
|
||||
};
|
||||
|
||||
template<Integral T>
|
||||
struct Traits<T> : public DefaultTraits<T> {
|
||||
static constexpr bool is_trivial() { return true; }
|
||||
|
|
|
@ -43,10 +43,8 @@ static constexpr size_t s_max_range_mask_size = s_max_glyph_count / (256 * 8);
|
|||
|
||||
}
|
||||
|
||||
// FIXME: We define the traits for the const FontFileHeader, because that's the one we use, and defining
|
||||
// Traits<T> doesn't apply to Traits<T const>. Once that's fixed, remove the const here.
|
||||
template<>
|
||||
class AK::Traits<Gfx::FontFileHeader const> : public DefaultTraits<Gfx::FontFileHeader const> {
|
||||
class AK::Traits<Gfx::FontFileHeader> : public DefaultTraits<Gfx::FontFileHeader> {
|
||||
public:
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
|
|
|
@ -55,19 +55,19 @@ static_assert(AssertSize<Version16Dot16, 4>());
|
|||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Traits<OpenType::Fixed const> : public DefaultTraits<OpenType::Fixed const> {
|
||||
struct Traits<OpenType::Fixed> : public DefaultTraits<OpenType::Fixed> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
template<>
|
||||
struct Traits<OpenType::LongDateTime const> : public DefaultTraits<OpenType::LongDateTime const> {
|
||||
struct Traits<OpenType::LongDateTime> : public DefaultTraits<OpenType::LongDateTime> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
template<>
|
||||
struct Traits<OpenType::Tag const> : public DefaultTraits<OpenType::Tag const> {
|
||||
struct Traits<OpenType::Tag> : public DefaultTraits<OpenType::Tag> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
template<>
|
||||
struct Traits<OpenType::Version16Dot16 const> : public DefaultTraits<OpenType::Version16Dot16 const> {
|
||||
struct Traits<OpenType::Version16Dot16> : public DefaultTraits<OpenType::Version16Dot16> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -48,13 +48,13 @@ static_assert(AssertSize<TableRecord, 16>());
|
|||
}
|
||||
|
||||
template<>
|
||||
class AK::Traits<OpenType::TableDirectory const> : public DefaultTraits<OpenType::TableDirectory const> {
|
||||
class AK::Traits<OpenType::TableDirectory> : public DefaultTraits<OpenType::TableDirectory> {
|
||||
public:
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
|
||||
template<>
|
||||
class AK::Traits<OpenType::TableRecord const> : public DefaultTraits<OpenType::TableRecord const> {
|
||||
class AK::Traits<OpenType::TableRecord> : public DefaultTraits<OpenType::TableRecord> {
|
||||
public:
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
|
@ -788,47 +788,47 @@ private:
|
|||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Traits<OpenType::Kern::Header const> : public DefaultTraits<OpenType::Kern::Header const> {
|
||||
struct Traits<OpenType::Kern::Header> : public DefaultTraits<OpenType::Kern::Header> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
template<>
|
||||
struct Traits<OpenType::Kern::SubtableHeader const> : public DefaultTraits<OpenType::Kern::SubtableHeader const> {
|
||||
struct Traits<OpenType::Kern::SubtableHeader> : public DefaultTraits<OpenType::Kern::SubtableHeader> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
template<>
|
||||
struct Traits<OpenType::Kern::Format0 const> : public DefaultTraits<OpenType::Kern::Format0 const> {
|
||||
struct Traits<OpenType::Kern::Format0> : public DefaultTraits<OpenType::Kern::Format0> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
template<>
|
||||
struct Traits<OpenType::Kern::Format0Pair const> : public DefaultTraits<OpenType::Kern::Format0Pair const> {
|
||||
struct Traits<OpenType::Kern::Format0Pair> : public DefaultTraits<OpenType::Kern::Format0Pair> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Traits<OpenType::GPOS::Version1_0 const> : public DefaultTraits<OpenType::GPOS::Version1_0 const> {
|
||||
struct Traits<OpenType::GPOS::Version1_0> : public DefaultTraits<OpenType::GPOS::Version1_0> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Traits<OpenType::FeatureList const> : public DefaultTraits<OpenType::FeatureList const> {
|
||||
struct Traits<OpenType::FeatureList> : public DefaultTraits<OpenType::FeatureList> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
template<>
|
||||
struct Traits<OpenType::FeatureRecord const> : public DefaultTraits<OpenType::FeatureRecord const> {
|
||||
struct Traits<OpenType::FeatureRecord> : public DefaultTraits<OpenType::FeatureRecord> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Traits<OpenType::LookupList const> : public DefaultTraits<OpenType::LookupList const> {
|
||||
struct Traits<OpenType::LookupList> : public DefaultTraits<OpenType::LookupList> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Traits<OpenType::ScriptList const> : public DefaultTraits<OpenType::ScriptList const> {
|
||||
struct Traits<OpenType::ScriptList> : public DefaultTraits<OpenType::ScriptList> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
template<>
|
||||
struct Traits<OpenType::ScriptRecord const> : public DefaultTraits<OpenType::ScriptRecord const> {
|
||||
struct Traits<OpenType::ScriptRecord> : public DefaultTraits<OpenType::ScriptRecord> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue