diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2018-05-25 01:01:28 -0400 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2018-05-26 13:57:52 -0700 |
commit | 729dad6661c904add043006e21def10b40881f49 (patch) | |
tree | a21e681d5896c49922d5d1ee9dfa316ee24a9c28 /gjs/jsapi-class.h | |
parent | b88ccfddde9e8d464e3509e78138a9237bc21f1b (diff) | |
download | gjs-729dad6661c904add043006e21def10b40881f49.tar.gz |
object: Remove getProperty/setProperty hooks
These hooks are going away in SpiderMonkey 60, so we have to do something
different. Instead of intercepting the getProperty/setProperty
operations, we lazily define a JS property for each GObject property or
field accessed in the resolve hook.
This uses the same native-accessor-with-private-data API used in
gi/boxed.cpp. Two separate sets of accessors are used for properties and
fields, which makes them a bit simpler than the previous code.
One behaviour change is that we now can't distinguish whether we're
setting a readonly property in strict mode or not. Now we always throw
when setting a readonly property; in effect, we treat the property set as
if it were always in strict mode. ES6 modules are always treated as
strict mode, so this is a change that client code will have to go through
anyway when using ES6 modules.
Closes: #160
Diffstat (limited to 'gjs/jsapi-class.h')
-rw-r--r-- | gjs/jsapi-class.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gjs/jsapi-class.h b/gjs/jsapi-class.h index c3c8fa97..6f76704c 100644 --- a/gjs/jsapi-class.h +++ b/gjs/jsapi-class.h @@ -55,6 +55,15 @@ JSObject *gjs_construct_object_dynamic(JSContext *cx, JS::HandleObject proto, const JS::HandleValueArray& args); +bool gjs_define_property_dynamic(JSContext *cx, + JS::HandleObject proto, + const char *prop_name, + const char *func_namespace, + JSNative getter, + JSNative setter, + JS::HandleValue private_slot, + unsigned flags); + /* * Helper methods to access private data: * @@ -335,4 +344,6 @@ gjs_##name##_constructor(JSContext *context, \ G_END_DECLS +JS::Value gjs_dynamic_property_private_slot(JSObject *accessor_obj); + #endif /* GJS_JSAPI_CLASS_H */ |