Permalink
Browse files

Merge pull request #10960 from unknownbrackets/debugger-json

Switch json to gason, include json writer in build
  • Loading branch information...
hrydgard committed Jun 6, 2018
2 parents f9cfb05 + 082ddf5 commit df699c67b2d573cbcf8fa7cea0391f7237cf853b
View
@@ -463,11 +463,9 @@ if(USING_GLES2)
find_package(X11)
endif()
add_library(vjson STATIC
ext/native/ext/vjson/json.cpp
ext/native/ext/vjson/json.h
ext/native/ext/vjson/block_allocator.cpp
ext/native/ext/vjson/block_allocator.h
add_library(gason STATIC
ext/native/ext/gason/gason.cpp
ext/native/ext/gason/gason.h
)
add_library(rg_etc1 STATIC
@@ -897,10 +895,6 @@ add_library(native STATIC
ext/native/base/timeutil.h
ext/native/data/compression.cpp
ext/native/data/compression.h
ext/native/ext/vjson/json.cpp
ext/native/ext/vjson/json.h
ext/native/ext/vjson/block_allocator.cpp
ext/native/ext/vjson/block_allocator.h
ext/native/file/chunk_file.cpp
ext/native/file/chunk_file.h
ext/native/file/fd_util.cpp
@@ -954,6 +948,10 @@ add_library(native STATIC
ext/native/input/keycodes.h
ext/native/input/input_state.h
ext/native/input/input_state.cpp
ext/native/json/json_reader.h
ext/native/json/json_reader.cpp
ext/native/json/json_writer.h
ext/native/json/json_writer.cpp
ext/native/math/fast/fast_math.c
ext/native/math/fast/fast_matrix.c
ext/native/math/fast/fast_matrix_neon.S
@@ -1040,7 +1038,7 @@ if(ANDROID)
SET(ATOMIC_LIB atomic)
endif()
target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} rg_etc1 vjson udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB})
target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} rg_etc1 gason udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB})
if(TARGET Ext::GLEW)
target_link_libraries(native Ext::GLEW)
endif()
View
@@ -22,9 +22,9 @@
#include "base/display.h"
#include "base/NativeApp.h"
#include "ext/vjson/json.h"
#include "file/ini_file.h"
#include "i18n/i18n.h"
#include "json/json_reader.h"
#include "gfx_es2/gpu_features.h"
#include "net/http_client.h"
#include "util/text/parsers.h"
@@ -1181,13 +1181,13 @@ void Config::DownloadCompletedCallback(http::Download &download) {
}
JsonReader reader(data.c_str(), data.size());
const json_value *root = reader.root();
const JsonGet root = reader.root();
if (!root) {
ERROR_LOG(LOADER, "Failed to parse json");
return;
}
std::string version = root->getString("version", "");
std::string version = root.getString("version", "");
const char *gitVer = PPSSPP_GIT_VERSION;
Version installed(gitVer);
View
@@ -21,9 +21,9 @@
#include <condition_variable>
#include "base/timeutil.h"
#include "ext/vjson/json.h"
#include "file/fd_util.h"
#include "i18n/i18n.h"
#include "json/json_reader.h"
#include "net/http_client.h"
#include "net/http_server.h"
#include "net/resolve.h"
@@ -252,16 +252,19 @@ static bool FindServer(std::string &resultHost, int &resultPort) {
return false;
}
const json_value *entries = reader.root();
if (!entries) {
const JsonValue entries = reader.rootArray();
if (entries.getTag() != JSON_ARRAY) {
return false;
}
std::vector<std::string> servers;
const json_value *entry = entries->first_child;
while (entry && !scanCancelled) {
const char *host = entry->getString("ip", "");
int port = entry->getInt("p", 0);
for (const auto pentry : entries) {
JsonGet entry = pentry->value;
if (scanCancelled)
return false;
const char *host = entry.getString("ip", "");
int port = entry.getInt("p", 0);
char url[1024] = {};
snprintf(url, sizeof(url), "http://%s:%d", host, port);
@@ -270,8 +273,6 @@ static bool FindServer(std::string &resultHost, int &resultPort) {
if (TryServer(host, port)) {
return true;
}
entry = entry->next_sibling;
}
// None of the local IPs were reachable.
View
@@ -18,7 +18,7 @@
#include <functional>
#include "base/basictypes.h"
#include "ext/vjson/json.h"
#include "json/json_reader.h"
#include "i18n/i18n.h"
#include "ui/screen.h"
@@ -392,33 +392,32 @@ void StoreScreen::update() {
void StoreScreen::ParseListing(std::string json) {
JsonReader reader(json.c_str(), json.size());
if (!reader.ok()) {
if (!reader.ok() || !reader.root()) {
ELOG("Error parsing JSON from store");
connectionError_ = true;
RecreateViews();
return;
}
json_value *root = reader.root();
const json_value *entries = root->getArray("entries");
const JsonGet root = reader.root();
const JsonNode *entries = root.getArray("entries");
if (entries) {
entries_.clear();
const json_value *game = entries->first_child;
while (game) {
for (const JsonNode *pgame : entries->value) {
JsonGet game = pgame->value;
StoreEntry e;
e.type = ENTRY_PBPZIP;
e.name = GetTranslatedString(game, "name");
e.description = GetTranslatedString(game, "description", "");
e.author = game->getString("author", "?");
e.size = game->getInt("size");
e.downloadURL = game->getString("download-url", "");
e.iconURL = game->getString("icon-url", "");
e.hidden = game->getBool("hidden", false);
const char *file = game->getString("file", 0);
e.author = game.getString("author", "?");
e.size = game.getInt("size");
e.downloadURL = game.getString("download-url", "");
e.iconURL = game.getString("icon-url", "");
e.hidden = game.getBool("hidden", false);
const char *file = game.getString("file", nullptr);
if (!file)
continue;
e.file = file;
entries_.push_back(e);
game = game->next_sibling;
}
}
}
@@ -541,16 +540,16 @@ std::string StoreScreen::GetStoreJsonURL(std::string storePath) const {
return path;
}
std::string StoreScreen::GetTranslatedString(const json_value *json, std::string key, const char *fallback) const {
const json_value *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());
std::string StoreScreen::GetTranslatedString(const JsonGet json, std::string key, const char *fallback) const {
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());
}
}
const char *str = 0;
const char *str = nullptr;
if (dict) {
str = dict->getString(key.c_str(), 0);
str = dict.getString(key.c_str(), nullptr);
}
if (str) {
return std::string(str);
View
@@ -29,7 +29,7 @@
// set game specific settings, etc.
// Uses GameInfoCache heavily to implement the functionality.
struct json_value;
struct JsonGet;
class ProductItemView;
enum EntryType {
@@ -79,7 +79,7 @@ class StoreScreen : public UIDialogScreenWithBackground {
std::vector<StoreEntry> FilterEntries();
std::string GetStoreJsonURL(std::string storePath) const;
std::string GetTranslatedString(const json_value *json, std::string key, const char *fallback = 0) const;
std::string GetTranslatedString(const JsonGet json, std::string key, const char *fallback = nullptr) const;
std::shared_ptr<http::Download> listing_;
std::shared_ptr<http::Download> image_;
@@ -328,8 +328,6 @@
<ClInclude Include="..\..\ext\native\ext\libzip\config.h" />
<ClInclude Include="..\..\ext\native\ext\libzip\zip.h" />
<ClInclude Include="..\..\ext\native\ext\libzip\zipint.h" />
<ClInclude Include="..\..\ext\native\ext\vjson\block_allocator.h" />
<ClInclude Include="..\..\ext\native\ext\vjson\json.h" />
<ClInclude Include="..\..\ext\native\file\chunk_file.h" />
<ClInclude Include="..\..\ext\native\file\fd_util.h" />
<ClInclude Include="..\..\ext\native\file\file_util.h" />
@@ -338,6 +336,8 @@
<ClInclude Include="..\..\ext\native\file\path.h" />
<ClInclude Include="..\..\ext\native\file\vfs.h" />
<ClInclude Include="..\..\ext\native\file\zip_read.h" />
<ClInclude Include="..\..\ext\native\json\json_reader.h" />
<ClInclude Include="..\..\ext\native\json\json_writer.h" />
<ClInclude Include="..\..\ext\native\gfx\texture_atlas.h" />
<ClInclude Include="..\..\ext\native\gfx_es2\draw_buffer.h" />
<ClInclude Include="..\..\ext\native\gfx_es2\draw_text.h" />
@@ -1160,15 +1160,15 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='UWP Gold|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\ext\native\ext\vjson\block_allocator.cpp" />
<ClCompile Include="..\..\ext\native\ext\vjson\json.cpp" />
<ClCompile Include="..\..\ext\native\file\chunk_file.cpp" />
<ClCompile Include="..\..\ext\native\file\fd_util.cpp" />
<ClCompile Include="..\..\ext\native\file\file_util.cpp" />
<ClCompile Include="..\..\ext\native\file\free.cpp" />
<ClCompile Include="..\..\ext\native\file\ini_file.cpp" />
<ClCompile Include="..\..\ext\native\file\path.cpp" />
<ClCompile Include="..\..\ext\native\file\zip_read.cpp" />
<ClCompile Include="..\..\ext\native\json\json_reader.cpp" />
<ClCompile Include="..\..\ext\native\json\json_writer.cpp" />
<ClCompile Include="..\..\ext\native\gfx\texture_atlas.cpp" />
<ClCompile Include="..\..\ext\native\gfx_es2\draw_buffer.cpp" />
<ClCompile Include="..\..\ext\native\gfx_es2\draw_text.cpp" />
@@ -37,9 +37,6 @@
<Filter Include="ext">
<UniqueIdentifier>{2be24387-0b6a-4253-97fa-b8b6f75a8a4c}</UniqueIdentifier>
</Filter>
<Filter Include="ext\vjson">
<UniqueIdentifier>{7fdd3320-a8e0-42ed-b08b-2d86ba2ff414}</UniqueIdentifier>
</Filter>
<Filter Include="ext\libzip">
<UniqueIdentifier>{1a486fc4-bac0-4b33-9139-262272690c74}</UniqueIdentifier>
</Filter>
@@ -214,12 +211,6 @@
<ClCompile Include="..\..\ext\native\i18n\i18n.cpp">
<Filter>i18n</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\ext\vjson\block_allocator.cpp">
<Filter>ext\vjson</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\ext\vjson\json.cpp">
<Filter>ext\vjson</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\ext\libzip\mkstemp.c">
<Filter>ext\libzip</Filter>
</ClCompile>
@@ -656,12 +647,6 @@
<ClInclude Include="..\..\ext\native\i18n\i18n.h">
<Filter>i18n</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\ext\vjson\block_allocator.h">
<Filter>ext\vjson</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\ext\vjson\json.h">
<Filter>ext\vjson</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\ext\libzip\config.h">
<Filter>ext\libzip</Filter>
</ClInclude>
View
@@ -35,15 +35,15 @@ LOCAL_SRC_FILES :=\
ext/jpge/jpgd.cpp \
ext/jpge/jpge.cpp \
ext/sha1/sha1.cpp \
ext/vjson/json.cpp \
ext/vjson/block_allocator.cpp \
ext/gason/gason.cpp \
file/fd_util.cpp \
file/chunk_file.cpp \
file/file_util.cpp \
file/free.cpp \
file/path.cpp \
file/ini_file.cpp \
file/zip_read.cpp \
json/json_reader.cpp \
json/json_writer.cpp \
i18n/i18n.cpp \
input/gesture_detector.cpp \
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013-2015 Ivan Vashchaev
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.
Oops, something went wrong.

0 comments on commit df699c6

Please sign in to comment.