Replace taocpp/json with dropbox/json11 which compiles on MSVC

This commit is contained in:
David Capello 2017-06-14 19:50:44 -03:00
parent 25b8b7098e
commit f37ccdc578
7 changed files with 70 additions and 51 deletions

6
.gitmodules vendored
View File

@ -45,9 +45,9 @@
[submodule "third_party/harfbuzz"]
path = third_party/harfbuzz
url = https://github.com/aseprite/harfbuzz.git
[submodule "third_party/json"]
path = third_party/json
url = https://github.com/aseprite/json.git
[submodule "third_party/libarchive"]
path = third_party/libarchive
url = https://github.com/aseprite/libarchive.git
[submodule "third_party/json11"]
path = third_party/json11
url = https://github.com/aseprite/json11.git

View File

@ -527,6 +527,30 @@ ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
```
# [json11](https://github.com/dropbox/json11/)
```
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.
```
# [libarchive](http://www.libarchive.org/)
```
@ -958,32 +982,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
# [The Art of C++ / JSON](https://github.com/taocpp/json/)
```
The MIT License (MIT)
Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey
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.
```
# [tinyxml](http://www.grinninglizard.com/tinyxml/)
```

View File

@ -542,7 +542,7 @@ target_link_libraries(app-lib
${ZLIB_LIBRARIES}
${FREETYPE_LIBRARIES}
${HARFBUZZ_LIBRARIES}
taocpp-json
json11
archive_static)
if(ENABLE_SCRIPTING)

View File

@ -17,15 +17,18 @@
#include "base/exception.h"
#include "base/file_handle.h"
#include "base/fs.h"
#include "base/fstream_path.h"
#include "base/unique_ptr.h"
#include "render/dithering_matrix.h"
#include "archive.h"
#include "archive_entry.h"
#include "tao/json.hpp"
#include "json11.hpp"
#include <fstream>
#include <queue>
#include <sstream>
#include <string>
namespace app {
@ -442,10 +445,13 @@ Extension* Extensions::installCompressedExtension(const std::string& zipFn)
std::stringstream out;
in.copyDataTo(out);
auto json = tao::json::from_stream(out);
auto name = json["name"].get_string();
dstExtensionPath =
base::join_path(m_userExtensionsPath, name);
std::string err;
auto json = json11::Json::parse(out.str(), err);
if (err.empty()) {
auto name = json["name"].string_value();
dstExtensionPath = base::join_path(m_userExtensionsPath, name);
}
break;
}
}
@ -500,9 +506,23 @@ Extension* Extensions::loadExtension(const std::string& path,
const std::string& fullPackageFilename,
const bool isBuiltinExtension)
{
auto json = tao::json::parse_file(fullPackageFilename);
auto name = json["name"].get_string();
auto displayName = json["displayName"].get_string();
json11::Json json;
{
std::string jsonText, line;
std::ifstream in(FSTREAM_PATH(fullPackageFilename), std::ifstream::binary);
while (std::getline(in, line)) {
jsonText += line;
jsonText.push_back('\n');
}
std::string err;
json = json11::Json::parse(jsonText, err);
if (!err.empty())
throw base::Exception("Error parsing JSON file: %s\n",
err.c_str());
}
auto name = json["name"].string_value();
auto displayName = json["displayName"].string_value();
LOG("EXT: Extension '%s' loaded\n", name.c_str());
@ -519,9 +539,9 @@ Extension* Extensions::loadExtension(const std::string& path,
// Themes
auto themes = contributes["themes"];
if (themes.is_array()) {
for (const auto& theme : themes.get_array()) {
std::string themeId = theme.at("id").get_string();
std::string themePath = theme.at("path").get_string();
for (const auto& theme : themes.array_items()) {
std::string themeId = theme["id"].string_value();
std::string themePath = theme["path"].string_value();
// The path must be always relative to the extension
themePath = base::join_path(path, themePath);
@ -537,9 +557,9 @@ Extension* Extensions::loadExtension(const std::string& path,
// Palettes
auto palettes = contributes["palettes"];
if (palettes.is_array()) {
for (const auto& palette : palettes.get_array()) {
std::string palId = palette.at("id").get_string();
std::string palPath = palette.at("path").get_string();
for (const auto& palette : palettes.array_items()) {
std::string palId = palette["id"].string_value();
std::string palPath = palette["path"].string_value();
// The path must be always relative to the extension
palPath = base::join_path(path, palPath);
@ -555,10 +575,12 @@ Extension* Extensions::loadExtension(const std::string& path,
// Dithering matrices
auto ditheringMatrices = contributes["ditheringMatrices"];
if (ditheringMatrices.is_array()) {
for (const auto& ditheringMatrix : ditheringMatrices.get_array()) {
std::string matId = ditheringMatrix.at("id").get_string();
std::string matPath = ditheringMatrix.at("path").get_string();
std::string matName = ditheringMatrix.at("name").get_string();
for (const auto& ditheringMatrix : ditheringMatrices.array_items()) {
std::string matId = ditheringMatrix["id"].string_value();
std::string matPath = ditheringMatrix["path"].string_value();
std::string matName = ditheringMatrix["name"].string_value();
if (matName.empty())
matName = matId;
// The path must be always relative to the extension
matPath = base::join_path(path, matPath);

View File

@ -109,8 +109,7 @@ if(NOT USE_SHARED_CMARK)
endif()
# JSON
set(TAOCPP_JSON_BUILD_TESTS OFF CACHE BOOL "Build test programs")
add_subdirectory(json)
add_subdirectory(json11)
# libarchive
set(ENABLE_TEST OFF CACHE BOOL "Enable unit and regression tests")

1
third_party/json vendored

@ -1 +0,0 @@
Subproject commit 450705891c39dfc38de0ef04e239c51f1d98855d

1
third_party/json11 vendored Submodule

@ -0,0 +1 @@
Subproject commit ed35a09c043c376969dde9a3293824e1c11aa1f1