<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 13, 2019 at 8:05 PM Nomis101 🐝 <<a href="mailto:Nomis101@web.de">Nomis101@web.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This is the patch to update json11 to v1.0.0 release against latest master. I also included the fix for json11 issue #131.<br>
Find patch attached.</blockquote><div><br></div><div>The patch applies on default and builds successfully in Mac and Linux, but gives build warnings and errors in windows. Could you please fix them and resend the patch?</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
# HG changeset patch<br>
# User Nomis101 <<a href="mailto:Nomis101@web.de" target="_blank">Nomis101@web.de</a>><br>
# Date 1555165564 -7200<br>
# Sat Apr 13 16:26:04 2019 +0200<br>
# Node ID c63e02ef363527e1321142403083ad82a33845eb<br>
# Parent 768ab38fd5fd104a8d58f42b646d6117d63b2c0a<br>
Update json11 to v1.0.0 (plus #131 fix) and fix Issue #373.<br>
<br>
diff -r 768ab38fd5fd -r c63e02ef3635 source/dynamicHDR10/json11/json11.cpp<br>
--- a/source/dynamicHDR10/json11/json11.cpp Thu Apr 04 13:35:58 2019 +0530<br>
+++ b/source/dynamicHDR10/json11/json11.cpp Sat Apr 13 16:26:04 2019 +0200<br>
@@ -21,38 +21,41 @@<br>
<br>
#include "json11.h"<br>
#include <cassert><br>
#include <cmath><br>
#include <cstdlib><br>
#include <cstdio><br>
#include <limits><br>
<br>
-#if _MSC_VER<br>
-#pragma warning(disable: 4510) //const member cannot be default initialized<br>
-#pragma warning(disable: 4512) //assignment operator could not be generated<br>
-#pragma warning(disable: 4610) //const member cannot be default initialized<br>
-#endif<br>
-<br>
namespace json11 {<br>
<br>
static const int max_depth = 200;<br>
<br>
using std::string;<br>
using std::vector;<br>
using std::map;<br>
using std::make_shared;<br>
using std::initializer_list;<br>
using std::move;<br>
<br>
+/* Helper for representing null - just a do-nothing struct, plus comparison<br>
+ * operators so the helpers in JsonValue work. We can't use nullptr_t because<br>
+ * it may not be orderable.<br>
+ */<br>
+struct NullStruct {<br>
+ bool operator==(NullStruct) const { return true; }<br>
+ bool operator<(NullStruct) const { return false; }<br>
+};<br>
+<br>
/* * * * * * * * * * * * * * * * * * * *<br>
* Serialization<br>
*/<br>
<br>
-static void dump(std::nullptr_t, string &out) {<br>
+static void dump(NullStruct, string &out) {<br>
out += "null";<br>
}<br>
<br>
static void dump(double value, string &out) {<br>
if (std::isfinite(value)) {<br>
char buf[32];<br>
snprintf(buf, sizeof buf, "%.17g", value);<br>
out += buf;<br>
@@ -209,19 +212,19 @@ public:<br>
class JsonObject final : public Value<Json::OBJECT, Json::object> {<br>
const Json::object &object_items() const override { return m_value; }<br>
const Json & operator[](const string &key) const override;<br>
public:<br>
explicit JsonObject(const Json::object &value) : Value(value) {}<br>
explicit JsonObject(Json::object &&value) : Value(move(value)) {}<br>
};<br>
<br>
-class JsonNull final : public Value<Json::NUL, std::nullptr_t> {<br>
+class JsonNull final : public Value<Json::NUL, NullStruct> {<br>
public:<br>
- JsonNull() : Value(nullptr) {}<br>
+ JsonNull() : Value({}) {}<br>
};<br>
<br>
/* * * * * * * * * * * * * * * * * * * *<br>
* Static globals - static-init-safe<br>
*/<br>
struct Statics {<br>
const std::shared_ptr<JsonValue> null = make_shared<JsonNull>();<br>
const std::shared_ptr<JsonValue> t = make_shared<JsonBoolean>(true);<br>
@@ -292,23 +295,27 @@ const Json & JsonArray::operator[] (size<br>
else return m_value[i];<br>
}<br>
<br>
/* * * * * * * * * * * * * * * * * * * *<br>
* Comparison<br>
*/<br>
<br>
bool Json::operator== (const Json &other) const {<br>
+ if (m_ptr == other.m_ptr)<br>
+ return true;<br>
if (m_ptr->type() != other.m_ptr->type())<br>
return false;<br>
<br>
return m_ptr->equals(other.m_ptr.get());<br>
}<br>
<br>
bool Json::operator< (const Json &other) const {<br>
+ if (m_ptr == other.m_ptr)<br>
+ return false;<br>
if (m_ptr->type() != other.m_ptr->type())<br>
return m_ptr->type() < other.m_ptr->type();<br>
<br>
return m_ptr->less(other.m_ptr.get());<br>
}<br>
<br>
/* * * * * * * * * * * * * * * * * * * *<br>
* Parsing<br>
@@ -376,44 +383,37 @@ struct JsonParser final {<br>
*<br>
* Advance comments (c-style inline and multiline).<br>
*/<br>
bool consume_comment() {<br>
bool comment_found = false;<br>
if (str[i] == '/') {<br>
i++;<br>
if (i == str.size())<br>
- return fail("unexpected end of input inside comment", false);<br>
+ return fail("unexpected end of input after start of comment", false);<br>
if (str[i] == '/') { // inline comment<br>
i++;<br>
- if (i == str.size())<br>
- return fail("unexpected end of input inside inline comment", false);<br>
- // advance until next line<br>
- while (str[i] != '\n') {<br>
+ // advance until next line, or end of input<br>
+ while (i < str.size() && str[i] != '\n') {<br>
i++;<br>
- if (i == str.size())<br>
- return fail("unexpected end of input inside inline comment", false);<br>
}<br>
comment_found = true;<br>
}<br>
else if (str[i] == '*') { // multiline comment<br>
i++;<br>
if (i > str.size()-2)<br>
return fail("unexpected end of input inside multi-line comment", false);<br>
// advance until closing tokens<br>
while (!(str[i] == '*' && str[i+1] == '/')) {<br>
i++;<br>
if (i > str.size()-2)<br>
return fail(<br>
"unexpected end of input inside multi-line comment", false);<br>
}<br>
i += 2;<br>
- if (i == str.size())<br>
- return fail(<br>
- "unexpected end of input inside multi-line comment", false);<br>
comment_found = true;<br>
}<br>
else<br>
return fail("malformed comment", false);<br>
}<br>
return comment_found;<br>
}<br>
<br>
@@ -422,31 +422,33 @@ struct JsonParser final {<br>
* Advance until the current character is non-whitespace and non-comment.<br>
*/<br>
void consume_garbage() {<br>
consume_whitespace();<br>
if(strategy == JsonParse::COMMENTS) {<br>
bool comment_found = false;<br>
do {<br>
comment_found = consume_comment();<br>
+ if (failed) return;<br>
consume_whitespace();<br>
}<br>
while(comment_found);<br>
}<br>
}<br>
<br>
/* get_next_token()<br>
*<br>
* Return the next non-whitespace character. If the end of the input is reached,<br>
* flag an error and return 0.<br>
*/<br>
char get_next_token() {<br>
consume_garbage();<br>
+ if (failed) return static_cast<char>(0);<br>
if (i == str.size())<br>
- return fail("unexpected end of input", '0');<br>
+ return fail("unexpected end of input", static_cast<char>(0));<br>
<br>
return str[i++];<br>
}<br>
<br>
/* encode_utf8(pt, out)<br>
*<br>
* Encode pt as UTF-8 and add it to out.<br>
*/<br>
@@ -473,17 +475,17 @@ struct JsonParser final {<br>
<br>
/* parse_string()<br>
*<br>
* Parse a string, starting at the current position.<br>
*/<br>
string parse_string() {<br>
string out;<br>
long last_escaped_codepoint = -1;<br>
- for (;;) {<br>
+ while (true) {<br>
if (i == str.size())<br>
return fail("unexpected end of input in string", "");<br>
<br>
char ch = str[i++];<br>
<br>
if (ch == '"') {<br>
encode_utf8(last_escaped_codepoint, out);<br>
return out;<br>
@@ -510,17 +512,17 @@ struct JsonParser final {<br>
// Extract 4-byte escape sequence<br>
string esc = str.substr(i, 4);<br>
// Explicitly check length of the substring. The following loop<br>
// relies on std::string returning the terminating NUL when<br>
// accessing str[length]. Checking here reduces brittleness.<br>
if (esc.length() < 4) {<br>
return fail("bad \\u escape: " + esc, "");<br>
}<br>
- for (int j = 0; j < 4; j++) {<br>
+ for (size_t j = 0; j < 4; j++) {<br>
if (!in_range(esc[j], 'a', 'f') && !in_range(esc[j], 'A', 'F')<br>
&& !in_range(esc[j], '0', '9'))<br>
return fail("bad \\u escape: " + esc, "");<br>
}<br>
<br>
long codepoint = strtol(esc.data(), nullptr, 16);<br>
<br>
// JSON specifies that characters outside the BMP shall be encoded as a pair<br>
@@ -666,17 +668,17 @@ struct JsonParser final {<br>
return parse_string();<br>
<br>
if (ch == '{') {<br>
map<string, Json> data;<br>
ch = get_next_token();<br>
if (ch == '}')<br>
return data;<br>
<br>
- for (;;) {<br>
+ while (1) {<br>
if (ch != '"')<br>
return fail("expected '\"' in object, got " + esc(ch));<br>
<br>
string key = parse_string();<br>
if (failed)<br>
return Json();<br>
<br>
ch = get_next_token();<br>
@@ -699,17 +701,17 @@ struct JsonParser final {<br>
}<br>
<br>
if (ch == '[') {<br>
vector<Json> data;<br>
ch = get_next_token();<br>
if (ch == ']')<br>
return data;<br>
<br>
- for (;;) {<br>
+ while (1) {<br>
i--;<br>
data.push_back(parse_json(depth + 1));<br>
if (failed)<br>
return Json();<br>
<br>
ch = get_next_token();<br>
if (ch == ']')<br>
break;<br>
@@ -728,36 +730,42 @@ struct JsonParser final {<br>
}//namespace {<br>
<br>
Json Json::parse(const string &in, string &err, JsonParse strategy) {<br>
JsonParser parser { in, 0, err, false, strategy };<br>
Json result = parser.parse_json(0);<br>
<br>
// Check for any trailing garbage<br>
parser.consume_garbage();<br>
+ if (parser.failed)<br>
+ return Json();<br>
if (parser.i != in.size())<br>
return parser.fail("unexpected trailing " + esc(in[parser.i]));<br>
<br>
return result;<br>
}<br>
<br>
// Documented in json11.hpp<br>
vector<Json> Json::parse_multi(const string &in,<br>
std::string::size_type &parser_stop_pos,<br>
string &err,<br>
JsonParse strategy) {<br>
JsonParser parser { in, 0, err, false, strategy };<br>
parser_stop_pos = 0;<br>
vector<Json> json_vec;<br>
while (parser.i != in.size() && !parser.failed) {<br>
json_vec.push_back(parser.parse_json(0));<br>
+ if (parser.failed)<br>
+ break;<br>
+<br>
// Check for another object<br>
parser.consume_garbage();<br>
- if (!parser.failed)<br>
- parser_stop_pos = parser.i;<br>
+ if (parser.failed)<br>
+ break;<br>
+ parser_stop_pos = parser.i;<br>
}<br>
return json_vec;<br>
}<br>
<br>
/* * * * * * * * * * * * * * * * * * * *<br>
* Shape-checking<br>
*/<br>
<br>
@@ -771,16 +779,10 @@ bool Json::has_shape(const shape & types<br>
if ((*this)[item.first].type() != item.second) {<br>
err = "bad type for " + item.first + " in " + dump();<br>
return false;<br>
}<br>
}<br>
<br>
return true;<br>
}<br>
-//void Json::add(std::string &key, std::string value)<br>
-//{<br>
-// (*m_ptr)[key] = value;<br>
-//}<br>
<br>
} // namespace json11<br>
-<br>
-<br>
diff -r 768ab38fd5fd -r c63e02ef3635 source/dynamicHDR10/json11/json11.h<br>
--- a/source/dynamicHDR10/json11/json11.h Thu Apr 04 13:35:58 2019 +0530<br>
+++ b/source/dynamicHDR10/json11/json11.h Sat Apr 13 16:26:04 2019 +0200<br>
@@ -71,17 +71,17 @@<br>
namespace json11 {<br>
<br>
enum JsonParse {<br>
STANDARD, COMMENTS<br>
};<br>
<br>
class JsonValue;<br>
<br>
-class Json final{ //final<br>
+class Json final {<br>
public:<br>
// Types<br>
enum Type {<br>
NUL, NUMBER, BOOL, STRING, ARRAY, OBJECT<br>
};<br>
<br>
// Array and object typedefs<br>
typedef std::vector<Json> array;<br>
@@ -95,32 +95,31 @@ public:<br>
Json(bool value); // BOOL<br>
Json(const std::string &value); // STRING<br>
Json(std::string &&value); // STRING<br>
Json(const char * value); // STRING<br>
Json(const array &values); // ARRAY<br>
Json(array &&values); // ARRAY<br>
Json(const object &values); // OBJECT<br>
Json(object &&values); // OBJECT<br>
- void add(std::string &key, std::string value);<br>
<br>
// Implicit constructor: anything with a to_json() function.<br>
template <class T, class = decltype(&T::to_json)><br>
Json(const T & t) : Json(t.to_json()) {}<br>
<br>
// Implicit constructor: map-like objects (std::map, std::unordered_map, etc)<br>
template <class M, typename std::enable_if<<br>
- std::is_constructible<std::string, typename M::key_type>::value<br>
- && std::is_constructible<Json, typename M::mapped_type>::value,<br>
+ std::is_constructible<std::string, decltype(std::declval<M>().begin()->first)>::value<br>
+ && std::is_constructible<Json, decltype(std::declval<M>().begin()->second)>::value,<br>
int>::type = 0><br>
Json(const M & m) : Json(object(m.begin(), m.end())) {}<br>
<br>
// Implicit constructor: vector-like objects (std::list, std::vector, std::set, etc)<br>
template <class V, typename std::enable_if<<br>
- std::is_constructible<Json, typename V::value_type>::value,<br>
+ std::is_constructible<Json, decltype(*std::declval<V>().begin())>::value,<br>
int>::type = 0><br>
Json(const V & v) : Json(array(v.begin(), v.end())) {}<br>
<br>
// This prevents Json(some_pointer) from accidentally producing a bool. Use<br>
// Json(bool(some_pointer)) if that behavior is desired.<br>
Json(void *) = delete;<br>
<br>
// Accessors<br>
@@ -128,17 +127,16 @@ public:<br>
<br>
bool is_null() const { return type() == NUL; }<br>
bool is_number() const { return type() == NUMBER; }<br>
bool is_bool() const { return type() == BOOL; }<br>
bool is_string() const { return type() == STRING; }<br>
bool is_array() const { return type() == ARRAY; }<br>
bool is_object() const { return type() == OBJECT; }<br>
<br>
-<br>
// Return the enclosed value if this is a number, 0 otherwise. Note that json11 does not<br>
// distinguish between integer and non-integer numbers - number_value() and int_value()<br>
// can both be applied to a NUMBER-typed object.<br>
double number_value() const;<br>
int int_value() const;<br>
<br>
// Return the enclosed value if this is a boolean, false otherwise.<br>
bool bool_value() const;<br>
@@ -224,12 +222,11 @@ protected:<br>
virtual int int_value() const;<br>
virtual bool bool_value() const;<br>
virtual const std::string &string_value() const;<br>
virtual const Json::array &array_items() const;<br>
virtual const Json &operator[](size_t i) const;<br>
virtual const Json::object &object_items() const;<br>
virtual const Json &operator[](const std::string &key) const;<br>
virtual ~JsonValue() {}<br>
-<br>
};<br>
<br>
} // namespace json11<br>
<br>
<br>
<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><font face="georgia, serif">Regards,</font><div><font face="georgia, serif">Aruna</font></div></div></div></div>