[gjs/mozjs91: 1/13] Use new property descriptor API to create complete descriptor




commit db23f267897c87cc6165af5c2dec2e4d570780e4
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Jan 16 13:36:24 2022 -0800

    Use new property descriptor API to create complete descriptor
    
    There is a new API that ensures that all fields of the property descriptor
    are set coherently ("complete"). setSetterObject() and setGetterObject()
    no longer exist.

 gi/object.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 72a7530a9..4c5a9efd5 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -754,10 +754,10 @@ static bool resolve_on_interface_prototype(JSContext* cx,
 
     // 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_ENUMERATE);
-    desc.setGetterObject(getter);
-    desc.setSetterObject(setter);
+    JS::PropertyAttributes attrs{JS::PropertyAttribute::Configurable,
+                                 JS::PropertyAttribute::Enumerable};
+    JS::Rooted<JS::PropertyDescriptor> desc(
+        cx, JS::PropertyDescriptor::Accessor(getter, setter, attrs));
 
     if (!JS_DefinePropertyById(cx, class_prototype, identifier, desc))
         return false;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]