summaryrefslogtreecommitdiff
path: root/gi/object.cpp
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2022-01-16 13:19:26 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2022-01-16 13:21:37 -0800
commit02503597cacc55d841860ffd5d3cc4e8d7a46912 (patch)
tree3163fcd4db43bf2921237f9ce729909917f13cf5 /gi/object.cpp
parent80265ba480f947e25a4e9c6bfe478198404c6c0a (diff)
downloadgjs-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.cpp6
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);