aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 0525dd49..fd09f478 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -336,11 +336,11 @@ mergeInto(LibraryManager.library, {
xhr.send(null);
},
- asyncLoad: function(url, onload, onerror) {
+ asyncLoad: function(url, onload, onerror, noRunDep) {
Browser.xhrLoad(url, function(arrayBuffer) {
assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
onload(new Uint8Array(arrayBuffer));
- removeRunDependency('al ' + url);
+ if (!noRunDep) removeRunDependency('al ' + url);
}, function(event) {
if (onerror) {
onerror();
@@ -348,7 +348,7 @@ mergeInto(LibraryManager.library, {
throw 'Loading data file "' + url + '" failed.';
}
});
- addRunDependency('al ' + url);
+ if (!noRunDep) addRunDependency('al ' + url);
},
resizeListeners: [],
@@ -377,14 +377,25 @@ mergeInto(LibraryManager.library, {
_file.substr(index +1),
_url, true, true,
function() {
- if (onload) FUNCTION_TABLE[onload](file);
+ if (onload) Runtime.dynCall('vi', onload, [file]);
},
function() {
- if (onerror) FUNCTION_TABLE[onerror](file);
+ if (onerror) Runtime.dynCall('vi', onerror, [file]);
}
);
},
+ emscripten_async_wget_data: function(url, arg, onload, onerror) {
+ Browser.asyncLoad(Pointer_stringify(url), function(byteArray) {
+ var buffer = _malloc(byteArray.length);
+ HEAPU8.set(byteArray, buffer);
+ FUNCTION_TABLE[onload](arg, buffer, byteArray.length);
+ _free(buffer);
+ }, function() {
+ if (onerror) FUNCTION_TABLE[onerror](arg);
+ }, true /* no need for run dependency, this is async but will not do any prepare etc. step */ );
+ },
+
emscripten_async_wget2: function(url, file, request, param, arg, onload, onerror, onprogress) {
var _url = Pointer_stringify(url);
var _file = Pointer_stringify(file);
@@ -417,7 +428,7 @@ mergeInto(LibraryManager.library, {
if (onprogress) FUNCTION_TABLE[onprogress](arg, percentComplete);
};
- // Useful because the browser can limit the number of redirection
+ // Useful because the browser can limit the number of redirection
try {
if (http.channel instanceof Ci.nsIHttpChannel)
http.channel.redirectionLimit = 0;
@@ -444,10 +455,10 @@ mergeInto(LibraryManager.library, {
_file.substr(index +1),
new Uint8Array(data.object.contents), true, true,
function() {
- if (onload) FUNCTION_TABLE[onload](file);
+ if (onload) Runtime.dynCall('vi', onload, [file]);
},
function() {
- if (onerror) FUNCTION_TABLE[onerror](file);
+ if (onerror) Runtime.dynCall('vi', onerror, [file]);
},
true // don'tCreateFile - it's already there
);
@@ -466,10 +477,10 @@ mergeInto(LibraryManager.library, {
{{{ makeHEAPView('U8', 'data', 'data + size') }}},
true, true,
function() {
- if (onload) FUNCTION_TABLE[onload](arg, cname);
+ if (onload) Runtime.dynCall('vii', onload, [arg, cname]);
},
function() {
- if (onerror) FUNCTION_TABLE[onerror](arg);
+ if (onerror) Runtime.dynCall('vi', onerror, [arg]);
},
true // don'tCreateFile - it's already there
);
@@ -489,7 +500,6 @@ mergeInto(LibraryManager.library, {
emscripten_set_main_loop: function(func, fps, simulateInfiniteLoop) {
Module['noExitRuntime'] = true;
- var jsFunc = FUNCTION_TABLE[func];
Browser.mainLoop.runner = function() {
if (Browser.mainLoop.queue.length > 0) {
var start = Date.now();
@@ -522,7 +532,7 @@ mergeInto(LibraryManager.library, {
Module['preMainLoop']();
}
- jsFunc();
+ Runtime.dynCall('v', func);
if (Module['postMainLoop']) {
Module['postMainLoop']();
@@ -566,12 +576,16 @@ mergeInto(LibraryManager.library, {
},
_emscripten_push_main_loop_blocker: function(func, arg, name) {
- Browser.mainLoop.queue.push({ func: FUNCTION_TABLE[func], arg: arg, name: Pointer_stringify(name), counted: true });
+ Browser.mainLoop.queue.push({ func: function() {
+ Runtime.dynCall('vi', func, [arg]);
+ }, name: Pointer_stringify(name), counted: true });
Browser.mainLoop.updateStatus();
},
_emscripten_push_uncounted_main_loop_blocker: function(func, arg, name) {
- Browser.mainLoop.queue.push({ func: FUNCTION_TABLE[func], arg: arg, name: Pointer_stringify(name), counted: false });
+ Browser.mainLoop.queue.push({ func: function() {
+ Runtime.dynCall('vi', func, [arg]);
+ }, name: Pointer_stringify(name), counted: false });
Browser.mainLoop.updateStatus();
},
@@ -585,7 +599,7 @@ mergeInto(LibraryManager.library, {
Module['noExitRuntime'] = true;
function wrapper() {
- Runtime.getFuncWrapper(func)(arg);
+ Runtime.getFuncWrapper(func, 'vi')(arg);
}
if (millis >= 0) {
@@ -669,7 +683,7 @@ mergeInto(LibraryManager.library, {
if (callback) {
callbackId = info.callbacks.length;
info.callbacks.push({
- func: Runtime.getFuncWrapper(callback),
+ func: Runtime.getFuncWrapper(callback, 'viii'),
arg: arg
});
info.awaited++;