[gjs/wip/ptomato/mozjs31prep: 17/18] class: Deprecate gjs_new_object_for_constructor()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31prep: 17/18] class: Deprecate gjs_new_object_for_constructor()
- Date: Wed, 21 Sep 2016 05:19:17 +0000 (UTC)
commit 8ca2b8219d250eb02b3cfa9d4a872390b8bc53d4
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Sep 18 10:40:30 2016 -0700
class: Deprecate gjs_new_object_for_constructor()
According to the comments, in mozjs 1.8.5, JS_NewObjectForConstructor()
did not work with our dynamic classes. Therefore a
gjs_new_object_for_constructor() shim was created that copied the
JS_NewObjectForConstructor() code from mozjs 1.9. Now that we are on
mozjs 24, we can get rid of this shim.
Unfortunately we can't remove the function altogether because it's public
API in libgjs.
https://bugzilla.gnome.org/show_bug.cgi?id=742249
gjs/compat.h | 2 +-
gjs/jsapi-dynamic-class.cpp | 22 +++++-----------------
gjs/jsapi-util.h | 4 +++-
3 files changed, 9 insertions(+), 19 deletions(-)
---
diff --git a/gjs/compat.h b/gjs/compat.h
index 693d871..8a3982f 100644
--- a/gjs/compat.h
+++ b/gjs/compat.h
@@ -99,7 +99,7 @@ gjs_##name##_constructor(JSContext *context, \
gjs_throw_constructor_error(context); \
return false; \
} \
- object = gjs_new_object_for_constructor(context, &gjs_##name##_class, vp); \
+ object = JS_NewObjectForConstructor(context, &gjs_##name##_class, vp); \
if (object == NULL) \
return false; \
}
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 3cb4633..c87fc9b 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -36,29 +36,17 @@
#include <math.h>
/*
- * JS 1.8.5 has JS_NewObjectForConstructor, but it attempts
- * to retrieve the JSClass from private fields in the constructor function,
- * which fails for our "dynamic classes".
- * This is the version included in SpiderMonkey 1.9 and later, to be
- * used until we rebase on a newer libmozjs.
+ * This shim was because of a bug in JS_NewObjectForConstructor in JS 1.8.5. It
+ * attempted to retrieve the JSClass from private fields in the constructor
+ * function, which failed for our "dynamic classes".
+ * This function is deprecated.
*/
JSObject *
gjs_new_object_for_constructor(JSContext *context,
JSClass *clasp,
JS::Value *vp)
{
- JS::Value callee;
- JSObject *parent;
- JS::Value prototype;
-
- callee = JS_CALLEE(context, vp);
- parent = JS_GetParent(&callee.toObject());
-
- if (!gjs_object_get_property_const(context, &callee.toObject(), GJS_STRING_PROTOTYPE, &prototype))
- return NULL;
-
- return JS_NewObjectWithGivenProto(context, clasp,
- &prototype.toObject(), parent);
+ return JS_NewObjectForConstructor(context, clasp, vp);
}
bool
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index b68d6fc..3aa0d0e 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -221,7 +221,9 @@ bool gjs_object_require_property (JSContext *context,
JSObject *gjs_new_object_for_constructor (JSContext *context,
JSClass *clasp,
- JS::Value *vp);
+ JS::Value *vp)
+G_GNUC_DEPRECATED_FOR(JS_NewObjectForConstructor);
+
bool gjs_init_class_dynamic (JSContext *context,
JSObject *in_object,
JSObject *parent_proto,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]