[gjs/wip/ptomato/mozjs45prep: 9/26] js: Use JS_NewPlainObject()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs45prep: 9/26] js: Use JS_NewPlainObject()
- Date: Wed, 29 Mar 2017 23:47:01 +0000 (UTC)
commit c3dccfa40b94d2abc736b9ed51981d51fe289404
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.
gi/arg.cpp | 2 +-
gi/enumeration.cpp | 2 +-
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(+), 14 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 5502b00..95a91ca 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 5f5e2f9..2a2491c 100644
--- a/gi/enumeration.cpp
+++ b/gi/enumeration.cpp
@@ -165,7 +165,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 43cb425..c4d6fdc 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2584,7 +2584,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,
@@ -3162,7 +3162,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 4e780fe..4ff17bb 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -293,11 +293,11 @@ 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, global));
+ JS::RootedObject versions(context, JS_NewPlainObject(context));
gjs_object_define_property(context, repo, GJS_STRING_GI_VERSIONS,
versions, JSPROP_PERMANENT);
- JS::RootedObject private_ns(context, JS_NewObject(context, NULL, global));
+ 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 d385ad6..81f4463 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -848,7 +848,7 @@ gjs_define_byte_array_stuff(JSContext *context,
{
JSObject *prototype;
- module.set(JS_NewObject(context, NULL));
+ module.set(JS_NewPlainObject(context));
prototype = JS_InitClass(context, module, JS::NullPtr(),
&gjs_byte_array_class,
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index c8e08bf..7f198ad 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -385,7 +385,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;
@@ -462,7 +462,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 f0bcd75..b5667a6 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -928,7 +928,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 beab0d3..2436f60 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -147,7 +147,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 f3e4647..973aa0d 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -63,7 +63,7 @@ gjs_js_define_cairo_stuff(JSContext *context,
JS::RootedObject surface_proto(context), pattern_proto(context),
gradient_proto(context);
- module.set(JS_NewObject(context, NULL));
+ module.set(JS_NewPlainObject(context));
obj = gjs_cairo_region_create_proto(context, module,
"Region", JS::NullPtr());
diff --git a/modules/console.cpp b/modules/console.cpp
index 60f095b..50c6212 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 79ffe17..c8ab1a2 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]