Fix RapidJSON implementation (hopefully)

This commit is contained in:
David 2023-02-15 23:21:09 -06:00
parent 1f9a4b97a3
commit 3831802717

View File

@ -3292,7 +3292,7 @@ static bool ParseJsonAsValue(Value *ret, const ::detail::json &o) {
val = Value(i); val = Value(i);
} else { } else {
double d = 0.0; double d = 0.0;
GetDouble(o, d); detail::GetDouble(o, d);
val = Value(d); val = Value(d);
} }
break; break;
@ -6555,7 +6555,7 @@ bool TinyGLTF::LoadBinaryFromFile(Model *model, std::string *err,
namespace detail { namespace detail {
::detail::json JsonFromString(const char *s) { ::detail::json JsonFromString(const char *s) {
#ifdef TINYGLTF_USE_RAPIDJSON #ifdef TINYGLTF_USE_RAPIDJSON
return ::detail::json(s, GetAllocator()); return ::detail::json(s, ::detail::GetAllocator());
#else #else
return ::detail::json(s); return ::detail::json(s);
#endif #endif
@ -6563,7 +6563,7 @@ namespace detail {
void JsonAssign(::detail::json &dest, const ::detail::json &src) { void JsonAssign(::detail::json &dest, const ::detail::json &src) {
#ifdef TINYGLTF_USE_RAPIDJSON #ifdef TINYGLTF_USE_RAPIDJSON
dest.CopyFrom(src, GetAllocator()); dest.CopyFrom(src, ::detail::GetAllocator());
#else #else
dest = src; dest = src;
#endif #endif
@ -6574,7 +6574,7 @@ void JsonAddMember(::detail::json &o, const char *key, ::detail::json &&value) {
if (!o.IsObject()) { if (!o.IsObject()) {
o.SetObject(); o.SetObject();
} }
o.AddMember(json(key, GetAllocator()), std::move(value), GetAllocator()); o.AddMember(::detail::json(key, ::detail::GetAllocator()), std::move(value), ::detail::GetAllocator());
#else #else
o[key] = std::move(value); o[key] = std::move(value);
#endif #endif
@ -6582,7 +6582,7 @@ void JsonAddMember(::detail::json &o, const char *key, ::detail::json &&value) {
void JsonPushBack(::detail::json &o, ::detail::json &&value) { void JsonPushBack(::detail::json &o, ::detail::json &&value) {
#ifdef TINYGLTF_USE_RAPIDJSON #ifdef TINYGLTF_USE_RAPIDJSON
o.PushBack(std::move(value), GetAllocator()); o.PushBack(std::move(value), ::detail::GetAllocator());
#else #else
o.push_back(std::move(value)); o.push_back(std::move(value));
#endif #endif
@ -6607,7 +6607,7 @@ void JsonSetObject(::detail::json &o) {
void JsonReserveArray(::detail::json &o, size_t s) { void JsonReserveArray(::detail::json &o, size_t s) {
#ifdef TINYGLTF_USE_RAPIDJSON #ifdef TINYGLTF_USE_RAPIDJSON
o.SetArray(); o.SetArray();
o.Reserve(static_cast<rapidjson::SizeType>(s), GetAllocator()); o.Reserve(static_cast<rapidjson::SizeType>(s), ::detail::GetAllocator());
#endif #endif
(void)(o); (void)(o);
(void)(s); (void)(s);
@ -6676,17 +6676,17 @@ static bool ValueToJson(const Value &value, ::detail::json *ret) {
obj.SetBool(value.Get<bool>()); obj.SetBool(value.Get<bool>());
break; break;
case STRING_TYPE: case STRING_TYPE:
obj.SetString(value.Get<std::string>().c_str(), GetAllocator()); obj.SetString(value.Get<std::string>().c_str(), ::detail::GetAllocator());
break; break;
case ARRAY_TYPE: { case ARRAY_TYPE: {
obj.SetArray(); obj.SetArray();
obj.Reserve(static_cast<rapidjson::SizeType>(value.ArrayLen()), obj.Reserve(static_cast<rapidjson::SizeType>(value.ArrayLen()),
GetAllocator()); ::detail::GetAllocator());
for (unsigned int i = 0; i < value.ArrayLen(); ++i) { for (unsigned int i = 0; i < value.ArrayLen(); ++i) {
Value elementValue = value.Get(int(i)); Value elementValue = value.Get(int(i));
::detail::json elementJson; ::detail::json elementJson;
if (ValueToJson(value.Get(int(i)), &elementJson)) if (ValueToJson(value.Get(int(i)), &elementJson))
obj.PushBack(std::move(elementJson), GetAllocator()); obj.PushBack(std::move(elementJson), ::detail::GetAllocator());
} }
break; break;
} }
@ -6701,8 +6701,8 @@ static bool ValueToJson(const Value &value, ::detail::json *ret) {
for (auto &it : objMap) { for (auto &it : objMap) {
::detail::json elementJson; ::detail::json elementJson;
if (ValueToJson(it.second, &elementJson)) { if (ValueToJson(it.second, &elementJson)) {
obj.AddMember(::detail::json(it.first.c_str(), GetAllocator()), obj.AddMember(::detail::json(it.first.c_str(), ::detail::GetAllocator()),
std::move(elementJson), GetAllocator()); std::move(elementJson), ::detail::GetAllocator());
} }
} }
break; break;