mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
emscripten: Don't use legacy JS library functions for assertions
(cherry picked from commit 54f5b73333
)
This commit is contained in:

committed by
Sam Lantinga

parent
59857acd08
commit
a934a36a18
@@ -34,15 +34,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
// older Emscriptens don't have this, but we need to for wasm64 compatibility.
|
|
||||||
#ifndef MAIN_THREAD_EM_ASM_PTR
|
|
||||||
#ifdef __wasm64__
|
|
||||||
#error You need to upgrade your Emscripten compiler to support wasm64
|
|
||||||
#else
|
|
||||||
#define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The size of the stack buffer to use for rendering assert messages.
|
// The size of the stack buffer to use for rendering assert messages.
|
||||||
@@ -252,7 +244,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
bool okay = true;
|
bool okay = true;
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({
|
int reply = MAIN_THREAD_EM_ASM_INT({
|
||||||
var str =
|
var str =
|
||||||
UTF8ToString($0) + '\n\n' +
|
UTF8ToString($0) + '\n\n' +
|
||||||
'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :';
|
'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :';
|
||||||
@@ -260,26 +252,32 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
|
|||||||
if (reply === null) {
|
if (reply === null) {
|
||||||
reply = "i";
|
reply = "i";
|
||||||
}
|
}
|
||||||
return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
|
return reply.length === 1 ? reply.charCodeAt(0) : -1;
|
||||||
}, message);
|
}, message);
|
||||||
/* *INDENT-ON* */ // clang-format on
|
/* *INDENT-ON* */ // clang-format on
|
||||||
|
|
||||||
if (SDL_strcmp(buf, "a") == 0) {
|
switch (reply) {
|
||||||
|
case 'a':
|
||||||
state = SDL_ASSERTION_ABORT;
|
state = SDL_ASSERTION_ABORT;
|
||||||
|
break;
|
||||||
#if 0 // (currently) no break functionality on Emscripten
|
#if 0 // (currently) no break functionality on Emscripten
|
||||||
} else if (SDL_strcmp(buf, "b") == 0) {
|
case 'b':
|
||||||
state = SDL_ASSERTION_BREAK;
|
state = SDL_ASSERTION_BREAK;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
} else if (SDL_strcmp(buf, "r") == 0) {
|
case 'r':
|
||||||
state = SDL_ASSERTION_RETRY;
|
state = SDL_ASSERTION_RETRY;
|
||||||
} else if (SDL_strcmp(buf, "i") == 0) {
|
break;
|
||||||
|
case 'i':
|
||||||
state = SDL_ASSERTION_IGNORE;
|
state = SDL_ASSERTION_IGNORE;
|
||||||
} else if (SDL_strcmp(buf, "A") == 0) {
|
break;
|
||||||
|
case 'A':
|
||||||
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
okay = false;
|
okay = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
free(buf); // This should NOT be SDL_free()
|
|
||||||
|
|
||||||
if (okay) {
|
if (okay) {
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user