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

Method set

src/PyDictProxyHandler.cc:64–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64bool PyDictProxyHandler::set(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
65 JS::HandleValue v, JS::HandleValue receiver,
66 JS::ObjectOpResult &result) const {
67 JS::RootedValue rootedV(cx, v);
68 PyObject *attrName = idToKey(cx, id);
69
70 PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
71 PyObject *value = pyTypeFactory(cx, rootedV);
72 if (PyDict_SetItem(self, attrName, value)) {
73 Py_DECREF(value);
74 return result.failCantSetInterposed(); // raises JS exception
75 }
76 Py_DECREF(value);
77 return result.succeed();
78}
79
80bool PyDictProxyHandler::enumerate(JSContext *cx, JS::HandleObject proxy,
81 JS::MutableHandleIdVector props) const {

Callers

nothing calls this directly

Calls 2

idToKeyFunction · 0.85
pyTypeFactoryFunction · 0.85

Tested by

no test coverage detected