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

Function array_reverse

src/PyListProxyHandler.cc:55–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55static bool array_reverse(JSContext *cx, unsigned argc, JS::Value *vp) {
56 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
57
58 JS::RootedObject proxy(cx, JS::ToObject(cx, args.thisv()));
59 if (!proxy) {
60 return false;
61 }
62 PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
63
64 if (PyList_GET_SIZE(self) > 1) {
65 if (PyList_Reverse(self) < 0) {
66 return false;
67 }
68 }
69
70 // return ref to self
71 args.rval().set(jsTypeFactory(cx, self));
72 return true;
73}
74
75static bool array_pop(JSContext *cx, unsigned argc, JS::Value *vp) {
76 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