[gjs/wip/ptomato/mozjs52: 21/38] importer: Seal import with JSPropertyDescriptor directly
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs52: 21/38] importer: Seal import with JSPropertyDescriptor directly
- Date: Wed, 28 Jun 2017 00:03:55 +0000 (UTC)
commit ad885b66ae0d6a7946bd2bfdfc29782bc864a887
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 63bb015..48034dd 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]