Apply patches to rapidjson
Some checks are pending
Build Android / Game (Android, Release ARM64) (push) Waiting to run
Build iOS / Game (iOS, Release ARM64) (push) Waiting to run
Build Linux / Editor (Linux, Development x64) (push) Waiting to run
Build Linux / Game (Linux, Release x64) (push) Waiting to run
Build macOS / Editor (Mac, Development ARM64) (push) Waiting to run
Build macOS / Game (Mac, Release ARM64) (push) Waiting to run
Build Windows / Editor (Windows, Development x64) (push) Waiting to run
Build Windows / Game (Windows, Release x64) (push) Waiting to run
Cooker / Cook (Mac) (push) Waiting to run
Tests / Tests (Linux) (push) Waiting to run
Tests / Tests (Windows) (push) Waiting to run

This commit is contained in:
2025-01-15 00:16:32 +02:00
parent c5c1751f74
commit aac7149106
6 changed files with 74 additions and 7 deletions

View File

@@ -5,14 +5,23 @@
#include "Engine/Core/Types/String.h"
#include "Engine/Core/Types/StringView.h"
// TODO: config RAPIDJSON_SSE2 for rapidjson
// TODO: config RAPIDJSON_SSE42 for rapidjson
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(_M_X64) || defined(_M_AMD64)
//#define RAPIDJSON_SSE42
#elif defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
//#define RAPIDJSON_NEON
#endif
#define RAPIDJSON_ERROR_CHARTYPE Char
#define RAPIDJSON_ERROR_STRING(x) TEXT(x)
#define RAPIDJSON_ASSERT(x) ASSERT(x)
#define RAPIDJSON_NEW(x) New<x>()
#define RAPIDJSON_NEW(x) New<x>
#define RAPIDJSON_DELETE(x) Delete(x)
#define RAPIDJSON_NOMEMBERITERATORCLASS
#include <ThirdParty/rapidjson/rapidjson.h>
//#define RAPIDJSON_MALLOC(size) ::malloc(size)
//#define RAPIDJSON_REALLOC(ptr, new_size) ::realloc(ptr, new_size)
//#define RAPIDJSON_FREE(ptr) ::free(ptr)
#include <ThirdParty/rapidjson/writer.h>
#include <ThirdParty/rapidjson/prettywriter.h>
#include <ThirdParty/rapidjson/document.h>

View File

@@ -1852,6 +1852,32 @@ public:
const Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return DataString(data_); }
::StringAnsiView GetStringAnsiView() const { RAPIDJSON_ASSERT(IsString()); return data_.f.flags & kInlineStrFlag ? ::StringAnsiView(data_.ss.str, data_.ss.GetLength()) : ::StringAnsiView(GetStringPointer(), data_.s.length); }
::String GetText() const
{
::String result;
if (IsString())
{
if (data_.f.flags & kInlineStrFlag)
result.SetUTF8(data_.ss.str, data_.ss.GetLength());
else
result.SetUTF8(GetStringPointer(), data_.s.length);
}
return result;
}
StringAnsi GetTextAnsi() const
{
StringAnsi result;
if (IsString())
{
if (data_.f.flags & kInlineStrFlag)
result.Set(data_.ss.str, data_.ss.GetLength());
else
result.Set(GetStringPointer(), data_.s.length);
}
return result;
}
//! Get the length of string.
/*! Since rapidjson permits "\\u0000" in the json string, strlen(v.GetString()) may not equal to v.GetStringLength().
*/
@@ -2798,6 +2824,12 @@ public:
return *allocator_;
}
//! Get the allocator of this document.
Allocator& GetAllocator() const {
RAPIDJSON_ASSERT(allocator_);
return *allocator_;
}
//! Get the capacity of stack in bytes.
size_t GetStackCapacity() const { return stack_.GetCapacity(); }

View File

@@ -17,9 +17,11 @@
#include "../rapidjson.h"
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && defined(_M_AMD64)
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && (defined(_M_AMD64) || defined(_M_ARM64))
#include <intrin.h> // for _umul128
#if !defined(_ARM64EC_)
#if defined(_M_ARM64)
#pragma intrinsic(__umulh)
#elif !defined(_ARM64EC_)
#pragma intrinsic(_umul128)
#else
#pragma comment(lib,"softintrin")

View File

@@ -23,9 +23,11 @@
#include "clzll.h"
#include <limits>
#if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__INTEL_COMPILER)
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && (defined(_M_AMD64) || defined(_M_ARM64))
#include <intrin.h>
#if !defined(_ARM64EC_)
#if defined(_M_ARM64)
#pragma intrinsic(__umulh)
#elif !defined(_ARM64EC_)
#pragma intrinsic(_umul128)
#else
#pragma comment(lib,"softintrin")

View File

@@ -41,6 +41,18 @@ public:
Stack(Allocator* allocator, size_t stackCapacity) : allocator_(allocator), ownAllocator_(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) {
}
#if false
Stack(const Stack& other)
: Stack(nullptr, other.initialCapacity_)
{
if (other.Empty())
return;
char* dst = Push<char>(other.GetSize());
const char* src = other.Bottom<char>();
memcpy(dst, src, other.GetSize());
}
#endif
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
Stack(Stack&& rhs)
: allocator_(rhs.allocator_),
@@ -211,7 +223,9 @@ private:
}
// Prohibit copy constructor & assignment operator.
#if false
Stack(const Stack&);
#endif
Stack& operator=(const Stack&);
Allocator* allocator_;

View File

@@ -43,6 +43,9 @@ public:
typedef typename Encoding::Ch Ch;
GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}
#if false
GenericStringBuffer(const GenericStringBuffer& other) : stack_(other.stack_) {}
#endif
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {}
@@ -57,6 +60,9 @@ public:
void PutUnsafe(Ch c) { *stack_.template PushUnsafe<Ch>() = c; }
void Flush() {}
#if false
void Destroy() { stack_.Clear(); stack_.ShrinkToFit(); }
#endif
void Clear() { stack_.Clear(); }
void ShrinkToFit() {
// Push and pop a null terminator. This is safe.
@@ -89,7 +95,9 @@ public:
private:
// Prohibit copy constructor & assignment operator.
#if false
GenericStringBuffer(const GenericStringBuffer&);
#endif
GenericStringBuffer& operator=(const GenericStringBuffer&);
};