Pyrogenesis  trunk
Classes | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
JSI_GUIProxy< GUIObjectType > Class Template Reference

Handles the js interface with C++ GUI objects. More...

#include <IGUIObject.h>

Inheritance diagram for JSI_GUIProxy< GUIObjectType >:
Inheritance graph
[legend]
Collaboration diagram for JSI_GUIProxy< GUIObjectType >:
Collaboration graph
[legend]

Classes

struct  PropCache
 

Static Public Member Functions

static JSI_GUIProxySingleton ()
 
static std::pair< const js::BaseProxyHandler *, GUIProxyProps * > CreateData (ScriptInterface &scriptInterface)
 
static std::unique_ptr< IGUIProxyObjectCreateJSObject (const ScriptRequest &rq, GUIObjectType *ptr, GUIProxyProps *data)
 

Protected Member Functions

 JSI_GUIProxy ()
 
 ~JSI_GUIProxy ()
 
bool PropGetter (JS::HandleObject proxy, const std::string &propName, JS::MutableHandleValue vp) const
 
virtual bool get (JSContext *cx, JS::HandleObject proxy, JS::HandleValue receiver, JS::HandleId id, JS::MutableHandleValue vp) const override final
 
virtual bool set (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue vp, JS::HandleValue receiver, JS::ObjectOpResult &result) const final
 
virtual bool delete_ (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult &result) const override final
 
virtual bool getOwnPropertyDescriptor (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::MutableHandle< mozilla::Maybe< JS::PropertyDescriptor >> desc) const override
 
virtual bool defineProperty (JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::Handle< JS::PropertyDescriptor > desc, JS::ObjectOpResult &result) const override
 
virtual bool ownPropertyKeys (JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override
 
virtual bool enumerate (JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override
 
virtual bool getPrototypeIfOrdinary (JSContext *cx, JS::HandleObject proxy, bool *isOrdinary, JS::MutableHandleObject protop) const override
 
virtual bool setImmutablePrototype (JSContext *cx, JS::HandleObject proxy, bool *succeeded) const override
 
virtual bool preventExtensions (JSContext *cx, JS::HandleObject proxy, JS::ObjectOpResult &result) const override
 
virtual bool isExtensible (JSContext *cx, JS::HandleObject proxy, bool *extensible) const override
 
template<>
void CreateFunctions (const ScriptRequest &rq, GUIProxyProps *cache)
 
template<>
void CreateFunctions (const ScriptRequest &rq, GUIProxyProps *cache)
 
template<>
void CreateFunctions (const ScriptRequest &rq, GUIProxyProps *cache)
 
template<>
void CreateFunctions (const ScriptRequest &rq, GUIProxyProps *cache)
 
template<>
void CreateFunctions (const ScriptRequest &rq, GUIProxyProps *cache)
 

Static Protected Member Functions

static GUIObjectType * FromPrivateSlot (const ScriptRequest &, JS::CallArgs &args)
 
static void CreateFunctions (const ScriptRequest &rq, GUIProxyProps *cache)
 
template<auto callable>
static void CreateFunction (const ScriptRequest &rq, GUIProxyProps *cache, const std::string &name)
 

Friends

template<typename T >
class JSI_GUIProxy
 

Detailed Description

template<typename GUIObjectType>
class JSI_GUIProxy< GUIObjectType >

Handles the js interface with C++ GUI objects.

Proxy handlers must live for at least as long as the JS runtime where a proxy object with that handler was created. The reason is that proxy handlers are called during GC, such as on runtime destruction. In practical terms, this means "just keep them static and store no data".

GUI Objects only exist in C++ and have no JS-only properties. As such, there is no "target" JS object that this proxy could point to, and thus we should inherit from BaseProxyHandler and not js::Wrapper.

Proxies can be used with prototypes and almost treated like regular JS objects. However, the default implementation embarks a lot of code that we don't really need here, since the only fanciness is that we cache JSFunction* properties. As such, these GUI proxies don't have one and instead override get/set directly.

To add a new JSI_GUIProxy, you'll need to:

Constructor & Destructor Documentation

◆ JSI_GUIProxy()

template<typename GUIObjectType>
JSI_GUIProxy< GUIObjectType >::JSI_GUIProxy ( )
inlineprotected

◆ ~JSI_GUIProxy()

template<typename GUIObjectType>
JSI_GUIProxy< GUIObjectType >::~JSI_GUIProxy ( )
inlineprotected

Member Function Documentation

◆ CreateData()

template<typename T >
std::pair< const js::BaseProxyHandler *, GUIProxyProps * > JSI_GUIProxy< T >::CreateData ( ScriptInterface scriptInterface)
static

◆ CreateFunction()

template<typename T >
template<auto callable>
void JSI_GUIProxy< T >::CreateFunction ( const ScriptRequest rq,
GUIProxyProps cache,
const std::string &  name 
)
staticprotected

◆ CreateFunctions() [1/6]

template<>
void JSI_GUIProxy< IGUIObject >::CreateFunctions ( const ScriptRequest rq,
GUIProxyProps cache 
)
protected

◆ CreateFunctions() [2/6]

template<>
void JSI_GUIProxy< CButton >::CreateFunctions ( const ScriptRequest rq,
GUIProxyProps cache 
)
protected

◆ CreateFunctions() [3/6]

template<>
void JSI_GUIProxy< CText >::CreateFunctions ( const ScriptRequest rq,
GUIProxyProps cache 
)
protected

◆ CreateFunctions() [4/6]

template<>
void JSI_GUIProxy< CList >::CreateFunctions ( const ScriptRequest rq,
GUIProxyProps cache 
)
protected

◆ CreateFunctions() [5/6]

template<>
void JSI_GUIProxy< CMiniMap >::CreateFunctions ( const ScriptRequest rq,
GUIProxyProps cache 
)
protected

◆ CreateFunctions() [6/6]

template<typename GUIObjectType>
static void JSI_GUIProxy< GUIObjectType >::CreateFunctions ( const ScriptRequest rq,
GUIProxyProps cache 
)
staticprotected

◆ CreateJSObject()

template<typename GUIObjectType>
std::unique_ptr< IGUIProxyObject > JSI_GUIProxy< T >::CreateJSObject ( const ScriptRequest rq,
GUIObjectType *  ptr,
GUIProxyProps data 
)
static

◆ defineProperty()

template<typename GUIObjectType>
virtual bool JSI_GUIProxy< GUIObjectType >::defineProperty ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
JS::Handle< JS::PropertyDescriptor >  desc,
JS::ObjectOpResult &  result 
) const
inlineoverrideprotectedvirtual

◆ delete_()

template<typename T >
bool JSI_GUIProxy< T >::delete_ ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
JS::ObjectOpResult &  result 
) const
finaloverrideprotectedvirtual

