[gjs/wip/ptomato/mozjs45prep: 7/26] function: Use JS_GetFunctionProto()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs45prep: 7/26] function: Use JS_GetFunctionProto()
- Date: Wed, 29 Mar 2017 23:46:51 +0000 (UTC)
commit 9b96e93aadfe060b462a3e9c49e1d165e55427be
Author: Philip Chimento <philip chimento gmail com>
Date: Mon Mar 27 19:29:07 2017 +0100
function: Use JS_GetFunctionProto()
Previously we got the global Function prototype in a roundabout way, but
there is a function in the API for that now.
gi/function.cpp | 19 +++++--------------
1 files changed, 5 insertions(+), 14 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index dcf6ee5..6fdff87 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1666,22 +1666,13 @@ function_new(JSContext *context,
if (!JS_HasProperty(context, global, gjs_function_class.name, &found))
return NULL;
+
if (!found) {
JSObject *prototype;
- JS::RootedObject parent_proto(context);
- JS::RootedValue v_native_function(context);
-
- JS_GetProperty(context, global, "Function", &v_native_function);
- JS::RootedObject native_function(context, &v_native_function.toObject());
- /* We take advantage from that fact that Function.__proto__ is Function.prototype */
- JS_GetPrototype(context, native_function, &parent_proto);
-
- prototype = JS_InitClass(context, global,
- /* parent prototype JSObject* for
- * prototype; NULL for
- * Object.prototype
- */
- parent_proto,
+ JS::RootedObject function_proto(context,
+ JS_GetFunctionPrototype(context, global));
+
+ prototype = JS_InitClass(context, global, function_proto,
&gjs_function_class,
/* constructor for instances (NULL for
* none - just name the prototype like
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]