18#ifndef INCLUDED_JSI_GUIPROXY
19#define INCLUDED_JSI_GUIPROXY
35# pragma GCC diagnostic push
36# pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
38# pragma warning(push, 1)
39# pragma warning(disable: 4265)
50 friend std::unique_ptr<IGUIProxyObject> std::make_unique<IGUIProxyObject>();
62 return static_cast<T*
>(FromPrivateSlot<IGUIObject>(obj));
68 return static_cast<T*
>(
static_cast<PrivateData>(js::GetProxyPrivate(obj).toPrivate()));
79template<>
IGUIObject* IGUIProxyObject::FromPrivateSlot<IGUIObject>(JSObject*);
91 virtual bool has(
const std::string& name)
const = 0;
93 virtual JSObject*
get(
const std::string& name)
const = 0;
119template<
typename GUIObjectType>
152 template<auto callable>
156 bool PropGetter(JS::HandleObject proxy,
const std::string& propName, JS::MutableHandleValue vp)
const;
161 virtual bool get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue receiver, JS::HandleId
id, JS::MutableHandleValue vp)
const override final;
163 virtual bool set(JSContext* cx, JS::HandleObject proxy, JS::HandleId
id, JS::HandleValue vp,
164 JS::HandleValue receiver, JS::ObjectOpResult& result)
const final;
166 virtual bool delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId
id, JS::ObjectOpResult& result)
const override final;
173 JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>>
UNUSED(desc))
const override
179 JS::Handle<JS::PropertyDescriptor>
UNUSED(desc), JS::ObjectOpResult&
UNUSED(result))
const override
216# pragma GCC diagnostic pop
Proxies need to store some data whose lifetime is tied to an interface.
Definition: JSInterface_GUIProxy.h:86
virtual bool setFunction(const ScriptRequest &rq, const std::string &name, JSFunction *function)=0
virtual bool has(const std::string &name) const =0
virtual JSObject * get(const std::string &name) const =0
virtual ~GUIProxyProps()
Definition: JSInterface_GUIProxy.h:88
GUI object such as a button or an input-box.
Definition: IGUIObject.h:60
JS GUI proxies need to store some private data.
Definition: JSInterface_GUIProxy.h:47
IGUIProxyObject(IGUIProxyObject &&)=delete
JS::PersistentRootedObject m_Object
Definition: JSInterface_GUIProxy.h:75
static T * FromPrivateSlot(JSObject *obj)
Definition: JSInterface_GUIProxy.h:60
IGUIProxyObject()=default
static T * UnsafeFromPrivateSlot(JSObject *obj)
Definition: JSInterface_GUIProxy.h:66
PrivateData m_Ptr
Definition: JSInterface_GUIProxy.h:76
IGUIProxyObject(const IGUIProxyObject &)=delete
JSObject * Get() const
Definition: JSInterface_GUIProxy.h:52
Handles the js interface with C++ GUI objects.
Definition: JSInterface_GUIProxy.h:121
virtual bool get(JSContext *cx, JS::HandleObject proxy, JS::HandleValue receiver, JS::HandleId id, JS::MutableHandleValue vp) const override final
Definition: JSInterface_GUIProxy_impl.h:167
~JSI_GUIProxy()
Definition: JSInterface_GUIProxy.h:140
virtual bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::Handle< JS::PropertyDescriptor > desc, JS::ObjectOpResult &result) const override
Definition: JSInterface_GUIProxy.h:178
static std::unique_ptr< IGUIProxyObject > CreateJSObject(const ScriptRequest &rq, GUIObjectType *ptr, GUIProxyProps *data)
Definition: JSInterface_GUIProxy_impl.h:150
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::MutableHandle< mozilla::Maybe< JS::PropertyDescriptor > > desc) const override
Definition: JSInterface_GUIProxy.h:172
virtual bool getPrototypeIfOrdinary(JSContext *cx, JS::HandleObject proxy, bool *isOrdinary, JS::MutableHandleObject protop) const override
Definition: JSInterface_GUIProxy.h:194
virtual bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible) const override
Definition: JSInterface_GUIProxy.h:208
bool PropGetter(JS::HandleObject proxy, const std::string &propName, JS::MutableHandleValue vp) const
Definition: JSInterface_GUIProxy_impl.h:113
virtual bool setImmutablePrototype(JSContext *cx, JS::HandleObject proxy, bool *succeeded) const override
Definition: JSInterface_GUIProxy.h:199
static JSI_GUIProxy & Singleton()
Definition: JSInterface_GUIProxy_impl.h:35
static GUIObjectType * FromPrivateSlot(const ScriptRequest &, JS::CallArgs &args)
Definition: JSInterface_GUIProxy_impl.h:106
virtual bool set(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue vp, JS::HandleValue receiver, JS::ObjectOpResult &result) const final
Definition: JSInterface_GUIProxy_impl.h:236
virtual bool enumerate(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override
Definition: JSInterface_GUIProxy.h:189
static void CreateFunctions(const ScriptRequest &rq, GUIProxyProps *cache)
virtual bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult &result) const override final
Definition: JSInterface_GUIProxy_impl.h:292
virtual bool ownPropertyKeys(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override
Definition: JSInterface_GUIProxy.h:184
JSI_GUIProxy()
Definition: JSInterface_GUIProxy.h:136
virtual bool preventExtensions(JSContext *cx, JS::HandleObject proxy, JS::ObjectOpResult &result) const override
Definition: JSInterface_GUIProxy.h:204
static std::pair< const js::BaseProxyHandler *, GUIProxyProps * > CreateData(ScriptInterface &scriptInterface)
Definition: JSInterface_GUIProxy_impl.h:127
static void CreateFunction(const ScriptRequest &rq, GUIProxyProps *cache, const std::string &name)
Definition: JSInterface_GUIProxy_impl.h:144
Abstraction around a SpiderMonkey JS::Realm.
Definition: ScriptInterface.h:72
Spidermonkey maintains some 'local' state via the JSContext* object.
Definition: ScriptRequest.h:60
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning.
Definition: code_annotation.h:40
#define T(string_literal)
Definition: secure_crt.cpp:77