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

Method set

src/PyObjectProxyHandler.cc:153–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153bool PyObjectProxyHandler::set(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
154 JS::HandleValue v, JS::HandleValue receiver,
155 JS::ObjectOpResult &result) const {
156 JS::RootedValue rootedV(cx, v);
157 PyObject *attrName = idToKey(cx, id);
158
159 PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
160 PyObject *value = pyTypeFactory(cx, rootedV);
161 if (PyObject_SetAttr(self, attrName, value)) {
162 Py_DECREF(value);
163 return result.failCantSetInterposed(); // raises JS exception
164 }
165 Py_DECREF(value);
166 return result.succeed();
167}
168
169bool PyObjectProxyHandler::enumerate(JSContext *cx, JS::HandleObject proxy,
170 JS::MutableHandleIdVector props) const {

Callers

nothing calls this directly

Calls 2

idToKeyFunction · 0.85
pyTypeFactoryFunction · 0.85

Tested by

no test coverage detected