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

Function invokeCallBack

src/PyListProxyHandler.cc:1636–1653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1634}
1635
1636static int invokeCallBack(PyObject *list, int index, JS::HandleValue leftValue, JSContext *cx, JS::HandleFunction callBack) {
1637 JS::Rooted<JS::ValueArray<2>> jArgs(cx);
1638
1639 jArgs[0].set(jsTypeFactory(cx, PyList_GetItem(list, index)));
1640 jArgs[1].set(leftValue);
1641
1642 JS::RootedValue retVal(cx);
1643 if (!JS_CallFunction(cx, nullptr, callBack, jArgs, &retVal)) {
1644 throw "JS_CallFunction failed";
1645 }
1646
1647 if (!retVal.isNumber()) {
1648 PyErr_Format(PyExc_TypeError, "incorrect compare function return type");
1649 return 0;
1650 }
1651
1652 return retVal.toInt32();
1653}
1654
1655// Adapted from Kernigan&Ritchie's C book
1656static void quickSort(PyObject *list, int left, int right, JSContext *cx, JS::HandleFunction callBack) {

Callers 1

quickSortFunction · 0.85

Calls 2

jsTypeFactoryFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected