| 96 | } |
| 97 | |
| 98 | bool PyObjectProxyHandler::ownPropertyKeys(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const { |
| 99 | PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot); |
| 100 | PyObject *keys = PyObject_Dir(self); |
| 101 | |
| 102 | if (keys != nullptr) { |
| 103 | size_t keysLength = PyList_Size(keys); |
| 104 | |
| 105 | PyObject *nonDunderKeys = PyList_New(0); |
| 106 | for (size_t i = 0; i < keysLength; i++) { |
| 107 | PyObject *key = PyList_GetItem(keys, i); |
| 108 | if (PyObject_CallMethod(key, "startswith", "(s)", "__") == Py_False) { // if key starts with "__", ignore it |
| 109 | PyList_Append(nonDunderKeys, key); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | return handleOwnPropertyKeys(cx, nonDunderKeys, PyList_Size(nonDunderKeys), props); |
| 114 | } |
| 115 | else { |
| 116 | if (PyErr_Occurred()) { |
| 117 | PyErr_Clear(); |
| 118 | } |
| 119 | |
| 120 | return handleOwnPropertyKeys(cx, PyList_New(0), 0, props); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | bool PyObjectProxyHandler::delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, |
| 125 | JS::ObjectOpResult &result) const { |
no outgoing calls
no test coverage detected