PythonMonkey   v1.0.0 (dev)
Loading...
Searching...
No Matches
PyObjectProxyHandler Struct Reference

This struct is the ProxyHandler for JS Proxy Objects pythonmonkey creates to handle coercion from python objects to JS Objects. More...

#include <PyObjectProxyHandler.hh>

Inheritance diagram for PyObjectProxyHandler:
[legend]
Collaboration diagram for PyObjectProxyHandler:
[legend]

Public Member Functions

 PyObjectProxyHandler ()
 
 PyObjectProxyHandler (const void *childFamily)
 
void finalize (JS::GCContext *gcx, JSObject *proxy) const override
 Handles python object reference count when JS Proxy object is finalized.
 
bool ownPropertyKeys (JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override
 [[OwnPropertyKeys]]
 
bool delete_ (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult &result) const override
 [[Delete]]
 
bool has (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp) const override
 [[HasProperty]]
 
bool set (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue v, JS::HandleValue receiver, JS::ObjectOpResult &result) const override
 [[Set]]
 
bool enumerate (JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override
 [[Enumerate]]
 
bool hasOwn (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp) const override
 Returns true if id is in proxy, false otherwise.
 
bool getOwnEnumerablePropertyKeys (JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override
 Returns vector of proxy's own keys.
 
bool getOwnPropertyDescriptor (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::MutableHandle< mozilla::Maybe< JS::PropertyDescriptor > > desc) const override
 
bool defineProperty (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::Handle< JS::PropertyDescriptor > desc, JS::ObjectOpResult &result) const override
 
bool getBuiltinClass (JSContext *cx, JS::HandleObject proxy, js::ESClass *cls) const override
 
- Public Member Functions inherited from PyBaseProxyHandler
 PyBaseProxyHandler (const void *family)
 
bool getPrototypeIfOrdinary (JSContext *cx, JS::HandleObject proxy, bool *isOrdinary, JS::MutableHandleObject protop) const override final
 
bool preventExtensions (JSContext *cx, JS::HandleObject proxy, JS::ObjectOpResult &result) const override final
 
bool isExtensible (JSContext *cx, JS::HandleObject proxy, bool *extensible) const override final
 

Static Public Member Functions

static bool handleOwnPropertyKeys (JSContext *cx, PyObject *keys, size_t length, JS::MutableHandleIdVector props)
 Helper function used by dicts and objects for ownPropertyKeys.
 
static bool handleGetOwnPropertyDescriptor (JSContext *cx, JS::HandleId id, JS::MutableHandle< mozilla::Maybe< JS::PropertyDescriptor > > desc, PyObject *item)
 Helper function used by dicts and objects for get OwnPropertyDescriptor.
 
static bool object_toString (JSContext *cx, unsigned argc, JS::Value *vp)
 Helper function used by dicts and objects to convert dict/object to String.
 
static bool object_toLocaleString (JSContext *cx, unsigned argc, JS::Value *vp)
 Helper function used by dicts and objects to convert dict/object to LocaleString.
 
static bool object_valueOf (JSContext *cx, unsigned argc, JS::Value *vp)
 Helper function used by dicts and objects to get valueOf, just returns a new reference to self
 

Static Public Attributes

static const char family = 0
 

Detailed Description

This struct is the ProxyHandler for JS Proxy Objects pythonmonkey creates to handle coercion from python objects to JS Objects.

Constructor & Destructor Documentation

◆ PyObjectProxyHandler() [1/2]

PyObjectProxyHandler::PyObjectProxyHandler ( )

◆ PyObjectProxyHandler() [2/2]

PyObjectProxyHandler::PyObjectProxyHandler ( const void *  childFamily)

Member Function Documentation

◆ defineProperty()

bool PyObjectProxyHandler::defineProperty ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
JS::Handle< JS::PropertyDescriptor >  desc,
JS::ObjectOpResult &  result 
) const
override

◆ delete_()

bool PyObjectProxyHandler::delete_ ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
JS::ObjectOpResult &  result 
) const
override

[[Delete]]

Parameters
cx- pointer to JSContext
proxy- The proxy object who's property we wish to delete
id- The key we wish to delete
result- whether the call succeeded or not
Returns
true - call succeeded
false - call failed and an exception has been raised

◆ enumerate()

bool PyObjectProxyHandler::enumerate ( JSContext *  cx,
JS::HandleObject  proxy,
JS::MutableHandleIdVector  props 
) const
override

[[Enumerate]]

Parameters
cx- pointer to JSContext
proxy- The proxy object who's keys we output
props- out-parameter of object IDs
Returns
true - call succeeded
false - call failed and an exception has been raised

◆ finalize()

void PyObjectProxyHandler::finalize ( JS::GCContext *  gcx,
JSObject *  proxy 
) const
override

Handles python object reference count when JS Proxy object is finalized.

Parameters
gcxpointer to JS::GCContext
proxythe proxy object being finalized

◆ getBuiltinClass()

bool PyObjectProxyHandler::getBuiltinClass ( JSContext *  cx,
JS::HandleObject  proxy,
js::ESClass *  cls 
) const
override

◆ getOwnEnumerablePropertyKeys()

bool PyObjectProxyHandler::getOwnEnumerablePropertyKeys ( JSContext *  cx,
JS::HandleObject  proxy,
JS::MutableHandleIdVector  props 
) const
override

Returns vector of proxy's own keys.

Parameters
cx- Pointer to the JSContext
proxy- the proxy object
props- out parameter, the vector of proxy's own keys
Returns
true - the call succeeded
false - the call failed and an exception has been raised

◆ getOwnPropertyDescriptor()

bool PyObjectProxyHandler::getOwnPropertyDescriptor ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
JS::MutableHandle< mozilla::Maybe< JS::PropertyDescriptor > >  desc 
) const
override

