From 37c031f3493ff300115358816f32428ae1343c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 28 Nov 2020 15:25:44 +0100 Subject: [PATCH] Platform: don't use const or let in EM_ASM(), breaks closure compiler. And add a note there to prevent this from being changed again in the future. --- src/Magnum/Platform/EmscriptenApplication.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Magnum/Platform/EmscriptenApplication.cpp b/src/Magnum/Platform/EmscriptenApplication.cpp index 86b0407e7..36c4c4ccf 100644 --- a/src/Magnum/Platform/EmscriptenApplication.cpp +++ b/src/Magnum/Platform/EmscriptenApplication.cpp @@ -185,10 +185,13 @@ namespace { std::string canvasId() { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" + /* Note: can't use let or const, as that breaks closure compiler: + ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only + supported for ECMASCRIPT6 mode or better: const declaration. */ char* id = reinterpret_cast(EM_ASM_INT({ - const id = Module['canvas'].id; - const bytes = lengthBytesUTF8(id) + 1; - const memory = _malloc(bytes); + var id = Module['canvas'].id; + var bytes = lengthBytesUTF8(id) + 1; + var memory = _malloc(bytes); stringToUTF8(id, memory, bytes); return memory; })); @@ -561,14 +564,17 @@ void EmscriptenApplication::setupCallbacks(bool resizable) { 1.38.27 depending on -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 but we don't want to force this flag on the users so the behavior handles both. */ + /* Note: can't use let or const, as that breaks closure compiler: + ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only + supported for ECMASCRIPT6 mode or better: const declaration. */ const char* keyboardListeningElement = reinterpret_cast(EM_ASM_INT({ var element = Module['keyboardListeningElement'] || document; if(element === document) return 1; /* EMSCRIPTEN_EVENT_TARGET_DOCUMENT */ if(element === window) return 2; /* EMSCRIPTEN_EVENT_TARGET_WINDOW */ if('id' in element) { - const bytes = lengthBytesUTF8(element.id) + 1; - const memory = _malloc(bytes); + var bytes = lengthBytesUTF8(element.id) + 1; + var memory = _malloc(bytes); stringToUTF8(element.id, memory, bytes); return memory; }