[gjs/wip/ptomato/mozjs31: 13/26] importer: Remove deprecated JS_{Get, Set}PropertyAttributes
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31: 13/26] importer: Remove deprecated JS_{Get, Set}PropertyAttributes
- Date: Sat, 5 Nov 2016 02:04:15 +0000 (UTC)
commit 5d1f7128f8fcd4ab8d219f61845499ec78ab5dde
Author: Philip Chimento <philip endlessm com>
Date: Fri Oct 21 17:50:38 2016 -0700
importer: Remove deprecated JS_{Get,Set}PropertyAttributes
This has no direct replacement in mozjs31, but the way to do it is to get
the property's descriptor, and overwrite the existing property with
JS_DefineProperty() when we want to change the attributes.
gjs/importer.cpp | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index edb78d2..e089bb0 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -153,27 +153,28 @@ define_import(JSContext *context,
* we do this after the import succesfully completes.
*/
static bool
-seal_import(JSContext *context,
- JSObject *obj,
- const char *name)
+seal_import(JSContext *cx,
+ JS::HandleObject obj,
+ const char *name)
{
- bool found;
- unsigned attrs;
+ JS::Rooted<JSPropertyDescriptor> descr(cx);
- if (!JS_GetPropertyAttributes(context, obj, name,
- &attrs, &found) || !found) {
+ if (!JS_GetOwnPropertyDescriptor(cx, obj, name, &descr) ||
+ descr.object() == NULL) {
gjs_debug(GJS_DEBUG_IMPORTER,
"Failed to get attributes to seal '%s' in importer",
name);
return false;
}
- attrs |= JSPROP_PERMANENT;
+ /* COMPAT: in mozjs45 use .setConfigurable(false) and the form of
+ * JS_DefineProperty that takes the JSPropertyDescriptor directly */
- if (!JS_SetPropertyAttributes(context, obj, name,
- attrs, &found) || !found) {
+ if (!JS_DefineProperty(cx, descr.object(), name, descr.value(),
+ descr.attributes() | JSPROP_PERMANENT,
+ descr.getter(), descr.setter())) {
gjs_debug(GJS_DEBUG_IMPORTER,
- "Failed to set attributes to seal '%s' in importer",
+ "Failed to redefine attributes to seal '%s' in importer",
name);
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]