| 125 | } |
| 126 | |
| 127 | static bool array_shift(JSContext *cx, unsigned argc, JS::Value *vp) { |
| 128 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
| 129 | |
| 130 | JS::RootedObject proxy(cx, JS::ToObject(cx, args.thisv())); |
| 131 | if (!proxy) { |
| 132 | return false; |
| 133 | } |
| 134 | PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot); |
| 135 | |
| 136 | Py_ssize_t selfSize = PyList_GET_SIZE(self); |
| 137 | |
| 138 | if (selfSize == 0) { |
| 139 | args.rval().setUndefined(); |
| 140 | return true; |
| 141 | } |
| 142 | |
| 143 | PyObject *result = PyList_GetItem(self, 0); |
| 144 | if (!result) { |
| 145 | return false; |
| 146 | } |
| 147 | if (PySequence_DelItem(self, 0) < 0) { |
| 148 | return false; |
| 149 | } |
| 150 | |
| 151 | args.rval().set(jsTypeFactory(cx, result)); |
| 152 | return true; |
| 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); |
nothing calls this directly
no test coverage detected