Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/jsTypeFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ bool callPyFunc(JSContext *cx, unsigned int argc, JS::Value *vp) {
JS::Value pyFuncVal = js::GetFunctionNativeReserved(&(callargs.callee()), 0);
PyObject *pyFunc = (PyObject *)(pyFuncVal.toPrivate());

JS::RootedObject thisv(cx);
JS_ValueToObject(cx, callargs.thisv(), &thisv);
JS::RootedObject *thisv = new JS::RootedObject(cx);
JS_ValueToObject(cx, callargs.thisv(), thisv);

if (!callargs.length()) {
PyObject *pyRval = PyObject_CallNoArgs(pyFunc);
Expand All @@ -171,8 +171,8 @@ bool callPyFunc(JSContext *cx, unsigned int argc, JS::Value *vp) {
// populate python args tuple
PyObject *pyArgs = PyTuple_New(callargs.length());
for (size_t i = 0; i < callargs.length(); i++) {
JS::RootedValue jsArg = JS::RootedValue(cx, callargs[i]);
PyType *pyArg = (pyTypeFactory(cx, &thisv, &jsArg));
JS::RootedValue *jsArg = new JS::RootedValue(cx, callargs[i]);
PyType *pyArg = pyTypeFactory(cx, thisv, jsArg);
PyTuple_SetItem(pyArgs, i, pyArg->getPyObject());
}

Expand Down
8 changes: 8 additions & 0 deletions tests/python/test_pythonmonkey_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,14 @@ def test_eval_functions_ucs4_string_args():

assert pm.asUCS4(concatenate(string1, string2)) == (string1 + string2)

def test_eval_functions_roundtrip():
# BF-60 https://github.com/Distributive-Network/PythonMonkey/pull/18
def ident(x):
return x
js_fn_back = pm.eval("(py_fn) => py_fn(()=>{ return 'YYZ' })")(ident)
# pm.collect() # TODO: to be fixed in BF-59
assert "YYZ" == js_fn_back()

def test_eval_functions_pyfunctions_ints():
caller = pm.eval("(func, param1, param2) => { return func(param1, param2) }")
def add(a, b):
Expand Down