◆ enumerate()

template<typename GUIObjectType>
virtual bool JSI_GUIProxy< GUIObjectType >::enumerate ( JSContext *  cx,
JS::HandleObject  proxy,
JS::MutableHandleIdVector  props 
) const
inlineoverrideprotectedvirtual

◆ FromPrivateSlot()

template<typename T >
T * JSI_GUIProxy< T >::FromPrivateSlot ( const ScriptRequest ,
JS::CallArgs &  args 
)
staticprotected

◆ get()

template<typename T >
bool JSI_GUIProxy< T >::get ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleValue  receiver,
JS::HandleId  id,
JS::MutableHandleValue  vp 
) const
finaloverrideprotectedvirtual

◆ getOwnPropertyDescriptor()

template<typename GUIObjectType>
virtual bool JSI_GUIProxy< GUIObjectType >::getOwnPropertyDescriptor ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
JS::MutableHandle< mozilla::Maybe< JS::PropertyDescriptor >>  desc 
) const
inlineoverrideprotectedvirtual

◆ getPrototypeIfOrdinary()

template<typename GUIObjectType>
virtual bool JSI_GUIProxy< GUIObjectType >::getPrototypeIfOrdinary ( JSContext *  cx,
JS::HandleObject  proxy,
bool *  isOrdinary,
JS::MutableHandleObject  protop 
) const
inlineoverrideprotectedvirtual

◆ isExtensible()

template<typename GUIObjectType>
virtual bool JSI_GUIProxy< GUIObjectType >::isExtensible ( JSContext *  cx,
JS::HandleObject  proxy,
bool *  extensible 
) const
inlineoverrideprotectedvirtual

◆ ownPropertyKeys()

template<typename GUIObjectType>
virtual bool JSI_GUIProxy< GUIObjectType >::ownPropertyKeys ( JSContext *  cx,
JS::HandleObject  proxy,
JS::MutableHandleIdVector  props 
) const
inlineoverrideprotectedvirtual

◆ preventExtensions()

template<typename GUIObjectType>
virtual bool JSI_GUIProxy< GUIObjectType >::preventExtensions ( JSContext *  cx,
JS::HandleObject  proxy,
JS::ObjectOpResult &  result 
) const
inlineoverrideprotectedvirtual

◆ PropGetter()

template<typename T >
bool JSI_GUIProxy< T >::PropGetter ( JS::HandleObject  proxy,
const std::string &  propName,
JS::MutableHandleValue  vp 
) const
protected

◆ set()

template<typename T >
bool JSI_GUIProxy< T >::set ( JSContext *  cx,
JS::HandleObject  proxy,
JS::HandleId  id,
JS::HandleValue  vp,
JS::HandleValue  receiver,
JS::ObjectOpResult &  result 
) const
finalprotectedvirtual

◆ setImmutablePrototype()

template<typename GUIObjectType>
virtual bool JSI_GUIProxy< GUIObjectType >::setImmutablePrototype ( JSContext *  cx,
JS::HandleObject  proxy,
bool *  succeeded 
) const
inlineoverrideprotectedvirtual

◆ Singleton()

template<typename T >
JSI_GUIProxy< T > & JSI_GUIProxy< T >::Singleton ( )
static

Friends And Related Function Documentation

◆ JSI_GUIProxy

template<typename GUIObjectType>
template<typename T >
friend class JSI_GUIProxy
friend

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