371
|
1 |
# the platform name (PyV8, smjs, Mozilla, IE6, Opera, Safari etc.)
|
|
2 |
platform = '' # to be updated by app, on compile
|
|
3 |
|
|
4 |
# a dictionary of module override names (platform-specific)
|
|
5 |
overrides = None # to be updated by app, on compile
|
|
6 |
|
|
7 |
# the remote path for loading modules
|
|
8 |
loadpath = None
|
|
9 |
|
|
10 |
stacktrace = None
|
|
11 |
|
|
12 |
appname = None
|
|
13 |
|
|
14 |
def setloadpath(lp):
|
|
15 |
global loadpath
|
|
16 |
loadpath = lp
|
|
17 |
|
|
18 |
def setappname(an):
|
|
19 |
global appname
|
|
20 |
appname = an
|
|
21 |
|
|
22 |
def getloadpath():
|
|
23 |
global loadpath
|
|
24 |
return loadpath
|
|
25 |
|
|
26 |
def addoverride(module_name, path):
|
|
27 |
global overrides
|
|
28 |
overrides[module_name] = path
|
|
29 |
|
|
30 |
def addstack(linedebug):
|
|
31 |
JS("""
|
|
32 |
if (pyjslib.bool((sys.stacktrace === null))) {
|
|
33 |
sys.stacktrace = new pyjslib.List([]);
|
|
34 |
}
|
|
35 |
sys.stacktrace.append(linedebug);
|
|
36 |
""")
|
|
37 |
def popstack():
|
|
38 |
JS("""
|
|
39 |
sys.stacktrace.pop()
|
|
40 |
""")
|
|
41 |
|
|
42 |
def printstack():
|
|
43 |
JS("""
|
|
44 |
var res = '';
|
|
45 |
|
|
46 |
var __l = sys.stacktrace.__iter__();
|
|
47 |
try {
|
|
48 |
while (true) {
|
|
49 |
var l = __l.next();
|
|
50 |
res += ( l + '\\n' ) ;
|
|
51 |
}
|
|
52 |
} catch (e) {
|
|
53 |
if (e != pyjslib.StopIteration) {
|
|
54 |
throw e;
|
|
55 |
}
|
|
56 |
}
|
|
57 |
|
|
58 |
return res;
|
|
59 |
""")
|