aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library_browser.js6
-rw-r--r--system/include/emscripten/emscripten.h4
-rw-r--r--tests/sdl_image_prepare_data.c12
3 files changed, 13 insertions, 9 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index fb2fa16b..99106fc3 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -402,7 +402,7 @@ mergeInto(LibraryManager.library, {
return 0;
},
- emscripten_async_prepare_data: function(data, size, suffix, onload, onerror) {
+ emscripten_async_prepare_data: function(data, size, suffix, arg, onload, onerror) {
var _suffix = Pointer_stringify(suffix);
if (!Browser.asyncPrepareDataCounter) Browser.asyncPrepareDataCounter = 0;
var name = 'prepare_data_' + (Browser.asyncPrepareDataCounter++) + '.' + _suffix;
@@ -414,10 +414,10 @@ mergeInto(LibraryManager.library, {
{{{ makeHEAPView('U8', 'data', 'data + size') }}},
true, true,
function() {
- if (onload) FUNCTION_TABLE[onload](data, cname);
+ if (onload) FUNCTION_TABLE[onload](arg, cname);
},
function() {
- if (onerror) FUNCTION_TABLE[onerror](data);
+ if (onerror) FUNCTION_TABLE[onerror](arg);
},
true // don'tCreateFile - it's already there
);
diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h
index 94f1c860..ed078acd 100644
--- a/system/include/emscripten/emscripten.h
+++ b/system/include/emscripten/emscripten.h
@@ -200,7 +200,7 @@ int emscripten_async_prepare(const char* file, void (*onload)(const char*), void
* Data version of emscripten_async_prepare, which receives
* raw data as input instead of a filename (this can prevent
* the need to write data to a file first). onload and
- * onerror are called back with the data pointer as the
+ * onerror are called back with the given arg pointer as the
* first parameter. onload also receives a second
* parameter, which is a 'fake' filename which you can
* then pass into IMG_Load (it is not an actual file,
@@ -210,7 +210,7 @@ int emscripten_async_prepare(const char* file, void (*onload)(const char*), void
* the fake filename.
* @suffix The file suffix, e.g. 'png' or 'jpg'.
*/
-void emscripten_async_prepare_data(char* data, int size, const char *suffix, void (*onload)(char*, const char*), void (*onerror)(char*));
+void emscripten_async_prepare_data(char* data, int size, const char *suffix, void *arg, void (*onload)(void*, const char*), void (*onerror)(void*));
/*
* Profiling tools.
diff --git a/tests/sdl_image_prepare_data.c b/tests/sdl_image_prepare_data.c
index fdad16d1..87e33399 100644
--- a/tests/sdl_image_prepare_data.c
+++ b/tests/sdl_image_prepare_data.c
@@ -25,18 +25,22 @@ int testImage(const char* fileName) {
return result;
}
-void ready(char *data, const char *fileName) {
- printf("ready! %s\n", fileName);
+void ready(void *arg, const char *fileName) {
+ printf("ready! %s (%d)\n", fileName, (int)arg);
static int first = 1;
static const char *seenName;
+ static void *seenArg;
if (first) {
first = 0;
seenName = fileName;
+ seenArg = arg;
} else {
printf("%s ? %s == %d\n", fileName, seenName, strcmp(fileName, seenName));
assert(strcmp(fileName, seenName)); // different names
+ assert(seenArg != arg); // different args
+
testImage(seenName);
free(seenName); // As the API docs say, we are responsible for freeing the 'fake' names we are given
@@ -57,8 +61,8 @@ int main() {
fread(buffer, SIZE, 1, f);
fclose(f);
- emscripten_async_prepare_data(buffer, SIZE, "jpg", ready, NULL);
- emscripten_async_prepare_data(buffer, SIZE, "jpg", ready, NULL); // twice to see different filenames
+ emscripten_async_prepare_data(buffer, SIZE, "jpg", (void*)25, ready, NULL);
+ emscripten_async_prepare_data(buffer, SIZE, "jpg", (void*)33, ready, NULL); // twice to see different filenames
return 0;
}