1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

Kernel: Don't compile JsonValue & friends into the kernel

This commit is contained in:
Andreas Kling 2021-06-30 11:31:12 +02:00
parent 65db56cd9f
commit 6f0e8f823b
4 changed files with 53 additions and 4 deletions

View file

@ -31,11 +31,13 @@ public:
finish(); finish();
} }
#ifndef KERNEL
void add(const JsonValue& value) void add(const JsonValue& value)
{ {
begin_item(); begin_item();
value.serialize(m_builder); value.serialize(m_builder);
} }
#endif
void add(const StringView& value) void add(const StringView& value)
{ {
@ -61,6 +63,48 @@ public:
m_builder.append('"'); m_builder.append('"');
} }
void add(bool value)
{
begin_item();
m_builder.append(value ? "true"sv : "false"sv);
}
void add(int value)
{
begin_item();
m_builder.appendff("{}", value);
}
void add(unsigned value)
{
begin_item();
m_builder.appendff("{}", value);
}
void add(long value)
{
begin_item();
m_builder.appendff("{}", value);
}
void add(long unsigned value)
{
begin_item();
m_builder.appendff("{}", value);
}
void add(long long value)
{
begin_item();
m_builder.appendff("{}", value);
}
void add(long long unsigned value)
{
begin_item();
m_builder.appendff("{}", value);
}
JsonArraySerializer<Builder> add_array() JsonArraySerializer<Builder> add_array()
{ {
begin_item(); begin_item();

View file

@ -7,7 +7,10 @@
#pragma once #pragma once
#include <AK/JsonArraySerializer.h> #include <AK/JsonArraySerializer.h>
#include <AK/JsonValue.h>
#ifndef KERNEL
# include <AK/JsonValue.h>
#endif
namespace AK { namespace AK {
@ -29,11 +32,13 @@ public:
finish(); finish();
} }
#ifndef KERNEL
void add(const StringView& key, const JsonValue& value) void add(const StringView& key, const JsonValue& value)
{ {
begin_item(key); begin_item(key);
value.serialize(m_builder); value.serialize(m_builder);
} }
#endif
void add(const StringView& key, const StringView& value) void add(const StringView& key, const StringView& value)
{ {
@ -101,11 +106,13 @@ public:
m_builder.appendff("{}", value); m_builder.appendff("{}", value);
} }
#ifndef KERNEL
void add(const StringView& key, double value) void add(const StringView& key, double value)
{ {
begin_item(key); begin_item(key);
m_builder.appendff("{}", value); m_builder.appendff("{}", value);
} }
#endif
JsonArraySerializer<Builder> add_array(const StringView& key) JsonArraySerializer<Builder> add_array(const StringView& key)
{ {

View file

@ -301,7 +301,6 @@ set(AK_SOURCES
../AK/FlyString.cpp ../AK/FlyString.cpp
../AK/GenericLexer.cpp ../AK/GenericLexer.cpp
../AK/Hex.cpp ../AK/Hex.cpp
../AK/JsonValue.cpp
../AK/LexicalPath.cpp ../AK/LexicalPath.cpp
../AK/String.cpp ../AK/String.cpp
../AK/StringBuilder.cpp ../AK/StringBuilder.cpp

View file

@ -5,7 +5,6 @@
*/ */
#include <AK/JsonArraySerializer.h> #include <AK/JsonArraySerializer.h>
#include <AK/JsonObject.h>
#include <AK/JsonObjectSerializer.h> #include <AK/JsonObjectSerializer.h>
#include <AK/JsonValue.h> #include <AK/JsonValue.h>
#include <Kernel/Arch/x86/InterruptDisabler.h> #include <Kernel/Arch/x86/InterruptDisabler.h>
@ -44,7 +43,7 @@ private:
address = 0xdeadc0de; address = 0xdeadc0de;
kernel_address_added = true; kernel_address_added = true;
} }
array.add(JsonValue(address)); array.add(address);
} }
array.finish(); array.finish();