aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-30 16:36:28 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-30 16:36:28 -0800
commite97f48a2c9376354a6b8927191322322f13808ba (patch)
tree1e1f079b5569ae2d7269ff2abf4b520ad82d3cdd /src/library_browser.js
parentc3ed294ed249b446bf5a290981fea79a8e4111d7 (diff)
emscripten_async_wget_data
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 00ee158c..b14099f6 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: [],
@@ -381,10 +381,21 @@ mergeInto(LibraryManager.library, {
},
function() {
if (onerror) FUNCTION_TABLE[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_prepare: function(file, onload, onerror) {
var _file = Pointer_stringify(file);
var data = FS.analyzePath(_file);