Subject: [gjs/wip/ptomato/mozjs38: 8/17] constructor-proxy:
Adapt to new js::DirectProxyHandler API



commit 9bedeba00054e894b18b76b3a36cdd41d9e61f39
Author: Philip Chimento <[email protected]>
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)<...

br> + 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
_______________________________________________
commits-list mailing list (read only)
https://mail.gnome.org/mailman/listinfo/commits-list

Want to limit the commits to a few modules? Go to above URL, log in to edit
your options and select the modules ('topics') you want.



Programming list archiving by: Enterprise Git Hosting