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

Function array_pop

src/PyListProxyHandler.cc:75–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75static bool array_pop(JSContext *cx, unsigned argc, JS::Value *vp) {
76 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
77
78 JS::RootedObject proxy(cx, JS::ToObject(cx, args.thisv()));
79 if (!proxy) {
80 return false;
81 }
82 PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
83
84 if (PyList_GET_SIZE(self) == 0) {
85 args.rval().setUndefined();
86 return true;
87 }
88
89 PyObject *result = PyObject_CallMethod(self, "pop", NULL);
90
91 if (!result) {
92 PyErr_Clear();
93 args.rval().setUndefined();
94 return true;
95 }
96
97 args.rval().set(jsTypeFactory(cx, result));
98 Py_DECREF(result);
99 return true;
100}
101
102static bool array_push(JSContext *cx, unsigned argc, JS::Value *vp) { // surely the function name is in there...review JSAPI examples
103 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);

Callers

nothing calls this directly

Calls 2

jsTypeFactoryFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected