Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
9a926ce8
Commit
9a926ce8
authored
Oct 09, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LINT
parent
d70f4833
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
src/pyodide.js
src/pyodide.js
+2
-1
src/runpython.c
src/runpython.c
+8
-11
No files found.
src/pyodide.js
View file @
9a926ce8
...
...
@@ -188,7 +188,8 @@ var languagePluginLoader = new Promise((resolve, reject) => {
let
loadPackage
=
(
names
,
messageCallback
)
=>
{
/* We want to make sure that only one loadPackage invocation runs at any
* given time, so this creates a "chain" of promises. */
loadPackagePromise
=
loadPackagePromise
.
then
(()
=>
_loadPackage
(
names
,
messageCallback
));
loadPackagePromise
=
loadPackagePromise
.
then
(()
=>
_loadPackage
(
names
,
messageCallback
));
return
loadPackagePromise
;
};
...
...
src/runpython.c
View file @
9a926ce8
...
...
@@ -34,7 +34,7 @@ _runPython(char* code)
}
int
_findImports
(
char
*
code
)
_findImports
(
char
*
code
)
{
PyObject
*
py_code
;
py_code
=
PyUnicode_FromString
(
code
);
...
...
@@ -42,8 +42,7 @@ _findImports(char *code)
return
pythonexc2js
();
}
PyObject
*
ret
=
PyObject_CallFunctionObjArgs
(
find_imports
,
py_code
,
NULL
);
PyObject
*
ret
=
PyObject_CallFunctionObjArgs
(
find_imports
,
py_code
,
NULL
);
if
(
ret
==
NULL
)
{
return
pythonexc2js
();
...
...
@@ -55,7 +54,8 @@ _findImports(char *code)
}
EM_JS
(
int
,
runpython_init_js
,
(),
{
Module
.
_runPythonInternal
=
function
(
pycode
)
{
Module
.
_runPythonInternal
=
function
(
pycode
)
{
var
idresult
=
Module
.
__runPython
(
pycode
);
var
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
Module
.
hiwire_decref
(
idresult
);
...
...
@@ -77,21 +77,18 @@ EM_JS(int, runpython_init_js, (), {
var
jsimports
=
Module
.
hiwire_get_value
(
idimports
);
Module
.
hiwire_decref
(
idimports
);
var
internal
=
function
()
{
return
Module
.
_runPythonInternal
(
pycode
);
};
var
internal
=
function
()
{
return
Module
.
_runPythonInternal
(
pycode
);
};
if
(
jsimports
.
length
)
{
var
packages
=
window
.
pyodide
.
_module
.
packages
.
dependencies
;
var
packageFilter
=
function
(
name
)
{
var
packageFilter
=
function
(
name
)
{
return
Object
.
prototype
.
hasOwnProperty
(
packages
,
name
);
};
jsimports
=
jsimports
.
filter
(
packageFilter
);
return
Module
.
loadPackage
(
jsimports
,
messageCallback
).
then
(
internal
);
}
else
{
var
resolve
=
function
(
resolve
)
{
return
resolve
();
};
var
resolve
=
function
(
resolve
)
{
return
resolve
();
};
return
new
Promise
(
resolve
).
then
(
internal
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment