From 637226addc0c94e6f364a6434888bc254c5a9c8b Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Wed, 6 Nov 2024 09:14:02 +0000 Subject: [PATCH] Javascript: Update choc dependency --- .../javascript/choc/containers/choc_Value.h | 55 +++++++------------ .../javascript/choc/math/choc_MathHelpers.h | 7 +++ .../choc/platform/choc_DisableAllWarnings.h | 1 + 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/modules/juce_core/javascript/choc/containers/choc_Value.h b/modules/juce_core/javascript/choc/containers/choc_Value.h index ed666049ee..8157a74af9 100644 --- a/modules/juce_core/javascript/choc/containers/choc_Value.h +++ b/modules/juce_core/javascript/choc/containers/choc_Value.h @@ -2323,7 +2323,7 @@ inline std::string_view ValueView::getString() const // from this function if (stringDictionary == nullptr) throwError ("No string dictionary supplied"); - + return stringDictionary->getStringForHandle (getStringHandle()); } @@ -2430,43 +2430,28 @@ void ValueView::serialise (OutputStream& output) const if (type.isVoid()) return; - auto dataSize = type.getValueDataSize(); - check (dataSize > 0, "Invalid data size"); + auto dataSize = type.getValueDataSize(); + check (dataSize > 0, "Invalid data size"); - if (stringDictionary == nullptr || ! type.usesStrings()) - { - output.write (data, dataSize); - return; - } + if (stringDictionary == nullptr || ! type.usesStrings()) + { + output.write (data, dataSize); + return; + } - uint8_t* localCopy = nullptr; + #if defined (_MSC_VER) + #pragma warning (push) + #pragma warning (disable: 6255) + auto* localCopy = (uint8_t*) _alloca (dataSize); + #pragma warning (pop) + #elif defined (__MINGW32__) + auto* localCopy = (uint8_t*) _alloca (dataSize); + #else + auto* localCopy = (uint8_t*) alloca (dataSize); + #endif - #if _MSC_VER - - #ifdef __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wlanguage-extension-token" - #endif - - __try - { - localCopy = (uint8_t*) _alloca (dataSize); - } - __except (GetExceptionCode() == STATUS_STACK_OVERFLOW) - { - throwError ("Stack overflow"); - } - - #ifdef __clang__ - #pragma clang diagnostic pop - #endif - - #else - localCopy = (uint8_t*) alloca (dataSize); - #endif - - check (localCopy != nullptr, "Stack allocation failed"); - std::memcpy (localCopy, data, dataSize); + check (localCopy != nullptr, "Stack allocation failed"); + std::memcpy (localCopy, data, dataSize); static constexpr uint32_t maxStrings = 128; uint32_t numStrings = 0, stringDataSize = 0; diff --git a/modules/juce_core/javascript/choc/math/choc_MathHelpers.h b/modules/juce_core/javascript/choc/math/choc_MathHelpers.h index f91b1953b0..a5f77bb8f2 100644 --- a/modules/juce_core/javascript/choc/math/choc_MathHelpers.h +++ b/modules/juce_core/javascript/choc/math/choc_MathHelpers.h @@ -100,7 +100,14 @@ inline Int128 multiply128 (uint64_t a, uint64_t b) result.low = _umul128 (a, b, &result.high); return result; #elif __LP64__ + #if __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpedantic" + #endif auto total = static_cast (a) * static_cast (b); + #if __GNUC__ + #pragma GCC diagnostic pop + #endif return { static_cast (total >> 64), static_cast (total) }; #else uint64_t a0 = static_cast (a), a1 = a >> 32, diff --git a/modules/juce_core/javascript/choc/platform/choc_DisableAllWarnings.h b/modules/juce_core/javascript/choc/platform/choc_DisableAllWarnings.h index c9c26e022a..a1d8b25f61 100644 --- a/modules/juce_core/javascript/choc/platform/choc_DisableAllWarnings.h +++ b/modules/juce_core/javascript/choc/platform/choc_DisableAllWarnings.h @@ -75,6 +75,7 @@ #pragma GCC diagnostic ignored "-Wvolatile" #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wpedantic" #ifndef __MINGW32__ #pragma GCC diagnostic ignored "-Wredundant-move" #endif