Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,12 @@ addToLibrary({
// Used to implement the native `abort` symbol. Note that we use the
// JavaScript `abort` helper in order to implement this function, but we use a
// distinct name here to avoid confusing the two.
_abort_js: () => {
_abort_js: () =>
#if ASSERTIONS
abort('native code called abort()');
abort('native code called abort()'),
#else
abort('');
abort(''),
#endif
},
#endif

// This object can be modified by the user during startup, which affects
Expand Down Expand Up @@ -443,9 +442,8 @@ addToLibrary({
// assert.h
// ==========================================================================

__assert_fail: (condition, filename, line, func) => {
abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
},
__assert_fail: (condition, filename, line, func) =>
abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']),
#endif

#if STACK_OVERFLOW_CHECK >= 2
Expand Down Expand Up @@ -662,9 +660,7 @@ addToLibrary({
$strError: (errno) => errno + '',
#else
$strError__deps: ['strerror', '$UTF8ToString'],
$strError: (errno) => {
return UTF8ToString(_strerror(errno));
},
$strError: (errno) => UTF8ToString(_strerror(errno)),
#endif

#if PROXY_POSIX_SOCKETS == 0
Expand All @@ -681,9 +677,8 @@ addToLibrary({
}
return (b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0;
},
$inetNtop4: (addr) => {
return (addr & 0xff) + '.' + ((addr >> 8) & 0xff) + '.' + ((addr >> 16) & 0xff) + '.' + ((addr >> 24) & 0xff)
},
$inetNtop4: (addr) =>
(addr & 0xff) + '.' + ((addr >> 8) & 0xff) + '.' + ((addr >> 16) & 0xff) + '.' + ((addr >> 24) & 0xff),
$inetPton6__deps: ['htons', '$jstoi_q'],
$inetPton6: (str) => {
var words;
Expand Down Expand Up @@ -1724,9 +1719,7 @@ addToLibrary({
return ___cxa_throw(ex, 0, 0);
},

_Unwind_DeleteException: (ex) => {
err('TODO: Unwind_DeleteException');
},
_Unwind_DeleteException: (ex) => err('TODO: Unwind_DeleteException'),
#endif

// special runtime support
Expand All @@ -1743,29 +1736,28 @@ addToLibrary({
},
#endif

$getExecutableName: () => {
#if MINIMAL_RUNTIME // MINIMAL_RUNTIME does not have a global runtime variable thisProgram
$getExecutableName: () => {
#if ENVIRONMENT_MAY_BE_NODE
if (ENVIRONMENT_IS_NODE && process.argv.length > 1) {
return process.argv[1].replace(/\\/g, '/');
}
#endif
return "./this.program";
},
#else
return thisProgram || './this.program';
$getExecutableName: () => thisProgram || './this.program',
#endif
},

$listenOnce: (object, event, func) => {
$listenOnce: (object, event, func) =>
#if MIN_CHROME_VERSION < 55 || MIN_FIREFOX_VERSION < 50 // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
object.addEventListener(event, function handler() {
func();
object.removeEventListener(event, handler);
});
}),
#else
object.addEventListener(event, func, { 'once': true });
object.addEventListener(event, func, { 'once': true }),
#endif
},

// Receives a Web Audio context plus a set of elements to listen for user
// input events on, and registers a context resume() for them. This lets
Expand Down Expand Up @@ -1999,9 +1991,7 @@ addToLibrary({
// Use program_invocation_short_name and program_invocation_name in compiled
// programs. This function is for implementing them.
_emscripten_get_progname__deps: ['$getExecutableName', '$stringToUTF8'],
_emscripten_get_progname: (str, len) => {
stringToUTF8(getExecutableName(), str, len);
},
_emscripten_get_progname: (str, len) => stringToUTF8(getExecutableName(), str, len),

emscripten_console_log: (str) => {
#if ASSERTIONS
Expand Down
4 changes: 1 addition & 3 deletions src/library_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,7 @@ var LibraryBrowser = {
},

emscripten_set_canvas_size__proxy: 'sync',
emscripten_set_canvas_size: (width, height) => {
Browser.setCanvasSize(width, height);
},
emscripten_set_canvas_size: (width, height) => Browser.setCanvasSize(width, height),

emscripten_get_canvas_size__proxy: 'sync',
emscripten_get_canvas_size: (width, height, isFullscreen) => {
Expand Down
10 changes: 4 additions & 6 deletions src/library_egl.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,13 @@ var LibraryEGL = {

// EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
eglGetConfigs__proxy: 'sync',
eglGetConfigs: (display, configs, config_size, numConfigs) => {
return EGL.chooseConfig(display, 0, configs, config_size, numConfigs);
},
eglGetConfigs: (display, configs, config_size, numConfigs) =>
EGL.chooseConfig(display, 0, configs, config_size, numConfigs),

// EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
eglChooseConfig__proxy: 'sync',
eglChooseConfig: (display, attrib_list, configs, config_size, numConfigs) => {
return EGL.chooseConfig(display, attrib_list, configs, config_size, numConfigs);
},
eglChooseConfig: (display, attrib_list, configs, config_size, numConfigs) =>
EGL.chooseConfig(display, attrib_list, configs, config_size, numConfigs),

// EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
eglGetConfigAttrib__proxy: 'sync',
Expand Down
8 changes: 2 additions & 6 deletions src/library_eventloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,10 @@ LibraryJSEventLoop = {
},

emscripten_pause_main_loop__deps: ['$MainLoop'],
emscripten_pause_main_loop: () => {
MainLoop.pause();
},
emscripten_pause_main_loop: () => MainLoop.pause(),

emscripten_resume_main_loop__deps: ['$MainLoop'],
emscripten_resume_main_loop: () => {
MainLoop.resume();
},
emscripten_resume_main_loop: () => MainLoop.resume(),

_emscripten_push_main_loop_blocker__deps: ['$MainLoop'],
_emscripten_push_main_loop_blocker: (func, arg, name) => {
Expand Down
5 changes: 2 additions & 3 deletions src/library_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -914,9 +914,8 @@ var LibraryHTML5 = {

emscripten_set_devicemotion_callback_on_thread__proxy: 'sync',
emscripten_set_devicemotion_callback_on_thread__deps: ['$registerDeviceMotionEventCallback'],
emscripten_set_devicemotion_callback_on_thread: (userData, useCapture, callbackfunc, targetThread) => {
return registerDeviceMotionEventCallback({{{ cDefs.EMSCRIPTEN_EVENT_TARGET_WINDOW }}}, userData, useCapture, callbackfunc, {{{ cDefs.EMSCRIPTEN_EVENT_DEVICEMOTION }}}, "devicemotion", targetThread);
},
emscripten_set_devicemotion_callback_on_thread: (userData, useCapture, callbackfunc, targetThread) =>
registerDeviceMotionEventCallback({{{ cDefs.EMSCRIPTEN_EVENT_TARGET_WINDOW }}}, userData, useCapture, callbackfunc, {{{ cDefs.EMSCRIPTEN_EVENT_DEVICEMOTION }}}, "devicemotion", targetThread),

emscripten_get_devicemotion_status__proxy: 'sync',
emscripten_get_devicemotion_status__deps: ['$JSEvents'],
Expand Down
5 changes: 2 additions & 3 deletions src/library_html5_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,8 @@ var LibraryHtml5WebGL = {
},

emscripten_is_webgl_context_lost__proxy: 'sync_on_webgl_context_handle_thread',
emscripten_is_webgl_context_lost: (contextHandle) => {
return !GL.contexts[contextHandle] || GL.contexts[contextHandle].GLctx.isContextLost(); // No context ~> lost context.
},
emscripten_is_webgl_context_lost: (contextHandle) =>
!GL.contexts[contextHandle] || GL.contexts[contextHandle].GLctx.isContextLost(), // No context ~> lost context.

emscripten_webgl_get_supported_extensions__proxy: 'sync_on_current_webgl_context_thread',
emscripten_webgl_get_supported_extensions__deps: ['$stringToNewUTF8'],
Expand Down
17 changes: 5 additions & 12 deletions src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2936,9 +2936,7 @@ var LibrarySDL = {
},
Mix_VolumeMusic__proxy: 'sync',
Mix_VolumeMusic: (volume) => {
return SDL.setGetVolume(SDL.music, volume);
},
Mix_VolumeMusic: (volume) => SDL.setGetVolume(SDL.music, volume),
Mix_LoadMUS_RW__deps: ['Mix_LoadWAV_RW'],
Mix_LoadMUS_RW: (filename) => _Mix_LoadWAV_RW(filename, 0),
Expand Down Expand Up @@ -3019,9 +3017,7 @@ var LibrarySDL = {
Mix_FadeOutMusic: 'Mix_HaltMusic', // XXX ignore fading out effect
Mix_PlayingMusic__proxy: 'sync',
Mix_PlayingMusic: () => {
return (SDL.music.audio && !SDL.music.audio.paused) ? 1 : 0;
},
Mix_PlayingMusic: () => (SDL.music.audio && !SDL.music.audio.paused),
// http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_38.html#SEC38
// "Note: Does not check if the channel has been paused."
Expand Down Expand Up @@ -3346,9 +3342,8 @@ var LibrarySDL = {
},

SDL_GL_SwapBuffers__proxy: 'sync',
SDL_GL_SwapBuffers: () => {
Browser.doSwapBuffers?.(); // in workers, this is used to send out a buffered frame
},
// in workers, this is used to send out a buffered frame
SDL_GL_SwapBuffers: () => Browser.doSwapBuffers?.(),

// SDL 2

Expand Down Expand Up @@ -3382,9 +3377,7 @@ var LibrarySDL = {
},

SDL_GL_SetSwapInterval__deps: ['emscripten_set_main_loop_timing'],
SDL_GL_SetSwapInterval: (state) => {
_emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, state);
},
SDL_GL_SetSwapInterval: (state) => _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, state),

SDL_SetWindowTitle__proxy: 'sync',
SDL_SetWindowTitle: (window, title) => {
Expand Down
30 changes: 12 additions & 18 deletions src/library_sockfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,27 +754,21 @@ addToLibrary({
SOCKFS.on(event, callback ? _callback : null);
},
emscripten_set_socket_error_callback__deps: ['$_setNetworkCallback'],
emscripten_set_socket_error_callback: (userData, callback) => {
_setNetworkCallback('error', userData, callback);
},
emscripten_set_socket_error_callback: (userData, callback) =>
_setNetworkCallback('error', userData, callback),
emscripten_set_socket_open_callback__deps: ['$_setNetworkCallback'],
emscripten_set_socket_open_callback: (userData, callback) => {
_setNetworkCallback('open', userData, callback);
},
emscripten_set_socket_open_callback: (userData, callback) =>
_setNetworkCallback('open', userData, callback),
emscripten_set_socket_listen_callback__deps: ['$_setNetworkCallback'],
emscripten_set_socket_listen_callback: (userData, callback) => {
_setNetworkCallback('listen', userData, callback);
},
emscripten_set_socket_listen_callback: (userData, callback) =>
_setNetworkCallback('listen', userData, callback),
emscripten_set_socket_connection_callback__deps: ['$_setNetworkCallback'],
emscripten_set_socket_connection_callback: (userData, callback) => {
_setNetworkCallback('connection', userData, callback);
},
emscripten_set_socket_connection_callback: (userData, callback) =>
_setNetworkCallback('connection', userData, callback),
emscripten_set_socket_message_callback__deps: ['$_setNetworkCallback'],
emscripten_set_socket_message_callback: (userData, callback) => {
_setNetworkCallback('message', userData, callback);
},
emscripten_set_socket_message_callback: (userData, callback) =>
_setNetworkCallback('message', userData, callback),
emscripten_set_socket_close_callback__deps: ['$_setNetworkCallback'],
emscripten_set_socket_close_callback: (userData, callback) => {
_setNetworkCallback('close', userData, callback);
}
emscripten_set_socket_close_callback: (userData, callback) =>
_setNetworkCallback('close', userData, callback),
});
4 changes: 1 addition & 3 deletions src/library_strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,7 @@ addToLibrary({

// Returns the number of bytes the given Javascript string takes if encoded as
// a UTF16 byte array, EXCLUDING the null terminator byte.
$lengthBytesUTF16: (str) => {
return str.length*2;
},
$lengthBytesUTF16: (str) => str.length*2,

$UTF32ToString: (ptr, maxBytesToRead) => {
#if ASSERTIONS
Expand Down
4 changes: 1 addition & 3 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,7 @@ var SyscallsLibrary = {
},
__syscall_fadvise64__nothrow: true,
__syscall_fadvise64__proxy: 'none',
__syscall_fadvise64: (fd, offset, len, advice) => {
return 0; // your advice is important to us (but we can't use it)
},
__syscall_fadvise64: (fd, offset, len, advice) => 0,
__syscall_openat__deps: ['$syscallGetVarargI'],
__syscall_openat: (dirfd, path, flags, varargs) => {
path = SYSCALLS.getStr(path);
Expand Down
4 changes: 1 addition & 3 deletions src/library_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,5 @@ addToLibrary({
return 0;
},
strptime_l__deps: ['strptime'],
strptime_l: (buf, format, tm, locale) => {
return _strptime(buf, format, tm); // no locale support yet
},
strptime_l: (buf, format, tm, locale) => _strptime(buf, format, tm), // no locale support yet
});
37 changes: 15 additions & 22 deletions src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,31 +138,27 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
emscripten_webgl_enable_WEBGL_draw_buffers: (ctx) => webgl_enable_WEBGL_draw_buffers(GL.contexts[ctx].GLctx),
#endif

$webgl_enable_WEBGL_multi_draw: (ctx) => {
$webgl_enable_WEBGL_multi_draw: (ctx) =>
// Closure is expected to be allowed to minify the '.multiDrawWebgl' property, so not accessing it quoted.
return !!(ctx.multiDrawWebgl = ctx.getExtension('WEBGL_multi_draw'));
},
!!(ctx.multiDrawWebgl = ctx.getExtension('WEBGL_multi_draw')),

emscripten_webgl_enable_WEBGL_multi_draw__deps: ['$webgl_enable_WEBGL_multi_draw'],
emscripten_webgl_enable_WEBGL_multi_draw: (ctx) => webgl_enable_WEBGL_multi_draw(GL.contexts[ctx].GLctx),

$webgl_enable_EXT_polygon_offset_clamp: (ctx) => {
return !!(ctx.extPolygonOffsetClamp = ctx.getExtension('EXT_polygon_offset_clamp'));
},
$webgl_enable_EXT_polygon_offset_clamp: (ctx) =>
!!(ctx.extPolygonOffsetClamp = ctx.getExtension('EXT_polygon_offset_clamp')),

emscripten_webgl_enable_EXT_polygon_offset_clamp__deps: ['$webgl_enable_EXT_polygon_offset_clamp'],
emscripten_webgl_enable_EXT_polygon_offset_clamp: (ctx) => webgl_enable_EXT_polygon_offset_clamp(GL.contexts[ctx].GLctx),

$webgl_enable_EXT_clip_control: (ctx) => {
return !!(ctx.extClipControl = ctx.getExtension('EXT_clip_control'));
},
$webgl_enable_EXT_clip_control: (ctx) =>
!!(ctx.extClipControl = ctx.getExtension('EXT_clip_control')),

emscripten_webgl_enable_EXT_clip_control__deps: ['$webgl_enable_EXT_clip_control'],
emscripten_webgl_enable_EXT_clip_control: (ctx) => webgl_enable_EXT_clip_control(GL.contexts[ctx].GLctx),

$webgl_enable_WEBGL_polygon_mode: (ctx) => {
return !!(ctx.webglPolygonMode = ctx.getExtension('WEBGL_polygon_mode'));
},
$webgl_enable_WEBGL_polygon_mode: (ctx) =>
!!(ctx.webglPolygonMode = ctx.getExtension('WEBGL_polygon_mode')),

emscripten_webgl_enable_WEBGL_polygon_mode__deps: ['$webgl_enable_WEBGL_polygon_mode'],
emscripten_webgl_enable_WEBGL_polygon_mode: (ctx) => webgl_enable_WEBGL_polygon_mode(GL.contexts[ctx].GLctx),
Expand Down Expand Up @@ -1273,7 +1269,7 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};

$webglGetExtensions__internal: true,
$webglGetExtensions__deps: ['$getEmscriptenSupportedExtensions'],
$webglGetExtensions() {
$webglGetExtensions: () => {
var exts = getEmscriptenSupportedExtensions(GLctx);
#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
exts = exts.concat(exts.map((e) => "GL_" + e));
Expand Down Expand Up @@ -3050,9 +3046,8 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
GLctx.vertexAttrib4f(index, HEAPF32[v>>2], HEAPF32[v+4>>2], HEAPF32[v+8>>2], HEAPF32[v+12>>2]);
},

glGetAttribLocation: (program, name) => {
return GLctx.getAttribLocation(GL.programs[program], UTF8ToString(name));
},
glGetAttribLocation: (program, name) =>
GLctx.getAttribLocation(GL.programs[program], UTF8ToString(name)),

$__glGetActiveAttribOrUniform__deps: ['$stringToUTF8'],
$__glGetActiveAttribOrUniform: (funcName, program, index, bufSize, length, size, type, name) => {
Expand All @@ -3071,14 +3066,12 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
},

glGetActiveAttrib__deps: ['$__glGetActiveAttribOrUniform'],
glGetActiveAttrib: (program, index, bufSize, length, size, type, name) => {
__glGetActiveAttribOrUniform('getActiveAttrib', program, index, bufSize, length, size, type, name);
},
glGetActiveAttrib: (program, index, bufSize, length, size, type, name) =>
__glGetActiveAttribOrUniform('getActiveAttrib', program, index, bufSize, length, size, type, name),

glGetActiveUniform__deps: ['$__glGetActiveAttribOrUniform'],
glGetActiveUniform: (program, index, bufSize, length, size, type, name) => {
__glGetActiveAttribOrUniform('getActiveUniform', program, index, bufSize, length, size, type, name);
},
glGetActiveUniform: (program, index, bufSize, length, size, type, name) =>
__glGetActiveAttribOrUniform('getActiveUniform', program, index, bufSize, length, size, type, name),

glCreateShader: (shaderType) => {
var id = GL.getNewId(GL.shaders);
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8449
8450
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20799
20797
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8434
8436
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20767
20765
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24642
24640
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8417
8419
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20693
20691
Loading
Loading