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
544ed5a6
Commit
544ed5a6
authored
May 30, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use cwrap
We only have two entry points, so it's easy to hardcode.
parent
6cbac839
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
16 deletions
+13
-16
Makefile
Makefile
+1
-2
src/pyimport.c
src/pyimport.c
+6
-6
src/runpython.c
src/runpython.c
+6
-8
No files found.
Makefile
View file @
544ed5a6
...
@@ -25,8 +25,7 @@ LDFLAGS=\
...
@@ -25,8 +25,7 @@ LDFLAGS=\
-s
MAIN_MODULE
=
1
\
-s
MAIN_MODULE
=
1
\
-s
EMULATED_FUNCTION_POINTERS
=
1
\
-s
EMULATED_FUNCTION_POINTERS
=
1
\
-s
EMULATE_FUNCTION_POINTER_CASTS
=
1
\
-s
EMULATE_FUNCTION_POINTER_CASTS
=
1
\
-s
EXPORTED_FUNCTIONS
=
'["_main", "_runPython", "__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv"]'
\
-s
EXPORTED_FUNCTIONS
=
'["_main", "__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv"]'
\
-s
EXTRA_EXPORTED_RUNTIME_METHODS
=
'["ccall", "cwrap"]'
\
-s
WASM
=
1
\
-s
WASM
=
1
\
-s
SWAPPABLE_ASM_MODULE
=
1
\
-s
SWAPPABLE_ASM_MODULE
=
1
\
-s
USE_FREETYPE
=
1
\
-s
USE_FREETYPE
=
1
\
...
...
src/pyimport.c
View file @
544ed5a6
...
@@ -22,13 +22,13 @@ int pyimport(char *name) {
...
@@ -22,13 +22,13 @@ int pyimport(char *name) {
}
}
EM_JS
(
int
,
pyimport_Ready
,
(),
{
EM_JS
(
int
,
pyimport_Ready
,
(),
{
Module
.
__pyimport
=
Module
.
cwrap
(
'
pyimport
'
,
'
number
'
,
[
'
string
'
]);
Module
.
pyimport
=
function
(
name
)
{
Module
.
pyimport
=
function
(
name
)
{
var
id
=
Module
.
__pyimport
(
name
);
var
pyname
=
allocate
(
intArrayFromString
(
name
),
'
i8
'
,
ALLOC_NORMAL
);
result
=
Module
.
hiwire_get_value
(
id
);
var
idresult
=
Module
.
_pyimport
(
pyname
);
Module
.
hiwire_decref
(
id
);
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
return
result
;
Module
.
hiwire_decref
(
idresult
);
_free
(
pyname
);
return
jsresult
;
};
};
return
0
;
return
0
;
...
...
src/runpython.c
View file @
544ed5a6
...
@@ -87,15 +87,13 @@ int runPython(char *code) {
...
@@ -87,15 +87,13 @@ int runPython(char *code) {
}
}
EM_JS
(
int
,
runPython_Ready
,
(),
{
EM_JS
(
int
,
runPython_Ready
,
(),
{
// TODO: Remove uses of cwrap
Module
.
__runPython
=
Module
.
cwrap
(
'
runPython
'
,
'
number
'
,
[
'
string
'
]);
Module
.
runPython
=
function
(
code
)
{
Module
.
runPython
=
function
(
code
)
{
var
jsid
=
Module
.
__runPython
(
code
);
var
pycode
=
allocate
(
intArrayFromString
(
code
),
'
i8
'
,
ALLOC_NORMAL
);
result
=
Module
.
hiwire_get_value
(
jsid
);
var
idresult
=
Module
.
_runPython
(
pycode
);
Module
.
hiwire_decref
(
jsid
);
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
return
result
;
Module
.
hiwire_decref
(
idresult
);
_free
(
pycode
);
return
jsresult
;
};
};
return
0
;
return
0
;
...
...
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