| 44 | } |
| 45 | |
| 46 | PyObject *JSMethodProxyMethodDefinitions::JSMethodProxy_call(PyObject *self, PyObject *args, PyObject *kwargs) { |
| 47 | JSContext *cx = GLOBAL_CX; |
| 48 | JS::RootedValue jsFunc(GLOBAL_CX, JS::ObjectValue(**((JSMethodProxy *)self)->jsFunc)); |
| 49 | JS::RootedValue selfValue(cx, jsTypeFactory(cx, ((JSMethodProxy *)self)->self)); |
| 50 | JS::RootedObject selfObject(cx); |
| 51 | JS_ValueToObject(cx, selfValue, &selfObject); |
| 52 | |
| 53 | JS::RootedVector<JS::Value> jsArgsVector(cx); |
| 54 | for (size_t i = 0; i < PyTuple_Size(args); i++) { |
| 55 | JS::Value jsValue = jsTypeFactory(cx, PyTuple_GetItem(args, i)); |
| 56 | if (PyErr_Occurred()) { // Check if an exception has already been set in the flow of control |
| 57 | return NULL; // Fail-fast |
| 58 | } |
| 59 | if (!jsArgsVector.append(jsValue)) { |
| 60 | // out of memory |
| 61 | setSpiderMonkeyException(cx); |
| 62 | return NULL; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | JS::HandleValueArray jsArgs(jsArgsVector); |
| 67 | JS::RootedValue jsReturnVal(cx); |
| 68 | if (!JS_CallFunctionValue(cx, selfObject, jsFunc, jsArgs, &jsReturnVal)) { |
| 69 | setSpiderMonkeyException(cx); |
| 70 | return NULL; |
| 71 | } |
| 72 | |
| 73 | if (PyErr_Occurred()) { |
| 74 | return NULL; |
| 75 | } |
| 76 | |
| 77 | return pyTypeFactory(cx, jsReturnVal); |
| 78 | } |
nothing calls this directly
no test coverage detected