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
528c0f29
Commit
528c0f29
authored
Nov 28, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #261: Support named arguments when calling a JS function
parent
de7dd4be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
src/jsproxy.c
src/jsproxy.c
+6
-0
test/test_python.py
test/test_python.py
+16
-0
No files found.
src/jsproxy.c
View file @
528c0f29
...
@@ -110,6 +110,12 @@ JsProxy_Call(PyObject* o, PyObject* args, PyObject* kwargs)
...
@@ -110,6 +110,12 @@ JsProxy_Call(PyObject* o, PyObject* args, PyObject* kwargs)
hiwire_decref
(
idarg
);
hiwire_decref
(
idarg
);
}
}
if
(
PyDict_Size
(
kwargs
))
{
int
idkwargs
=
python2js
(
kwargs
);
hiwire_push_array
(
idargs
,
idkwargs
);
hiwire_decref
(
idkwargs
);
}
int
idresult
=
hiwire_call
(
self
->
js
,
idargs
);
int
idresult
=
hiwire_call
(
self
->
js
,
idargs
);
hiwire_decref
(
idargs
);
hiwire_decref
(
idargs
);
PyObject
*
pyresult
=
js2python
(
idresult
);
PyObject
*
pyresult
=
js2python
(
idresult
);
...
...
test/test_python.py
View file @
528c0f29
...
@@ -342,6 +342,22 @@ def test_jsproxy_implicit_iter(selenium):
...
@@ -342,6 +342,22 @@ def test_jsproxy_implicit_iter(selenium):
"list(Object.values(ITER))"
)
==
[
1
,
2
,
3
]
"list(Object.values(ITER))"
)
==
[
1
,
2
,
3
]
def
test_jsproxy_kwargs
(
selenium
):
selenium
.
run_js
(
"""
window.kwarg_function = ({ a = 1, b = 1 }) => {
return a / b;
};
"""
)
assert
selenium
.
run
(
"""
from js import kwarg_function
kwarg_function(b = 2, a = 10)
"""
)
==
5
def
test_open_url
(
selenium
):
def
test_open_url
(
selenium
):
assert
selenium
.
run
(
assert
selenium
.
run
(
"""
"""
...
...
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