FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

mock emscripten native module · python-emscripten/python@946fd86 · GitHub

Repository navigation

Commit 946fd86

Browse files
committed
mock emscripten native module
1 parent 997cd7f commit 946fd86

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

‎emscripten.pyx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cdef void callpyfunc_arg(void* p):
4848

4949

5050
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
5252
emscripten_set_main_loop_arg(callpyfunc, <PyObject*>py_function, fps, simulate_infinite_loop)
5353

5454
def async_call(func, arg, millis):

‎mock/emscripten.pyx‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff 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"

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL