Skip to content

Commit c323f5c

Browse files
committed
[Website] Fix emscripten settings, so demo doesn't crash in Firefox
Fixes #633 Also fixes #621, because I wasn't able to run it otherwise.
1 parent 9035296 commit c323f5c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ OPT ?= -O3
3232
CXXFLAGS ?= -g $(OPT) -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json
3333
CFLAGS ?= -g $(OPT) -Wall -Wextra -pedantic -std=c99 -fPIC -Iinclude
3434
MAKEDEPENDFLAGS ?= -Iinclude -Ithird_party/md5 -Ithird_party/json
35-
EMCXXFLAGS = $(CXXFLAGS) -g0 -Os --memory-init-file 0 -s DISABLE_EXCEPTION_CATCHING=0 -s OUTLINING_LIMIT=10000 -s RESERVED_FUNCTION_POINTERS=20
36-
EMCFLAGS = $(CFLAGS) --memory-init-file 0 -s DISABLE_EXCEPTION_CATCHING=0
35+
EMCXXFLAGS = $(CXXFLAGS) -g0 -Os --memory-init-file 0 -s DISABLE_EXCEPTION_CATCHING=0 -s OUTLINING_LIMIT=10000 -s RESERVED_FUNCTION_POINTERS=20 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1
36+
EMCFLAGS = $(CFLAGS) --memory-init-file 0 -s DISABLE_EXCEPTION_CATCHING=0 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1
3737
LDFLAGS ?=
3838

3939
SHARED_LDFLAGS ?= -shared
@@ -131,7 +131,7 @@ libjsonnet++.so: $(LIB_CPP_OBJ)
131131
# JavaScript build of C binding
132132
JS_EXPORTED_FUNCTIONS = 'EXPORTED_FUNCTIONS=["_jsonnet_make", "_jsonnet_evaluate_snippet", "_jsonnet_fmt_snippet", "_jsonnet_ext_var", "_jsonnet_ext_code", "_jsonnet_tla_var", "_jsonnet_tla_code", "_jsonnet_realloc", "_jsonnet_destroy", "_jsonnet_import_callback"]'
133133

134-
JS_RUNTIME_METHODS = 'EXTRA_EXPORTED_RUNTIME_METHODS=["cwrap", "_free", "getValue", "lengthBytesUTF8", "_malloc", "Pointer_stringify", "setValue", "stringToUTF8", "addFunction"]'
134+
JS_RUNTIME_METHODS = 'EXTRA_EXPORTED_RUNTIME_METHODS=["cwrap", "_free", "getValue", "lengthBytesUTF8", "_malloc", "UTF8ToString", "setValue", "stringToUTF8", "addFunction"]'
135135

136136

137137
libjsonnet.js: $(LIB_SRC) $(ALL_HEADERS)

doc/js/demo.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ let ctx_counter = 1;
3535
let import_callback = addFunction(function (ctx_, base_, rel_, found_here_, success_) {
3636
let vm = ctx_mapping[ctx_].vm
3737
let files = ctx_mapping[ctx_].files
38-
let base = Module.Pointer_stringify(base_);
39-
let rel = Module.Pointer_stringify(rel_);
38+
let base = Module.UTF8ToString(base_);
39+
let rel = Module.UTF8ToString(rel_);
4040
let abs_path;
4141
// It is possible that rel is actually absolute.
4242
if (rel[0] == '/') {
@@ -77,7 +77,7 @@ function jsonnet_evaluate_snippet_wrapped(
7777
let output_ptr = jsonnet_evaluate_snippet(vm, filename, code, error_ptr);
7878
let error = Module.getValue(error_ptr, 'i32*');
7979
Module._free(error_ptr);
80-
let result = Module.Pointer_stringify(output_ptr);
80+
let result = Module.UTF8ToString(output_ptr);
8181
jsonnet_realloc(vm, output_ptr, 0);
8282
jsonnet_destroy(vm);
8383
delete ctx_mapping[ctx_ptr];
@@ -94,7 +94,7 @@ function jsonnet_fmt_snippet_wrapped(filename, code) {
9494
let output_ptr = jsonnet_fmt_snippet(vm, filename, code, error_ptr);
9595
let error = Module.getValue(error_ptr, 'i32*');
9696
Module._free(error_ptr);
97-
let result = Module.Pointer_stringify(output_ptr);
97+
let result = Module.UTF8ToString(output_ptr);
9898
jsonnet_realloc(vm, output_ptr, 0);
9999
jsonnet_destroy(vm);
100100
if (error) {

0 commit comments

Comments
 (0)