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/CMakeLists.txt b/CMakeLists.txt index bffaa11320..2e34d5fe76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -822,6 +822,7 @@ endif() list(APPEND NativeAppSource android/jni/TestRunner.cpp + UI/DiscordIntegration.cpp UI/NativeApp.cpp UI/BackgroundAudio.cpp UI/DevScreens.cpp diff --git a/Core/Config.cpp b/Core/Config.cpp index e6bf5440ea..02da5ff142 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -396,6 +396,7 @@ static ConfigSetting generalSettings[] = { ConfigSetting("CheckForNewVersion", &g_Config.bCheckForNewVersion, true), ConfigSetting("Language", &g_Config.sLanguageIni, &DefaultLangRegion), ConfigSetting("ForceLagSync", &g_Config.bForceLagSync, false, true, true), + ConfigSetting("DiscordPresence", &g_Config.bDiscordPresence, true, true, false), // Or maybe it makes sense to have it per-game? Race conditions abound... ReportedConfigSetting("NumWorkerThreads", &g_Config.iNumWorkerThreads, &DefaultNumWorkers, true, true), ConfigSetting("AutoLoadSaveState", &g_Config.iAutoLoadSaveState, 0, true, true), @@ -1162,8 +1163,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/Config.h b/Core/Config.h index 10ae5c23d8..e956c2b97c 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -117,6 +117,8 @@ public: std::vector vPinnedPaths; std::string sLanguageIni; + bool bDiscordPresence; // Enables setting the Discord presence to the current game (or menu) + // GFX int iGPUBackend; // We have separate device parameters for each backend so it doesn't get erased if you switch backends. 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/DiscordIntegration.cpp b/UI/DiscordIntegration.cpp new file mode 100644 index 0000000000..cc5b21b0cb --- /dev/null +++ b/UI/DiscordIntegration.cpp @@ -0,0 +1,131 @@ +#include +#include + +#include "ppsspp_config.h" +#include "Common/Log.h" +#include "Core/Config.h" +#include "DiscordIntegration.h" +#include "i18n/i18n.h" + +#ifdef _WIN32 + +#define ENABLE_DISCORD + +#else + +// TODO + +#endif + +#ifdef ENABLE_DISCORD +#include "ext/discord-rpc/include/discord_rpc.h" +#endif + +// TODO: Enable on more platforms. Make optional. + +Discord g_Discord; + +static const char *ppsspp_app_id = "423397985041383434"; + +// No context argument? What? +static void handleDiscordError(int errCode, const char *message) { + ERROR_LOG(SYSTEM, "Discord error code %d: '%s'", message); +} + +Discord::~Discord() { + assert(!initialized_); +} + +bool Discord::IsEnabled() const { + return g_Config.bDiscordPresence; +} + +void Discord::Init() { + assert(IsEnabled()); + assert(!initialized_); + +#ifdef ENABLE_DISCORD + DiscordEventHandlers eventHandlers{}; + eventHandlers.errored = &handleDiscordError; + Discord_Initialize(ppsspp_app_id, &eventHandlers, 0, nullptr); +#endif + + initialized_ = true; +} + +void Discord::Shutdown() { + assert(initialized_); +#ifdef ENABLE_DISCORD + Discord_Shutdown(); +#endif + initialized_ = false; +} + +void Discord::Update() { + if (!IsEnabled()) { + if (initialized_) { + Shutdown(); + } + return; + } else { + if (!initialized_) { + Init(); + } + } + +#ifdef ENABLE_DISCORD +#ifdef DISCORD_DISABLE_IO_THREAD + Discord_UpdateConnection(); +#endif + Discord_RunCallbacks(); +#endif +} + +void Discord::SetPresenceGame(const char *gameTitle) { + if (!IsEnabled()) + return; + + if (!initialized_) { + Init(); + } + +#ifdef ENABLE_DISCORD + I18NCategory *sc = GetI18NCategory("Screen"); + + DiscordRichPresence discordPresence{}; + discordPresence.state = gameTitle; + std::string details = sc->T("Playing"); + discordPresence.details = details.c_str(); + discordPresence.startTimestamp = time(0); +#ifdef GOLD + discordPresence.largeImageKey = "icon_gold_png"; +#else + discordPresence.largeImageKey = "icon_regular_png"; +#endif + Discord_UpdatePresence(&discordPresence); +#endif +} + +void Discord::SetPresenceMenu() { + if (!IsEnabled()) + return; + + if (!initialized_) { + Init(); + } + +#ifdef ENABLE_DISCORD + I18NCategory *sc = GetI18NCategory("Screen"); + + DiscordRichPresence discordPresence{}; + discordPresence.state = sc->T("In menu"); + discordPresence.details = ""; + discordPresence.startTimestamp = time(0); +#ifdef GOLD + discordPresence.largeImageKey = "icon_gold_png"; +#else + discordPresence.largeImageKey = "icon_regular_png"; +#endif + Discord_UpdatePresence(&discordPresence); +#endif +} diff --git a/UI/DiscordIntegration.h b/UI/DiscordIntegration.h new file mode 100644 index 0000000000..cd700d59ea --- /dev/null +++ b/UI/DiscordIntegration.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +// Simple wrapper around the Discord api. + +// All platforms should call it, but we only actually take action on +// platforms where we want it enabled (only PC initially). + +// All you need to call is FrameCallback, Shutdown, and UpdatePresence. + +class Discord { +public: + ~Discord(); + void Update(); // Call every frame or at least regularly. Will initialize if necessary. + void Shutdown(); + + void SetPresenceGame(const char *gameTitle); + void SetPresenceMenu(); + +private: + void Init(); + bool IsEnabled() const; + + bool initialized_ = false; +}; + +extern Discord g_Discord; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index b4e761e980..e34a8e10c7 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -77,6 +77,7 @@ #include "UI/GameSettingsScreen.h" #include "UI/InstallZipScreen.h" #include "UI/ProfilerDraw.h" +#include "UI/DiscordIntegration.h" #if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) #include "Windows/MainWindow.h" @@ -186,12 +187,18 @@ void EmuScreen::bootGame(const std::string &filename) { if (!bootAllowStorage(filename)) return; + I18NCategory *sc = GetI18NCategory("Screen"); + //pre-emptive loading of game specific config if possible, to get all the settings std::shared_ptr info = g_gameInfoCache->GetInfo(nullptr, filename, 0); if (info && !info->id.empty()) { g_Config.loadGameConfig(info->id); // Reset views in case controls are in a different place. RecreateViews(); + + g_Discord.SetPresenceGame(info->GetTitle().c_str()); + } else { + g_Discord.SetPresenceGame(sc->T("Untitled PSP game")); } invalid_ = true; @@ -333,6 +340,7 @@ EmuScreen::~EmuScreen() { startDumping = false; } #endif + g_Discord.SetPresenceMenu(); } void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 8ccec4b5e7..5e289b6151 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -642,6 +642,7 @@ void GameSettingsScreen::CreateViews() { networkingSettings->Add(new Choice(n->T("Adhoc Multiplayer forum")))->OnClick.Handle(this, &GameSettingsScreen::OnAdhocGuides); networkingSettings->Add(new CheckBox(&g_Config.bEnableWlan, n->T("Enable networking", "Enable networking/wlan (beta)"))); + networkingSettings->Add(new CheckBox(&g_Config.bDiscordPresence, n->T("Send Discord Presence information"))); #if !defined(MOBILE_DEVICE) && !defined(USING_QT_UI) networkingSettings->Add(new PopupTextInputChoice(&g_Config.proAdhocServer, n->T("Change proAdhocServer Address"), "", 255, screenManager())); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index bd9c3937ee..10850b33df 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -98,6 +98,7 @@ #include "UI/TiltEventProcessor.h" #include "UI/BackgroundAudio.h" #include "UI/TextureUtil.h" +#include "UI/DiscordIntegration.h" #if !defined(MOBILE_DEVICE) #include "Common/KeyMap.h" @@ -352,6 +353,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch InitFastMath(cpu_info.bNEON); SetupAudioFormats(); + g_Discord.SetPresenceMenu(); + // Make sure UI state is MENU. ResetUIState(); @@ -1028,6 +1031,8 @@ void NativeUpdate() { g_DownloadManager.Update(); screenManager->update(); + + g_Discord.Update(); } bool NativeIsAtTopLevel() { @@ -1213,6 +1218,8 @@ void NativeShutdown() { net::Shutdown(); + g_Discord.Shutdown(); + delete logger; logger = nullptr; 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/UI/UI.vcxproj b/UI/UI.vcxproj index 06f979c86b..905c9d9384 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -24,6 +24,7 @@ + @@ -54,6 +55,7 @@ + @@ -80,11 +82,17 @@ + + + {beb0a821-3c7f-410f-a525-63afbc69bf8f} + + {004B8D11-2BE3-4BD9-AB40-2BE04CF2096F} Win32Proj UI - + + diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index 8332d11762..0b5c2dd240 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -70,6 +70,7 @@ Screens + @@ -141,6 +142,7 @@ Screens + diff --git a/UWP/UI_UWP/UI_UWP.vcxproj b/UWP/UI_UWP/UI_UWP.vcxproj index 7fda5b55f9..3b54be0228 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj +++ b/UWP/UI_UWP/UI_UWP.vcxproj @@ -304,6 +304,7 @@ + @@ -337,6 +338,7 @@ + @@ -376,4 +378,4 @@ - \ No newline at end of file + diff --git a/UWP/UI_UWP/UI_UWP.vcxproj.filters b/UWP/UI_UWP/UI_UWP.vcxproj.filters index 2dda8c4b86..b3ee44e3c8 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj.filters +++ b/UWP/UI_UWP/UI_UWP.vcxproj.filters @@ -7,6 +7,7 @@ + @@ -40,6 +41,7 @@ + @@ -65,4 +67,4 @@ - \ No newline at end of file + diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 83b5286771..848b8cb5fa 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -913,7 +913,7 @@ namespace MainWindow InputDevice::StopPolling(); MainThread_Stop(); coreState = CORE_POWERUP; - ResetUIState(); + UpdateUIState(UISTATE_MENU); MainThread_Start(g_Config.iGPUBackend == (int)GPUBackend::OPENGL); InputDevice::BeginPolling(); break; diff --git a/Windows/PPSSPP.sln b/Windows/PPSSPP.sln index 13abef5350..918e2910d6 100644 --- a/Windows/PPSSPP.sln +++ b/Windows/PPSSPP.sln @@ -77,6 +77,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glslang", "..\ext\glslang.v EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPIRV-Cross", "..\ext\SPIRV-Cross.vcxproj", "{4328A62C-F1E9-47ED-B816-A1A81DAF4363}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "discord-rpc", "..\ext\discord-rpc-build\discord-rpc.vcxproj", "{BEB0A821-3C7F-410F-A525-63AFBC69BF8F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -105,7 +107,6 @@ Global {F761046E-6C38-4428-A5F1-38391A37BB34}.Debug|Win32.Build.0 = Debug|Win32 {F761046E-6C38-4428-A5F1-38391A37BB34}.Debug|x64.ActiveCfg = Debug|x64 {F761046E-6C38-4428-A5F1-38391A37BB34}.Debug|x64.Build.0 = Debug|x64 - {F761046E-6C38-4428-A5F1-38391A37BB34}.Release|ARM.ActiveCfg = Release|Win32 {F761046E-6C38-4428-A5F1-38391A37BB34}.Release|Win32.ActiveCfg = Release|Win32 {F761046E-6C38-4428-A5F1-38391A37BB34}.Release|Win32.Build.0 = Release|Win32 {F761046E-6C38-4428-A5F1-38391A37BB34}.Release|x64.ActiveCfg = Release|x64 @@ -114,7 +115,6 @@ Global {457F45D2-556F-47BC-A31D-AFF0D15BEAED}.Debug|Win32.Build.0 = Debug|Win32 {457F45D2-556F-47BC-A31D-AFF0D15BEAED}.Debug|x64.ActiveCfg = Debug|x64 {457F45D2-556F-47BC-A31D-AFF0D15BEAED}.Debug|x64.Build.0 = Debug|x64 - {457F45D2-556F-47BC-A31D-AFF0D15BEAED}.Release|ARM.ActiveCfg = Release|Win32 {457F45D2-556F-47BC-A31D-AFF0D15BEAED}.Release|Win32.ActiveCfg = Release|Win32 {457F45D2-556F-47BC-A31D-AFF0D15BEAED}.Release|Win32.Build.0 = Release|Win32 {457F45D2-556F-47BC-A31D-AFF0D15BEAED}.Release|x64.ActiveCfg = Release|x64 @@ -191,8 +191,19 @@ Global {4328A62C-F1E9-47ED-B816-A1A81DAF4363}.Release|Win32.Build.0 = Release|Win32 {4328A62C-F1E9-47ED-B816-A1A81DAF4363}.Release|x64.ActiveCfg = Release|x64 {4328A62C-F1E9-47ED-B816-A1A81DAF4363}.Release|x64.Build.0 = Release|x64 + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F}.Debug|Win32.ActiveCfg = Debug|Win32 + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F}.Debug|Win32.Build.0 = Debug|Win32 + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F}.Debug|x64.ActiveCfg = Debug|x64 + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F}.Debug|x64.Build.0 = Debug|x64 + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F}.Release|Win32.ActiveCfg = Release|Win32 + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F}.Release|Win32.Build.0 = Release|Win32 + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F}.Release|x64.ActiveCfg = Release|x64 + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2FD47774-A031-48F4-B645-A49A3140A29B} + EndGlobalSection EndGlobal diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 2b837a0ef2..b6a7c18f53 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -485,6 +485,7 @@ LOCAL_SRC_FILES := \ $(SRC)/android/jni/native_audio.cpp \ $(SRC)/android/jni/native-audio-so.cpp \ $(SRC)/UI/BackgroundAudio.cpp \ + $(SRC)/UI/DiscordIntegration.cpp \ $(SRC)/UI/DevScreens.cpp \ $(SRC)/UI/DisplayLayoutEditor.cpp \ $(SRC)/UI/DisplayLayoutScreen.cpp \ 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/discord-rpc-build/discord-rpc.vcxproj b/ext/discord-rpc-build/discord-rpc.vcxproj new file mode 100644 index 0000000000..52c18de82b --- /dev/null +++ b/ext/discord-rpc-build/discord-rpc.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + {BEB0A821-3C7F-410F-A525-63AFBC69BF8F} + Win32Proj + discordrpc + 10.0.17134.0 + + + + StaticLibrary + true + $(DefaultPlatformToolset)_xp + Unicode + + + StaticLibrary + false + $(DefaultPlatformToolset)_xp + true + Unicode + + + StaticLibrary + true + $(DefaultPlatformToolset)_xp + Unicode + + + StaticLibrary + false + $(DefaultPlatformToolset)_xp + true + Unicode + + + + + + + + + + + + + + + + + + + + + false + + + true + + + true + + + false + + + + Level3 + MaxSpeed + true + true + true + NDEBUG;_LIB;%(PreprocessorDefinitions) + true + ..\discord-rpc\include;..\discord-rpc\src;..\rapidjson\include + MultiThreaded + + + Windows + true + true + true + + + + + Level3 + Disabled + true + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + ..\discord-rpc\include;..\discord-rpc\src;..\rapidjson\include + MultiThreadedDebug + + + Windows + true + + + + + Level3 + Disabled + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + ..\discord-rpc\include;..\discord-rpc\src;..\rapidjson\include + MultiThreadedDebug + + + Windows + true + + + + + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + ..\discord-rpc\include;..\discord-rpc\src;..\rapidjson\include + MultiThreaded + + + Windows + true + true + true + + + + + + diff --git a/ext/discord-rpc-build/discord-rpc.vcxproj.filters b/ext/discord-rpc-build/discord-rpc.vcxproj.filters new file mode 100644 index 0000000000..ac36b4d139 --- /dev/null +++ b/ext/discord-rpc-build/discord-rpc.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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