[gjs/wip/ptomato/mozjs38: 17/27] constructor-proxy: Adapt to new js::DirectProxyHandler API
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs38: 17/27] constructor-proxy: Adapt to new js::DirectProxyHandler API
- Date: Thu, 9 Feb 2017 06:41:47 +0000 (UTC)
commit 13395fb3fbbd8dec1e3943ee37bd174418ac6336
Author: Philip Chimento <philip chimento gmail com>
Date: Wed Jan 11 23:19:14 2017 -0800
constructor-proxy: Adapt to new js::DirectProxyHandler API
Callability is no longer indicated with the bizarre setDefaultClass()
method, but instead by overriding the isCallable() and isConstructor()
methods; and some signatures have changed.
https://bugzilla.gnome.org/show_bug.cgi?id=777962
gjs/jsapi-constructor-proxy.cpp | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/gjs/jsapi-constructor-proxy.cpp b/gjs/jsapi-constructor-proxy.cpp
index 9dab6c0..02dc1a1 100644
--- a/gjs/jsapi-constructor-proxy.cpp
+++ b/gjs/jsapi-constructor-proxy.cpp
@@ -82,16 +82,15 @@ class GjsConstructorHandler : public js::DirectProxyHandler {
}
public:
- GjsConstructorHandler() : js::DirectProxyHandler(&constructor_proxy_family)
- {
- setHasPrototype(true);
- }
+ GjsConstructorHandler()
+ : js::DirectProxyHandler(&constructor_proxy_family, true /* hasPrototype */)
+ { }
bool
getPrototypeOf(JSContext *cx,
JS::HandleObject proxy,
JS::MutableHandleObject proto_p)
- override
+ const override
{
proto_p.set(proto(proxy));
return true;
@@ -102,13 +101,27 @@ public:
void
finalize(JSFreeOp *fop,
JSObject *proxy)
- override
+ const override
{
GJS_DEC_COUNTER(constructor_proxy);
gjs_debug_lifecycle(GJS_DEBUG_PROXY,
"constructor proxy %p destroyed", proxy);
}
+ bool
+ isCallable(JSObject *obj)
+ const override
+ {
+ return true;
+ }
+
+ bool
+ isConstructor(JSObject *obj)
+ const override
+ {
+ return true;
+ }
+
static GjsConstructorHandler&
singleton(void)
{
@@ -141,14 +154,9 @@ create_gjs_constructor_proxy(JSContext *cx,
return false;
}
- js::ProxyOptions options;
- /* "true" makes the proxy callable, otherwise the "call" and "construct"
- * traps are ignored */
- options.selectDefaultClass(true);
-
JS::RootedObject proxy(cx,
js::NewProxyObject(cx, &GjsConstructorHandler::singleton(), args[0],
- &args[1].toObject(), nullptr, options));
+ &args[1].toObject(), nullptr));
/* We stick this extra object into one of the proxy object's "extra slots",
* even though it is private data of the proxy handler. This is because
* proxy handlers cannot have trace callbacks. The proxy object does have a
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]