| 73 | } |
| 74 | |
| 75 | static 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 | |
| 102 | static 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); |
nothing calls this directly
no test coverage detected