diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2022-01-16 13:19:26 -0800 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2022-01-16 13:21:37 -0800 |
commit | 02503597cacc55d841860ffd5d3cc4e8d7a46912 (patch) | |
tree | 3163fcd4db43bf2921237f9ce729909917f13cf5 /gi/object.cpp | |
parent | 80265ba480f947e25a4e9c6bfe478198404c6c0a (diff) | |
download | gjs-02503597cacc55d841860ffd5d3cc4e8d7a46912.tar.gz |
object: Fix interface property descriptor flags
Before the previous commit, the new property descriptor got the default
flags because JS::PropertyDescriptor didn't have a copy constructor, so it
was always configurable and non-enumerable. This changes the property
descriptor to be enumerable, since we generally define introspected API
properties to be enumerable.
JSPROP_SETTER and JSPROP_GETTER are already set by setGetterObject() and
setSetterObject(), so we don't need to provide them explicitly here.
Diffstat (limited to 'gi/object.cpp')
-rw-r--r-- | gi/object.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gi/object.cpp b/gi/object.cpp index 294b7dc6..7b046097 100644 --- a/gi/object.cpp +++ b/gi/object.cpp @@ -750,10 +750,10 @@ static bool resolve_on_interface_prototype(JSContext* cx, if (!JS_SetPropertyById(cx, accessor, atoms.prototype(), v_prototype)) return false; - // Copy the original descriptor and remove any value, instead - // adding our getter and setter. + // Create a new descriptor with our getter and setter, that is configurable + // and enumerable, because GObject may need to redefine it later. JS::Rooted<JS::PropertyDescriptor> desc(cx); - desc.setAttributes(JSPROP_SETTER | JSPROP_GETTER); + desc.setAttributes(JSPROP_ENUMERATE); desc.setGetterObject(getter); desc.setSetterObject(setter); |