| 153 | } |
| 154 | |
| 155 | static bool array_unshift(JSContext *cx, unsigned argc, JS::Value *vp) { // surely the function name is in there...review JSAPI examples |
| 156 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
| 157 | |
| 158 | JS::RootedObject proxy(cx, JS::ToObject(cx, args.thisv())); |
| 159 | if (!proxy) { |
| 160 | return false; |
| 161 | } |
| 162 | PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot); |
| 163 | |
| 164 | JS::RootedValue elementVal(cx); |
| 165 | for (int index = args.length() - 1; index >= 0; index--) { |
| 166 | elementVal.set(args[index].get()); |
| 167 | PyObject *value = pyTypeFactory(cx, elementVal); |
| 168 | if (PyList_Insert(self, 0, value) < 0) { |
| 169 | Py_DECREF(value); |
| 170 | return false; |
| 171 | } |
| 172 | Py_DECREF(value); |
| 173 | } |
| 174 | |
| 175 | args.rval().setInt32(PyList_GET_SIZE(self)); |
| 176 | return true; |
| 177 | } |
| 178 | |
| 179 | // private util |
| 180 | static inline uint64_t normalizeSliceTerm(int64_t value, uint64_t length) { |
nothing calls this directly
no test coverage detected