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

Function array_push

src/PyListProxyHandler.cc:102–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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);
104
105 JS::RootedObject proxy(cx, JS::ToObject(cx, args.thisv()));
106 if (!proxy) {
107 return false;
108 }
109 PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
110
111 unsigned numArgs = args.length();
112 JS::RootedValue elementVal(cx);
113 for (unsigned index = 0; index < numArgs; index++) {
114 elementVal.set(args[index].get());
115 PyObject *value = pyTypeFactory(cx, elementVal);
116 if (PyList_Append(self, value) < 0) {
117 Py_DECREF(value);
118 return false;
119 }
120 Py_DECREF(value);
121 }
122
123 args.rval().setInt32(PyList_GET_SIZE(self));
124 return true;
125}
126
127static bool array_shift(JSContext *cx, unsigned argc, JS::Value *vp) {
128 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);

Callers

nothing calls this directly

Calls 3

pyTypeFactoryFunction · 0.85
getMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected