MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / JSMethodProxy_call

Method JSMethodProxy_call

src/JSMethodProxy.cc:46–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46PyObject *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}

Callers

nothing calls this directly

Calls 4

jsTypeFactoryFunction · 0.85
setSpiderMonkeyExceptionFunction · 0.85
pyTypeFactoryFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected