[gjs/wip/ptomato/mozjs45prep: 15/16] improvement: JSPropertyDescriptor stuff
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs45prep: 15/16] improvement: JSPropertyDescriptor stuff
- Date: Sun, 19 Mar 2017 05:22:07 +0000 (UTC)
commit 427bdb586e8e0f47381f30de7f25b50f6d10d713
Author: Philip Chimento <philip endlessm com>
Date: Sun Mar 19 05:18:36 2017 +0000
improvement: JSPropertyDescriptor stuff
gjs/importer.cpp | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index c1fa666..9bf6cdc 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -207,11 +207,12 @@ define_import(JSContext *context,
static bool
seal_import(JSContext *cx,
JS::HandleObject obj,
+ JS::HandleId id,
const char *name)
{
JS::Rooted<JSPropertyDescriptor> descr(cx);
- if (!JS_GetOwnPropertyDescriptor(cx, obj, name, &descr) ||
+ if (!JS_GetOwnPropertyDescriptorById(cx, obj, id, &descr) ||
descr.object() == NULL) {
gjs_debug(GJS_DEBUG_IMPORTER,
"Failed to get attributes to seal '%s' in importer",
@@ -219,13 +220,9 @@ seal_import(JSContext *cx,
return false;
}
- /* COMPAT: in mozjs45 use .setConfigurable(false) and the form of
- * JS_DefineProperty that takes the JSPropertyDescriptor directly */
+ descr.setConfigurable(false);
- if (!JS_DefineProperty(cx, descr.object(), name, descr.value(),
- descr.attributes() | JSPROP_PERMANENT,
- JS_PROPERTYOP_GETTER(descr.getter()),
- JS_PROPERTYOP_SETTER(descr.setter()))) {
+ if (!JS_DefinePropertyById(cx, descr.object(), id, descr)) {
gjs_debug(GJS_DEBUG_IMPORTER,
"Failed to redefine attributes to seal '%s' in importer",
name);
@@ -456,6 +453,7 @@ import_symbol_from_init_js(JSContext *cx,
static bool
import_file_on_module(JSContext *context,
JS::HandleObject obj,
+ JS::HandleId id,
const char *name,
GFile *file)
{
@@ -478,7 +476,7 @@ import_file_on_module(JSContext *context,
0, 0))
goto out;
- if (!seal_import(context, obj, name))
+ if (!seal_import(context, obj, id, name))
goto out;
retval = true;
@@ -495,6 +493,7 @@ static bool
do_import(JSContext *context,
JS::HandleObject obj,
Importer *priv,
+ JS::HandleId id,
const char *name)
{
char *filename;
@@ -620,7 +619,7 @@ do_import(JSContext *context,
continue;
}
- if (import_file_on_module (context, obj, name, gfile)) {
+ if (import_file_on_module(context, obj, id, name, gfile)) {
gjs_debug(GJS_DEBUG_IMPORTER,
"successfully imported module '%s'", name);
result = true;
@@ -828,7 +827,7 @@ importer_resolve(JSContext *context,
}
JSAutoRequest ar(context);
- if (!do_import(context, obj, priv, name)) {
+ if (!do_import(context, obj, priv, id, name)) {
g_free(name);
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]