1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:34:57 +00:00

AK: Allow JsonValue to store 64-bit integers internally

Add dedicated internal types for Int64 and UnsignedInt64. This makes it
a bit more straightforward to work with 64-bit numbers (instead of just
implicitly storing them as doubles.)
This commit is contained in:
Andreas Kling 2019-10-29 16:36:50 +01:00
parent 5442e365c9
commit 014f8ca8c4
6 changed files with 120 additions and 87 deletions

View file

@ -63,21 +63,28 @@ JsonValue& JsonValue::operator=(JsonValue&& other)
return *this;
}
JsonValue::JsonValue(int value)
: m_type(Type::Int)
JsonValue::JsonValue(i32 value)
: m_type(Type::Int32)
{
m_value.as_int = value;
m_value.as_i32 = value;
}
JsonValue::JsonValue(long unsigned value)
: JsonValue((unsigned)value)
JsonValue::JsonValue(u32 value)
: m_type(Type::UnsignedInt32)
{
m_value.as_u32 = value;
}
JsonValue::JsonValue(unsigned value)
: m_type(Type::UnsignedInt)
JsonValue::JsonValue(i64 value)
: m_type(Type::Int64)
{
m_value.as_uint = value;
m_value.as_i64 = value;
}
JsonValue::JsonValue(u64 value)
: m_type(Type::UnsignedInt64)
{
m_value.as_u64 = value;
}
JsonValue::JsonValue(const char* cstring)