* @brief This struct is the ProxyHandler for JS Proxy Objects pythonmonkey creates to handle coercion from python objects to JS Objects * */
| 22 | * |
| 23 | */ |
| 24 | struct PyObjectProxyHandler : public PyBaseProxyHandler { |
| 25 | public: |
| 26 | PyObjectProxyHandler() : PyBaseProxyHandler(&family) {}; |
| 27 | PyObjectProxyHandler(const void *childFamily) : PyBaseProxyHandler(childFamily) {}; |
| 28 | static const char family; |
| 29 | |
| 30 | /** |
| 31 | * @brief Helper function used by dicts and objects for ownPropertyKeys |
| 32 | * |
| 33 | * @param cx - pointer to the JSContext |
| 34 | * @param keys - PyListObject containing the keys of the proxy'd dict/object |
| 35 | * @param length - the length of keys param |
| 36 | * @param props - out-param, will be a JS vector of the keys converted to JS Ids |
| 37 | * @return true - the function succeeded |
| 38 | * @return false - the function failed (an Exception should be raised) |
| 39 | */ |
| 40 | static bool handleOwnPropertyKeys(JSContext *cx, PyObject *keys, size_t length, JS::MutableHandleIdVector props); |
| 41 | |
| 42 | /** |
| 43 | * @brief Helper function used by dicts and objects for get OwnPropertyDescriptor |
| 44 | * |
| 45 | * @param cx - pointer to the JSContext |
| 46 | * @param id - id of the prop to get |
| 47 | * @param desc - out-param, the property descriptor |
| 48 | * @param item - the python object to be converted to a JS prop |
| 49 | * @return true - the function succeeded |
| 50 | * @return false - the function has failed and an exception has been raised |
| 51 | */ |
| 52 | static bool handleGetOwnPropertyDescriptor(JSContext *cx, JS::HandleId id, |
| 53 | JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> desc, PyObject *item); |
| 54 | |
| 55 | /** |
| 56 | * @brief Handles python object reference count when JS Proxy object is finalized |
| 57 | * |
| 58 | * @param gcx pointer to JS::GCContext |
| 59 | * @param proxy the proxy object being finalized |
| 60 | */ |
| 61 | void finalize(JS::GCContext *gcx, JSObject *proxy) const override; |
| 62 | |
| 63 | /** |
| 64 | * @brief Helper function used by dicts and objects to convert dict/object to String |
| 65 | * |
| 66 | * @param cx - pointer to the JSContext |
| 67 | * @param argc - unused |
| 68 | * @param vp - unused |
| 69 | * @return true - this function always returns true |
| 70 | */ |
| 71 | static bool object_toString(JSContext *cx, unsigned argc, JS::Value *vp); |
| 72 | |
| 73 | /** |
| 74 | * @brief Helper function used by dicts and objects to convert dict/object to LocaleString |
| 75 | * |
| 76 | * @param cx - pointer to the JSContext |
| 77 | * @param argc - unused |
| 78 | * @param vp - unused |
| 79 | * @return true - this function always returns true |
| 80 | */ |
| 81 | static bool object_toLocaleString(JSContext *cx, unsigned argc, JS::Value *vp); |
nothing calls this directly
no outgoing calls
no test coverage detected