[gjs/wip/ptomato/mozjs52: 21/38] importer: Seal import with JSPropertyDescriptor directly



commit 0ba44ee2a5067589e8e7340e7bcf06286898c706
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 c21a59e..b929915 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]