Skip to content

Commit

Permalink
Kernel: Don't compile JsonValue & friends into the kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jun 30, 2021
1 parent 65db56c commit 6f0e8f8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
44 changes: 44 additions & 0 deletions AK/JsonArraySerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ class JsonArraySerializer {
finish();
}

#ifndef KERNEL
void add(const JsonValue& value)
{
begin_item();
value.serialize(m_builder);
}
#endif

void add(const StringView& value)
{
Expand All @@ -61,6 +63,48 @@ class JsonArraySerializer {
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()
{
begin_item();
Expand Down
9 changes: 8 additions & 1 deletion AK/JsonObjectSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
#pragma once

#include <AK/JsonArraySerializer.h>
#include <AK/JsonValue.h>

#ifndef KERNEL
# include <AK/JsonValue.h>
#endif

namespace AK {

Expand All @@ -29,11 +32,13 @@ class JsonObjectSerializer {
finish();
}

#ifndef KERNEL
void add(const StringView& key, const JsonValue& value)
{
begin_item(key);
value.serialize(m_builder);
}
#endif

void add(const StringView& key, const StringView& value)
{
Expand Down Expand Up @@ -101,11 +106,13 @@ class JsonObjectSerializer {
m_builder.appendff("{}", value);
}

#ifndef KERNEL
void add(const StringView& key, double value)
{
begin_item(key);
m_builder.appendff("{}", value);
}
#endif

JsonArraySerializer<Builder> add_array(const StringView& key)
{
Expand Down
1 change: 0 additions & 1 deletion Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ set(AK_SOURCES
../AK/FlyString.cpp
../AK/GenericLexer.cpp
../AK/Hex.cpp
../AK/JsonValue.cpp
../AK/LexicalPath.cpp
../AK/String.cpp
../AK/StringBuilder.cpp
Expand Down
3 changes: 1 addition & 2 deletions Kernel/ProcessSpecificExposed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

#include <AK/JsonArraySerializer.h>
#include <AK/JsonObject.h>
#include <AK/JsonObjectSerializer.h>
#include <AK/JsonValue.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
Expand Down Expand Up @@ -44,7 +43,7 @@ class ProcFSThreadStack final : public ProcFSProcessInformation {
address = 0xdeadc0de;
kernel_address_added = true;
}
array.add(JsonValue(address));
array.add(address);
}

array.finish();
Expand Down

0 comments on commit 6f0e8f8

Please sign in to comment.