[gjs/wip/ptomato/mozjs52: 20/37] importer: Seal import with JSPropertyDescriptor directly



commit 5486093a959048c84f4b9911c4aa145cc292e276
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Mar 19 05:18:36 2017 +0000

    importer: Seal import with JSPropertyDescriptor directly
    
    Previously we "sealed" the import by redefining the property on the
    importer object so that it was undeleteable. Now we can do this in a more
    direct way by getting and modifying the property's descriptor.
    
    In order to make this more convenient and faster we thread the jsid
    through the call stack so we don't have to convert it to and from a
    string.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784196

 gjs/importer.cpp |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)
---
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 9bc217e..fe31869 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -206,13 +206,8 @@ seal_import(JSContext       *cx,
         return false;
     }
 
-    /* COMPAT: in mozjs45 use .setConfigurable(false) and the form of
-     * JS_DefineProperty that takes the JSPropertyDescriptor directly */
-
-    if (!JS_DefinePropertyById(cx, descr.object(), id, descr.value(),
-                               descr.attributes() | JSPROP_PERMANENT,
-                               JS_PROPERTYOP_GETTER(descr.getter()),
-                               JS_PROPERTYOP_SETTER(descr.setter()))) {
+    descr.setConfigurable(false);
+    if (!JS_DefinePropertyById(cx, descr.object(), id, descr)) {
         gjs_debug(GJS_DEBUG_IMPORTER,
                   "Failed to redefine attributes to seal '%s' in importer",
                   name);


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