Commit 544ed5a6 authored by Michael Droettboom's avatar Michael Droettboom

Don't use cwrap

We only have two entry points, so it's easy to hardcode.
parent 6cbac839
......@@ -25,8 +25,7 @@ LDFLAGS=\
-s MAIN_MODULE=1 \
-s EMULATED_FUNCTION_POINTERS=1 \
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
-s EXPORTED_FUNCTIONS='["_main", "_runPython", "__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv"]' \
-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \
-s EXPORTED_FUNCTIONS='["_main", "__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv"]' \
-s WASM=1 \
-s SWAPPABLE_ASM_MODULE=1 \
-s USE_FREETYPE=1 \
......
......@@ -22,13 +22,13 @@ int pyimport(char *name) {
}
EM_JS(int, pyimport_Ready, (), {
Module.__pyimport = Module.cwrap('pyimport', 'number', ['string']);
Module.pyimport = function(name) {
var id = Module.__pyimport(name);
result = Module.hiwire_get_value(id);
Module.hiwire_decref(id);
return result;
var pyname = allocate(intArrayFromString(name), 'i8', ALLOC_NORMAL);
var idresult = Module._pyimport(pyname);
jsresult = Module.hiwire_get_value(idresult);
Module.hiwire_decref(idresult);
_free(pyname);
return jsresult;
};
return 0;
......
......@@ -87,15 +87,13 @@ int runPython(char *code) {
}
EM_JS(int, runPython_Ready, (), {
// TODO: Remove uses of cwrap
Module.__runPython = Module.cwrap('runPython', 'number', ['string']);
Module.runPython = function (code) {
var jsid = Module.__runPython(code);
result = Module.hiwire_get_value(jsid);
Module.hiwire_decref(jsid);
return result;
var pycode = allocate(intArrayFromString(code), 'i8', ALLOC_NORMAL);
var idresult = Module._runPython(pycode);
jsresult = Module.hiwire_get_value(idresult);
Module.hiwire_decref(idresult);
_free(pycode);
return jsresult;
};
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment