Skip to content

Commit eace963

Browse files
authored
Merge pull request #296 from ethereum/emscripten-addfunction
Support multiple versions of Emscripten (module.Runtime.addFunction vs. module.addFunction)
2 parents f617301 + 714162e commit eace963

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

wrapper.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,21 @@ function setupMethods (soljson) {
3434
};
3535
};
3636
}
37-
var cb = soljson.Runtime.addFunction(wrapCallback(readCallback));
37+
38+
// This is to support multiple versions of Emscripten.
39+
var addFunction = soljson.addFunction || soljson.Runtime.addFunction;
40+
var removeFunction = soljson.removeFunction || soljson.Runtime.removeFunction;
41+
42+
var cb = addFunction(wrapCallback(readCallback));
3843
var output;
3944
try {
4045
args.push(cb);
4146
output = compile.apply(undefined, args);
4247
} catch (e) {
43-
soljson.Runtime.removeFunction(cb);
48+
removeFunction(cb);
4449
throw e;
4550
}
46-
soljson.Runtime.removeFunction(cb);
51+
removeFunction(cb);
4752
return output;
4853
};
4954

0 commit comments

Comments
 (0)