python-emscripten  Check-in [16267ba494]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:webprompt: fix native test
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:16267ba494cf1bde9dc4749f6db500c6eb412fa84c6ccd463d4e9a2eb9aff71b
User & Date: Beuc 2020-05-08 16:26:09
Context
2020-05-08
16:26
Simplify Python compilation a bit check-in: 6319bb7bc7 user: Beuc tags: trunk
16:26
webprompt: fix native test check-in: 16267ba494 user: Beuc tags: trunk
16:25
webprompt: fix native test check-in: f221e978c5 user: Beuc tags: trunk
Changes

Changes to mock/emscripten.pyx.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Fake python wrapper for emscripten_* C functions for native testing

# Copyright (C) 2018  Sylvain Beucler

# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.

import time
import sys

sys.platform = 'emscripten'

def set_main_loop(py_function, fps, simulate_infinite_loop):
    print "def: set_main_loop", py_function, fps, simulate_infinite_loop
    if not simulate_infinite_loop:
        # TODO: simulate browser loop in another Python script?
        pass
    py_function = <object>(py_function)
    if fps <= 0:
        fps = 60  # common screen refresh rate
    while True:
................................................................................

def async_call(func, arg, millis):
    py_function = <object>(func)
    py_arg = <object>(arg)
    py_function(py_arg)

def exit_with_live_runtime():
    print "exit_with_live_runtime"

def sleep(ms):
    time.sleep(ms/1000.0)

def sleep_with_yield(ms):
    sleep(ms)

def run_script(script):
    print "run_script"
    print '\n'.join(["  "+l for l in script.splitlines()])

def syncfs():
    print "syncfs"


|












|







 







|








|
|


|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Fake python wrapper for emscripten_* C functions for native testing

# Copyright (C) 2018, 2020  Sylvain Beucler

# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.

import time
import sys

sys.platform = 'emscripten'

def set_main_loop(py_function, fps, simulate_infinite_loop):
    print("def: set_main_loop", py_function, fps, simulate_infinite_loop)
    if not simulate_infinite_loop:
        # TODO: simulate browser loop in another Python script?
        pass
    py_function = <object>(py_function)
    if fps <= 0:
        fps = 60  # common screen refresh rate
    while True:
................................................................................

def async_call(func, arg, millis):
    py_function = <object>(func)
    py_arg = <object>(arg)
    py_function(py_arg)

def exit_with_live_runtime():
    print("exit_with_live_runtime")

def sleep(ms):
    time.sleep(ms/1000.0)

def sleep_with_yield(ms):
    sleep(ms)

def run_script(script):
    print("run_script")
    print('\n'.join(["  "+l for l in script.splitlines()]))

def syncfs():
    print("syncfs")

Added mock/emscripten_fetch.pyx.



















>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
# Fake python wrapper for emscripten_fetch* C functions for native testing

# Copyright (C) 2020  Sylvain Beucler

# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.