[gjs: 10/15] object: Fix interface property descriptor flags
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 10/15] object: Fix interface property descriptor flags
- Date: Sun, 16 Jan 2022 21:28:17 +0000 (UTC)
commit 02503597cacc55d841860ffd5d3cc4e8d7a46912
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Jan 16 13:19:26 2022 -0800
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.
gi/object.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 294b7dc6b..7b046097c 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]