[gjs/wip/ptomato/mozjs38: 17/24] 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/24] constructor-proxy: Adapt to new js::DirectProxyHandler API
- Date: Sat, 21 Jan 2017 02:25:56 +0000 (UTC)
commit 39e2c249333d233fa1f0c686d513f75d098d4939
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.
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]