From 913829ae4ed44db26dc6ecd78d3a229955add5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 24 Apr 2025 00:03:17 +0200 Subject: [PATCH] wasm: use emscripten::typed_memory_view() Use typed_memory_view() instead to create UInt8Arrays pointing to an area of the heap, instead of HEAPU8. Fixes issue on emsdk >= 4.0.7 where HEAPU8 etc are no longer exported by default. Change-Id: I2c632b2c54dc1e9947b11ab3d2613d790b994440 Reviewed-by: Lorn Potter --- src/corelib/platform/wasm/qstdweb.cpp | 12 +----------- src/corelib/platform/wasm/qstdweb_p.h | 2 -- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/corelib/platform/wasm/qstdweb.cpp b/src/corelib/platform/wasm/qstdweb.cpp index d518029c7e9..18ab0ec1a9c 100644 --- a/src/corelib/platform/wasm/qstdweb.cpp +++ b/src/corelib/platform/wasm/qstdweb.cpp @@ -330,11 +330,6 @@ emscripten::val FileReader::val() const return m_fileReader; } -Uint8Array Uint8Array::heap() -{ - return Uint8Array(heap_()); -} - // Constructs a Uint8Array which references the given emscripten::val, which must contain a JS Unit8Array Uint8Array::Uint8Array(const emscripten::val &uint8Array) : m_uint8Array(uint8Array) @@ -358,7 +353,7 @@ Uint8Array::Uint8Array(const ArrayBuffer &buffer, uint32_t offset, uint32_t leng // Constructs a Uint8Array which references an area on the heap. Uint8Array::Uint8Array(const char *buffer, uint32_t size) -:m_uint8Array(Uint8Array::constructor_().new_(Uint8Array::heap().buffer().m_arrayBuffer, uintptr_t(buffer), size)) +:m_uint8Array(emscripten::typed_memory_view(size, buffer)) { } @@ -435,11 +430,6 @@ emscripten::val Uint8Array::val() const return m_uint8Array; } -emscripten::val Uint8Array::heap_() -{ - return emscripten::val::module_property("HEAPU8"); -} - emscripten::val Uint8Array::constructor_() { return emscripten::val::global("Uint8Array"); diff --git a/src/corelib/platform/wasm/qstdweb_p.h b/src/corelib/platform/wasm/qstdweb_p.h index 95a77560372..711751f65ab 100644 --- a/src/corelib/platform/wasm/qstdweb_p.h +++ b/src/corelib/platform/wasm/qstdweb_p.h @@ -171,7 +171,6 @@ namespace qstdweb { class Q_CORE_EXPORT Uint8Array { public: - static Uint8Array heap(); explicit Uint8Array(const emscripten::val &uint8Array); explicit Uint8Array(const ArrayBuffer &buffer); explicit Uint8Array(uint32_t size); @@ -192,7 +191,6 @@ namespace qstdweb { emscripten::val val() const; private: - static emscripten::val heap_(); static emscripten::val constructor_(); emscripten::val m_uint8Array = emscripten::val::undefined(); };