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

Function iterable_values

src/PyIterableProxyHandler.cc:174–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174static bool iterable_values(JSContext *cx, unsigned argc, JS::Value *vp) {
175 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
176
177 JS::RootedObject proxy(cx, JS::ToObject(cx, args.thisv()));
178 if (!proxy) {
179 return false;
180 }
181
182 PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
183
184 JS::RootedObject global(cx, JS::GetNonCCWObjectGlobal(proxy));
185
186 JS::RootedValue constructor_val(cx);
187 if (!JS_GetProperty(cx, global, "IterableIterator", &constructor_val)) return false;
188 if (!constructor_val.isObject()) {
189 if (!DefineIterableIterator(cx, global)) {
190 return false;
191 }
192
193 if (!JS_GetProperty(cx, global, "IterableIterator", &constructor_val)) return false;
194 if (!constructor_val.isObject()) {
195 JS_ReportErrorASCII(cx, "IterableIterator is not a constructor");
196 return false;
197 }
198 }
199 JS::RootedObject constructor(cx, &constructor_val.toObject());
200
201 JS::RootedObject obj(cx);
202 if (!JS::Construct(cx, constructor_val, JS::HandleValueArray::empty(), &obj)) return false;
203 if (!obj) return false;
204
205 JS::SetReservedSlot(obj, IterableIteratorSlotIterableObject, JS::PrivateValue((void *)self));
206
207 args.rval().setObject(*obj);
208 return true;
209}
210
211bool PyIterableProxyHandler::getOwnPropertyDescriptor(
212 JSContext *cx, JS::HandleObject proxy, JS::HandleId id,

Callers

nothing calls this directly

Calls 1

DefineIterableIteratorFunction · 0.85

Tested by

no test coverage detected