diff --git a/examples/DemoRunner/Builds/Android/app/CMakeLists.txt b/examples/DemoRunner/Builds/Android/app/CMakeLists.txt
index 8cdc8ac8e4..b87f38ac38 100644
--- a/examples/DemoRunner/Builds/Android/app/CMakeLists.txt
+++ b/examples/DemoRunner/Builds/Android/app/CMakeLists.txt
@@ -1066,7 +1066,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_core/javascript/choc/text/choc_JSON.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_StringUtilities.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_UTF8.h"
- "../../../../../modules/juce_core/javascript/choc/JUCE_CHANGES.txt"
"../../../../../modules/juce_core/javascript/choc/LICENSE.md"
"../../../../../modules/juce_core/javascript/juce_Javascript.cpp"
"../../../../../modules/juce_core/javascript/juce_Javascript.h"
@@ -3649,7 +3648,6 @@ set_source_files_properties(
"../../../../../modules/juce_core/javascript/choc/text/choc_JSON.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_StringUtilities.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_UTF8.h"
- "../../../../../modules/juce_core/javascript/choc/JUCE_CHANGES.txt"
"../../../../../modules/juce_core/javascript/choc/LICENSE.md"
"../../../../../modules/juce_core/javascript/juce_Javascript.cpp"
"../../../../../modules/juce_core/javascript/juce_Javascript.h"
diff --git a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj
index b09d2e3323..de3b4229d6 100644
--- a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj
+++ b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj
@@ -4704,7 +4704,6 @@
-
diff --git a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters
index dcf3b6e7ff..a729569ab5 100644
--- a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters
+++ b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters
@@ -8561,9 +8561,6 @@
JUCE Modules\juce_box2d\box2d
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj
index 5a3aa07992..7b63be293f 100644
--- a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj
+++ b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj
@@ -4704,7 +4704,6 @@
-
diff --git a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters
index 78d4b9efb1..dc90c6dcb6 100644
--- a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters
+++ b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters
@@ -8561,9 +8561,6 @@
JUCE Modules\juce_box2d\box2d
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt b/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt
index 1ff4941d1e..05fcb65b7f 100644
--- a/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt
+++ b/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt
@@ -925,7 +925,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_core/javascript/choc/text/choc_JSON.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_StringUtilities.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_UTF8.h"
- "../../../../../modules/juce_core/javascript/choc/JUCE_CHANGES.txt"
"../../../../../modules/juce_core/javascript/choc/LICENSE.md"
"../../../../../modules/juce_core/javascript/juce_Javascript.cpp"
"../../../../../modules/juce_core/javascript/juce_Javascript.h"
@@ -3191,7 +3190,6 @@ set_source_files_properties(
"../../../../../modules/juce_core/javascript/choc/text/choc_JSON.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_StringUtilities.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_UTF8.h"
- "../../../../../modules/juce_core/javascript/choc/JUCE_CHANGES.txt"
"../../../../../modules/juce_core/javascript/choc/LICENSE.md"
"../../../../../modules/juce_core/javascript/juce_Javascript.cpp"
"../../../../../modules/juce_core/javascript/juce_Javascript.h"
diff --git a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj
index 4fdec41335..c98a271a5b 100644
--- a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj
+++ b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj
@@ -4123,7 +4123,6 @@
-
diff --git a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters
index f36750a14c..d3cb19667d 100644
--- a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters
+++ b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters
@@ -7460,9 +7460,6 @@
JUCE Modules\juce_audio_processors\format_types\VST3_SDK
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt b/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt
index 3394ce15ee..ba4030cf86 100644
--- a/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt
+++ b/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt
@@ -958,7 +958,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_core/javascript/choc/text/choc_JSON.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_StringUtilities.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_UTF8.h"
- "../../../../../modules/juce_core/javascript/choc/JUCE_CHANGES.txt"
"../../../../../modules/juce_core/javascript/choc/LICENSE.md"
"../../../../../modules/juce_core/javascript/juce_Javascript.cpp"
"../../../../../modules/juce_core/javascript/juce_Javascript.h"
@@ -3377,7 +3376,6 @@ set_source_files_properties(
"../../../../../modules/juce_core/javascript/choc/text/choc_JSON.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_StringUtilities.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_UTF8.h"
- "../../../../../modules/juce_core/javascript/choc/JUCE_CHANGES.txt"
"../../../../../modules/juce_core/javascript/choc/LICENSE.md"
"../../../../../modules/juce_core/javascript/juce_Javascript.cpp"
"../../../../../modules/juce_core/javascript/juce_Javascript.h"
diff --git a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj
index 0c4968beea..15c06d120c 100644
--- a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj
+++ b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj
@@ -4389,7 +4389,6 @@
-
diff --git a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters
index 893f8556f0..ddf55fa8ae 100644
--- a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters
+++ b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters
@@ -7994,9 +7994,6 @@
JUCE Modules\juce_audio_processors\format_types\VST3_SDK
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj
index dc01ed1e33..3e7ee35953 100644
--- a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj
+++ b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj
@@ -4389,7 +4389,6 @@
-
diff --git a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters
index 41196f6ac6..c5337335d7 100644
--- a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters
+++ b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters
@@ -7994,9 +7994,6 @@
JUCE Modules\juce_audio_processors\format_types\VST3_SDK
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/BinaryBuilder/Builds/VisualStudio2022/BinaryBuilder_ConsoleApp.vcxproj b/extras/BinaryBuilder/Builds/VisualStudio2022/BinaryBuilder_ConsoleApp.vcxproj
index 2a5d125c11..b00fd2667d 100644
--- a/extras/BinaryBuilder/Builds/VisualStudio2022/BinaryBuilder_ConsoleApp.vcxproj
+++ b/extras/BinaryBuilder/Builds/VisualStudio2022/BinaryBuilder_ConsoleApp.vcxproj
@@ -688,7 +688,6 @@
-
diff --git a/extras/BinaryBuilder/Builds/VisualStudio2022/BinaryBuilder_ConsoleApp.vcxproj.filters b/extras/BinaryBuilder/Builds/VisualStudio2022/BinaryBuilder_ConsoleApp.vcxproj.filters
index d7c6eba364..2ecd52e5d5 100644
--- a/extras/BinaryBuilder/Builds/VisualStudio2022/BinaryBuilder_ConsoleApp.vcxproj.filters
+++ b/extras/BinaryBuilder/Builds/VisualStudio2022/BinaryBuilder_ConsoleApp.vcxproj.filters
@@ -1019,9 +1019,6 @@
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt b/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt
index 7b45b7a291..53a2725a42 100644
--- a/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt
+++ b/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt
@@ -929,7 +929,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_core/javascript/choc/text/choc_JSON.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_StringUtilities.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_UTF8.h"
- "../../../../../modules/juce_core/javascript/choc/JUCE_CHANGES.txt"
"../../../../../modules/juce_core/javascript/choc/LICENSE.md"
"../../../../../modules/juce_core/javascript/juce_Javascript.cpp"
"../../../../../modules/juce_core/javascript/juce_Javascript.h"
@@ -3275,7 +3274,6 @@ set_source_files_properties(
"../../../../../modules/juce_core/javascript/choc/text/choc_JSON.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_StringUtilities.h"
"../../../../../modules/juce_core/javascript/choc/text/choc_UTF8.h"
- "../../../../../modules/juce_core/javascript/choc/JUCE_CHANGES.txt"
"../../../../../modules/juce_core/javascript/choc/LICENSE.md"
"../../../../../modules/juce_core/javascript/juce_Javascript.cpp"
"../../../../../modules/juce_core/javascript/juce_Javascript.h"
diff --git a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj
index e91b2f9f6b..bdab9480c7 100644
--- a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj
+++ b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj
@@ -4257,7 +4257,6 @@
-
diff --git a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters
index a872282016..bdb0f6ca94 100644
--- a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters
+++ b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters
@@ -7730,9 +7730,6 @@
JUCE Modules\juce_audio_processors\format_types\VST3_SDK
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj
index 398267d35e..1b04a4a2c7 100644
--- a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj
+++ b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj
@@ -2944,7 +2944,6 @@
-
diff --git a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters
index 04fded88b9..642e615b7d 100644
--- a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters
+++ b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters
@@ -5315,9 +5315,6 @@
Projucer\BinaryData
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj
index f414b1287b..c8152aaeec 100644
--- a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj
+++ b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj
@@ -2944,7 +2944,6 @@
-
diff --git a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters
index 15b4d9fd7f..cb6010a122 100644
--- a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters
+++ b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters
@@ -5315,9 +5315,6 @@
Projucer\BinaryData
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj
index a7699fa770..728838a489 100644
--- a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj
+++ b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj
@@ -4524,7 +4524,6 @@
-
diff --git a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters
index 2e114bc283..38db8b39c1 100644
--- a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters
+++ b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters
@@ -8225,9 +8225,6 @@
JUCE Modules\juce_audio_processors\format_types\VST3_SDK
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj
index 049b0cd2fe..8a72351c82 100644
--- a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj
+++ b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj
@@ -4524,7 +4524,6 @@
-
diff --git a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters
index f726cde998..9303b28f4a 100644
--- a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters
+++ b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters
@@ -8225,9 +8225,6 @@
JUCE Modules\juce_audio_processors\format_types\VST3_SDK
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj
index 2a9d08753c..54891cc9ce 100644
--- a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj
+++ b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj
@@ -4232,7 +4232,6 @@
-
diff --git a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj.filters b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj.filters
index 2928024b1a..21348392bd 100644
--- a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj.filters
+++ b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj.filters
@@ -7694,9 +7694,6 @@
JUCE Modules\juce_audio_processors\format_types\VST3_SDK
-
- JUCE Modules\juce_core\javascript\choc
-
JUCE Modules\juce_core\javascript\choc
diff --git a/modules/juce_core/javascript/choc/JUCE_CHANGES.txt b/modules/juce_core/javascript/choc/JUCE_CHANGES.txt
deleted file mode 100644
index 343f6f777b..0000000000
--- a/modules/juce_core/javascript/choc/JUCE_CHANGES.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-The files in this directory were downloaded from the choc repository at
-https://github.com/Tracktion/choc.
-
-In order to avoid exposing any symbols in the choc implementation, the files were modified by
-prepending all `namespace choc...` lines with `namespace {`, and by adding corresponding closing
-brackets as well.
-
-Enclosing all choc definitions in an anonymous namespace allows JUCE based projects to use an
-external copy of choc without running into multiply defined symbol compilation errors.
-
-By placing the anonymous namespace encapsulation inside the choc header files we avoid the issue of
-including the system headers in the namespace as well.
diff --git a/modules/juce_core/javascript/choc/containers/choc_Value.h b/modules/juce_core/javascript/choc/containers/choc_Value.h
index 101b212f9d..ed666049ee 100644
--- a/modules/juce_core/javascript/choc/containers/choc_Value.h
+++ b/modules/juce_core/javascript/choc/containers/choc_Value.h
@@ -27,8 +27,6 @@
#include
#include "../platform/choc_Assert.h"
-namespace
-{
namespace choc::value
{
@@ -430,19 +428,36 @@ public:
//==============================================================================
/** A simple implementation of StringDictionary.
This should have good performance for typical-sized dictionaries.
- Adding new strings will require O(n) time where n = dictionary size, but
+ Adding new strings will require O(log n) time where n = dictionary size, but
retrieving the string for a handle is fast with O(1).
*/
struct SimpleStringDictionary : public StringDictionary
{
+ SimpleStringDictionary() = default;
+ SimpleStringDictionary (const SimpleStringDictionary& other) : strings (other.strings), stringMap (other.stringMap) {}
+ SimpleStringDictionary (SimpleStringDictionary&& other) : strings (std::move (other.strings)), stringMap (std::move (other.stringMap)) {}
+ SimpleStringDictionary& operator= (const SimpleStringDictionary& other) { strings = other.strings; stringMap = other.stringMap; return *this; }
+ SimpleStringDictionary& operator= (SimpleStringDictionary&& other) { strings = std::move (other.strings); stringMap = std::move (other.stringMap); return *this; }
+
Handle getHandleForString (std::string_view) override;
std::string_view getStringForHandle (Handle handle) const override;
+ bool empty() const { return strings.empty(); }
void clear();
+ size_t getRawDataSize() const { return strings.size(); }
+ const char* getRawData() const { return strings.data(); }
+
+ void setRawData (const void*, size_t);
+
+private:
+ std::pair::const_iterator, bool> findGreaterThanOrEqual (std::string_view) const;
+
/// The strings are stored in a single chunk, which can be saved and
- /// reloaded if necessary.
+ /// reloaded if necessary. The stringMap is a sorted vector of handles
+ /// supporting fast lookup of strings in the map
std::vector strings;
+ std::vector stringMap;
};
//==============================================================================
@@ -1654,15 +1669,17 @@ inline int Type::getObjectMemberIndex (std::string_view name) const
template
inline constexpr Type::MainType Type::selectMainType()
{
- if constexpr (std::is_same::value) return MainType::int32;
- if constexpr (std::is_same::value) return MainType::int64;
- if constexpr (std::is_same::value) return MainType::float32;
- if constexpr (std::is_same::value) return MainType::float64;
- if constexpr (std::is_same::value) return MainType::boolean;
- if constexpr (std::is_same::value) return MainType::string;
- if constexpr (std::is_same::value) return MainType::string;
+ Type::MainType result = MainType::void_;
- return MainType::void_;
+ if constexpr (std::is_same::value) result = MainType::int32;
+ else if constexpr (std::is_same::value) result = MainType::int64;
+ else if constexpr (std::is_same::value) result = MainType::float32;
+ else if constexpr (std::is_same::value) result = MainType::float64;
+ else if constexpr (std::is_same::value) result = MainType::boolean;
+ else if constexpr (std::is_same::value) result = MainType::string;
+ else if constexpr (std::is_same::value) result = MainType::string;
+
+ return result;
}
template
@@ -2302,7 +2319,11 @@ inline StringDictionary::Handle ValueView::getStringHandle() const
inline std::string_view ValueView::getString() const
{
- check (stringDictionary != nullptr, "No string dictionary supplied");
+ // To satisfy the MSVC code analyser this check needs to be handled directly
+ // from this function
+ if (stringDictionary == nullptr)
+ throwError ("No string dictionary supplied");
+
return stringDictionary->getStringForHandle (getStringHandle());
}
@@ -2409,21 +2430,43 @@ void ValueView::serialise (OutputStream& output) const
if (type.isVoid())
return;
- auto dataSize = type.getValueDataSize();
+ 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;
+ }
- static constexpr uint32_t maximumSize = 16384;
+ uint8_t* localCopy = nullptr;
- if (dataSize > maximumSize)
- throwError ("Out of local scratch space");
+ #if _MSC_VER
- uint8_t localCopy[maximumSize];
- std::memcpy (localCopy, data, dataSize);
+ #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);
static constexpr uint32_t maxStrings = 128;
uint32_t numStrings = 0, stringDataSize = 0;
@@ -2918,11 +2961,10 @@ template void Value::serialise (OutputStream& o) const
{
o.write (getRawData(), value.type.getValueDataSize());
- if (auto stringDataSize = static_cast (dictionary.strings.size()))
+ if (auto stringDataSize = static_cast (dictionary.getRawDataSize()))
{
- CHOC_ASSERT (dictionary.strings.back() == 0);
Type::SerialisationHelpers::writeVariableLengthInt (o, stringDataSize);
- o.write (dictionary.strings.data(), stringDataSize);
+ o.write (dictionary.getRawData(), stringDataSize);
}
}
}
@@ -2947,9 +2989,7 @@ inline Value Value::deserialise (InputData& input)
{
auto stringDataSize = Type::SerialisationHelpers::readVariableLengthInt (input);
Type::SerialisationHelpers::expect (stringDataSize <= static_cast (input.end - input.start));
- v.dictionary.strings.resize (stringDataSize);
- std::memcpy (v.dictionary.strings.data(), input.start, stringDataSize);
- Type::SerialisationHelpers::expect (v.dictionary.strings.back() == 0);
+ v.dictionary.setRawData (input.start, stringDataSize);
}
return v;
@@ -3207,20 +3247,20 @@ inline SimpleStringDictionary::Handle SimpleStringDictionary::getHandleForString
if (text.empty())
return {};
- for (size_t i = 0; i < strings.size(); ++i)
- {
- std::string_view sv (strings.data() + i);
+ auto i = findGreaterThanOrEqual (text);
- if (text == sv)
- return { static_cast (i + 1) };
-
- i += sv.length();
- }
+ if (i.second)
+ return { *i.first };
auto newHandle = static_cast (strings.size() + 1);
- strings.reserve (strings.size() + text.length() + 1);
+
+ if (strings.size() > 100 && (strings.capacity() < (strings.size() + text.length() + 1)))
+ strings.reserve (strings.size() + 1000);
+
strings.insert (strings.end(), text.begin(), text.end());
strings.push_back (0);
+
+ stringMap.insert (i.first, newHandle);
return { newHandle };
}
@@ -3235,9 +3275,41 @@ inline std::string_view SimpleStringDictionary::getStringForHandle (Handle handl
return std::string_view (strings.data() + (handle.handle - 1));
}
-inline void SimpleStringDictionary::clear() { strings.clear(); }
+inline void SimpleStringDictionary::clear() { strings.clear(); stringMap.clear(); }
+
+inline void SimpleStringDictionary::setRawData (const void* p, size_t n)
+{
+ strings.resize (n);
+ std::memcpy (strings.data(), p, n);
+
+ // Populate string map
+ for (size_t i = 0; i < strings.size(); ++i)
+ {
+ std::string_view sv (strings.data() + i);
+ auto v = findGreaterThanOrEqual (sv);
+ stringMap.insert (v.first, static_cast (i));
+ i += sv.length();
+ }
+}
+
+inline std::pair::const_iterator, bool> SimpleStringDictionary::findGreaterThanOrEqual (std::string_view v) const
+{
+ bool exactMatch = false;
+
+ auto it = std::lower_bound (stringMap.begin(), stringMap.end(), v, [&] (uint32_t i, std::string_view sv) -> bool
+ {
+ auto c = sv.compare (getStringForHandle ( { i }));
+
+ if (c == 0)
+ exactMatch = true;
+
+ return c > 0;
+ });
+
+ return std::pair (it, exactMatch);
+}
} // namespace choc::value
-} // anonymous namespace
+
#endif // CHOC_VALUE_POOL_HEADER_INCLUDED
diff --git a/modules/juce_core/javascript/choc/javascript/choc_javascript.h b/modules/juce_core/javascript/choc/javascript/choc_javascript.h
index 6f3e63d6d2..95f16780a7 100644
--- a/modules/juce_core/javascript/choc/javascript/choc_javascript.h
+++ b/modules/juce_core/javascript/choc/javascript/choc_javascript.h
@@ -33,8 +33,6 @@
choc::javascript::createQuickJSContext() to create a context for running
javascript code.
*/
-namespace
-{
namespace choc::javascript
{
/// This is thrown by any javascript functions that need to report an error
@@ -95,23 +93,40 @@ namespace choc::javascript
Context& operator= (Context&&);
~Context();
+ /// Returns true if the context is valid.
+ operator bool() const { return pimpl != nullptr; }
+
+ //==============================================================================
+ /// This callback is used by the run() method.
+ using CompletionHandler = std::function;
+
+ /// Executes some javascript asynchronously.
+ /// If a CompletionHandler callback is provided, it will be called asynchronously
+ /// with the return value and any errors that occurred. Note that if you want to execute
+ /// the script as a module, use runModule() instead.
+ void run (const std::string& javascriptCode,
+ CompletionHandler handleResult = {});
+
/// When parsing modules, this function is expected to take a path to a module, and
/// to return the content of that module, or an empty optional if not found.
using ReadModuleContentFn = std::function(std::string_view)>;
- //==============================================================================
- /// Evaluates the given chunk of javascript.
- /// If there are any parse errors, this will throw a choc::javascript::Error exception.
- /// If the engine supports modules, then providing a value for the resolveModuleContent
- /// function will treat the code as a module and will call your function to read the
- /// content of any dependencies.
- /// None of the methods in this class are either thread-safe or realtime-safe, so you'll
- /// need to organise your own locking if you're calling into a single Context from
- /// multiple threads.
- choc::value::Value evaluate (const std::string& javascriptCode,
- ReadModuleContentFn* resolveModuleContent = nullptr);
+ /// This callback will asynchronously parse the script as a module, and will use the
+ /// ReadModuleContentFn functor to resolve any imported modules that it needs. If a
+ /// CompletionHandler callback is provided, it will be called asynchronously with the
+ /// return value and any errors that occurred.
+ /// NB: Not all engines support modules.
+ void runModule (const std::string& moduleCode,
+ ReadModuleContentFn,
+ CompletionHandler handleResult = {});
- /// Attempts to invoke a global function with no arguments.
+ /// Evaluates a javascript expression synchronously, and returns the result.
+ /// If there are any parse errors, this will throw a choc::javascript::Error exception.
+ /// Note that if you want to execute the script as a module, use runModule() instead.
+ choc::value::Value evaluateExpression (const std::string& javascriptCode);
+
+ /// Attempts to synchronously invoke a global function with no arguments.
/// Any errors will throw a choc::javascript::Error exception.
/// None of the methods in this class are either thread-safe or realtime-safe, so you'll
/// need to organise your own locking if you're calling into a single Context from
@@ -153,8 +168,6 @@ namespace choc::javascript
/// @internal
Context (std::unique_ptr);
- Pimpl* getPimpl() const;
-
private:
std::unique_ptr pimpl;
};
@@ -172,8 +185,13 @@ namespace choc::javascript
/// make sure that your project also has the V8 header folder in its
/// search path, and that you statically link the appropriate V8 libs.
Context createV8Context();
+
+ //==============================================================================
+ /// Sanitises a string to provide a version of it that is safe for use as a
+ /// javascript identifier. This involves removing/replacing any illegal
+ /// characters and modifying the string to avoid clashes with reserved words.
+ std::string makeSafeIdentifier (std::string name);
}
-} // anonymous namespace
//==============================================================================
@@ -187,8 +205,6 @@ namespace choc::javascript
//
//==============================================================================
-namespace
-{
namespace choc::javascript
{
@@ -207,7 +223,8 @@ struct Context::Pimpl
virtual ~Pimpl() = default;
virtual void registerFunction (const std::string&, NativeFunction) = 0;
- virtual choc::value::Value evaluate (const std::string&, ReadModuleContentFn*) = 0;
+ virtual choc::value::Value evaluateExpression (const std::string&) = 0;
+ virtual void run (const std::string&, ReadModuleContentFn*, CompletionHandler) = 0;
virtual void prepareForCall (std::string_view, uint32_t numArgs) = 0;
virtual choc::value::Value performCall() = 0;
virtual void pushObjectOrArray (const choc::value::ValueView&) = 0;
@@ -277,10 +294,22 @@ inline void Context::registerFunction (const std::string& name, NativeFunction f
pimpl->registerFunction (name, std::move (fn));
}
-inline choc::value::Value Context::evaluate (const std::string& javascriptCode, ReadModuleContentFn* resolveModule)
+inline choc::value::Value Context::evaluateExpression (const std::string& javascriptCode)
{
CHOC_ASSERT (pimpl != nullptr); // cannot call this on a moved-from context!
- return pimpl->evaluate (javascriptCode, resolveModule);
+ return pimpl->evaluateExpression (javascriptCode);
+}
+
+inline void Context::run (const std::string& javascriptCode, CompletionHandler handleResult)
+{
+ CHOC_ASSERT (pimpl != nullptr); // cannot call this on a moved-from context!
+ pimpl->run (javascriptCode, nullptr, std::move (handleResult));
+}
+
+inline void Context::runModule (const std::string& moduleCode, ReadModuleContentFn readModule, CompletionHandler handleResult)
+{
+ CHOC_ASSERT (pimpl != nullptr); // cannot call this on a moved-from context!
+ pimpl->run (moduleCode, std::addressof (readModule), std::move (handleResult));
}
inline void Context::pumpMessageLoop()
@@ -289,13 +318,40 @@ inline void Context::pumpMessageLoop()
pimpl->pumpMessageLoop();
}
-Context::Pimpl* Context::getPimpl() const
+inline std::string makeSafeIdentifier (std::string s)
{
- return pimpl.get();
+ constexpr static std::string_view reservedWords[] =
+ {
+ "abstract", "arguments", "await", "boolean", "break", "byte", "case", "catch",
+ "char", "class", "const", "continue", "debugger", "default", "delete", "do",
+ "double", "else", "enum", "eval", "export", "extends", "false", "final",
+ "finally", "float", "for", "function", "goto", "if", "implements", "import",
+ "in", "instanceof", "int", "interface", "let", "long", "native", "new",
+ "null", "package", "private", "protected", "public", "return", "short", "static",
+ "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true",
+ "try", "typeof", "var", "void", "volatile", "while", "with", "yield"
+ };
+
+ for (auto& c : s)
+ if (std::string_view (" ,./;:").find (c) != std::string_view::npos)
+ c = '_';
+
+ s.erase (std::remove_if (s.begin(), s.end(), [&] (char c)
+ {
+ return ! ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= '0' && c <= '9'));
+ }), s.end());
+
+ if (s[0] >= '0' && s[0] <= '9') // Identifiers can't start with a digit
+ s = "_" + s;
+
+ for (auto keyword : reservedWords)
+ if (s == keyword)
+ return s + "_";
+
+ return s;
}
} // namespace choc::javascript
-} // anonymous namespace
#endif // CHOC_JAVASCRIPT_HEADER_INCLUDED
diff --git a/modules/juce_core/javascript/choc/javascript/choc_javascript_QuickJS.h b/modules/juce_core/javascript/choc/javascript/choc_javascript_QuickJS.h
index 12e93f8771..99101236f1 100644
--- a/modules/juce_core/javascript/choc/javascript/choc_javascript_QuickJS.h
+++ b/modules/juce_core/javascript/choc/javascript/choc_javascript_QuickJS.h
@@ -45,9 +45,7 @@
#include
#include
#include
-
#include
-
#include
#include
#include
@@ -73,8 +71,6 @@
#include
#endif
-namespace
-{
namespace choc::javascript
{
@@ -393,7 +389,7 @@ void rqsort(void *base, size_t nmemb, size_t size,
int (*cmp)(const void *, const void *, void *),
void *arg);
-void pstrcpy(char *buf, int buf_size, const char *str)
+inline void pstrcpy(char *buf, int buf_size, const char *str)
{
int c;
char *q = buf;
@@ -411,7 +407,7 @@ void pstrcpy(char *buf, int buf_size, const char *str)
}
/* strcat and truncate. */
-char *pstrcat(char *buf, int buf_size, const char *s)
+inline char *pstrcat(char *buf, int buf_size, const char *s)
{
int len;
len = strlen(buf);
@@ -420,7 +416,7 @@ char *pstrcat(char *buf, int buf_size, const char *s)
return buf;
}
-int strstart(const char *str, const char *val, const char **ptr)
+inline int strstart(const char *str, const char *val, const char **ptr)
{
const char *p, *q;
p = str;
@@ -436,7 +432,7 @@ int strstart(const char *str, const char *val, const char **ptr)
return 1;
}
-int has_suffix(const char *str, const char *suffix)
+inline int has_suffix(const char *str, const char *suffix)
{
size_t len = strlen(str);
size_t slen = strlen(suffix);
@@ -450,7 +446,7 @@ static void *dbuf_default_realloc(void *opaque, void *ptr, size_t size)
return realloc(ptr, size);
}
-void dbuf_init2(DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func)
+inline void dbuf_init2(DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func)
{
memset(s, 0, sizeof(*s));
if (!realloc_func)
@@ -459,13 +455,13 @@ void dbuf_init2(DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func)
s->realloc_func = realloc_func;
}
-void dbuf_init(DynBuf *s)
+inline void dbuf_init(DynBuf *s)
{
dbuf_init2(s, NULL, NULL);
}
/* return < 0 if error */
-int dbuf_realloc(DynBuf *s, size_t new_size)
+inline int dbuf_realloc(DynBuf *s, size_t new_size)
{
size_t size;
uint8_t *new_buf;
@@ -486,7 +482,7 @@ int dbuf_realloc(DynBuf *s, size_t new_size)
return 0;
}
-int dbuf_write(DynBuf *s, size_t offset, const uint8_t *data, size_t len)
+inline int dbuf_write(DynBuf *s, size_t offset, const uint8_t *data, size_t len)
{
size_t end;
end = offset + len;
@@ -498,7 +494,7 @@ int dbuf_write(DynBuf *s, size_t offset, const uint8_t *data, size_t len)
return 0;
}
-int dbuf_put(DynBuf *s, const uint8_t *data, size_t len)
+inline int dbuf_put(DynBuf *s, const uint8_t *data, size_t len)
{
if (js_unlikely((s->size + len) > s->allocated_size)) {
if (dbuf_realloc(s, s->size + len))
@@ -509,7 +505,7 @@ int dbuf_put(DynBuf *s, const uint8_t *data, size_t len)
return 0;
}
-int dbuf_put_self(DynBuf *s, size_t offset, size_t len)
+inline int dbuf_put_self(DynBuf *s, size_t offset, size_t len)
{
if (js_unlikely((s->size + len) > s->allocated_size)) {
if (dbuf_realloc(s, s->size + len))
@@ -520,17 +516,17 @@ int dbuf_put_self(DynBuf *s, size_t offset, size_t len)
return 0;
}
-int dbuf_putc(DynBuf *s, uint8_t c)
+inline int dbuf_putc(DynBuf *s, uint8_t c)
{
return dbuf_put(s, &c, 1);
}
-int dbuf_putstr(DynBuf *s, const char *str)
+inline int dbuf_putstr(DynBuf *s, const char *str)
{
return dbuf_put(s, (const uint8_t *)str, strlen(str));
}
-int dbuf_printf(DynBuf *s, const char *fmt, ...)
+inline int dbuf_printf(DynBuf *s, const char *fmt, ...)
{
va_list ap;
char buf[128];
@@ -554,7 +550,7 @@ int dbuf_printf(DynBuf *s, const char *fmt, ...)
return 0;
}
-void dbuf_free(DynBuf *s)
+inline void dbuf_free(DynBuf *s)
{
/* we test s->buf as a fail safe to avoid crashing if dbuf_free()
is called twice */
@@ -566,7 +562,7 @@ void dbuf_free(DynBuf *s)
/* Note: at most 31 bits are encoded. At most UTF8_CHAR_LEN_MAX bytes
are output. */
-int unicode_to_utf8(uint8_t *buf, unsigned int c)
+inline int unicode_to_utf8(uint8_t *buf, unsigned int c)
{
uint8_t *q = buf;
@@ -611,7 +607,7 @@ static const unsigned char utf8_first_code_mask[5] = {
/* return -1 if error. *pp is not updated in this case. max_len must
be >= 1. The maximum length for a UTF8 byte sequence is 6 bytes. */
-int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp)
+inline int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp)
{
int l, c, b, i;
@@ -846,7 +842,7 @@ static inline void *med3(void *a, void *b, void *c, cmp_f cmp, void *opaque)
}
/* pointer based version with local stack and insertion sort threshhold */
-void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
+inline void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
{
struct { uint8_t *base; size_t count; int depth; } stack[50], *sp = stack;
uint8_t *ptr, *pi, *pj, *plt, *pgt, *top, *m;
@@ -4408,7 +4404,7 @@ static const uint16_t char_range_s[] = {
0xFEFF, 0xFEFF + 1,
};
-BOOL lre_is_space(int c)
+inline BOOL lre_is_space(int c)
{
int i, n, low, high;
n = (countof(char_range_s) - 1) / 2;
@@ -4423,12 +4419,12 @@ BOOL lre_is_space(int c)
return FALSE;
}
-uint32_t const lre_id_start_table_ascii[4] = {
+inline uint32_t const lre_id_start_table_ascii[4] = {
/* $ A-Z _ a-z */
0x00000000, 0x00000010, 0x87FFFFFE, 0x07FFFFFE
};
-uint32_t const lre_id_continue_table_ascii[4] = {
+inline uint32_t const lre_id_continue_table_ascii[4] = {
/* $ 0-9 A-Z _ a-z */
0x00000000, 0x03FF0010, 0x87FFFFFE, 0x07FFFFFE
};
@@ -4726,7 +4722,7 @@ static int re_parse_expect(REParseState *s, const uint8_t **pp, int c)
Return the unicode char and update *pp if recognized,
return -1 if malformed escape,
return -2 otherwise. */
-int lre_parse_escape(const uint8_t **pp, int allow_utf16)
+inline int lre_parse_escape(const uint8_t **pp, int allow_utf16)
{
const uint8_t *p;
uint32_t c;
@@ -6059,7 +6055,7 @@ static int compute_stack_size(const uint8_t *bc_buf, int bc_buf_len)
Return NULL if error and allocate an error message in *perror_msg,
otherwise the compiled bytecode and its length in plen.
*/
-uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
+inline uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
const char *buf, size_t buf_len, int re_flags,
void *opaque)
{
@@ -6737,9 +6733,9 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
/* Return 1 if match, 0 if not match or -1 if error. cindex is the
starting position of the match and must be such as 0 <= cindex <=
clen. */
-int lre_exec(uint8_t **capture,
- const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen,
- int cbuf_type, void *opaque)
+inline int lre_exec(uint8_t **capture,
+ const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen,
+ int cbuf_type, void *opaque)
{
REExecContext s_s, *s = &s_s;
int re_flags, i, alloca_size, ret;
@@ -6775,19 +6771,19 @@ int lre_exec(uint8_t **capture,
return ret;
}
-int lre_get_capture_count(const uint8_t *bc_buf)
+inline int lre_get_capture_count(const uint8_t *bc_buf)
{
return bc_buf[RE_HEADER_CAPTURE_COUNT];
}
-int lre_get_flags(const uint8_t *bc_buf)
+inline int lre_get_flags(const uint8_t *bc_buf)
{
return bc_buf[RE_HEADER_FLAGS];
}
/* Return NULL if no group names. Otherwise, return a pointer to
'capture_count - 1' zero terminated UTF-8 strings. */
-const char *lre_get_groupnames(const uint8_t *bc_buf)
+inline const char *lre_get_groupnames(const uint8_t *bc_buf)
{
uint32_t re_bytecode_len;
if ((lre_get_flags(bc_buf) & LRE_FLAG_NAMED_GROUPS) == 0)
@@ -6888,7 +6884,7 @@ enum {
1 = to lower
2 = case folding (= to lower with modifications)
*/
-int lre_case_conv(uint32_t *res, uint32_t c, int conv_type)
+inline int lre_case_conv(uint32_t *res, uint32_t c, int conv_type)
{
if (c < 128) {
if (conv_type) {
@@ -7072,7 +7068,7 @@ static BOOL lre_is_in_table(uint32_t c, const uint8_t *table,
}
}
-BOOL lre_is_cased(uint32_t c)
+inline BOOL lre_is_cased(uint32_t c)
{
uint32_t v, code, len;
int idx, idx_min, idx_max;
@@ -7097,7 +7093,7 @@ BOOL lre_is_cased(uint32_t c)
sizeof(unicode_prop_Cased1_index) / 3);
}
-BOOL lre_is_case_ignorable(uint32_t c)
+inline BOOL lre_is_case_ignorable(uint32_t c)
{
return lre_is_in_table(c, unicode_prop_Case_Ignorable_table,
unicode_prop_Case_Ignorable_index,
@@ -7111,7 +7107,7 @@ static void *cr_default_realloc(void *opaque, void *ptr, size_t size)
return realloc(ptr, size);
}
-void cr_init(CharRange *cr, void *mem_opaque, DynBufReallocFunc *realloc_func)
+inline void cr_init(CharRange *cr, void *mem_opaque, DynBufReallocFunc *realloc_func)
{
cr->len = cr->size = 0;
cr->points = NULL;
@@ -7119,12 +7115,12 @@ void cr_init(CharRange *cr, void *mem_opaque, DynBufReallocFunc *realloc_func)
cr->realloc_func = realloc_func ? realloc_func : cr_default_realloc;
}
-void cr_free(CharRange *cr)
+inline void cr_free(CharRange *cr)
{
cr->realloc_func(cr->mem_opaque, cr->points, 0);
}
-int cr_realloc(CharRange *cr, int size)
+inline int cr_realloc(CharRange *cr, int size)
{
int new_size;
uint32_t *new_buf;
@@ -7141,7 +7137,7 @@ int cr_realloc(CharRange *cr, int size)
return 0;
}
-int cr_copy(CharRange *cr, const CharRange *cr1)
+inline int cr_copy(CharRange *cr, const CharRange *cr1)
{
if (cr_realloc(cr, cr1->len))
return -1;
@@ -7180,7 +7176,7 @@ static void cr_compress(CharRange *cr)
}
/* union or intersection */
-int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
+inline int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
const uint32_t *b_pt, int b_len, int op)
{
int a_idx, b_idx, is_in;
@@ -7232,7 +7228,7 @@ int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
return 0;
}
-int cr_union1(CharRange *cr, const uint32_t *b_pt, int b_len)
+inline int cr_union1(CharRange *cr, const uint32_t *b_pt, int b_len)
{
CharRange a = *cr;
int ret;
@@ -7244,7 +7240,7 @@ int cr_union1(CharRange *cr, const uint32_t *b_pt, int b_len)
return ret;
}
-int cr_invert(CharRange *cr)
+inline int cr_invert(CharRange *cr)
{
int len;
len = cr->len;
@@ -7260,14 +7256,14 @@ int cr_invert(CharRange *cr)
#ifdef CONFIG_ALL_UNICODE
-BOOL lre_is_id_start(uint32_t c)
+inline BOOL lre_is_id_start(uint32_t c)
{
return lre_is_in_table(c, unicode_prop_ID_Start_table,
unicode_prop_ID_Start_index,
sizeof(unicode_prop_ID_Start_index) / 3);
}
-BOOL lre_is_id_continue(uint32_t c)
+inline BOOL lre_is_id_continue(uint32_t c)
{
return lre_is_id_start(c) ||
lre_is_in_table(c, unicode_prop_ID_Continue1_table,
@@ -7678,7 +7674,7 @@ static int compose_pair(uint32_t c0, uint32_t c1)
}
}
-int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len,
+inline int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len,
UnicodeNormalizationEnum n_type,
void *opaque, DynBufReallocFunc *realloc_func)
{
@@ -7782,7 +7778,7 @@ static int unicode_find_name(const char *name_table, const char *name)
/* 'cr' must be initialized and empty. Return 0 if OK, -1 if error, -2
if not found */
-int unicode_script(CharRange *cr,
+inline int unicode_script(CharRange *cr,
const char *script_name, BOOL is_ext)
{
int script_idx;
@@ -8169,7 +8165,7 @@ static const uint32_t unicode_gc_mask_table[] = {
/* 'cr' must be initialized and empty. Return 0 if OK, -1 if error, -2
if not found */
-int unicode_general_category(CharRange *cr, const char *gc_name)
+inline int unicode_general_category(CharRange *cr, const char *gc_name)
{
int gc_idx;
uint32_t gc_mask;
@@ -8188,7 +8184,7 @@ int unicode_general_category(CharRange *cr, const char *gc_name)
/* 'cr' must be initialized and empty. Return 0 if OK, -1 if error, -2
if not found */
-int unicode_prop(CharRange *cr, const char *prop_name)
+inline int unicode_prop(CharRange *cr, const char *prop_name)
{
int prop_idx, ret;
@@ -8388,10 +8384,10 @@ int unicode_prop(CharRange *cr, const char *prop_name)
using JS_BOOL = int;
-typedef struct JSRuntime JSRuntime;
-typedef struct JSContext JSContext;
-typedef struct JSObject JSObject;
-typedef struct JSClass JSClass;
+struct JSRuntime;
+struct JSContext;
+struct JSObject;
+struct JSClass;
typedef uint32_t JSClassID;
typedef uint32_t JSAtom;
@@ -9437,6 +9433,14 @@ int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,
#define CONFIG_STACK_CHECK
#endif
+// Avoid enabling the stack check if the sanitiser is active, as it causes all
+// kinds of (hopefully) spurious exceptions
+#if defined (__has_feature)
+ #if __has_feature (address_sanitizer) && __has_feature (undefined_behavior_sanitizer)
+ #undef CONFIG_STACK_CHECK
+ #endif
+#endif
+
/* dump object free */
//#define DUMP_FREE
@@ -11188,7 +11192,6 @@ void JS_SetUncatchableError(JSContext *ctx, JSValueConst val, BOOL flag);
extern const JSClassExoticMethods js_arguments_exotic_methods;
extern const JSClassExoticMethods js_string_exotic_methods;
-extern const JSClassExoticMethods js_proxy_exotic_methods;
extern const JSClassExoticMethods js_module_ns_exotic_methods;
static JSClassID js_class_id_alloc = JS_CLASS_INIT_COUNT;
@@ -11217,27 +11220,27 @@ static size_t js_malloc_usable_size_unknown(const void *ptr)
return 0;
}
-void *js_malloc_rt(JSRuntime *rt, size_t size)
+inline void *js_malloc_rt(JSRuntime *rt, size_t size)
{
return rt->mf.js_malloc(&rt->malloc_state, size);
}
-void js_free_rt(JSRuntime *rt, void *ptr)
+inline void js_free_rt(JSRuntime *rt, void *ptr)
{
rt->mf.js_free(&rt->malloc_state, ptr);
}
-void *js_realloc_rt(void *rt, void *ptr, size_t size)
+inline void *js_realloc_rt(void *rt, void *ptr, size_t size)
{
return ((JSRuntime*) rt)->mf.js_realloc(&((JSRuntime*) rt)->malloc_state, ptr, size);
}
-size_t js_malloc_usable_size_rt(JSRuntime *rt, const void *ptr)
+inline size_t js_malloc_usable_size_rt(JSRuntime *rt, const void *ptr)
{
return rt->mf.js_malloc_usable_size(ptr);
}
-void *js_mallocz_rt(JSRuntime *rt, size_t size)
+inline void *js_mallocz_rt(JSRuntime *rt, size_t size)
{
void *ptr;
ptr = js_malloc_rt(rt, size);
@@ -11256,7 +11259,7 @@ static void *js_bf_realloc(void *opaque, void *ptr, size_t size)
#endif /* CONFIG_BIGNUM */
/* Throw out of memory in case of error */
-void *js_malloc(JSContext *ctx, size_t size)
+inline void *js_malloc(JSContext *ctx, size_t size)
{
void *ptr;
ptr = js_malloc_rt(ctx->rt, size);
@@ -11268,7 +11271,7 @@ void *js_malloc(JSContext *ctx, size_t size)
}
/* Throw out of memory in case of error */
-void *js_mallocz(JSContext *ctx, size_t size)
+inline void *js_mallocz(JSContext *ctx, size_t size)
{
void *ptr;
ptr = js_mallocz_rt(ctx->rt, size);
@@ -11279,13 +11282,13 @@ void *js_mallocz(JSContext *ctx, size_t size)
return ptr;
}
-void js_free(JSContext *ctx, void *ptr)
+inline void js_free(JSContext *ctx, void *ptr)
{
js_free_rt(ctx->rt, ptr);
}
/* Throw out of memory in case of error */
-void *js_realloc(JSContext *ctx, void *ptr, size_t size)
+inline void *js_realloc(JSContext *ctx, void *ptr, size_t size)
{
void *ret;
ret = js_realloc_rt(ctx->rt, ptr, size);
@@ -11297,7 +11300,7 @@ void *js_realloc(JSContext *ctx, void *ptr, size_t size)
}
/* store extra allocated size in *pslack if successful */
-void *js_realloc2(JSContext *ctx, void *ptr, size_t size, size_t *pslack)
+inline void *js_realloc2(JSContext *ctx, void *ptr, size_t size, size_t *pslack)
{
void *ret;
ret = js_realloc_rt(ctx->rt, ptr, size);
@@ -11312,13 +11315,13 @@ void *js_realloc2(JSContext *ctx, void *ptr, size_t size, size_t *pslack)
return ret;
}
-size_t js_malloc_usable_size(JSContext *ctx, const void *ptr)
+inline size_t js_malloc_usable_size(JSContext *ctx, const void *ptr)
{
return js_malloc_usable_size_rt(ctx->rt, ptr);
}
/* Throw out of memory exception in case of error */
-char *js_strndup(JSContext *ctx, const char *s, size_t n)
+inline char *js_strndup(JSContext *ctx, const char *s, size_t n)
{
auto ptr = (char*) js_malloc(ctx, n + 1);
@@ -11329,7 +11332,7 @@ char *js_strndup(JSContext *ctx, const char *s, size_t n)
return ptr;
}
-char *js_strdup(JSContext *ctx, const char *str)
+inline char *js_strdup(JSContext *ctx, const char *str)
{
return js_strndup(ctx, str, strlen(str));
}
@@ -11531,7 +11534,7 @@ static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_size)
}
#endif
-JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque)
+inline JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque)
{
JSRuntime *rt;
JSMallocState ms;
@@ -11598,12 +11601,12 @@ JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque)
return NULL;
}
-void *JS_GetRuntimeOpaque(JSRuntime *rt)
+inline void *JS_GetRuntimeOpaque(JSRuntime *rt)
{
return rt->user_opaque;
}
-void JS_SetRuntimeOpaque(JSRuntime *rt, void *opaque)
+inline void JS_SetRuntimeOpaque(JSRuntime *rt, void *opaque)
{
rt->user_opaque = opaque;
}
@@ -11699,41 +11702,41 @@ static const JSMallocFunctions def_malloc_funcs = {
#endif
};
-JSRuntime *JS_NewRuntime(void)
+inline JSRuntime *JS_NewRuntime(void)
{
return JS_NewRuntime2(&def_malloc_funcs, NULL);
}
-void JS_SetMemoryLimit(JSRuntime *rt, size_t limit)
+inline void JS_SetMemoryLimit(JSRuntime *rt, size_t limit)
{
rt->malloc_state.malloc_limit = limit;
}
/* use -1 to disable automatic GC */
-void JS_SetGCThreshold(JSRuntime *rt, size_t gc_threshold)
+inline void JS_SetGCThreshold(JSRuntime *rt, size_t gc_threshold)
{
rt->malloc_gc_threshold = gc_threshold;
}
-void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void *opaque)
+inline void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void *opaque)
{
rt->interrupt_handler = cb;
rt->interrupt_opaque = opaque;
}
-void JS_SetCanBlock(JSRuntime *rt, BOOL can_block)
+inline void JS_SetCanBlock(JSRuntime *rt, BOOL can_block)
{
rt->can_block = can_block;
}
-void JS_SetSharedArrayBufferFunctions(JSRuntime *rt,
+inline void JS_SetSharedArrayBufferFunctions(JSRuntime *rt,
const JSSharedArrayBufferFunctions *sf)
{
rt->sab_funcs = *sf;
}
/* return 0 if OK, < 0 if exception */
-int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func,
+inline int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func,
int argc, JSValueConst *argv)
{
JSRuntime *rt = ctx->rt;
@@ -11753,14 +11756,14 @@ int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func,
return 0;
}
-BOOL JS_IsJobPending(JSRuntime *rt)
+inline BOOL JS_IsJobPending(JSRuntime *rt)
{
return !list_empty(&rt->job_list);
}
/* return < 0 if exception, 0 if no job pending, 1 if a job was
executed successfully. the context of the job is stored in '*pctx' */
-int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx)
+inline int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx)
{
JSContext *ctx;
JSJobEntry *e;
@@ -11848,13 +11851,13 @@ static inline void js_free_string(JSRuntime *rt, JSString *str)
}
}
-void JS_SetRuntimeInfo(JSRuntime *rt, const char *s)
+inline void JS_SetRuntimeInfo(JSRuntime *rt, const char *s)
{
if (rt)
rt->rt_info = s;
}
-void JS_FreeRuntime(JSRuntime *rt)
+inline void JS_FreeRuntime(JSRuntime *rt)
{
struct list_head *el, *el1;
int i;
@@ -12042,7 +12045,7 @@ void JS_FreeRuntime(JSRuntime *rt)
}
}
-JSContext *JS_NewContextRaw(JSRuntime *rt)
+inline JSContext *JS_NewContextRaw(JSRuntime *rt)
{
int i;
@@ -12075,7 +12078,7 @@ JSContext *JS_NewContextRaw(JSRuntime *rt)
return ctx;
}
-JSContext *JS_NewContext(JSRuntime *rt)
+inline JSContext *JS_NewContext(JSRuntime *rt)
{
JSContext *ctx;
@@ -12099,12 +12102,12 @@ JSContext *JS_NewContext(JSRuntime *rt)
return ctx;
}
-void *JS_GetContextOpaque(JSContext *ctx)
+inline void *JS_GetContextOpaque(JSContext *ctx)
{
return ctx->user_opaque;
}
-void JS_SetContextOpaque(JSContext *ctx, void *opaque)
+inline void JS_SetContextOpaque(JSContext *ctx, void *opaque)
{
ctx->user_opaque = opaque;
}
@@ -12119,14 +12122,14 @@ static inline void set_value(JSContext *ctx, JSValue *pval, JSValue new_val)
JS_FreeValue(ctx, old_val);
}
-void JS_SetClassProto(JSContext *ctx, JSClassID class_id, JSValue obj)
+inline void JS_SetClassProto(JSContext *ctx, JSClassID class_id, JSValue obj)
{
JSRuntime *rt = ctx->rt;
assert(class_id < rt->class_count);
set_value(ctx, &ctx->class_proto[class_id], obj);
}
-JSValue JS_GetClassProto(JSContext *ctx, JSClassID class_id)
+inline JSValue JS_GetClassProto(JSContext *ctx, JSClassID class_id)
{
JSRuntime *rt = ctx->rt;
assert(class_id < rt->class_count);
@@ -12153,7 +12156,7 @@ static void js_free_modules(JSContext *ctx, JSFreeModuleEnum flag)
}
}
-JSContext *JS_DupContext(JSContext *ctx)
+inline JSContext *JS_DupContext(JSContext *ctx)
{
ctx->header.ref_count++;
return ctx;
@@ -12198,7 +12201,7 @@ static void JS_MarkContext(JSRuntime *rt, JSContext *ctx,
mark_func(rt, &ctx->array_shape->header);
}
-void JS_FreeContext(JSContext *ctx)
+inline void JS_FreeContext(JSContext *ctx)
{
JSRuntime *rt = ctx->rt;
int i;
@@ -12265,7 +12268,7 @@ void JS_FreeContext(JSContext *ctx)
js_free_rt(ctx->rt, ctx);
}
-JSRuntime *JS_GetRuntime(JSContext *ctx)
+inline JSRuntime *JS_GetRuntime(JSContext *ctx)
{
return ctx->rt;
}
@@ -12279,13 +12282,13 @@ static void update_stack_limit(JSRuntime *rt)
}
}
-void JS_SetMaxStackSize(JSRuntime *rt, size_t stack_size)
+inline void JS_SetMaxStackSize(JSRuntime *rt, size_t stack_size)
{
rt->stack_size = stack_size;
update_stack_limit(rt);
}
-void JS_UpdateStackTop(JSRuntime *rt)
+inline void JS_UpdateStackTop(JSRuntime *rt)
{
rt->stack_top = js_get_stack_pointer();
update_stack_limit(rt);
@@ -12549,7 +12552,7 @@ static JSAtom JS_DupAtomRT(JSRuntime *rt, JSAtom v)
return v;
}
-JSAtom JS_DupAtom(JSContext *ctx, JSAtom v)
+inline JSAtom JS_DupAtom(JSContext *ctx, JSAtom v)
{
JSRuntime *rt;
JSAtomStruct *p;
@@ -12876,7 +12879,7 @@ static JSAtom JS_NewAtomStr(JSContext *ctx, JSString *p)
return __JS_NewAtom(rt, p, JS_ATOM_TYPE_STRING);
}
-JSAtom JS_NewAtomLen(JSContext *ctx, const char *str, size_t len)
+inline JSAtom JS_NewAtomLen(JSContext *ctx, const char *str, size_t len)
{
JSValue val;
@@ -12891,12 +12894,12 @@ JSAtom JS_NewAtomLen(JSContext *ctx, const char *str, size_t len)
return JS_NewAtomStr(ctx, JS_VALUE_GET_STRING(val));
}
-JSAtom JS_NewAtom(JSContext *ctx, const char *str)
+inline JSAtom JS_NewAtom(JSContext *ctx, const char *str)
{
return JS_NewAtomLen(ctx, str, strlen(str));
}
-JSAtom JS_NewAtomUInt32(JSContext *ctx, uint32_t n)
+inline JSAtom JS_NewAtomUInt32(JSContext *ctx, uint32_t n)
{
if (n <= JS_ATOM_MAX_INT) {
return __JS_AtomFromUInt32(n);
@@ -13037,12 +13040,12 @@ static JSValue __JS_AtomToValue(JSContext *ctx, JSAtom atom, BOOL force_string)
}
}
-JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom)
+inline JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom)
{
return __JS_AtomToValue(ctx, atom, FALSE);
}
-JSValue JS_AtomToString(JSContext *ctx, JSAtom atom)
+inline JSValue JS_AtomToString(JSContext *ctx, JSAtom atom)
{
return __JS_AtomToValue(ctx, atom, TRUE);
}
@@ -13169,13 +13172,13 @@ static int JS_AtomIsNumericIndex(JSContext *ctx, JSAtom atom)
return TRUE;
}
-void JS_FreeAtom(JSContext *ctx, JSAtom v)
+inline void JS_FreeAtom(JSContext *ctx, JSAtom v)
{
if (!__JS_AtomIsConst(v))
__JS_FreeAtom(ctx->rt, v);
}
-void JS_FreeAtomRT(JSRuntime *rt, JSAtom v)
+inline void JS_FreeAtomRT(JSRuntime *rt, JSAtom v)
{
if (!__JS_AtomIsConst(v))
__JS_FreeAtom(rt, v);
@@ -13236,7 +13239,7 @@ inline void print_atom(JSContext *ctx, JSAtom atom)
}
/* free with JS_FreeCString() */
-const char *JS_AtomToCString(JSContext *ctx, JSAtom atom)
+inline const char *JS_AtomToCString(JSContext *ctx, JSAtom atom)
{
JSValue str;
const char *cstr;
@@ -13297,7 +13300,7 @@ static inline BOOL JS_IsEmptyString(JSValueConst v)
/* JSClass support */
/* a new class ID is allocated if *pclass_id != 0 */
-JSClassID JS_NewClassID(JSClassID *pclass_id)
+inline JSClassID JS_NewClassID(JSClassID *pclass_id)
{
JSClassID class_id;
/* XXX: make it thread safe */
@@ -13309,7 +13312,7 @@ JSClassID JS_NewClassID(JSClassID *pclass_id)
return class_id;
}
-BOOL JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id)
+inline BOOL JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id)
{
return (class_id < rt->class_count &&
rt->class_array[class_id].class_id != 0);
@@ -13366,7 +13369,7 @@ static int JS_NewClass1(JSRuntime *rt, JSClassID class_id,
return 0;
}
-int JS_NewClass(JSRuntime *rt, JSClassID class_id, const JSClassDef *class_def)
+inline int JS_NewClass(JSRuntime *rt, JSClassID class_id, const JSClassDef *class_def)
{
int ret, len;
JSAtom name;
@@ -13789,7 +13792,7 @@ static JSValue string_buffer_end(StringBuffer *s)
}
/* create a string from a UTF-8 buffer */
-JSValue JS_NewStringLen(JSContext *ctx, const char *buf, size_t buf_len)
+inline JSValue JS_NewStringLen(JSContext *ctx, const char *buf, size_t buf_len)
{
const uint8_t *p, *p_end, *p_start, *p_next;
uint32_t c;
@@ -13880,12 +13883,12 @@ static JSValue JS_ConcatString3(JSContext *ctx, const char *str1,
return JS_EXCEPTION;
}
-JSValue JS_NewString(JSContext *ctx, const char *str)
+inline JSValue JS_NewString(JSContext *ctx, const char *str)
{
return JS_NewStringLen(ctx, str, strlen(str));
}
-JSValue JS_NewAtomString(JSContext *ctx, const char *str)
+inline JSValue JS_NewAtomString(JSContext *ctx, const char *str)
{
JSAtom atom = JS_NewAtom(ctx, str);
if (atom == JS_ATOM_NULL)
@@ -13898,7 +13901,7 @@ JSValue JS_NewAtomString(JSContext *ctx, const char *str)
/* return (NULL, 0) if exception. */
/* return pointer into a JSString with a live ref_count */
/* cesu8 determines if non-BMP1 codepoints are encoded as 1 or 2 utf-8 sequences */
-const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValueConst val1, BOOL cesu8)
+inline const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValueConst val1, BOOL cesu8)
{
JSValue val;
JSString *str, *str_new;
@@ -13995,7 +13998,7 @@ const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValueConst val1, BO
return NULL;
}
-void JS_FreeCString(JSContext *ctx, const char *ptr)
+inline void JS_FreeCString(JSContext *ctx, const char *ptr)
{
JSString *p;
if (!ptr)
@@ -14761,7 +14764,7 @@ static JSObject *get_proto_obj(JSValueConst proto_val)
}
/* WARNING: proto must be an object or JS_NULL */
-JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto_val,
+inline JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto_val,
JSClassID class_id)
{
JSShape *sh;
@@ -14832,23 +14835,23 @@ static int JS_SetObjectData(JSContext *ctx, JSValueConst obj, JSValue val)
return -1;
}
-JSValue JS_NewObjectClass(JSContext *ctx, int class_id)
+inline JSValue JS_NewObjectClass(JSContext *ctx, int class_id)
{
return JS_NewObjectProtoClass(ctx, ctx->class_proto[class_id], class_id);
}
-JSValue JS_NewObjectProto(JSContext *ctx, JSValueConst proto)
+inline JSValue JS_NewObjectProto(JSContext *ctx, JSValueConst proto)
{
return JS_NewObjectProtoClass(ctx, proto, JS_CLASS_OBJECT);
}
-JSValue JS_NewArray(JSContext *ctx)
+inline JSValue JS_NewArray(JSContext *ctx)
{
return JS_NewObjectFromShape(ctx, js_dup_shape(ctx->array_shape),
JS_CLASS_ARRAY);
}
-JSValue JS_NewObject(JSContext *ctx)
+inline JSValue JS_NewObject(JSContext *ctx)
{
/* inline JS_NewObjectClass(ctx, JS_CLASS_OBJECT); */
return JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], JS_CLASS_OBJECT);
@@ -14976,7 +14979,7 @@ static JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func,
}
/* Note: at least 'length' arguments will be readable in 'argv' */
-JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func,
+inline JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func,
const char *name,
int length, JSCFunctionEnum cproto, int magic)
{
@@ -15040,7 +15043,7 @@ static JSValue js_c_function_data_call(JSContext *ctx, JSValueConst func_obj,
return s->func(ctx, this_val, argc, arg_buf, s->magic, s->data);
}
-JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func,
+inline JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func,
int length, int magic, int data_len,
JSValueConst *data)
{
@@ -15398,7 +15401,7 @@ static void free_zero_refcount(JSRuntime *rt)
}
/* called with the ref_count of 'v' reaches zero. */
-void __JS_FreeValueRT(JSRuntime *rt, JSValue v)
+inline void __JS_FreeValueRT(JSRuntime *rt, JSValue v)
{
uint32_t tag = JS_VALUE_GET_TAG(v);
@@ -15473,7 +15476,7 @@ void __JS_FreeValueRT(JSRuntime *rt, JSValue v)
}
}
-void __JS_FreeValue(JSContext *ctx, JSValue v)
+inline void __JS_FreeValue(JSContext *ctx, JSValue v)
{
__JS_FreeValueRT(ctx->rt, v);
}
@@ -15493,7 +15496,7 @@ static void remove_gc_object(JSGCObjectHeader *h)
list_del(&h->link);
}
-void JS_MarkValue(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func)
+inline void JS_MarkValue(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func)
{
if (JS_VALUE_HAS_REF_COUNT(val)) {
switch(JS_VALUE_GET_TAG(val)) {
@@ -15720,7 +15723,7 @@ static void gc_free_cycles(JSRuntime *rt)
init_list_head(&rt->gc_zero_ref_count_list);
}
-void JS_RunGC(JSRuntime *rt)
+inline void JS_RunGC(JSRuntime *rt)
{
/* decrement the reference of the children of each object. mark =
1 after this pass. */
@@ -15736,7 +15739,7 @@ void JS_RunGC(JSRuntime *rt)
/* Return false if not an object or if the object has already been
freed (zombie objects are visible in finalizers when freeing
cycles). */
-BOOL JS_IsLiveObject(JSRuntime *rt, JSValueConst obj)
+inline BOOL JS_IsLiveObject(JSRuntime *rt, JSValueConst obj)
{
JSObject *p;
if (!JS_IsObject(obj))
@@ -15825,7 +15828,7 @@ static void compute_value_size(JSValueConst val, JSMemoryUsage_helper *hp)
}
}
-void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s)
+inline void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s)
{
struct list_head *el, *el1;
int i;
@@ -16115,7 +16118,7 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s)
s->js_func_size + s->js_func_code_size + s->js_func_pc2line_size;
}
-void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
+inline void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
{
fprintf(fp, "QuickJS memory usage -- "
#ifdef CONFIG_BIGNUM
@@ -16244,13 +16247,13 @@ void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
}
}
-JSValue JS_GetGlobalObject(JSContext *ctx)
+inline JSValue JS_GetGlobalObject(JSContext *ctx)
{
return JS_DupValue(ctx, ctx->global_obj);
}
/* WARNING: obj is freed */
-JSValue JS_Throw(JSContext *ctx, JSValue obj)
+inline JSValue JS_Throw(JSContext *ctx, JSValue obj)
{
JSRuntime *rt = ctx->rt;
JS_FreeValue(ctx, rt->current_exception);
@@ -16259,7 +16262,7 @@ JSValue JS_Throw(JSContext *ctx, JSValue obj)
}
/* return the pending exception (cannot be called twice). */
-JSValue JS_GetException(JSContext *ctx)
+inline JSValue JS_GetException(JSContext *ctx)
{
JSValue val;
JSRuntime *rt = ctx->rt;
@@ -16488,7 +16491,7 @@ static BOOL is_backtrace_needed(JSContext *ctx, JSValueConst obj)
return TRUE;
}
-JSValue JS_NewError(JSContext *ctx)
+inline JSValue JS_NewError(JSContext *ctx)
{
return JS_NewObjectClass(ctx, JS_CLASS_ERROR);
}
@@ -16531,7 +16534,7 @@ static JSValue JS_ThrowError(JSContext *ctx, JSErrorEnum error_num,
return JS_ThrowError2(ctx, error_num, fmt, ap, add_backtrace);
}
-JSValue JS_ThrowSyntaxError(JSContext *ctx, const char *fmt, ...)
+inline JSValue JS_ThrowSyntaxError(JSContext *ctx, const char *fmt, ...)
{
JSValue val;
va_list ap;
@@ -16542,7 +16545,7 @@ JSValue JS_ThrowSyntaxError(JSContext *ctx, const char *fmt, ...)
return val;
}
-JSValue JS_ThrowTypeError(JSContext *ctx, const char *fmt, ...)
+inline JSValue JS_ThrowTypeError(JSContext *ctx, const char *fmt, ...)
{
JSValue val;
va_list ap;
@@ -16600,7 +16603,7 @@ static int JS_ThrowTypeErrorReadOnly(JSContext *ctx, int flags, JSAtom atom)
}
}
-JSValue JS_ThrowReferenceError(JSContext *ctx, const char *fmt, ...)
+inline JSValue JS_ThrowReferenceError(JSContext *ctx, const char *fmt, ...)
{
JSValue val;
va_list ap;
@@ -16611,7 +16614,7 @@ JSValue JS_ThrowReferenceError(JSContext *ctx, const char *fmt, ...)
return val;
}
-JSValue JS_ThrowRangeError(JSContext *ctx, const char *fmt, ...)
+inline JSValue JS_ThrowRangeError(JSContext *ctx, const char *fmt, ...)
{
JSValue val;
va_list ap;
@@ -16622,7 +16625,7 @@ JSValue JS_ThrowRangeError(JSContext *ctx, const char *fmt, ...)
return val;
}
-JSValue JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...)
+inline JSValue JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...)
{
JSValue val;
va_list ap;
@@ -16633,7 +16636,7 @@ JSValue JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...)
return val;
}
-JSValue JS_ThrowOutOfMemory(JSContext *ctx)
+inline JSValue JS_ThrowOutOfMemory(JSContext *ctx)
{
JSRuntime *rt = ctx->rt;
if (!rt->in_out_of_memory) {
@@ -16793,7 +16796,7 @@ static int JS_SetPrototypeInternal(JSContext *ctx, JSValueConst obj,
}
/* return -1 (exception) or TRUE/FALSE */
-int JS_SetPrototype(JSContext *ctx, JSValueConst obj, JSValueConst proto_val)
+inline int JS_SetPrototype(JSContext *ctx, JSValueConst obj, JSValueConst proto_val)
{
return JS_SetPrototypeInternal(ctx, obj, proto_val, TRUE);
}
@@ -16837,7 +16840,7 @@ static JSValueConst JS_GetPrototypePrimitive(JSContext *ctx, JSValueConst val)
}
/* Return an Object, JS_NULL or JS_EXCEPTION in case of Proxy object. */
-JSValue JS_GetPrototype(JSContext *ctx, JSValueConst obj)
+inline JSValue JS_GetPrototype(JSContext *ctx, JSValueConst obj)
{
JSValue val;
if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) {
@@ -16941,7 +16944,7 @@ done:
}
/* return TRUE, FALSE or (-1) in case of exception */
-int JS_IsInstanceOf(JSContext *ctx, JSValueConst val, JSValueConst obj)
+inline int JS_IsInstanceOf(JSContext *ctx, JSValueConst val, JSValueConst obj)
{
JSValue method;
@@ -16998,7 +17001,7 @@ static int JS_AutoInitProperty(JSContext *ctx, JSObject *p, JSAtom prop,
return 0;
}
-JSValue JS_GetPropertyInternal(JSContext *ctx, JSValueConst obj,
+inline JSValue JS_GetPropertyInternal(JSContext *ctx, JSValueConst obj,
JSAtom prop, JSValueConst this_obj,
BOOL throw_ref_error)
{
@@ -17563,7 +17566,7 @@ static void js_free_prop_enum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len)
return 0;
}
-int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab,
+inline int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab,
uint32_t *plen, JSValueConst obj, int flags)
{
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) {
@@ -17655,7 +17658,7 @@ retry:
return FALSE;
}
-int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc,
+inline int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc,
JSValueConst obj, JSAtom prop)
{
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) {
@@ -17666,7 +17669,7 @@ int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc,
}
/* return -1 if exception (Proxy object only) or TRUE/FALSE */
-int JS_IsExtensible(JSContext *ctx, JSValueConst obj)
+inline int JS_IsExtensible(JSContext *ctx, JSValueConst obj)
{
JSObject *p;
@@ -17680,7 +17683,7 @@ int JS_IsExtensible(JSContext *ctx, JSValueConst obj)
}
/* return -1 if exception (Proxy object only) or TRUE/FALSE */
-int JS_PreventExtensions(JSContext *ctx, JSValueConst obj)
+inline int JS_PreventExtensions(JSContext *ctx, JSValueConst obj)
{
JSObject *p;
@@ -17694,7 +17697,7 @@ int JS_PreventExtensions(JSContext *ctx, JSValueConst obj)
}
/* return -1 if exception otherwise TRUE or FALSE */
-int JS_HasProperty(JSContext *ctx, JSValueConst obj, JSAtom prop)
+inline int JS_HasProperty(JSContext *ctx, JSValueConst obj, JSAtom prop)
{
JSObject *p;
int ret;
@@ -17744,7 +17747,7 @@ static JSAtom js_symbol_to_atom(JSContext *ctx, JSValue val)
}
/* return JS_ATOM_NULL in case of exception */
-JSAtom JS_ValueToAtom(JSContext *ctx, JSValueConst val)
+inline JSAtom JS_ValueToAtom(JSContext *ctx, JSValueConst val)
{
JSAtom atom;
uint32_t tag;
@@ -17828,8 +17831,7 @@ static JSValue JS_GetPropertyValue(JSContext *ctx, JSValueConst this_obj,
}
}
-JSValue JS_GetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
- uint32_t idx)
+inline JSValue JS_GetPropertyUint32(JSContext *ctx, JSValueConst this_obj, uint32_t idx)
{
return JS_GetPropertyValue(ctx, this_obj, JS_NewUint32(ctx, idx));
}
@@ -17888,7 +17890,7 @@ static JSValue JS_GetPropertyInt64(JSContext *ctx, JSValueConst obj, int64_t idx
return val;
}
-JSValue JS_GetPropertyStr(JSContext *ctx, JSValueConst this_obj,
+inline JSValue JS_GetPropertyStr(JSContext *ctx, JSValueConst this_obj,
const char *prop)
{
JSAtom atom;
@@ -17944,7 +17946,7 @@ static JSProperty *add_property(JSContext *ctx,
/* can be called on Array or Arguments objects. return < 0 if
memory alloc error. */
-[[nodiscard]] static no_inline int convert_fast_array_to_array(JSContext *ctx,
+[[nodiscard]] static inline int convert_fast_array_to_array(JSContext *ctx,
JSObject *p)
{
JSProperty *pr;
@@ -18347,7 +18349,7 @@ static int JS_SetPropertyGeneric(JSContext *ctx,
freed by the function. 'flags' is a bitmask of JS_PROP_NO_ADD,
JS_PROP_THROW or JS_PROP_THROW_STRICT. If JS_PROP_NO_ADD is set,
the new property is not added and an error is raised. */
-int JS_SetPropertyInternal(JSContext *ctx, JSValueConst this_obj,
+inline int JS_SetPropertyInternal(JSContext *ctx, JSValueConst this_obj,
JSAtom prop, JSValue val, int flags)
{
JSObject *p, *p1;
@@ -18700,14 +18702,14 @@ static int JS_SetPropertyValue(JSContext *ctx, JSValueConst this_obj,
}
}
-int JS_SetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
+inline int JS_SetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
uint32_t idx, JSValue val)
{
return JS_SetPropertyValue(ctx, this_obj, JS_NewUint32(ctx, idx), val,
JS_PROP_THROW);
}
-int JS_SetPropertyInt64(JSContext *ctx, JSValueConst this_obj,
+inline int JS_SetPropertyInt64(JSContext *ctx, JSValueConst this_obj,
int64_t idx, JSValue val)
{
JSAtom prop;
@@ -18728,7 +18730,7 @@ int JS_SetPropertyInt64(JSContext *ctx, JSValueConst this_obj,
return res;
}
-int JS_SetPropertyStr(JSContext *ctx, JSValueConst this_obj,
+inline int JS_SetPropertyStr(JSContext *ctx, JSValueConst this_obj,
const char *prop, JSValue val)
{
JSAtom atom;
@@ -18943,7 +18945,7 @@ static int js_update_property_flags(JSContext *ctx, JSObject *p,
define_own_property callback.
return -1 (exception), FALSE or TRUE.
*/
-int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
+inline int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
JSAtom prop, JSValueConst val,
JSValueConst getter, JSValueConst setter, int flags)
{
@@ -19242,7 +19244,7 @@ static int JS_DefineAutoInitProperty(JSContext *ctx, JSValueConst this_obj,
}
/* shortcut to add or redefine a new property value */
-int JS_DefinePropertyValue(JSContext *ctx, JSValueConst this_obj,
+inline int JS_DefinePropertyValue(JSContext *ctx, JSValueConst this_obj,
JSAtom prop, JSValue val, int flags)
{
int ret;
@@ -19252,7 +19254,7 @@ int JS_DefinePropertyValue(JSContext *ctx, JSValueConst this_obj,
return ret;
}
-int JS_DefinePropertyValueValue(JSContext *ctx, JSValueConst this_obj,
+inline int JS_DefinePropertyValueValue(JSContext *ctx, JSValueConst this_obj,
JSValue prop, JSValue val, int flags)
{
JSAtom atom;
@@ -19268,21 +19270,21 @@ int JS_DefinePropertyValueValue(JSContext *ctx, JSValueConst this_obj,
return ret;
}
-int JS_DefinePropertyValueUint32(JSContext *ctx, JSValueConst this_obj,
+inline int JS_DefinePropertyValueUint32(JSContext *ctx, JSValueConst this_obj,
uint32_t idx, JSValue val, int flags)
{
return JS_DefinePropertyValueValue(ctx, this_obj, JS_NewUint32(ctx, idx),
val, flags);
}
-int JS_DefinePropertyValueInt64(JSContext *ctx, JSValueConst this_obj,
+inline int JS_DefinePropertyValueInt64(JSContext *ctx, JSValueConst this_obj,
int64_t idx, JSValue val, int flags)
{
return JS_DefinePropertyValueValue(ctx, this_obj, JS_NewInt64(ctx, idx),
val, flags);
}
-int JS_DefinePropertyValueStr(JSContext *ctx, JSValueConst this_obj,
+inline int JS_DefinePropertyValueStr(JSContext *ctx, JSValueConst this_obj,
const char *prop, JSValue val, int flags)
{
JSAtom atom;
@@ -19294,7 +19296,7 @@ int JS_DefinePropertyValueStr(JSContext *ctx, JSValueConst this_obj,
}
/* shortcut to add getter & setter */
-int JS_DefinePropertyGetSet(JSContext *ctx, JSValueConst this_obj,
+inline int JS_DefinePropertyGetSet(JSContext *ctx, JSValueConst this_obj,
JSAtom prop, JSValue getter, JSValue setter,
int flags)
{
@@ -19591,7 +19593,7 @@ static int JS_SetGlobalVar(JSContext *ctx, JSAtom prop, JSValue val,
/* return -1, FALSE or TRUE. return FALSE if not configurable or
invalid object. return -1 in case of exception.
flags can be 0, JS_PROP_THROW or JS_PROP_THROW_STRICT */
-int JS_DeleteProperty(JSContext *ctx, JSValueConst obj, JSAtom prop, int flags)
+inline int JS_DeleteProperty(JSContext *ctx, JSValueConst obj, JSAtom prop, int flags)
{
JSValue obj1;
JSObject *p;
@@ -19613,7 +19615,7 @@ int JS_DeleteProperty(JSContext *ctx, JSValueConst obj, JSAtom prop, int flags)
return FALSE;
}
-int JS_DeletePropertyInt64(JSContext *ctx, JSValueConst obj, int64_t idx, int flags)
+inline int JS_DeletePropertyInt64(JSContext *ctx, JSValueConst obj, int64_t idx, int flags)
{
JSAtom prop;
int res;
@@ -19630,7 +19632,7 @@ int JS_DeletePropertyInt64(JSContext *ctx, JSValueConst obj, int64_t idx, int fl
return res;
}
-BOOL JS_IsFunction(JSContext *ctx, JSValueConst val)
+inline BOOL JS_IsFunction(JSContext *ctx, JSValueConst val)
{
JSObject *p;
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
@@ -19646,7 +19648,7 @@ BOOL JS_IsFunction(JSContext *ctx, JSValueConst val)
}
}
-BOOL JS_IsCFunction(JSContext *ctx, JSValueConst val, JSCFunction *func, int magic)
+inline BOOL JS_IsCFunction(JSContext *ctx, JSValueConst val, JSCFunction *func, int magic)
{
JSObject *p;
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
@@ -19658,7 +19660,7 @@ BOOL JS_IsCFunction(JSContext *ctx, JSValueConst val, JSCFunction *func, int mag
return FALSE;
}
-BOOL JS_IsConstructor(JSContext *ctx, JSValueConst val)
+inline BOOL JS_IsConstructor(JSContext *ctx, JSValueConst val)
{
JSObject *p;
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
@@ -19667,7 +19669,7 @@ BOOL JS_IsConstructor(JSContext *ctx, JSValueConst val)
return p->is_constructor;
}
-BOOL JS_SetConstructorBit(JSContext *ctx, JSValueConst func_obj, BOOL val)
+inline BOOL JS_SetConstructorBit(JSContext *ctx, JSValueConst func_obj, BOOL val)
{
JSObject *p;
if (JS_VALUE_GET_TAG(func_obj) != JS_TAG_OBJECT)
@@ -19677,7 +19679,7 @@ BOOL JS_SetConstructorBit(JSContext *ctx, JSValueConst func_obj, BOOL val)
return TRUE;
}
-BOOL JS_IsError(JSContext *ctx, JSValueConst val)
+inline BOOL JS_IsError(JSContext *ctx, JSValueConst val)
{
JSObject *p;
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
@@ -19687,7 +19689,7 @@ BOOL JS_IsError(JSContext *ctx, JSValueConst val)
}
/* used to avoid catching interrupt exceptions */
-BOOL JS_IsUncatchableError(JSContext *ctx, JSValueConst val)
+inline BOOL JS_IsUncatchableError(JSContext *ctx, JSValueConst val)
{
JSObject *p;
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
@@ -19696,7 +19698,7 @@ BOOL JS_IsUncatchableError(JSContext *ctx, JSValueConst val)
return p->class_id == JS_CLASS_ERROR && p->is_uncatchable_error;
}
-void JS_SetUncatchableError(JSContext *ctx, JSValueConst val, BOOL flag)
+inline void JS_SetUncatchableError(JSContext *ctx, JSValueConst val, BOOL flag)
{
JSObject *p;
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
@@ -19706,12 +19708,12 @@ void JS_SetUncatchableError(JSContext *ctx, JSValueConst val, BOOL flag)
p->is_uncatchable_error = flag;
}
-void JS_ResetUncatchableError(JSContext *ctx)
+inline void JS_ResetUncatchableError(JSContext *ctx)
{
JS_SetUncatchableError(ctx, ctx->rt->current_exception, FALSE);
}
-void JS_SetOpaque(JSValue obj, void *opaque)
+inline void JS_SetOpaque(JSValue obj, void *opaque)
{
JSObject *p;
if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) {
@@ -19721,7 +19723,7 @@ void JS_SetOpaque(JSValue obj, void *opaque)
}
/* return NULL if not an object of class class_id */
-void *JS_GetOpaque(JSValueConst obj, JSClassID class_id)
+inline void *JS_GetOpaque(JSValueConst obj, JSClassID class_id)
{
JSObject *p;
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)
@@ -19732,7 +19734,7 @@ void *JS_GetOpaque(JSValueConst obj, JSClassID class_id)
return p->u.opaque;
}
-void *JS_GetOpaque2(JSContext *ctx, JSValueConst obj, JSClassID class_id)
+inline void *JS_GetOpaque2(JSContext *ctx, JSValueConst obj, JSClassID class_id)
{
void *p = JS_GetOpaque(obj, class_id);
if (js_unlikely(!p)) {
@@ -19826,7 +19828,7 @@ static JSValue JS_ToPrimitive(JSContext *ctx, JSValueConst val, int hint)
return JS_ToPrimitiveFree(ctx, JS_DupValue(ctx, val), hint);
}
-void JS_SetIsHTMLDDA(JSContext *ctx, JSValueConst obj)
+inline void JS_SetIsHTMLDDA(JSContext *ctx, JSValueConst obj)
{
JSObject *p;
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)
@@ -19901,7 +19903,7 @@ static int JS_ToBoolFree(JSContext *ctx, JSValue val)
}
}
-int JS_ToBool(JSContext *ctx, JSValueConst val)
+inline int JS_ToBool(JSContext *ctx, JSValueConst val)
{
return JS_ToBoolFree(ctx, JS_DupValue(ctx, val));
}
@@ -20619,12 +20621,12 @@ static int JS_ToInt32SatFree(JSContext *ctx, int *pres, JSValue val)
return 0;
}
-int JS_ToInt32Sat(JSContext *ctx, int *pres, JSValueConst val)
+inline int JS_ToInt32Sat(JSContext *ctx, int *pres, JSValueConst val)
{
return JS_ToInt32SatFree(ctx, pres, JS_DupValue(ctx, val));
}
-int JS_ToInt32Clamp(JSContext *ctx, int *pres, JSValueConst val,
+inline int JS_ToInt32Clamp(JSContext *ctx, int *pres, JSValueConst val,
int min, int max, int min_offset)
{
int res = JS_ToInt32SatFree(ctx, pres, JS_DupValue(ctx, val));
@@ -20691,12 +20693,12 @@ static int JS_ToInt64SatFree(JSContext *ctx, int64_t *pres, JSValue val)
}
}
-int JS_ToInt64Sat(JSContext *ctx, int64_t *pres, JSValueConst val)
+inline int JS_ToInt64Sat(JSContext *ctx, int64_t *pres, JSValueConst val)
{
return JS_ToInt64SatFree(ctx, pres, JS_DupValue(ctx, val));
}
-int JS_ToInt64Clamp(JSContext *ctx, int64_t *pres, JSValueConst val,
+inline int JS_ToInt64Clamp(JSContext *ctx, int64_t *pres, JSValueConst val,
int64_t min, int64_t max, int64_t neg_offset)
{
int res = JS_ToInt64SatFree(ctx, pres, JS_DupValue(ctx, val));
@@ -20773,12 +20775,12 @@ static int JS_ToInt64Free(JSContext *ctx, int64_t *pres, JSValue val)
return 0;
}
-int JS_ToInt64(JSContext *ctx, int64_t *pres, JSValueConst val)
+inline int JS_ToInt64(JSContext *ctx, int64_t *pres, JSValueConst val)
{
return JS_ToInt64Free(ctx, pres, JS_DupValue(ctx, val));
}
-int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValueConst val)
+inline int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValueConst val)
{
if (JS_IsBigInt(ctx, val))
return JS_ToBigInt64(ctx, pres, val);
@@ -20848,7 +20850,7 @@ static int JS_ToInt32Free(JSContext *ctx, int32_t *pres, JSValue val)
return 0;
}
-int JS_ToInt32(JSContext *ctx, int32_t *pres, JSValueConst val)
+inline int JS_ToInt32(JSContext *ctx, int32_t *pres, JSValueConst val)
{
return JS_ToInt32Free(ctx, pres, JS_DupValue(ctx, val));
}
@@ -21003,7 +21005,7 @@ static BOOL is_safe_integer(double d)
fabs(d) <= (double)MAX_SAFE_INTEGER;
}
-int JS_ToIndex(JSContext *ctx, uint64_t *plen, JSValueConst val)
+inline int JS_ToIndex(JSContext *ctx, uint64_t *plen, JSValueConst val)
{
int64_t v;
if (JS_ToInt64Sat(ctx, &v, val))
@@ -21466,7 +21468,7 @@ static JSValue js_dtoa(JSContext *ctx,
return JS_NewString(ctx, buf);
}
-JSValue JS_ToStringInternal(JSContext *ctx, JSValueConst val, BOOL is_ToPropertyKey)
+inline JSValue JS_ToStringInternal(JSContext *ctx, JSValueConst val, BOOL is_ToPropertyKey)
{
uint32_t tag;
const char *str;
@@ -21527,7 +21529,7 @@ JSValue JS_ToStringInternal(JSContext *ctx, JSValueConst val, BOOL is_ToProperty
}
}
-JSValue JS_ToString(JSContext *ctx, JSValueConst val)
+inline JSValue JS_ToString(JSContext *ctx, JSValueConst val)
{
return JS_ToStringInternal(ctx, val, FALSE);
}
@@ -21547,7 +21549,7 @@ static JSValue JS_ToLocaleStringFree(JSContext *ctx, JSValue val)
return JS_InvokeFree(ctx, val, JS_ATOM_toLocaleString, 0, NULL);
}
-JSValue JS_ToPropertyKey(JSContext *ctx, JSValueConst val)
+inline JSValue JS_ToPropertyKey(JSContext *ctx, JSValueConst val)
{
return JS_ToStringInternal(ctx, val, TRUE);
}
@@ -21889,7 +21891,7 @@ inline void JS_PrintValue(JSContext *ctx, const char *str, JSValueConst val)
}
/* return -1 if exception (proxy case) or TRUE/FALSE */
-int JS_IsArray(JSContext *ctx, JSValueConst val)
+inline int JS_IsArray(JSContext *ctx, JSValueConst val)
{
JSObject *p;
if (JS_VALUE_GET_TAG(val) == JS_TAG_OBJECT) {
@@ -21915,7 +21917,7 @@ static double js_pow(double a, double b)
#ifdef CONFIG_BIGNUM
-JSValue JS_NewBigInt64_1(JSContext *ctx, int64_t v)
+inline JSValue JS_NewBigInt64_1(JSContext *ctx, int64_t v)
{
JSValue val;
bf_t *a;
@@ -21930,7 +21932,7 @@ JSValue JS_NewBigInt64_1(JSContext *ctx, int64_t v)
return val;
}
-JSValue JS_NewBigInt64(JSContext *ctx, int64_t v)
+inline JSValue JS_NewBigInt64(JSContext *ctx, int64_t v)
{
if (is_math_mode(ctx) &&
v >= -MAX_SAFE_INTEGER && v <= MAX_SAFE_INTEGER) {
@@ -21940,7 +21942,7 @@ JSValue JS_NewBigInt64(JSContext *ctx, int64_t v)
}
}
-JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v)
+inline JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v)
{
JSValue val;
if (is_math_mode(ctx) && v <= MAX_SAFE_INTEGER) {
@@ -22193,7 +22195,7 @@ static int JS_ToBigInt64Free(JSContext *ctx, int64_t *pres, JSValue val)
return 0;
}
-int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValueConst val)
+inline int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValueConst val)
{
return JS_ToBigInt64Free(ctx, pres, JS_DupValue(ctx, val));
}
@@ -24098,17 +24100,17 @@ static JSValue JS_ThrowUnsupportedBigint(JSContext *ctx)
return JS_ThrowTypeError(ctx, "bigint is not supported");
}
-JSValue JS_NewBigInt64(JSContext *ctx, int64_t v)
+inline JSValue JS_NewBigInt64(JSContext *ctx, int64_t v)
{
return JS_ThrowUnsupportedBigint(ctx);
}
-JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v)
+inline JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v)
{
return JS_ThrowUnsupportedBigint(ctx);
}
-int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValueConst val)
+inline int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValueConst val)
{
JS_ThrowUnsupportedBigint(ctx);
*pres = 0;
@@ -24863,7 +24865,7 @@ static int js_arguments_define_own_property(JSContext *ctx,
flags | JS_PROP_NO_EXOTIC);
}
-const JSClassExoticMethods js_arguments_exotic_methods = {
+inline const JSClassExoticMethods js_arguments_exotic_methods = {
nullptr, nullptr, nullptr, js_arguments_define_own_property, nullptr, nullptr
};
@@ -28642,7 +28644,7 @@ QUICKJS_OPCODES(FMT, DEF, def)
return ret_val;
}
-JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj,
+inline JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj,
int argc, JSValueConst *argv)
{
return JS_CallInternal(ctx, func_obj, this_obj, JS_UNDEFINED,
@@ -28782,7 +28784,7 @@ static JSValue JS_CallConstructorInternal(JSContext *ctx,
}
}
-JSValue JS_CallConstructor2(JSContext *ctx, JSValueConst func_obj,
+inline JSValue JS_CallConstructor2(JSContext *ctx, JSValueConst func_obj,
JSValueConst new_target,
int argc, JSValueConst *argv)
{
@@ -28791,7 +28793,7 @@ JSValue JS_CallConstructor2(JSContext *ctx, JSValueConst func_obj,
JS_CALL_FLAG_COPY_ARGV);
}
-JSValue JS_CallConstructor(JSContext *ctx, JSValueConst func_obj,
+inline JSValue JS_CallConstructor(JSContext *ctx, JSValueConst func_obj,
int argc, JSValueConst *argv)
{
return JS_CallConstructorInternal(ctx, func_obj, func_obj,
@@ -28799,7 +28801,7 @@ JSValue JS_CallConstructor(JSContext *ctx, JSValueConst func_obj,
JS_CALL_FLAG_COPY_ARGV);
}
-JSValue JS_Invoke(JSContext *ctx, JSValueConst this_val, JSAtom atom,
+inline JSValue JS_Invoke(JSContext *ctx, JSValueConst this_val, JSAtom atom,
int argc, JSValueConst *argv)
{
JSValue func_obj;
@@ -30164,7 +30166,7 @@ static void dump_token(JSParseState *s, const JSToken *token)
}
#endif
-int js_parse_error(JSParseState *s, const char *fmt, ...)
+inline int js_parse_error(JSParseState *s, const char *fmt, ...)
{
JSContext *ctx = s->ctx;
va_list ap;
@@ -31423,7 +31425,7 @@ static int peek_token(JSParseState *s, BOOL no_line_terminator)
Heuristic: skip comments and expect 'import' keyword not followed
by '(' or '.' or export keyword.
*/
-BOOL JS_DetectModule(const char *input, size_t input_len)
+inline BOOL JS_DetectModule(const char *input, size_t input_len)
{
const uint8_t *p = (const uint8_t *)input;
int tok;
@@ -37127,7 +37129,7 @@ static int add_star_export_entry(JSContext *ctx, JSModuleDef *m,
}
/* create a C module */
-JSModuleDef *JS_NewCModule(JSContext *ctx, const char *name_str,
+inline JSModuleDef *JS_NewCModule(JSContext *ctx, const char *name_str,
JSModuleInitFunc *func)
{
JSModuleDef *m;
@@ -37140,7 +37142,7 @@ JSModuleDef *JS_NewCModule(JSContext *ctx, const char *name_str,
return m;
}
-int JS_AddModuleExport(JSContext *ctx, JSModuleDef *m, const char *export_name)
+inline int JS_AddModuleExport(JSContext *ctx, JSModuleDef *m, const char *export_name)
{
JSExportEntry *me;
JSAtom name;
@@ -37156,7 +37158,7 @@ int JS_AddModuleExport(JSContext *ctx, JSModuleDef *m, const char *export_name)
return 0;
}
-int JS_SetModuleExport(JSContext *ctx, JSModuleDef *m, const char *export_name,
+inline int JS_SetModuleExport(JSContext *ctx, JSModuleDef *m, const char *export_name,
JSValue val)
{
JSExportEntry *me;
@@ -37175,7 +37177,7 @@ int JS_SetModuleExport(JSContext *ctx, JSModuleDef *m, const char *export_name,
return -1;
}
-void JS_SetModuleLoaderFunc(JSRuntime *rt,
+inline void JS_SetModuleLoaderFunc(JSRuntime *rt,
JSModuleNormalizeFunc *module_normalize,
JSModuleLoaderFunc *module_loader, void *opaque)
{
@@ -37592,7 +37594,7 @@ static int js_module_ns_has(JSContext *ctx, JSValueConst obj, JSAtom atom)
return (find_own_property1(JS_VALUE_GET_OBJ(obj), atom) != NULL);
}
-const JSClassExoticMethods js_module_ns_exotic_methods = {
+inline const JSClassExoticMethods js_module_ns_exotic_methods = {
nullptr, nullptr, nullptr, nullptr, js_module_ns_has, nullptr, nullptr
};
@@ -38046,7 +38048,7 @@ static int js_link_module(JSContext *ctx, JSModuleDef *m)
/* return JS_ATOM_NULL if the name cannot be found. Only works with
not striped bytecode functions. */
-JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels)
+inline JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels)
{
JSStackFrame *sf;
JSFunctionBytecode *b;
@@ -38073,12 +38075,12 @@ JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels)
return JS_DupAtom(ctx, b->debug.filename);
}
-JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m)
+inline JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m)
{
return JS_DupAtom(ctx, m->module_name);
}
-JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m)
+inline JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m)
{
JSValue obj;
/* allocate meta_obj only if requested to save memory */
@@ -38114,7 +38116,7 @@ static JSValue js_import_meta(JSContext *ctx)
}
/* used by os.Worker() and import() */
-JSModuleDef *JS_RunModule(JSContext *ctx, const char *basename,
+inline JSModuleDef *JS_RunModule(JSContext *ctx, const char *basename,
const char *filename)
{
JSModuleDef *m;
@@ -43479,7 +43481,7 @@ static JSValue JS_EvalFunctionInternal(JSContext *ctx, JSValue fun_obj,
return ret_val;
}
-JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj)
+inline JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj)
{
return JS_EvalFunctionInternal(ctx, fun_obj, ctx->global_obj, NULL, NULL);
}
@@ -43650,7 +43652,7 @@ static JSValue JS_EvalObject(JSContext *ctx, JSValueConst this_obj,
}
-JSValue JS_EvalThis(JSContext *ctx, JSValueConst this_obj,
+inline JSValue JS_EvalThis(JSContext *ctx, JSValueConst this_obj,
const char *input, size_t input_len,
const char *filename, int eval_flags)
{
@@ -43664,14 +43666,14 @@ JSValue JS_EvalThis(JSContext *ctx, JSValueConst this_obj,
return ret;
}
-JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
+inline JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
const char *filename, int eval_flags)
{
return JS_EvalThis(ctx, ctx->global_obj, input, input_len, filename,
eval_flags);
}
-int JS_ResolveModule(JSContext *ctx, JSValueConst obj)
+inline int JS_ResolveModule(JSContext *ctx, JSValueConst obj)
{
if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) {
auto m = (JSModuleDef*) JS_VALUE_GET_PTR(obj);
@@ -44662,7 +44664,7 @@ static int JS_WriteObjectAtoms(BCWriterState *s)
return -1;
}
-uint8_t *JS_WriteObject2(JSContext *ctx, size_t *psize, JSValueConst obj,
+inline uint8_t *JS_WriteObject2(JSContext *ctx, size_t *psize, JSValueConst obj,
int flags, uint8_t ***psab_tab, size_t *psab_tab_len)
{
BCWriterState ss, *s = &ss;
@@ -44708,7 +44710,7 @@ uint8_t *JS_WriteObject2(JSContext *ctx, size_t *psize, JSValueConst obj,
return NULL;
}
-uint8_t *JS_WriteObject(JSContext *ctx, size_t *psize, JSValueConst obj,
+inline uint8_t *JS_WriteObject(JSContext *ctx, size_t *psize, JSValueConst obj,
int flags)
{
return JS_WriteObject2(ctx, psize, obj, flags, NULL, NULL);
@@ -45843,7 +45845,7 @@ static void bc_reader_free(BCReaderState *s)
js_free(s->ctx, s->objects);
}
-JSValue JS_ReadObject(JSContext *ctx, const uint8_t *buf, size_t buf_len,
+inline JSValue JS_ReadObject(JSContext *ctx, const uint8_t *buf, size_t buf_len,
int flags)
{
BCReaderState ss, *s = &ss;
@@ -46038,7 +46040,7 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
return 0;
}
-void JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj,
+inline void JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj,
const JSCFunctionListEntry *tab, int len)
{
int i;
@@ -46051,7 +46053,7 @@ void JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj,
}
}
-int JS_AddModuleExportList(JSContext *ctx, JSModuleDef *m,
+inline int JS_AddModuleExportList(JSContext *ctx, JSModuleDef *m,
const JSCFunctionListEntry *tab, int len)
{
int i;
@@ -46062,7 +46064,7 @@ int JS_AddModuleExportList(JSContext *ctx, JSModuleDef *m,
return 0;
}
-int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,
+inline int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,
const JSCFunctionListEntry *tab, int len)
{
int i;
@@ -46115,7 +46117,7 @@ static void JS_SetConstructor2(JSContext *ctx,
set_cycle_flag(ctx, proto);
}
-void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
+inline void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
JSValueConst proto)
{
JS_SetConstructor2(ctx, func_obj, proto,
@@ -50102,7 +50104,7 @@ static int js_string_delete_property(JSContext *ctx,
return TRUE;
}
-const JSClassExoticMethods js_string_exotic_methods = {
+inline const JSClassExoticMethods js_string_exotic_methods = {
js_string_get_own_property, nullptr, js_string_delete_property,
js_string_define_own_property, nullptr, nullptr, nullptr
};
@@ -50245,7 +50247,7 @@ exception:
}
/* only used in test262 */
-JSValue js_string_codePointRange(JSContext *ctx, JSValueConst this_val,
+inline JSValue js_string_codePointRange(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
uint32_t start, end, i, n;
@@ -51647,7 +51649,7 @@ static const JSCFunctionListEntry js_string_proto_normalize[] = {
};
#endif
-void JS_AddIntrinsicStringNormalize(JSContext *ctx)
+inline void JS_AddIntrinsicStringNormalize(JSContext *ctx)
{
#ifdef CONFIG_ALL_UNICODE
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_STRING], js_string_proto_normalize,
@@ -52485,13 +52487,13 @@ fail:
return JS_EXCEPTION;
}
-BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size)
+inline BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size)
{
auto ctx = (JSContext*) opaque;
return js_check_stack_overflow(ctx->rt, alloca_size);
}
-void *lre_realloc(void *opaque, void *ptr, size_t size)
+inline void *lre_realloc(void *opaque, void *ptr, size_t size)
{
auto ctx = (JSContext*) opaque;
/* No JS exception is raised here */
@@ -53476,12 +53478,12 @@ static const JSCFunctionListEntry js_regexp_string_iterator_proto_funcs[] = {
JS_PROP_STRING_DEF("[Symbol.toStringTag]", "RegExp String Iterator", JS_PROP_CONFIGURABLE ),
};
-void JS_AddIntrinsicRegExpCompiler(JSContext *ctx)
+inline void JS_AddIntrinsicRegExpCompiler(JSContext *ctx)
{
ctx->compile_regexp = js_compile_regexp;
}
-void JS_AddIntrinsicRegExp(JSContext *ctx)
+inline void JS_AddIntrinsicRegExp(JSContext *ctx)
{
JSValueConst obj;
@@ -53640,7 +53642,7 @@ static JSValue json_parse_value(JSParseState *s)
return JS_EXCEPTION;
}
-JSValue JS_ParseJSON2(JSContext *ctx, const char *buf, size_t buf_len,
+inline JSValue JS_ParseJSON2(JSContext *ctx, const char *buf, size_t buf_len,
const char *filename, int flags)
{
JSParseState s1, *s = &s1;
@@ -53664,7 +53666,7 @@ JSValue JS_ParseJSON2(JSContext *ctx, const char *buf, size_t buf_len,
return JS_EXCEPTION;
}
-JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,
+inline JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,
const char *filename)
{
return JS_ParseJSON2(ctx, buf, buf_len, filename, 0);
@@ -54046,7 +54048,7 @@ exception:
return -1;
}
-JSValue JS_JSONStringify(JSContext *ctx, JSValueConst obj,
+inline JSValue JS_JSONStringify(JSContext *ctx, JSValueConst obj,
JSValueConst replacer, JSValueConst space0)
{
StringBuffer b_s;
@@ -54197,7 +54199,7 @@ static const JSCFunctionListEntry js_json_obj[] = {
JS_OBJECT_DEF("JSON", js_json_funcs, countof(js_json_funcs), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
};
-void JS_AddIntrinsicJSON(JSContext *ctx)
+inline void JS_AddIntrinsicJSON(JSContext *ctx)
{
/* add JSON as autoinit object */
JS_SetPropertyFunctionList(ctx, ctx->global_obj, js_json_obj, countof(js_json_obj));
@@ -55210,7 +55212,7 @@ static int js_proxy_isArray(JSContext *ctx, JSValueConst obj)
return JS_IsArray(ctx, s->target);
}
-const JSClassExoticMethods js_proxy_exotic_methods = {
+static constexpr const JSClassExoticMethods js_proxy_exotic_methods = {
js_proxy_get_own_property,
js_proxy_get_own_property_names,
js_proxy_delete_property,
@@ -55303,7 +55305,7 @@ static const JSClassShortDef js_proxy_class_def[] = {
{ JS_ATOM_Object, js_proxy_finalizer, js_proxy_mark }, /* JS_CLASS_PROXY */
};
-void JS_AddIntrinsicProxy(JSContext *ctx)
+inline void JS_AddIntrinsicProxy(JSContext *ctx)
{
JSRuntime *rt = ctx->rt;
JSValue obj1;
@@ -56183,7 +56185,7 @@ static const uint8_t js_map_proto_funcs_count[6] = {
countof(js_set_iterator_proto_funcs),
};
-void JS_AddIntrinsicMapSet(JSContext *ctx)
+inline void JS_AddIntrinsicMapSet(JSContext *ctx)
{
int i;
JSValue obj1;
@@ -56312,7 +56314,7 @@ static JSValue promise_reaction_job(JSContext *ctx, int argc,
return res2;
}
-void JS_SetHostPromiseRejectionTracker(JSRuntime *rt,
+inline void JS_SetHostPromiseRejectionTracker(JSRuntime *rt,
JSHostPromiseRejectionTracker *cb,
void *opaque)
{
@@ -56665,7 +56667,7 @@ static JSValue js_new_promise_capability(JSContext *ctx,
return JS_EXCEPTION;
}
-JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs)
+inline JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs)
{
return js_new_promise_capability(ctx, resolving_funcs, JS_UNDEFINED);
}
@@ -57452,7 +57454,7 @@ static JSClassShortDef const js_async_class_def[] = {
{ JS_ATOM_AsyncGenerator, js_async_generator_finalizer, js_async_generator_mark }, /* JS_CLASS_ASYNC_GENERATOR */
};
-void JS_AddIntrinsicPromise(JSContext *ctx)
+inline void JS_AddIntrinsicPromise(JSContext *ctx)
{
JSRuntime *rt = ctx->rt;
JSValue obj1;
@@ -58757,7 +58759,7 @@ static const JSCFunctionListEntry js_date_proto_funcs[] = {
JS_CFUNC_DEF("toJSON", 1, js_date_toJSON ),
};
-void JS_AddIntrinsicDate(JSContext *ctx)
+inline void JS_AddIntrinsicDate(JSContext *ctx)
{
JSValueConst obj;
@@ -58772,7 +58774,7 @@ void JS_AddIntrinsicDate(JSContext *ctx)
/* eval */
-void JS_AddIntrinsicEval(JSContext *ctx)
+inline void JS_AddIntrinsicEval(JSContext *ctx)
{
ctx->eval_internal = __JS_EvalInternal;
}
@@ -60875,7 +60877,7 @@ static void JS_AddIntrinsicBasicObjects(JSContext *ctx)
// assert(ctx->rt->atom_count == JS_ATOM_END);
}
-void JS_AddIntrinsicBaseObjects(JSContext *ctx)
+inline void JS_AddIntrinsicBaseObjects(JSContext *ctx)
{
int i;
JSValueConst obj, number_obj;
@@ -61074,7 +61076,7 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
/* Typed Arrays */
-uint8_t const typed_array_size_log2[JS_TYPED_ARRAY_COUNT] = {
+inline uint8_t const typed_array_size_log2[JS_TYPED_ARRAY_COUNT] = {
0, 0, 0, 1, 1, 2, 2,
#ifdef CONFIG_BIGNUM
3, 3, /* BigInt64Array, BigUint64Array */
@@ -61163,7 +61165,7 @@ static JSValue js_array_buffer_constructor1(JSContext *ctx,
JS_CLASS_ARRAY_BUFFER);
}
-JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
+inline JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
JSFreeArrayBufferDataFunc *free_func, void *opaque,
BOOL is_shared)
{
@@ -61173,7 +61175,7 @@ JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
}
/* create a new ArrayBuffer of length 'len' and copy 'buf' to it */
-JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len)
+inline JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len)
{
return js_array_buffer_constructor3(ctx, JS_UNDEFINED, len,
JS_CLASS_ARRAY_BUFFER,
@@ -61261,7 +61263,7 @@ static JSValue js_array_buffer_get_byteLength(JSContext *ctx,
return JS_NewUint32(ctx, abuf->byte_length);
}
-void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj)
+inline void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj)
{
auto abuf = (JSArrayBuffer*) JS_GetOpaque(obj, JS_CLASS_ARRAY_BUFFER);
struct list_head *el;
@@ -61306,7 +61308,7 @@ static JSArrayBuffer *js_get_array_buffer(JSContext *ctx, JSValueConst obj)
/* return NULL if exception. WARNING: any JS call can detach the
buffer and render the returned pointer invalid */
-uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj)
+inline uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj)
{
JSArrayBuffer *abuf = js_get_array_buffer(ctx, obj);
if (!abuf)
@@ -61525,7 +61527,7 @@ static JSValue js_typed_array_get_byteOffset(JSContext *ctx,
/* Return the buffer associated to the typed array or an exception if
it is not a typed array or if the buffer is detached. pbyte_offset,
pbyte_length or pbytes_per_element can be NULL. */
-JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
+inline JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
size_t *pbyte_offset,
size_t *pbyte_length,
size_t *pbytes_per_element)
@@ -63934,7 +63936,7 @@ void JS_AddIntrinsicAtomics(JSContext *ctx)
#endif /* CONFIG_ATOMICS */
-void JS_AddIntrinsicTypedArrays(JSContext *ctx)
+inline void JS_AddIntrinsicTypedArrays(JSContext *ctx)
{
JSValue typed_array_base_proto, typed_array_base_func;
JSValueConst array_buffer_func, shared_array_buffer_func;
@@ -64063,27 +64065,47 @@ struct QuickJSContext : public Context::Pimpl
void pushArg (double v) override { functionArgs.push_back (JS_NewFloat64 (context, v)); }
void pushArg (bool v) override { functionArgs.push_back (JS_NewBool (context, v)); }
- choc::value::Value evaluate (const std::string& code, Context::ReadModuleContentFn* resolveModule) override
+ choc::value::Value evaluateExpression (const std::string& code) override
{
- if (resolveModule != nullptr)
- {
- JS_SetModuleLoaderFunc (runtime, nullptr, moduleLoaderFunc, resolveModule);
- auto result = takeValue (JS_Eval (context, code.c_str(), code.size(), "", JS_EVAL_TYPE_MODULE)).toChocValue();
- JS_SetModuleLoaderFunc (runtime, nullptr, nullptr, nullptr);
- return result;
- }
-
return takeValue (JS_Eval (context, code.c_str(), code.size(), "", JS_EVAL_TYPE_GLOBAL)).toChocValue();
}
- static JSModuleDef* moduleLoaderFunc (JSContext* ctx, const char* module_name, void* resolveModule)
+ void run (const std::string& code, Context::ReadModuleContentFn* resolveModule, Context::CompletionHandler handleResult) override
{
- auto content = (*static_cast (resolveModule)) (std::string_view (module_name));
+ try
+ {
+ if (resolveModule != nullptr)
+ {
+ JS_SetModuleLoaderFunc (runtime, nullptr, moduleLoaderFunc, resolveModule);
+ auto result = takeValue (JS_Eval (context, code.c_str(), code.size(), "", JS_EVAL_TYPE_MODULE));
+ JS_SetModuleLoaderFunc (runtime, nullptr, nullptr, nullptr);
+
+ if (handleResult)
+ handleResult ({}, result.toChocValue());
+ }
+ else
+ {
+ auto result = takeValue (JS_Eval (context, code.c_str(), code.size(), "", JS_EVAL_TYPE_GLOBAL));
+
+ if (handleResult)
+ handleResult ({}, result.toChocValue());
+ }
+ }
+ catch (const std::exception& e)
+ {
+ if (handleResult)
+ handleResult (e.what(), {});
+ }
+ }
+
+ static JSModuleDef* moduleLoaderFunc (JSContext* ctx, const char* moduleName, void* resolveModule)
+ {
+ auto content = (*static_cast (resolveModule)) (std::string_view (moduleName));
if (! content)
- throw Error ("Cannot find module '" + std::string (module_name) + "'");
+ throw Error ("Cannot find module '" + std::string (moduleName) + "'");
- auto result = ValuePtr (JS_Eval (ctx, content->data(), content->length(), module_name,
+ auto result = ValuePtr (JS_Eval (ctx, content->data(), content->length(), moduleName,
JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY), ctx);
result.throwIfError();
return static_cast (JS_VALUE_GET_PTR (result.get()));
@@ -64335,12 +64357,11 @@ struct QuickJSContext : public Context::Pimpl
} // namespace quickjs
-Context createQuickJSContext()
+inline Context createQuickJSContext()
{
return Context (std::make_unique());
}
} // namespace choc::javascript
-} // anonymous namespace
#endif // CHOC_JAVASCRIPT_QUICKJS_HEADER_INCLUDED
diff --git a/modules/juce_core/javascript/choc/math/choc_MathHelpers.h b/modules/juce_core/javascript/choc/math/choc_MathHelpers.h
index 99810423af..f91b1953b0 100644
--- a/modules/juce_core/javascript/choc/math/choc_MathHelpers.h
+++ b/modules/juce_core/javascript/choc/math/choc_MathHelpers.h
@@ -30,14 +30,12 @@
#pragma intrinsic (_BitScanReverse64)
#endif
- #ifdef _M_X64
+ #if defined (_M_X64) && ! defined (_M_ARM64EC)
#pragma intrinsic (_umul128)
#define CHOC_HAS_UMUL128 1
#endif
#endif
-namespace
-{
namespace choc::math
{
@@ -116,6 +114,5 @@ inline Int128 multiply128 (uint64_t a, uint64_t b)
} // namespace choc::math
-} // anonymous namespace
#endif
diff --git a/modules/juce_core/javascript/choc/platform/choc_DisableAllWarnings.h b/modules/juce_core/javascript/choc/platform/choc_DisableAllWarnings.h
index a7abac80bf..c9c26e022a 100644
--- a/modules/juce_core/javascript/choc/platform/choc_DisableAllWarnings.h
+++ b/modules/juce_core/javascript/choc/platform/choc_DisableAllWarnings.h
@@ -65,14 +65,37 @@
#pragma GCC diagnostic ignored "-Wnarrowing"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wwrite-strings"
+ #pragma GCC diagnostic ignored "-Wformat-overflow"
+ #pragma GCC diagnostic ignored "-Wdeprecated-copy-with-dtor"
+ #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+ #pragma GCC diagnostic ignored "-Wdeprecated"
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ #pragma GCC diagnostic ignored "-Wuse-after-free"
+ #pragma GCC diagnostic ignored "-Warray-bounds"
+ #pragma GCC diagnostic ignored "-Wvolatile"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#pragma GCC diagnostic ignored "-Wfloat-equal"
-
#ifndef __MINGW32__
#pragma GCC diagnostic ignored "-Wredundant-move"
#endif
#else
#pragma warning (push, 0)
+ #pragma warning (disable: 2440)
+ #pragma warning (disable: 2664)
+ #pragma warning (disable: 4244)
+ #pragma warning (disable: 4701)
#pragma warning (disable: 4702)
#pragma warning (disable: 4706)
+ #pragma warning (disable: 4722)
+ #pragma warning (disable: 6011)
+ #pragma warning (disable: 6246)
+ #pragma warning (disable: 6255)
+ #pragma warning (disable: 6262)
+ #pragma warning (disable: 6297)
+ #pragma warning (disable: 6308)
+ #pragma warning (disable: 6323)
+ #pragma warning (disable: 6340)
+ #pragma warning (disable: 6385)
+ #pragma warning (disable: 6386)
+ #pragma warning (disable: 28182)
#endif
diff --git a/modules/juce_core/javascript/choc/text/choc_FloatToString.h b/modules/juce_core/javascript/choc/text/choc_FloatToString.h
index bc13c53f32..bf8993321b 100644
--- a/modules/juce_core/javascript/choc/text/choc_FloatToString.h
+++ b/modules/juce_core/javascript/choc/text/choc_FloatToString.h
@@ -23,8 +23,6 @@
#include
#include "../math/choc_MathHelpers.h"
-namespace
-{
namespace choc::text
{
@@ -395,6 +393,5 @@ inline std::string floatToString (float value, int maxDecimals, bool omitPointIf
inline std::string floatToString (double value, int maxDecimals, bool omitPointIfPossible) { return FloatToStringBuffer (value, maxDecimals, omitPointIfPossible).toString(); }
} // namespace choc::text
-} // anonymous namespace
#endif
diff --git a/modules/juce_core/javascript/choc/text/choc_JSON.h b/modules/juce_core/javascript/choc/text/choc_JSON.h
index 056aae4c3f..2bfe2cf2b4 100644
--- a/modules/juce_core/javascript/choc/text/choc_JSON.h
+++ b/modules/juce_core/javascript/choc/text/choc_JSON.h
@@ -31,8 +31,6 @@
#undef max // It's never a smart idea to include any C headers before your C++ ones, as it
#undef min // risks polluting your namespace with all kinds of dangerous macros like these ones.
-namespace
-{
namespace choc::json
{
@@ -48,14 +46,14 @@ struct ParseError : public std::runtime_error
/// Parses some JSON text into a choc::value::Value object, using the given pool.
/// Any errors will result in a ParseError exception being thrown.
-value::Value parse (text::UTF8Pointer);
+[[nodiscard]] value::Value parse (text::UTF8Pointer);
/// Parses some JSON text into a choc::value::Value object, using the given pool.
/// Any errors will result in a ParseError exception being thrown.
-value::Value parse (std::string_view);
+[[nodiscard]] value::Value parse (std::string_view);
/// Attempts to parse a bare JSON value such as a number, string, object etc
-value::Value parseValue (std::string_view);
+[[nodiscard]] value::Value parseValue (std::string_view);
/// A helper function to create a JSON-friendly Value object with a set of properties.
/// The argument list must be contain pairs of names and values, e.g.
@@ -67,13 +65,13 @@ value::Value parseValue (std::string_view);
/// Essentially, this is a shorthand for calling choc::value::createObject()
/// and passing it an empty type name.
template
-value::Value create (Properties&&... propertyNamesAndValues);
+[[nodiscard]] value::Value create (Properties&&... propertyNamesAndValues);
//==============================================================================
/// Formats a value as a JSON string.
/// If useLineBreaks is true, it'll be formatted as multi-line JSON, if false it'll
/// just be returned as a single line.
-std::string toString (const value::ValueView&, bool useLineBreaks = false);
+[[nodiscard]] std::string toString (const value::ValueView&, bool useLineBreaks = false);
/// Writes a version of a string to an output stream, with any illegal or non-ascii
/// written as their equivalent JSON escape sequences.
@@ -82,15 +80,15 @@ void writeWithEscapeCharacters (OutputStreamType&, text::UTF8Pointer sourceStrin
/// Returns a version of a string with illegal or non-ascii converted into the
/// equivalent JSON escape sequences.
-std::string addEscapeCharacters (text::UTF8Pointer sourceString);
+[[nodiscard]] std::string addEscapeCharacters (text::UTF8Pointer sourceString);
/// Returns a version of a string with illegal or non-ascii converted into the
/// equivalent JSON escape sequences.
-std::string addEscapeCharacters (std::string_view sourceString);
+[[nodiscard]] std::string addEscapeCharacters (std::string_view sourceString);
/// Returns a version of a string with illegal or non-ascii converted into the
/// equivalent JSON escape sequences.
-std::string getEscapedQuotedString (std::string_view sourceString);
+[[nodiscard]] std::string getEscapedQuotedString (std::string_view sourceString);
/// Converts a double to a JSON-format string representation.
std::string doubleToString (double value);
@@ -160,7 +158,7 @@ void writeWithEscapeCharacters (OutputStreamType& out, text::UTF8Pointer source)
inline std::string addEscapeCharacters (text::UTF8Pointer source)
{
- std::ostringstream result;
+ std::ostringstream result (std::ios::binary);
writeWithEscapeCharacters (result, source);
return result.str();
}
@@ -172,7 +170,7 @@ inline std::string addEscapeCharacters (std::string_view source)
inline std::string getEscapedQuotedString (std::string_view s)
{
- std::ostringstream result;
+ std::ostringstream result (std::ios::binary);
result << '"';
writeWithEscapeCharacters (result, text::UTF8Pointer (std::string (s).c_str()));
result << '"';
@@ -287,7 +285,7 @@ void writeAsJSON (Stream& output, const value::ValueView& value, bool useMultipl
inline std::string toString (const value::ValueView& v, bool useLineBreaks)
{
- std::ostringstream out;
+ std::ostringstream out (std::ios::binary);
writeAsJSON (out, v, useLineBreaks);
return out.str();
}
@@ -458,7 +456,7 @@ inline value::Value parse (text::UTF8Pointer text, bool parseBareValue)
std::string parseString()
{
- std::ostringstream s;
+ std::ostringstream s (std::ios::binary);
for (;;)
{
@@ -559,6 +557,5 @@ value::Value create (Properties&&... properties)
} // namespace choc::json
-} // anonymous namespace
#endif
diff --git a/modules/juce_core/javascript/choc/text/choc_StringUtilities.h b/modules/juce_core/javascript/choc/text/choc_StringUtilities.h
index 831fd16bad..6633f68b28 100644
--- a/modules/juce_core/javascript/choc/text/choc_StringUtilities.h
+++ b/modules/juce_core/javascript/choc/text/choc_StringUtilities.h
@@ -29,8 +29,6 @@
#include
#include "../platform/choc_Assert.h"
-namespace
-{
namespace choc::text
{
@@ -42,77 +40,80 @@ inline bool isDigit (char c) { return static_
/// The arguments must be a sequence of pairs of strings, where the first of each pair is the string to
/// look for, followed by its replacement.
template
-std::string replace (StringType textToSearch,
- std::string_view firstSubstringToReplace, std::string_view firstReplacement,
- OtherReplacements&&... otherPairsOfStringsToReplace);
+[[nodiscard]] std::string replace (StringType textToSearch,
+ std::string_view firstSubstringToReplace, std::string_view firstReplacement,
+ OtherReplacements&&... otherPairsOfStringsToReplace);
/// Returns a string with any whitespace trimmed from its start and end.
-std::string trim (std::string textToTrim);
+[[nodiscard]] std::string trim (std::string textToTrim);
/// Returns a string with any whitespace trimmed from its start and end.
-std::string_view trim (std::string_view textToTrim);
+[[nodiscard]] std::string_view trim (std::string_view textToTrim);
/// Returns a string with any whitespace trimmed from its start and end.
-std::string_view trim (const char* textToTrim);
+[[nodiscard]] std::string_view trim (const char* textToTrim);
/// Returns a string with any whitespace trimmed from its start.
-std::string trimStart (std::string textToTrim);
+[[nodiscard]] std::string trimStart (std::string textToTrim);
/// Returns a string with any whitespace trimmed from its start.
-std::string_view trimStart (std::string_view textToTrim);
+[[nodiscard]] std::string_view trimStart (std::string_view textToTrim);
/// Returns a string with any whitespace trimmed from its start.
-std::string_view trimStart (const char* textToTrim);
+[[nodiscard]] std::string_view trimStart (const char* textToTrim);
/// Returns a string with any whitespace trimmed from its end.
-std::string trimEnd (std::string textToTrim);
+[[nodiscard]] std::string trimEnd (std::string textToTrim);
/// Returns a string with any whitespace trimmed from its end.
-std::string_view trimEnd (std::string_view textToTrim);
+[[nodiscard]] std::string_view trimEnd (std::string_view textToTrim);
/// Returns a string with any whitespace trimmed from its end.
-std::string_view trimEnd (const char* textToTrim);
+[[nodiscard]] std::string_view trimEnd (const char* textToTrim);
/// If the string begins with one or more instances of the given character, this
/// skips past them, returning the remainder of the string.
-std::string_view trimCharacterAtStart (std::string_view textToTrim, char characterToSkip);
+[[nodiscard]] std::string_view trimCharacterAtStart (std::string_view textToTrim, char characterToSkip);
/// If the given character is at the start and end of the string, it trims it away.
-std::string removeOuterCharacter (std::string text, char outerChar);
+[[nodiscard]] std::string removeOuterCharacter (std::string text, char outerChar);
-inline std::string removeDoubleQuotes (std::string text) { return removeOuterCharacter (std::move (text), '"'); }
-inline std::string removeSingleQuotes (std::string text) { return removeOuterCharacter (std::move (text), '\''); }
+[[nodiscard]] inline std::string removeDoubleQuotes (std::string text) { return removeOuterCharacter (std::move (text), '"'); }
+[[nodiscard]] inline std::string removeSingleQuotes (std::string text) { return removeOuterCharacter (std::move (text), '\''); }
-inline std::string addDoubleQuotes (std::string text) { return "\"" + std::move (text) + "\""; }
-inline std::string addSingleQuotes (std::string text) { return "'" + std::move (text) + "'"; }
+[[nodiscard]] inline std::string addDoubleQuotes (std::string text) { return "\"" + std::move (text) + "\""; }
+[[nodiscard]] inline std::string addSingleQuotes (std::string text) { return "'" + std::move (text) + "'"; }
-std::string toLowerCase (std::string);
-std::string toUpperCase (std::string);
+[[nodiscard]] std::string toLowerCase (std::string);
+[[nodiscard]] std::string toUpperCase (std::string);
template
-std::vector splitString (std::string_view textToSplit,
- IsDelimiterChar&& isDelimiterChar,
- bool includeDelimitersInResult);
+[[nodiscard]] std::vector splitString (std::string_view textToSplit,
+ IsDelimiterChar&& isDelimiterChar,
+ bool includeDelimitersInResult);
template
-std::vector splitString (std::string_view textToSplit,
- CharStartsDelimiter&& isDelimiterStart,
- CharIsInDelimiterBody&& isDelimiterBody,
- bool includeDelimitersInResult);
+[[nodiscard]] std::vector splitString (std::string_view textToSplit,
+ CharStartsDelimiter&& isDelimiterStart,
+ CharIsInDelimiterBody&& isDelimiterBody,
+ bool includeDelimitersInResult);
-std::vector splitString (std::string_view textToSplit,
- char delimiterCharacter,
- bool includeDelimitersInResult);
+[[nodiscard]] std::vector splitString (std::string_view textToSplit,
+ char delimiterCharacter,
+ bool includeDelimitersInResult);
-std::vector splitAtWhitespace (std::string_view text, bool keepDelimiters = false);
+[[nodiscard]] std::vector splitAtWhitespace (std::string_view text,
+ bool keepDelimiters = false);
/// Splits a string at newline characters, returning an array of strings.
-std::vector splitIntoLines (std::string_view text, bool includeNewLinesInResult);
+[[nodiscard]] std::vector splitIntoLines (std::string_view text,
+ bool includeNewLinesInResult);
/// Joins some kind of array of strings into a single string, adding the given separator
/// between them (but not adding it at the start or end)
template
-std::string joinStrings (const ArrayOfStrings& strings, std::string_view separator);
+[[nodiscard]] std::string joinStrings (const ArrayOfStrings& strings,
+ std::string_view separator);
/// Returns true if this text contains the given sub-string.
bool contains (std::string_view text, std::string_view possibleSubstring);
@@ -595,6 +596,5 @@ inline std::string percentEncodeURI (std::string_view text)
} // namespace choc::text
-} // anonymous namespace
#endif
diff --git a/modules/juce_core/javascript/choc/text/choc_UTF8.h b/modules/juce_core/javascript/choc/text/choc_UTF8.h
index 6e62e986e5..da48299a05 100644
--- a/modules/juce_core/javascript/choc/text/choc_UTF8.h
+++ b/modules/juce_core/javascript/choc/text/choc_UTF8.h
@@ -22,8 +22,6 @@
#include
#include "choc_StringUtilities.h"
-namespace
-{
namespace choc::text
{
@@ -103,14 +101,14 @@ struct UTF8Pointer
/// Returns a pointer to the first non-whitespace character in the given string (which may
/// be the terminating null character if it's all whitespace).
- UTF8Pointer findEndOfWhitespace() const;
+ [[nodiscard]] UTF8Pointer findEndOfWhitespace() const;
/// Iterates backwards from this position to find the first character that follows
/// a new-line. The pointer provided marks the furthest back that the function should search
- UTF8Pointer findStartOfLine (UTF8Pointer startOfValidText) const;
+ [[nodiscard]] UTF8Pointer findStartOfLine (UTF8Pointer startOfValidText) const;
/// Searches forwards for the next character that is followed by a new-line or a null-terminator.
- UTF8Pointer findEndOfLine() const;
+ [[nodiscard]] UTF8Pointer findEndOfLine() const;
//==============================================================================
struct EndIterator {};
@@ -200,7 +198,7 @@ bool isValidCESU8 (std::string_view utf8);
/// Converts any 32-bit characters in this UTF-8 string to surrogate pairs, which makes
/// the resulting string suitable for use at CESU-8.
-std::string convertUTF8ToCESU8 (UTF8Pointer);
+[[nodiscard]] std::string convertUTF8ToCESU8 (UTF8Pointer);
//==============================================================================
@@ -653,6 +651,5 @@ inline std::string convertUTF8ToCESU8 (UTF8Pointer utf8)
} // namespace choc::text
-} // anonymous namespace
#endif
diff --git a/modules/juce_core/javascript/juce_Javascript.cpp b/modules/juce_core/javascript/juce_Javascript.cpp
index 9ffb209130..23c004f2a3 100644
--- a/modules/juce_core/javascript/juce_Javascript.cpp
+++ b/modules/juce_core/javascript/juce_Javascript.cpp
@@ -32,16 +32,9 @@
==============================================================================
*/
-JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-copy-with-dtor",
- "-Wunused-but-set-variable",
- "-Wdeprecated",
- "-Wunused-function",
- "-Wpedantic")
-JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4163 6011 6246 6255 6262 6297 6308 6323 6340 6385 6386 28182)
+#define choc juce::detail::choc
#include
-#include
-JUCE_END_IGNORE_WARNINGS_MSVC
-JUCE_END_IGNORE_WARNINGS_GCC_LIKE
+#undef choc
namespace juce
{
@@ -56,7 +49,7 @@ template
static int64_t toJuceInt64 (const T& convertible) { return (int64) (int64_t) convertible; }
//==============================================================================
-namespace qjs = choc::javascript::quickjs;
+namespace qjs = detail::choc::javascript::quickjs;
using VarOrError = std::variant;
@@ -412,7 +405,7 @@ static VarOrError quickJSToJuce (const qjs::QuickJSContext::ValuePtr& ptr)
{
return tryQuickJSToJuce (ptr);
}
- catch (const choc::javascript::Error& error)
+ catch (const detail::choc::javascript::Error& error)
{
return String (error.what());
}
@@ -428,17 +421,12 @@ class detail::QuickJSWrapper
public:
qjs::JSContext* getQuickJSContext() const
{
- return static_cast (context.getPimpl())->context;
+ return impl->context;
}
qjs::JSRuntime* getQuickJSRuntime() const
{
- return static_cast (context.getPimpl())->runtime;
- }
-
- choc::javascript::Context& getContext()
- {
- return context;
+ return impl->runtime;
}
/* Returning a value > 0 will interrupt the QuickJS engine.
@@ -460,7 +448,7 @@ private:
return 0;
}
- choc::javascript::Context context = choc::javascript::createQuickJSContext();
+ std::unique_ptr impl = std::make_unique();
std::function interruptHandler;
};
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
@@ -558,11 +546,11 @@ struct DynamicObjectWrapper
}
//==============================================================================
- static choc::javascript::quickjs::JSValue callDispatcher (qjs::JSContext* ctx,
- qjs::JSValueConst thisValue,
- int numArgs,
- qjs::JSValueConst* args,
- int ordinal)
+ static qjs::JSValue callDispatcher (qjs::JSContext* ctx,
+ qjs::JSValueConst thisValue,
+ int numArgs,
+ qjs::JSValueConst* args,
+ int ordinal)
{
auto& self = *static_cast (qjs::JS_GetOpaque2 (ctx, thisValue, getClassId()));
const auto argList = quickJSToJuce (Span { args, (size_t) numArgs }, ctx);