Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ globals:
debug: true
__SYSCALL: true
runtime: true
performance: true

env:
es6: true
Expand Down
2 changes: 2 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ config = {
'deps/printf',
'deps/miniz',
'deps/libsodium/src/libsodium/include',
'deps/json11',
'src',
'test',
],
Expand All @@ -130,6 +131,7 @@ config = {
'acpica',
'printf',
'sodium',
'json11',
'musl',
'gcc',
],
Expand Down
15 changes: 14 additions & 1 deletion deps/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ libs_config = {
'concurrentqueue',
'printf',
'trace_event',
'json11',
'v8/include',
'v8/src',
'v8',
Expand Down Expand Up @@ -1238,11 +1239,23 @@ libs_config = {
'libsodium/src/libsodium/sodium/version.c',
],
},
"json11": {
"include": [
'musl/src/internal',
'musl/include',
'musl/arch/x86_64',
'musl/arch/x86_64/bits',
'libcxx/include',
'json11'
],
"source": [
'json11/json11.cpp',
],
},
}


for targetname, params in libs_config.items():
target_env = env_base.Clone();
target_env.Replace(CPPPATH = params["include"])
target_env.Library(target = targetname, source = params["source"])

12 changes: 12 additions & 0 deletions deps/json11/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# generated files
test
libjson11.a
json11.pc

# Cmake
CMakeCache.txt
CTestTestfile.cmake
CMakeFiles
CMakeScripts
cmake_install.cmake
install_manifest.txt
22 changes: 22 additions & 0 deletions deps/json11/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.2)
project(json11 VERSION 1.0.0 LANGUAGES CXX)

enable_testing()

option(JSON11_BUILD_TESTS "Build unit tests" ON)

add_library(json11 json11.cpp)
target_include_directories(json11 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_options(json11
PUBLIC -std=c++11
PRIVATE -fno-rtti -fno-exceptions -Wall -Wextra -Werror)
configure_file("json11.pc.in" "json11.pc" @ONLY)

if (JSON11_BUILD_TESTS)
add_executable(json11_test test.cpp)
target_link_libraries(json11_test json11)
endif()

install(TARGETS json11 DESTINATION lib)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include)
install(FILES "${CMAKE_BINARY_DIR}/json11.pc" DESTINATION lib/pkgconfig)
19 changes: 19 additions & 0 deletions deps/json11/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2013 Dropbox, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
15 changes: 15 additions & 0 deletions deps/json11/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Environment variable to enable or disable code which demonstrates the behavior change
# in Xcode 7 / Clang 3.7, introduced by DR1467 and described here:
# https://llvm.org/bugs/show_bug.cgi?id=23812
# Defaults to on in order to act as a warning to anyone who's unaware of the issue.
ifneq ($(JSON11_ENABLE_DR1467_CANARY),)
CANARY_ARGS = -DJSON11_ENABLE_DR1467_CANARY=$(JSON11_ENABLE_DR1467_CANARY)
endif

test: json11.cpp json11.hpp test.cpp
$(CXX) $(CANARY_ARGS) -O -std=c++11 json11.cpp test.cpp -o test -fno-rtti -fno-exceptions

clean:
if [ -e test ]; then rm test; fi

.PHONY: clean
42 changes: 42 additions & 0 deletions deps/json11/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
json11
------

json11 is a tiny JSON library for C++11, providing JSON parsing and serialization.

The core object provided by the library is json11::Json. A Json object represents any JSON
value: null, bool, number (int or double), string (std::string), array (std::vector), or
object (std::map).

Json objects act like values. They can be assigned, copied, moved, compared for equality or
order, and so on. There are also helper methods Json::dump, to serialize a Json to a string, and
Json::parse (static) to parse a std::string as a Json object.

It's easy to make a JSON object with C++11's new initializer syntax:

Json my_json = Json::object {
{ "key1", "value1" },
{ "key2", false },
{ "key3", Json::array { 1, 2, 3 } },
};
std::string json_str = my_json.dump();

There are also implicit constructors that allow standard and user-defined types to be
automatically converted to JSON. For example:

class Point {
public:
int x;
int y;
Point (int x, int y) : x(x), y(y) {}
Json to_json() const { return Json::array { x, y }; }
};

std::vector<Point> points = { { 1, 2 }, { 10, 20 }, { 100, 200 } };
std::string points_json = Json(points).dump();

JSON values can have their values queried and inspected:

Json json = Json::array { Json::object { { "k", "v" } } };
std::string str = json[0]["k"].string_value();

More documentation is still to come. For now, see json11.hpp.
Loading