diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2017-03-27 19:46:45 +0100 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2017-04-17 21:41:11 -0700 |
commit | 93a13dc8b12bac8a7d2daa0415a7aaeaa63512cb (patch) | |
tree | a00c877244430a052e25deea4950573db2ba1544 | |
parent | 726c23071b4c5f20297f28cfc512c3c97b1b883d (diff) | |
download | gjs-93a13dc8b12bac8a7d2daa0415a7aaeaa63512cb.tar.gz |
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
-rw-r--r-- | gi/arg.cpp | 2 | ||||
-rw-r--r-- | gi/enumeration.cpp | 3 | ||||
-rw-r--r-- | gi/object.cpp | 4 | ||||
-rw-r--r-- | gi/repo.cpp | 4 | ||||
-rw-r--r-- | gjs/byteArray.cpp | 2 | ||||
-rw-r--r-- | gjs/importer.cpp | 4 | ||||
-rw-r--r-- | gjs/jsapi-util.cpp | 2 | ||||
-rw-r--r-- | modules/cairo-region.cpp | 2 | ||||
-rw-r--r-- | modules/cairo.cpp | 2 | ||||
-rw-r--r-- | modules/console.cpp | 2 | ||||
-rw-r--r-- | modules/system.cpp | 2 |
11 files changed, 14 insertions, 15 deletions
@@ -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 af27fd4d..9b0f4701 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 4e33c607..4b5ddcf5 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 1785966e..2f2bbcdc 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 212629ca..3f551509 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 d1ca30a1..5ee128ef 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 ce3982e6..4d59d595 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 19029e07..871f258c 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 03f25466..a541d3de 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 ce757437..74e410a8 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 7bb2fc97..64617607 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; |