aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js23
-rw-r--r--src/preamble.js6
-rw-r--r--tools/shared.py2
3 files changed, 18 insertions, 13 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 3da296f1..1e02555f 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -277,19 +277,18 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
snippet = '_' + snippet;
}
} else if (typeof snippet === 'object') {
- // JSON.stringify removes functions, so we need to make sure they are added
- var funcs = [];
- var hasNonFunc = false;
- for (var x in snippet) {
- if (typeof snippet[x] === 'function') {
- funcs.push(x + ': ' + snippet[x].toString());
- } else {
- hasNonFunc = true;
+ if (snippet === null) {
+ snippet = 'null';
+ } else {
+ var members = [];
+ for (var property in snippet) {
+ if (typeof snippet[property] === 'function') {
+ members.push(property + ': ' + snippet[property].toString());
+ } else {
+ members.push(property + ': ' + JSON.stringify(snippet[property]));
+ }
}
- }
- snippet = JSON.stringify(snippet);
- if (funcs.length > 0) {
- snippet = snippet.replace(/}$/, (hasNonFunc ? ', ' : '') + funcs.join(', ') + ' }');
+ snippet = '{' + members.join(', ') + ' }';
}
} else if (typeof snippet === 'function') {
snippet = snippet.toString();
diff --git a/src/preamble.js b/src/preamble.js
index 2cbd9cf0..64b3e222 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -398,6 +398,7 @@ function Pointer_stringify(ptr) {
}
return ret;
}
+Module['Pointer_stringify'] = Pointer_stringify;
function Array_stringify(array) {
var ret = "";
@@ -406,6 +407,7 @@ function Array_stringify(array) {
}
return ret;
}
+Module['Array_stringify'] = Array_stringify;
// Memory management
@@ -537,12 +539,14 @@ function Array_copy(ptr, num) {
#endif
return HEAP.slice(ptr, ptr+num);
}
+Module['Array_copy'] = Array_copy;
function String_len(ptr) {
var i = 0;
while ({{{ makeGetValue('ptr', 'i', 'i8') }}}) i++; // Note: should be |!= 0|, technically. But this helps catch bugs with undefineds
return i;
}
+Module['String_len'] = String_len;
// Copies a C-style string, terminated by a zero, from the HEAP into
// a normal JavaScript array of numbers
@@ -553,6 +557,7 @@ function String_copy(ptr, addZero) {
if (addZero) ret[len-1] = 0;
return ret;
}
+Module['String_copy'] = String_copy;
// Tools
@@ -598,6 +603,7 @@ function intArrayToString(array) {
}
return ret.join('');
}
+Module['intArrayToString'] = intArrayToString;
{{{ unSign }}}
{{{ reSign }}}
diff --git a/tools/shared.py b/tools/shared.py
index 3c9eeb60..ce42d794 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -44,7 +44,7 @@ def timeout_run(proc, timeout, note):
return proc.communicate()[0]
def run_js(engine, filename, args, check_timeout=False, stdout=PIPE, stderr=STDOUT, cwd=None):
- return timeout_run(Popen(engine + [filename] + (['--'] if 'v8' in engine[0] else []) + args,
+ return timeout_run(Popen(engine + [filename] + (['--'] if 'd8' in engine[0] else []) + args,
stdout=stdout, stderr=stderr, cwd=cwd), 15*60 if check_timeout else None, 'Execution')
def to_cc(cxx):