Fix Js to Python type coercion

This commit is contained in:
Michael Droettboom 2018-03-07 11:37:06 -05:00
parent 5bfe045262
commit c06cda30b9
1 changed files with 14 additions and 9 deletions

View File

@ -17,20 +17,25 @@ PyObject *jsToPython(val x) {
} else if (xType.equals(val("number"))) {
double x_double = x.as<double>();
return PyFloat_FromDouble(x_double);
} else if (xType.equals(val("undefined"))) {
} else if (x.isUndefined()) {
Py_INCREF(Py_None);
return Py_None;
} else {
try {
} else if (x.isTrue()) {
Py_INCREF(Py_True);
return Py_True;
} else if (x.isFalse()) {
Py_INCREF(Py_False);
return Py_False;
} else if (!x["$$"].isUndefined() &&
x["$$"]["ptrType"]["name"].equals(val("Py*"))) {
Py py_x = x.as<Py>();
PyObject *pypy_x = py_x.x;
Py_INCREF(pypy_x);
return pypy_x;
} catch (...) {
} else {
return JsProxy_cnew(x);
}
}
}
PyObject *jsToPythonArgs(val args) {
if (!Array->call<bool>("isArray", args)) {