[gjs/wip/ptomato/mozjs45: 5/27] js: Use JS_NewPlainObject()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs45: 5/27] js: Use JS_NewPlainObject()
- Date: Tue, 18 Apr 2017 04:42:55 +0000 (UTC)
commit 93a13dc8b12bac8a7d2daa0415a7aaeaa63512cb
Author: Philip Chimento <philip chimento gmail com>
Date: Mon Mar 27 19:46:45 2017 +0100
js: Use JS_NewPlainObject()
Instead of JS_NewObject(context, NULL) passing NULL for the JSClass
pointer, use JS_NewPlainObject() when we want a blank object to fill in
with properties. JS_NewPlainObject() is the same as "{}" or "new
Object()" in Javascript.
https://bugzilla.gnome.org/show_bug.cgi?id=781429
gi/arg.cpp | 2 +-
gi/enumeration.cpp | 3 +--
gi/object.cpp | 4 ++--
gi/repo.cpp | 4 ++--
gjs/byteArray.cpp | 2 +-
gjs/importer.cpp | 4 ++--
gjs/jsapi-util.cpp | 2 +-
modules/cairo-region.cpp | 2 +-
modules/cairo.cpp | 2 +-
modules/console.cpp | 2 +-
modules/system.cpp | 2 +-
11 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 16a265a..f111696 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2527,7 +2527,7 @@ gjs_object_from_g_hash (JSContext *context,
return true;
}
- JS::RootedObject obj(context, JS_NewObject(context, NULL));
+ JS::RootedObject obj(context, JS_NewPlainObject(context));
if (obj == NULL)
return false;
diff --git a/gi/enumeration.cpp b/gi/enumeration.cpp
index af27fd4..9b0f470 100644
--- a/gi/enumeration.cpp
+++ b/gi/enumeration.cpp
@@ -152,7 +152,6 @@ gjs_define_enumeration(JSContext *context,
GIEnumInfo *info)
{
const char *enum_name;
- JS::RootedObject global(context, gjs_get_import_global(context));
/* An enumeration is simply an object containing integer attributes for
* each enum value. It does not have a special JSClass.
@@ -165,7 +164,7 @@ gjs_define_enumeration(JSContext *context,
enum_name = g_base_info_get_name( (GIBaseInfo*) info);
- JS::RootedObject enum_obj(context, JS_NewObject(context, NULL, global));
+ JS::RootedObject enum_obj(context, JS_NewPlainObject(context));
if (enum_obj == NULL) {
g_error("Could not create enumeration %s.%s",
g_base_info_get_namespace( (GIBaseInfo*) info),
diff --git a/gi/object.cpp b/gi/object.cpp
index 4e33c60..4b5ddcf 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2419,7 +2419,7 @@ gjs_object_constructor (GType type,
if (n_construct_properties) {
guint i;
- JS::RootedObject props_hash(context, JS_NewObject(context, NULL));
+ JS::RootedObject props_hash(context, JS_NewPlainObject(context));
for (i = 0; i < n_construct_properties; i++)
jsobj_set_gproperty(context, props_hash,
@@ -2987,7 +2987,7 @@ bool
gjs_define_private_gi_stuff(JSContext *cx,
JS::MutableHandleObject module)
{
- module.set(JS_NewObject(cx, NULL));
+ module.set(JS_NewPlainObject(cx));
return JS_DefineFunctions(cx, module, &module_funcs[0]);
}
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 1785966..2f2bbcd 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -271,7 +271,7 @@ repo_new(JSContext *context)
gjs_debug_lifecycle(GJS_DEBUG_GREPO,
"repo constructor, obj %p priv %p", repo.get(), priv);
- JS::RootedObject versions(context, JS_NewObject(context, NULL));
+ JS::RootedObject versions(context, JS_NewPlainObject(context));
gjs_object_define_property(context, repo, GJS_STRING_GI_VERSIONS,
versions, JSPROP_PERMANENT);
@@ -289,7 +289,7 @@ repo_new(JSContext *context)
JSPROP_PERMANENT))
return nullptr;
- JS::RootedObject private_ns(context, JS_NewObject(context, NULL));
+ JS::RootedObject private_ns(context, JS_NewPlainObject(context));
gjs_object_define_property(context, repo,
GJS_STRING_PRIVATE_NS_MARKER, private_ns,
JSPROP_PERMANENT);
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 212629c..3f55150 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -834,7 +834,7 @@ bool
gjs_define_byte_array_stuff(JSContext *cx,
JS::MutableHandleObject module)
{
- module.set(JS_NewObject(cx, NULL));
+ module.set(JS_NewPlainObject(cx));
JS::RootedObject proto(cx);
return gjs_byte_array_define_proto(cx, module, &proto) &&
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index d1ca30a..5ee128e 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -388,7 +388,7 @@ load_module_init(JSContext *context,
}
}
- JS::RootedObject module_obj(context, JS_NewObject(context, NULL));
+ JS::RootedObject module_obj(context, JS_NewPlainObject(context));
GjsAutoUnref<GFile> file = g_file_new_for_commandline_arg(full_path);
if (!import_file (context, "__init__", file, module_obj))
return module_obj;
@@ -465,7 +465,7 @@ import_file_on_module(JSContext *context,
bool retval = false;
char *full_path = NULL;
- JS::RootedObject module_obj(context, JS_NewObject(context, NULL));
+ JS::RootedObject module_obj(context, JS_NewPlainObject(context));
if (!define_import(context, obj, module_obj, name))
goto out;
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index ce3982e..4d59d59 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -929,7 +929,7 @@ gjs_eval_with_scope(JSContext *context,
JS::RootedObject eval_obj(context, object);
if (!eval_obj)
- eval_obj = JS_NewObject(context, NULL);
+ eval_obj = JS_NewPlainObject(context);
JS::CompileOptions options(context);
options.setUTF8(true)
diff --git a/modules/cairo-region.cpp b/modules/cairo-region.cpp
index 19029e0..871f258 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -152,7 +152,7 @@ static JSObject *
make_rectangle(JSContext *context,
cairo_rectangle_int_t *rect)
{
- JS::RootedObject rect_obj(context, JS_NewObject(context, NULL));
+ JS::RootedObject rect_obj(context, JS_NewPlainObject(context));
JS::RootedValue val(context);
val = JS::Int32Value(rect->x);
diff --git a/modules/cairo.cpp b/modules/cairo.cpp
index 03f2546..a541d3d 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -59,7 +59,7 @@ bool
gjs_js_define_cairo_stuff(JSContext *context,
JS::MutableHandleObject module)
{
- module.set(JS_NewObject(context, NULL));
+ module.set(JS_NewPlainObject(context));
JS::RootedObject proto(context); /* not used */
if (!gjs_cairo_region_define_proto(context, module, &proto))
diff --git a/modules/console.cpp b/modules/console.cpp
index ce75743..74e410a 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -245,7 +245,7 @@ bool
gjs_define_console_stuff(JSContext *context,
JS::MutableHandleObject module)
{
- module.set(JS_NewObject(context, NULL));
+ module.set(JS_NewPlainObject(context));
return JS_DefineFunction(context, module, "interact", gjs_console_interact,
1, GJS_MODULE_PROP_FLAGS);
}
diff --git a/modules/system.cpp b/modules/system.cpp
index 7bb2fc9..6461760 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -162,7 +162,7 @@ gjs_js_define_system_stuff(JSContext *context,
char *program_name;
bool retval;
- module.set(JS_NewObject(context, NULL));
+ module.set(JS_NewPlainObject(context));
if (!JS_DefineFunctions(context, module, &module_funcs[0]))
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]