PythonMonkey   v0.3.1 (dev)
Loading...
Searching...
No Matches
PyBaseProxyHandler.hh
Go to the documentation of this file.
1
12#ifndef PythonMonkey_PyBaseProxy_
13#define PythonMonkey_PyBaseProxy_
14
15#include <jsapi.h>
16#include <jsfriendapi.h>
17#include <js/Conversions.h>
18#include <js/Proxy.h>
19
20#include <Python.h>
21
25struct PyBaseProxyHandler : public js::BaseProxyHandler {
26public:
27 PyBaseProxyHandler(PyObject *pyObj, const void *family) : js::BaseProxyHandler(family), pyObject(pyObj) {};
28 PyObject *pyObject; // @TODO (Caleb Aikens) Consider putting this in a private slot
29
30 bool getPrototypeIfOrdinary(JSContext *cx, JS::HandleObject proxy, bool *isOrdinary, JS::MutableHandleObject protop) const override final;
31 bool preventExtensions(JSContext *cx, JS::HandleObject proxy, JS::ObjectOpResult &result) const override final;
32 bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible) const override final;
33};
34
36
37typedef struct {
38 const char *name; /* The name of the method */
39 JSNative call; /* The C function that implements it */
40 uint16_t nargs; /* The argument count for the method */
42
46PyObject *idToKey(JSContext *cx, JS::HandleId id);
47
51bool keyToId(PyObject *key, JS::MutableHandleId idp);
52
53bool idToIndex(JSContext *cx, JS::HandleId id, Py_ssize_t *index);
54
55#endif
ProxySlots
Definition PyBaseProxyHandler.hh:35
@ PyObjectSlot
Definition PyBaseProxyHandler.hh:35
PyObject * idToKey(JSContext *cx, JS::HandleId id)
Convert jsid to a PyObject to be used as dict keys.
Definition PyBaseProxyHandler.cc:17
bool keyToId(PyObject *key, JS::MutableHandleId idp)
Convert Python dict key to jsid.
Definition JSObjectProxy.cc:34
bool idToIndex(JSContext *cx, JS::HandleId id, Py_ssize_t *index)
Definition PyBaseProxyHandler.cc:33
Definition PyBaseProxyHandler.hh:37
const char * name
Definition PyBaseProxyHandler.hh:38
JSNative call
Definition PyBaseProxyHandler.hh:39
uint16_t nargs
Definition PyBaseProxyHandler.hh:40
base class for PyDictProxyHandler and PyListProxyHandler
Definition PyBaseProxyHandler.hh:25
PyBaseProxyHandler(PyObject *pyObj, const void *family)
Definition PyBaseProxyHandler.hh:27
PyObject * pyObject
Definition PyBaseProxyHandler.hh:28
bool preventExtensions(JSContext *cx, JS::HandleObject proxy, JS::ObjectOpResult &result) const override final
Definition PyBaseProxyHandler.cc:51
bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible) const override final
Definition PyBaseProxyHandler.cc:57
bool getPrototypeIfOrdinary(JSContext *cx, JS::HandleObject proxy, bool *isOrdinary, JS::MutableHandleObject protop) const override final
Definition PyBaseProxyHandler.cc:42