From eddaf9793834dfba80605a04e0455fef93fb21af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 13 Aug 2018 00:05:00 +0200 Subject: [PATCH] Add submodules, namespace json to prepare for the addition of rapidjson (sigh) --- .gitmodules | 6 ++++++ Core/Config.cpp | 4 ++-- Core/Debugger/WebSocket/WebSocketUtils.h | 2 ++ UI/RemoteISOScreen.cpp | 2 ++ UI/Store.cpp | 5 +++-- UI/Store.h | 7 +++++-- ext/discord-rpc | 1 + ext/native/json/json_reader.cpp | 4 ++++ ext/native/json/json_reader.h | 5 +++++ ext/native/json/json_writer.cpp | 5 +++++ ext/native/json/json_writer.h | 7 ++++++- ext/rapidjson | 1 + 12 files changed, 42 insertions(+), 7 deletions(-) create mode 160000 ext/discord-rpc create mode 160000 ext/rapidjson diff --git a/.gitmodules b/.gitmodules index 57a0d7933e..d39e459a44 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,9 @@ [submodule "ext/SPIRV-Cross"] path = ext/SPIRV-Cross url = https://github.com/KhronosGroup/SPIRV-Cross.git +[submodule "ext/discord-rpc"] + path = ext/discord-rpc + url = https://github.com/discordapp/discord-rpc.git +[submodule "ext/rapidjson"] + path = ext/rapidjson + url = https://github.com/Tencent/rapidjson.git diff --git a/Core/Config.cpp b/Core/Config.cpp index e7c22fe0ad..6b16d7cb3f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1162,8 +1162,8 @@ void Config::DownloadCompletedCallback(http::Download &download) { return; } - JsonReader reader(data.c_str(), data.size()); - const JsonGet root = reader.root(); + json::JsonReader reader(data.c_str(), data.size()); + const json::JsonGet root = reader.root(); if (!root) { ERROR_LOG(LOADER, "Failed to parse json"); return; diff --git a/Core/Debugger/WebSocket/WebSocketUtils.h b/Core/Debugger/WebSocket/WebSocketUtils.h index e49647dcf8..70c08828b2 100644 --- a/Core/Debugger/WebSocket/WebSocketUtils.h +++ b/Core/Debugger/WebSocket/WebSocketUtils.h @@ -24,6 +24,8 @@ #include "net/websocket_server.h" #include "Common/Log.h" +using namespace json; + static inline void DebuggerJsonAddTicket(JsonWriter &writer, const JsonGet &data) { const JsonNode *value = data.get("ticket"); if (value) diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 31d8f9f966..7e4238b96c 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -82,6 +82,8 @@ static bool FindServer(std::string &resultHost, int &resultPort) { std::string json; result.TakeAll(&json); + using namespace json; + JsonReader reader(json.c_str(), json.size()); if (!reader.ok()) { return false; diff --git a/UI/Store.cpp b/UI/Store.cpp index da2d2f1a4f..58e780dbda 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -391,6 +391,7 @@ void StoreScreen::update() { } void StoreScreen::ParseListing(std::string json) { + using namespace json; JsonReader reader(json.c_str(), json.size()); if (!reader.ok() || !reader.root()) { ELOG("Error parsing JSON from store"); @@ -540,8 +541,8 @@ std::string StoreScreen::GetStoreJsonURL(std::string storePath) const { return path; } -std::string StoreScreen::GetTranslatedString(const JsonGet json, std::string key, const char *fallback) const { - JsonGet dict = json.getDict("en_US"); +std::string StoreScreen::GetTranslatedString(const json::JsonGet json, std::string key, const char *fallback) const { + json::JsonGet dict = json.getDict("en_US"); if (dict && json.hasChild(lang_.c_str(), JSON_OBJECT)) { if (json.getDict(lang_.c_str()).hasChild(key.c_str(), JSON_STRING)) { dict = json.getDict(lang_.c_str()); diff --git a/UI/Store.h b/UI/Store.h index e7786c7c9c..c935bcb042 100644 --- a/UI/Store.h +++ b/UI/Store.h @@ -29,7 +29,10 @@ // set game specific settings, etc. // Uses GameInfoCache heavily to implement the functionality. -struct JsonGet; +namespace json { + struct JsonGet; +} + class ProductItemView; enum EntryType { @@ -79,7 +82,7 @@ private: std::vector FilterEntries(); std::string GetStoreJsonURL(std::string storePath) const; - std::string GetTranslatedString(const JsonGet json, std::string key, const char *fallback = nullptr) const; + std::string GetTranslatedString(const json::JsonGet json, std::string key, const char *fallback = nullptr) const; std::shared_ptr listing_; std::shared_ptr image_; diff --git a/ext/discord-rpc b/ext/discord-rpc new file mode 160000 index 0000000000..3d3ae7129d --- /dev/null +++ b/ext/discord-rpc @@ -0,0 +1 @@ +Subproject commit 3d3ae7129d17643bc706da0a2eea85aafd10ab3a diff --git a/ext/native/json/json_reader.cpp b/ext/native/json/json_reader.cpp index 83fbe94fa4..eaf9d0ae08 100644 --- a/ext/native/json/json_reader.cpp +++ b/ext/native/json/json_reader.cpp @@ -2,6 +2,8 @@ #include "file/vfs.h" #include "json/json_reader.h" +namespace json { + JsonReader::JsonReader(const std::string &filename) { size_t buf_size; buffer_ = (char *)VFSReadFile(filename.c_str(), &buf_size); @@ -117,3 +119,5 @@ bool JsonGet::getBool(const char *child_name, bool default_value) const { } return default_value; } + +} // namespace json diff --git a/ext/native/json/json_reader.h b/ext/native/json/json_reader.h index b9e8de5e53..a18915f488 100644 --- a/ext/native/json/json_reader.h +++ b/ext/native/json/json_reader.h @@ -1,9 +1,12 @@ #include #include + #include "base/basictypes.h" #include "base/logging.h" #include "ext/gason/gason.h" +namespace json { + struct JsonGet { JsonGet(const JsonValue &value) : value_(value) { } @@ -83,3 +86,5 @@ private: DISALLOW_COPY_AND_ASSIGN(JsonReader); }; + +} // namespace json diff --git a/ext/native/json/json_writer.cpp b/ext/native/json/json_writer.cpp index 7d1c47a620..7440cf731d 100644 --- a/ext/native/json/json_writer.cpp +++ b/ext/native/json/json_writer.cpp @@ -1,9 +1,12 @@ #include #include #include + #include "json/json_reader.h" #include "json/json_writer.h" +namespace json { + JsonWriter::JsonWriter(int flags) { pretty_ = (flags & PRETTY) != 0; str_.imbue(std::locale::classic()); @@ -383,3 +386,5 @@ static void json_stringify_array(JsonWriter &writer, const JsonNode *node) { break; } } + +} // namespace json diff --git a/ext/native/json/json_writer.h b/ext/native/json/json_writer.h index 22c712c856..d82b7151cf 100644 --- a/ext/native/json/json_writer.h +++ b/ext/native/json/json_writer.h @@ -13,6 +13,10 @@ #include #include +struct JsonNode; + +namespace json { + class JsonWriter { public: JsonWriter(int flags = NORMAL); @@ -79,5 +83,6 @@ private: bool pretty_; }; -struct JsonNode; std::string json_stringify(const JsonNode *json); + +} // namespace json diff --git a/ext/rapidjson b/ext/rapidjson new file mode 160000 index 0000000000..73063f5002 --- /dev/null +++ b/ext/rapidjson @@ -0,0 +1 @@ +Subproject commit 73063f5002612c6bf64fe24f851cd5cc0d83eef9