| 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); |
| 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 | |
| 127 | static bool array_shift(JSContext *cx, unsigned argc, JS::Value *vp) { |
| 128 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
nothing calls this directly
no test coverage detected