◆ handleGetOwnPropertyDescriptor()

bool PyObjectProxyHandler::handleGetOwnPropertyDescriptor ( JSContext *  cx,
JS::HandleId  id,
JS::MutableHandle< mozilla::Maybe< JS::PropertyDescriptor > >  desc,
PyObject *  item 
)
static

Helper function used by dicts and objects for get OwnPropertyDescriptor.

Parameters
cx- pointer to the JSContext
id- id of the prop to get
desc- out-param, the property descriptor
item- the python object to be converted to a JS prop
Returns
true - the function succeeded
false - the function has failed and an exception has been raised

◆ handleOwnPropertyKeys()

bool PyObjectProxyHandler::handleOwnPropertyKeys ( JSContext *  cx,
PyObject *  keys,
size_t  length,
JS::MutableHandleIdVector  props 
)
static

Helper function used by dicts and objects for ownPropertyKeys.

Parameters
cx- pointer to the JSContext
keys- PyListObject containing the keys of the proxy'd dict/object
length- the length of keys param
props- out-param, will be a JS vector of the keys converted to JS Ids
Returns
true - the function succeeded
false - the function failed (an Exception should be raised)

◆ has()

bool PyObjectProxyHandler::has ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
bool *  bp 
) const
override

[[HasProperty]]

Parameters
cx- pointer to JSContext
proxy- The proxy object who's propery we wish to check
id- key value of the property to check
bp- out-paramter: true if object has property, false if not
Returns
true - call succeeded
false - call failed and an exception has been raised

◆ hasOwn()

bool PyObjectProxyHandler::hasOwn ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
bool *  bp 
) const
override

Returns true if id is in proxy, false otherwise.

Parameters
cxpointer to JSContext
proxyThe proxy object who's property we wish to check
idKey of the property we wish to check
bpout-paramter: true if object has property, false if not
Returns
true call succeeded
false call failed and an exception has been raised

◆ object_toLocaleString()

static bool PyObjectProxyHandler::object_toLocaleString ( JSContext *  cx,
unsigned  argc,
JS::Value *  vp 
)
static

Helper function used by dicts and objects to convert dict/object to LocaleString.

Parameters
cx- pointer to the JSContext
argc- unused
vp- unused
Returns
true - this function always returns true

◆ object_toString()

static bool PyObjectProxyHandler::object_toString ( JSContext *  cx,
unsigned  argc,
JS::Value *  vp 
)
static

Helper function used by dicts and objects to convert dict/object to String.

Parameters
cx- pointer to the JSContext
argc- unused
vp- unused
Returns
true - this function always returns true

◆ object_valueOf()

static bool PyObjectProxyHandler::object_valueOf ( JSContext *  cx,
unsigned  argc,
JS::Value *  vp 
)
static

Helper function used by dicts and objects to get valueOf, just returns a new reference to self

Parameters
cx- pointer to the JSContext
argc- unused
vp- unused
Returns
true - the function succeeded
false - the function failed and an exception has been raised

◆ ownPropertyKeys()

bool PyObjectProxyHandler::ownPropertyKeys ( JSContext *  cx,
JS::HandleObject  proxy,
JS::MutableHandleIdVector  props 
) const
override

[[OwnPropertyKeys]]

Parameters
cx- pointer to JSContext
proxy- The proxy object who's keys we output
props- out-parameter of object IDs
Returns
true - call succeeded
false - call failed and an exception has been raised

◆ set()

bool PyObjectProxyHandler::set ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
JS::HandleValue  v,
JS::HandleValue  receiver,
JS::ObjectOpResult &  result 
) const
override

[[Set]]

Parameters
cxpointer to JSContext
proxyThe proxy object who's property we wish to set
idKey of the property we wish to set
vValue that we wish to set the property to
receiverThe this value to use when executing any code
resultwhether or not the call succeeded
Returns
true call succeed
false call failed and an exception has been raised

Member Data Documentation

◆ family

const char PyObjectProxyHandler::family = 0
static

The documentation for this struct was generated from the following files: