| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,7 @@ cdef void callpyfunc_arg(void* p): | |||
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | 50 | def set_main_loop(py_function, fps, simulate_infinite_loop): | |
| 51 | - #print "def: set_main_loop", func, fps, simulate_infinite_loop | ||
| 51 | + #print "def: set_main_loop", py_function, fps, simulate_infinite_loop | ||
| 52 | 52 | emscripten_set_main_loop_arg(callpyfunc, <PyObject*>py_function, fps, simulate_infinite_loop) | |
| 53 | 53 | ||
| 54 | 54 | def async_call(func, arg, millis): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,46 @@ | |||
| 1 | + # Fake python wrapper for emscripten_* C functions for native testing | ||
| 2 | + | ||
| 3 | + # Copyright (C) 2018 Sylvain Beucler | ||
| 4 | + | ||
| 5 | + # Copying and distribution of this file, with or without modification, | ||
| 6 | + # are permitted in any medium without royalty provided the copyright | ||
| 7 | + # notice and this notice are preserved. This file is offered as-is, | ||
| 8 | + # without any warranty. | ||
| 9 | + | ||
| 10 | + import time | ||
| 11 | + import sys | ||
| 12 | + | ||
| 13 | + sys.platform = 'emscripten' | ||
| 14 | + | ||
| 15 | + def set_main_loop(py_function, fps, simulate_infinite_loop): | ||
| 16 | + print "def: set_main_loop", py_function, fps, simulate_infinite_loop | ||
| 17 | + if not simulate_infinite_loop: | ||
| 18 | + # TODO: simulate browser loop in another Python script? | ||
| 19 | + pass | ||
| 20 | + py_function = <object>(py_function) | ||
| 21 | + if fps <= 0: | ||
| 22 | + fps = 60 # common screen refresh rate | ||
| 23 | + while True: | ||
| 24 | + time.sleep(1.0/fps) | ||
| 25 | + py_function() | ||
| 26 | + | ||
| 27 | + def async_call(func, arg, millis): | ||
| 28 | + py_function = <object>(func) | ||
| 29 | + py_arg = <object>(arg) | ||
| 30 | + py_function(py_arg) | ||
| 31 | + | ||
| 32 | + def exit_with_live_runtime(): | ||
| 33 | + print "exit_with_live_runtime" | ||
| 34 | + | ||
| 35 | + def sleep(ms): | ||
| 36 | + time.sleep(ms/1000.0) | ||
| 37 | + | ||
| 38 | + def sleep_with_yield(ms): | ||
| 39 | + sleep(ms) | ||
| 40 | + | ||
| 41 | + def run_script(script): | ||
| 42 | + print "run_script" | ||
| 43 | + print '\n'.join([" "+l for l in script.splitlines()]) | ||
| 44 | + | ||
| 45 | + def syncfs(): | ||
| 46 | + print "syncfs" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments