aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-06-17 13:55:45 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-06-17 13:55:45 -0700
commit1325723c82ff8cacdbe9dd3b493b1dd304ed84a8 (patch)
tree25e2ceb250ccc81c0d571409151433a063281321 /src
parent81404885333898b87da39c074b33ed70f327ea63 (diff)
allow multiple preRun/postRun
Diffstat (limited to 'src')
-rw-r--r--src/postamble.js17
-rw-r--r--src/shell.js4
2 files changed, 15 insertions, 6 deletions
diff --git a/src/postamble.js b/src/postamble.js
index 56586487..10ac1888 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -33,11 +33,13 @@ function run(args) {
args = args || Module['arguments'];
if (Module['preRun']) {
- Module['preRun']();
- if (runDependencies > 0) {
- // preRun added a dependency, run will be called later
- Module['preRun'] = null;
- return 0;
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length > 0) {
+ Module['preRun'].pop()();
+ if (runDependencies > 0) {
+ // preRun added a dependency, run will be called later
+ return 0;
+ }
}
}
@@ -51,7 +53,10 @@ function run(args) {
}
}
if (Module['postRun']) {
- Module['postRun']();
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length > 0) {
+ Module['postRun'].pop()();
+ }
}
return ret;
}
diff --git a/src/shell.js b/src/shell.js
index e48be3b0..754cdb8e 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -119,6 +119,10 @@ if (!Module['arguments']) {
Module.print = Module['print'];
Module.printErr = Module['printErr'];
+// Callbacks
+if (!Module['preRun']) Module['preRun'] = [];
+if (!Module['postRun']) Module['postRun'] = [];
+
{{BODY}}
// {{MODULE_ADDITIONS}}