| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7b269d6 commit bd7b311
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -166,8 +166,11 @@ | |||
| 166 | 166 | if (!ready) { Module.print('Python is loading, please wait...'); return; } | |
| 167 | 167 | Module.print('>>> <textarea>'); | |
| 168 | 168 | source_code = document.getElementById('file').value; | |
| 169 | - Module.cwrap('PyRun_SimpleString', 'number', ['string'])(source_code); | ||
| 170 | - // or: Module.ccall('PyRun_SimpleString', 'number', ['string'], [source_code]); | ||
| 169 | + var opts = {} | ||
| 170 | + if (typeof Asyncify === 'object') | ||
| 171 | + opts = { async: true }; | ||
| 172 | + Module.cwrap('PyRun_SimpleString', 'number', ['string'], opts)(source_code); | ||
| 173 | + // or: Module.ccall('PyRun_SimpleString', 'number', ['string'], [source_code], opts); | ||
| 171 | 174 | } | |
| 172 | 175 | ||
| 173 | 176 | var hist = ['']; | |
@@ -179,8 +182,11 @@ | |||
| 179 | 182 | Module.print('>>> ' + input.value); | |
| 180 | 183 | ||
| 181 | 184 | // Execute Python code with emulated stdin | |
| 182 | - FS.writeFile('/tmp/input.py', input.value + '\n') | ||
| 183 | - Module.ccall('pyruni'); | ||
| 185 | + FS.writeFile('/tmp/input.py', input.value + '\n'); | ||
| 186 | + var opts = {} | ||
| 187 | + if (typeof Asyncify === 'object') | ||
| 188 | + opts = { async: true }; | ||
| 189 | + Module.ccall('pyruni', 'undefined', [], [], opts); | ||
| 184 | 190 | ||
| 185 | 191 | hist[hist.length-1] = input.value; | |
| 186 | 192 | hist.push(''); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,9 +23,13 @@ PREFIX=$INSTALLDIR OUTDIR=$BUILD ./package-pythonhome.sh \ | |||
| 23 | 23 | encodings/utf_32_be.py | |
| 24 | 24 | ||
| 25 | 25 | FLAGS='-O3' | |
| 26 | - if [ "$1" == "debug" ]; then | ||
| 27 | - FLAGS='-s ASSERTIONS=1 -g -s FETCH_DEBUG=1' | ||
| 28 | - fi | ||
| 26 | + while (( $# )); do | ||
| 27 | + case "$1" in | ||
| 28 | + debug) FLAGS='-s ASSERTIONS=1 -g -s FETCH_DEBUG=1';; | ||
| 29 | + async) ASYNC='-s ASYNCIFY=1 -O3';; | ||
| 30 | + esac | ||
| 31 | + shift | ||
| 32 | + done | ||
| 29 | 33 | emcc -o $BUILD/index.html \ | |
| 30 | 34 | webprompt-main.c $BUILD/emscripten.c \ | |
| 31 | 35 | $FLAGS \ | |
@@ -35,10 +39,10 @@ emcc -o $BUILD/index.html \ | |||
| 35 | 39 | -s FETCH=1 \ | |
| 36 | 40 | -s ALLOW_MEMORY_GROWTH=1 \ | |
| 37 | 41 | -s FORCE_FILESYSTEM=1 -s RETAIN_COMPILER_SETTINGS=1 \ | |
| 42 | + $ASYNC \ | ||
| 38 | 43 | --shell-file webprompt-shell.html -s MINIFY_HTML=0 \ | |
| 39 | - -s EXPORTED_FUNCTIONS="['_main', '_Py_Initialize', '_PyRun_SimpleString', '_pyruni']" \ | ||
| 40 | - -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' | ||
| 41 | - # -s ASYNCIFY=1 | ||
| 44 | + -s EXPORTED_FUNCTIONS='[_main, _Py_Initialize, _PyRun_SimpleString, _pyruni, _emscripten_debugger]' \ | ||
| 45 | + -s EXTRA_EXPORTED_RUNTIME_METHODS='[ccall, cwrap]' | ||
| 42 | 46 | ||
| 43 | 47 | # cython ../mock/emscripten.pyx -o t/mock.c | |
| 44 | 48 | # gcc -g -I build/hostpython/include/python2.7 -L build/hostpython/lib/ t/mock.c webprompt-main.c -lpython2.7 -ldl -lm -lutil -lz | |
| Back | FazBrowse Home | New Git URL |
0 commit comments