[gjs/wip/ptomato/mozjs31: 25/25] WIP - stuff
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31: 25/25] WIP - stuff
- Date: Fri, 4 Nov 2016 01:42:42 +0000 (UTC)
commit 88e6be1b0a10d3070cdcb2e6f311d18679062ee2
Author: Philip Chimento <philip endlessm com>
Date: Thu Nov 3 18:40:18 2016 -0700
WIP - stuff
gi/arg.cpp | 5 +--
gi/boxed.cpp | 6 ++--
gi/enumeration.cpp | 5 +---
gi/function.cpp | 16 +++-------
gi/fundamental.cpp | 3 +-
gi/interface.cpp | 3 +-
gi/object.cpp | 22 +++++++-------
gi/param.cpp | 3 +-
gi/repo.cpp | 6 +---
gi/union.cpp | 3 +-
gjs/byteArray.cpp | 4 +--
gjs/context.cpp | 7 ++---
gjs/coverage.cpp | 62 +++++++++++++++++-------------------------
gjs/importer.cpp | 20 +++++++-------
gjs/jsapi-dynamic-class.cpp | 14 +++++----
gjs/jsapi-util-args.h | 3 +-
gjs/jsapi-util-error.cpp | 7 +++--
gjs/jsapi-util.cpp | 9 +++---
gjs/jsapi-util.h | 6 ++--
gjs/stack.cpp | 3 +-
modules/cairo-context.cpp | 6 ++--
modules/system.cpp | 8 +++---
22 files changed, 95 insertions(+), 126 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 783acab..00b9a49 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -966,7 +966,7 @@ gjs_array_from_flat_gvalue_array(JSContext *context,
if (result) {
JSObject *jsarray;
- jsarray = JS_NewArrayObject(context, length, elems.begin());
+ jsarray = JS_NewArrayObject(context, elems);
value.setObjectOrNull(jsarray);
}
@@ -2567,8 +2567,7 @@ gjs_object_from_g_hash (JSContext *context,
true))
goto out;
- if (!JS_DefineProperty(context, obj, keyutf8, valjs,
- NULL, NULL, JSPROP_ENUMERATE))
+ if (!JS_DefineProperty(context, obj, keyutf8, valjs, JSPROP_ENUMERATE))
goto out;
g_free(keyutf8);
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 97dcbc2..fa11d9a 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -862,8 +862,8 @@ define_boxed_class_fields (JSContext *context,
bool result;
result = JS_DefineProperty(context, proto, field_name, JS::NullHandleValue,
- boxed_field_getter, boxed_field_setter,
- JSPROP_PERMANENT | JSPROP_SHARED);
+ JSPROP_PERMANENT | JSPROP_SHARED,
+ boxed_field_getter, boxed_field_setter);
g_base_info_unref ((GIBaseInfo *)field);
@@ -1175,7 +1175,7 @@ gjs_define_boxed_class(JSContext *context,
JS::RootedValue value(context,
JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context, priv->gtype)));
JS_DefineProperty(context, constructor, "$gtype", value,
- NULL, NULL, JSPROP_PERMANENT);
+ JSPROP_PERMANENT);
}
JSObject*
diff --git a/gi/enumeration.cpp b/gi/enumeration.cpp
index f4b901e..051ffa2 100644
--- a/gi/enumeration.cpp
+++ b/gi/enumeration.cpp
@@ -68,7 +68,6 @@ gjs_define_enum_value(JSContext *context,
JS::RootedValue value_js(context, JS::NumberValue(value_val));
if (!JS_DefineProperty(context, in_object,
fixed_name, value_js,
- NULL, NULL,
GJS_MODULE_PROP_FLAGS)) {
gjs_throw(context, "Unable to define enumeration value %s %" G_GINT64_FORMAT " (no memory most
likely)",
fixed_name, value_val);
@@ -108,8 +107,7 @@ gjs_define_enum_values(JSContext *context,
gtype = g_registered_type_info_get_g_type((GIRegisteredTypeInfo*)info);
JS::RootedValue value(context,
JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context, gtype)));
- JS_DefineProperty(context, in_object, "$gtype", value,
- NULL, NULL, JSPROP_PERMANENT);
+ JS_DefineProperty(context, in_object, "$gtype", value, JSPROP_PERMANENT);
return true;
}
@@ -191,7 +189,6 @@ gjs_define_enumeration(JSContext *context,
JS::RootedValue v_enum(context, JS::ObjectValue(*enum_obj));
if (!JS_DefineProperty(context, in_object, enum_name, v_enum,
- NULL, NULL,
GJS_MODULE_PROP_FLAGS)) {
gjs_throw(context, "Unable to define enumeration property (no memory most likely)");
return false;
diff --git a/gi/function.cpp b/gi/function.cpp
index 8f8d5f1..8dffc5d 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -87,7 +87,7 @@ gjs_callback_trampoline_unref(GjsCallbackTrampoline *trampoline)
if (!trampoline->is_vfunc) {
JS_BeginRequest(context);
- JS_RemoveValueRoot(context, trampoline->js_function.unsafeGet());
+ JS::RemoveValueRoot(context, &trampoline->js_function);
JS_EndRequest(context);
}
@@ -292,8 +292,7 @@ gjs_callback_closure(ffi_cif *cif,
if (!JS_CallFunctionValue(context,
this_object,
rooted_function,
- n_jsargs,
- jsargs.begin(),
+ jsargs,
&rval)) {
goto out;
}
@@ -455,7 +454,7 @@ gjs_callback_trampoline_new(JSContext *context,
g_base_info_ref((GIBaseInfo*)trampoline->info);
trampoline->js_function = function;
if (!is_vfunc)
- JS_AddValueRoot(context, trampoline->js_function.unsafeGet());
+ JS::AddValueRoot(context, &trampoline->js_function);
/* Analyze param types and directions, similarly to init_cached_function_data */
n_args = g_callable_info_get_n_args(trampoline->info);
@@ -1279,9 +1278,7 @@ release:
*js_rval = return_values[0];
} else {
JSObject *array;
- array = JS_NewArrayObject(context,
- function->js_out_argc,
- &return_values[0]);
+ array = JS_NewArrayObject(context, return_values);
if (array == NULL) {
failed = true;
} else {
@@ -1746,10 +1743,7 @@ gjs_define_function(JSContext *context,
g_assert_not_reached ();
}
- /* COMPAT: JS_DefineProperty is overloaded to take JS::HandleObject in 31 */
- JS::RootedValue v_function(context, JS::ObjectValue(*function));
- if (!JS_DefineProperty(context, in_object, name, v_function,
- NULL, NULL,
+ if (!JS_DefineProperty(context, in_object, name, function,
GJS_MODULE_PROP_FLAGS)) {
gjs_debug(GJS_DEBUG_GFUNCTION, "Failed to define function");
function = NULL;
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 197709a..8b0679d 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -732,8 +732,7 @@ gjs_define_fundamental_class(JSContext *context,
JS::RootedValue value(context,
JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context, gtype)));
- JS_DefineProperty(context, constructor, "$gtype", value,
- NULL, NULL, JSPROP_PERMANENT);
+ JS_DefineProperty(context, constructor, "$gtype", value, JSPROP_PERMANENT);
return true;
}
diff --git a/gi/interface.cpp b/gi/interface.cpp
index 631eef0..ee844cb 100644
--- a/gi/interface.cpp
+++ b/gi/interface.cpp
@@ -227,8 +227,7 @@ gjs_define_interface_class(JSContext *context,
JS::RootedValue value(context,
JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context, priv->gtype)));
- JS_DefineProperty(context, constructor, "$gtype", value,
- NULL, NULL, JSPROP_PERMANENT);
+ JS_DefineProperty(context, constructor, "$gtype", value, JSPROP_PERMANENT);
return true;
}
diff --git a/gi/object.cpp b/gi/object.cpp
index 05871ce..4525d34 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -98,6 +98,8 @@ static volatile gint pending_idle_toggles;
GJS_DEFINE_PRIV_FROM_JS(ObjectInstance, gjs_object_instance_class)
+static JS::Heap<JSObject *> *ensure_heap_wrapper(GObject *gobj);
+
static JSObject* peek_js_obj (GObject *gobj);
static void set_js_obj (GObject *gobj,
JSObject *obj);
@@ -1065,10 +1067,7 @@ wrapped_gobj_toggle_notify(gpointer data,
G_OBJECT_TYPE_NAME(gobj));
}
if (is_sweeping) {
- JSObject *object;
-
- object = peek_js_obj(gobj);
- if (JS_IsAboutToBeFinalized(&object)) {
+ if (JS_IsAboutToBeFinalized(ensure_heap_wrapper(gobj))) {
/* Ouch, the JS object is dead already. Disassociate the GObject
* and hope the GObject dies too.
*/
@@ -1708,9 +1707,9 @@ emit_func(JSContext *context,
g_value_init(value, signal_query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE);
if ((signal_query.param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE) != 0)
- failed = !gjs_value_to_g_value_no_copy(context, argv.handleOrUndefinedAt(i + 1), value);
+ failed = !gjs_value_to_g_value_no_copy(context, argv.get(i + 1), value);
else
- failed = !gjs_value_to_g_value(context, argv.handleOrUndefinedAt(i + 1), value);
+ failed = !gjs_value_to_g_value(context, argv.get(i + 1), value);
if (failed)
break;
@@ -1965,7 +1964,7 @@ gjs_define_object_class(JSContext *context,
JS::RootedValue value(context,
JS::ObjectValue(*gjs_gtype_create_gtype_wrapper(context, gtype)));
JS_DefineProperty(context, constructor, "$gtype", value,
- NULL, NULL, JSPROP_PERMANENT);
+ JSPROP_PERMANENT);
}
static void
@@ -2428,10 +2427,11 @@ gjs_object_constructor (GType type,
construct_properties[i].value,
construct_properties[i].pspec);
- JS::RootedValue argv(context, JS::ObjectValue(*props_hash));
- object = JS_New(context, constructor, 1, argv.address());
+ JS::AutoValueArray<1> args(context);
+ args[0].set(JS::ObjectValue(*props_hash));
+ object = JS_New(context, constructor, args);
} else {
- object = JS_New(context, constructor, 0, NULL);
+ object = JS_New(context, constructor, JS::HandleValueArray::empty());
}
if (!object)
@@ -2611,7 +2611,7 @@ gjs_object_custom_init(GTypeInstance *instance,
JS::RootedValue r(context);
if (!JS_CallFunctionValue(context, object, v,
- 0, NULL, &r))
+ JS::HandleValueArray::empty(), &r))
gjs_log_exception(context);
}
diff --git a/gi/param.cpp b/gi/param.cpp
index baa7960..aefdc3a 100644
--- a/gi/param.cpp
+++ b/gi/param.cpp
@@ -239,8 +239,7 @@ gjs_define_param_class(JSContext *context,
JS::RootedValue value(context,
JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context, G_TYPE_PARAM)));
- JS_DefineProperty(context, constructor, "$gtype", value,
- NULL, NULL, JSPROP_PERMANENT);
+ JS_DefineProperty(context, constructor, "$gtype", value, JSPROP_PERMANENT);
info = (GIObjectInfo*)g_irepository_find_by_gtype(g_irepository_get_default(), G_TYPE_PARAM);
gjs_object_define_static_methods(context, constructor, G_TYPE_PARAM, info);
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 2767e82..6606ef1 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -122,7 +122,6 @@ resolve_namespace_object(JSContext *context,
the override module looks for namespaces that import this */
JS::RootedValue v_namespace(context, JS::ObjectValue(*gi_namespace));
if (!JS_DefineProperty(context, repo_obj, ns_name, v_namespace,
- NULL, NULL,
GJS_MODULE_PROP_FLAGS))
g_error("no memory to define ns property");
@@ -132,9 +131,7 @@ resolve_namespace_object(JSContext *context,
if (!override.isNull() &&
!JS_CallFunctionValue (context, gi_namespace, /* thisp */
override, /* callee */
- 0, /* argc */
- NULL, /* argv */
- &result))
+ JS::HandleValueArray::empty(), &result))
return false;
gjs_debug(GJS_DEBUG_GNAMESPACE,
@@ -356,7 +353,6 @@ gjs_define_constant(JSContext *context,
if (JS_DefineProperty(context, in_object,
name, value,
- NULL, NULL,
GJS_MODULE_PROP_FLAGS))
ret = true;
diff --git a/gi/union.cpp b/gi/union.cpp
index bdedaa7..29da5dd 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -376,8 +376,7 @@ gjs_define_union_class(JSContext *context,
JS::RootedValue value(context,
JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context, gtype)));
- JS_DefineProperty(context, constructor, "$gtype", value,
- NULL, NULL, JSPROP_PERMANENT);
+ JS_DefineProperty(context, constructor, "$gtype", value, JSPROP_PERMANENT);
return true;
}
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index ebb6ba3..49c19fa 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -250,9 +250,7 @@ byte_array_length_setter(JSContext *context,
byte_array_ensure_array(priv);
- // COMPAT: Indexing JS::CallArgs should provide a handle in mozjs31
- JS::RootedValue arg(context, args[0]);
- if (!gjs_value_to_gsize(context, arg, &len)) {
+ if (!gjs_value_to_gsize(context, args[0], &len)) {
gjs_throw(context,
"Can't set ByteArray length to non-integer");
return false;
diff --git a/gjs/context.cpp b/gjs/context.cpp
index c255926..29ef9ad 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -172,8 +172,7 @@ gjs_log_error(JSContext *context,
JS_RestoreExceptionState(context, exc_state);
}
- /* COMPAT: JS::CallArgs::operator[] will yield Handle in mozjs31 */
- gjs_log_exception_full(context, argv.handleOrUndefinedAt(0), jstr);
+ gjs_log_exception_full(context, argv[0], jstr);
JS_EndRequest(context);
argv.rval().setUndefined();
@@ -441,7 +440,6 @@ gjs_context_constructed(GObject *object)
JS::RootedValue v_global(js_context->context, JS::ObjectValue(*global));
if (!JS_DefineProperty(js_context->context, global,
"window", v_global,
- NULL, NULL,
JSPROP_READONLY | JSPROP_PERMANENT))
g_error("No memory to export global object as 'window'");
@@ -721,8 +719,9 @@ gjs_context_define_string_array(GjsContext *js_context,
GError **error)
{
JSAutoCompartment ac(js_context->context, js_context->global);
+ JS::RootedObject global_root(js_context->context, js_context->global);
if (!gjs_define_string_array(js_context->context,
- js_context->global,
+ global_root,
array_name, array_length, array_values,
JSPROP_READONLY | JSPROP_PERMANENT)) {
gjs_log_exception(js_context->context);
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 7d1342f..47be2da 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -406,8 +406,7 @@ get_array_from_js_value(JSContext *context,
g_return_val_if_fail(out_array != NULL, false);
g_return_val_if_fail(*out_array == NULL, false);
- JS::RootedObject js_array(context, &value.toObject());
- if (!JS_IsArrayObject(context, js_array)) {
+ if (!JS_IsArrayObject(context, value)) {
g_critical("Returned object from is not an array");
return false;
}
@@ -417,6 +416,7 @@ get_array_from_js_value(JSContext *context,
* preallocate to. */
GArray *c_side_array = g_array_new(true, true, array_element_size);
u_int32_t js_array_len;
+ JS::RootedObject js_array(context, &value.toObject());
if (element_clear_func)
g_array_set_clear_func(c_side_array, element_clear_func);
@@ -472,12 +472,11 @@ get_executed_lines_for(JSContext *context,
{
GArray *array = NULL;
JS::RootedValue rval(context);
+ JS::AutoValueArray<1> args(context);
+ args[0].set(filename_value);
- /* Removing const with cast is OK because the function arguments are not
- * mutated in JS_CallFunction */
if (!JS_CallFunctionName(context, coverage_statistics, "getExecutedLinesFor",
- 1, (JS::Value *) filename_value.address(),
- &rval)) {
+ args, &rval)) {
gjs_log_exception(context);
return NULL;
}
@@ -585,12 +584,11 @@ get_functions_for(JSContext *context,
{
GArray *array = NULL;
JS::RootedValue rval(context);
+ JS::AutoValueArray<1> args(context);
+ args[0].set(filename_value);
- /* Removing const with cast is OK because the function arguments are not
- * mutated in JS_CallFunction */
if (!JS_CallFunctionName(context, coverage_statistics, "getFunctionsFor",
- 1, (JS::Value *) filename_value.address(),
- &rval)) {
+ args, &rval)) {
gjs_log_exception(context);
return NULL;
}
@@ -714,13 +712,12 @@ get_branches_for(JSContext *context,
JS::HandleValue filename_value)
{
GArray *array = NULL;
+ JS::AutoValueArray<1> args(context);
+ args[0].set(filename_value);
JS::RootedValue rval(context);
- /* Removing const with cast is OK because the function arguments are not
- * mutated in JS_CallFunction */
if (!JS_CallFunctionName(context, coverage_statistics, "getBranchesFor",
- 1, (JS::Value *) filename_value.address(),
- &rval)) {
+ args, &rval)) {
gjs_log_exception(context);
return NULL;
}
@@ -855,7 +852,7 @@ get_covered_files(GjsCoverage *coverage)
uint32_t n_files;
if (!JS_CallFunctionName(context, rooted_priv, "getCoveredFiles",
- 0, NULL, &rval)) {
+ JS::HandleValueArray::empty(), &rval)) {
gjs_log_exception(context);
return NULL;
}
@@ -1013,8 +1010,7 @@ gjs_serialize_statistics(GjsCoverage *coverage)
JS::RootedValue string_value_return(js_runtime);
if (!JS_CallFunctionName(js_context, rooted_priv, "stringify",
- 0,
- NULL,
+ JS::HandleValueArray::empty(),
&string_value_return)) {
gjs_log_exception(js_context);
return NULL;
@@ -1169,8 +1165,7 @@ coverage_statistics_has_stale_cache(GjsCoverage *coverage)
JS::RootedObject rooted_priv(js_context, priv->coverage_statistics);
JS::RootedValue stale_cache_value(js_context);
if (!JS_CallFunctionName(js_context, rooted_priv, "staleCache",
- 0,
- NULL,
+ JS::HandleValueArray::empty(),
&stale_cache_value)) {
gjs_log_exception(js_context);
g_error("Failed to call into javascript to get stale cache value. This is a bug");
@@ -1378,8 +1373,7 @@ coverage_get_file_modification_time(JSContext *context,
goto out;
if (gjs_get_path_mtime(filename, &mtime)) {
- JS::RootedObject mtime_values_array(runtime,
- JS_NewArrayObject(context, 0, NULL));
+ JS::RootedObject mtime_values_array(runtime, JS_NewArrayObject(context, 0));
if (!JS_DefineElement(context, mtime_values_array, 0, JS::Int32Value(mtime.tv_sec), NULL, NULL, 0))
goto out;
if (!JS_DefineElement(context, mtime_values_array, 1, JS::Int32Value(mtime.tv_usec), NULL, NULL, 0))
@@ -1493,10 +1487,8 @@ gjs_run_script_in_coverage_compartment(GjsCoverage *coverage,
JSContext *js_context = (JSContext *) gjs_context_get_native_context(priv->context);
JSAutoCompartment ac(js_context, priv->coverage_statistics);
JS::RootedValue rval(js_context);
- if (!gjs_eval_with_scope(js_context,
- priv->coverage_statistics,
- script,
- strlen(script),
+ JS::RootedObject rooted_priv(js_context, priv->coverage_statistics);
+ if (!gjs_eval_with_scope(js_context, rooted_priv, script, strlen(script),
"<coverage_modifier>",
&rval)) {
gjs_log_exception(js_context);
@@ -1521,8 +1513,7 @@ gjs_inject_value_into_coverage_compartment(GjsCoverage *coverage,
JS::RootedObject coverage_global_scope(JS_GetRuntime(js_context),
JS_GetGlobalForObject(js_context, priv->coverage_statistics));
- if (!JS_SetProperty(js_context, coverage_global_scope, property,
- value)) {
+ if (!JS_SetProperty(js_context, coverage_global_scope, property, value)) {
g_warning("Failed to set property %s to requested value", property);
return false;
}
@@ -1568,7 +1559,8 @@ bootstrap_coverage(GjsCoverage *coverage)
JS::CompartmentOptions options;
options.setVersion(JSVERSION_LATEST);
JS::RootedObject debugger_compartment(JS_GetRuntime(context),
- JS_NewGlobalObject(context, &coverage_global_class, NULL,
options));
+ JS_NewGlobalObject(context, &coverage_global_class, NULL,
+ JS::FireOnNewGlobalHook, options));
{
JSAutoCompartment compartment(context, debugger_compartment);
JS::RootedObject debuggeeWrapper(context, debuggee);
@@ -1655,15 +1647,13 @@ bootstrap_coverage(GjsCoverage *coverage)
/* Now create the array to pass the desired prefixes over */
JSObject *prefixes = gjs_build_string_array(context, -1, priv->prefixes);
- JS::Value coverage_statistics_constructor_arguments[] = {
- JS::ObjectValue(*prefixes),
- cache_value.get()
- };
+ JS::AutoValueArray<2> coverage_statistics_constructor_args(context);
+ coverage_statistics_constructor_args[0].setObject(*prefixes);
+ coverage_statistics_constructor_args[1].set(cache_value);
JSObject *coverage_statistics = JS_New(context,
coverage_statistics_constructor,
- 2,
- coverage_statistics_constructor_arguments);
+ coverage_statistics_constructor_args);
if (!coverage_statistics) {
gjs_throw(context, "Failed to create coverage_statitiscs object");
@@ -1741,9 +1731,7 @@ gjs_clear_js_side_statistics_from_coverage_object(GjsCoverage *coverage)
JS::RootedObject rooted_priv(js_context, priv->coverage_statistics);
JS::RootedValue rval(JS_GetRuntime(js_context));
if (!JS_CallFunctionName(js_context, rooted_priv, "deactivate",
- 0,
- NULL,
- &rval)) {
+ JS::HandleValueArray::empty(), &rval)) {
gjs_log_exception(js_context);
g_error("Failed to deactivate debugger - this is a fatal error");
}
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index b58124d..eadd80d 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -74,7 +74,6 @@ define_meta_properties(JSContext *context,
JS::RootedValue file_val(context,
JS::StringValue(JS_NewStringCopyZ(context, full_path)));
if (!JS_DefineProperty(context, module_obj, "__file__", file_val,
- NULL, NULL,
/* don't set ENUMERATE since we wouldn't want to copy
* this symbol to any other object for example.
*/
@@ -91,7 +90,6 @@ define_meta_properties(JSContext *context,
if (!JS_DefineProperty(context, module_obj,
"__moduleName__", module_name_val,
- NULL, NULL,
/* don't set ENUMERATE since we wouldn't want to copy
* this symbol to any other object for example.
*/
@@ -100,7 +98,6 @@ define_meta_properties(JSContext *context,
if (!JS_DefineProperty(context, module_obj,
"__parentModule__", parent_module_val,
- NULL, NULL,
/* don't set ENUMERATE since we wouldn't want to copy
* this symbol to any other object for example.
*/
@@ -138,7 +135,6 @@ define_import(JSContext *context,
{
JS::RootedValue module_val(context, JS::ObjectValue(*module_obj));
if (!JS_DefineProperty(context, obj, name, module_val,
- NULL, NULL,
GJS_MODULE_PROP_FLAGS & ~JSPROP_PERMANENT)) {
gjs_debug(GJS_DEBUG_IMPORTER,
"Failed to define '%s' in importer",
@@ -264,6 +260,7 @@ import_file(JSContext *context,
GError *error = NULL;
JS::CompileOptions options(context);
+ JS::RootedValue ignored(context);
if (!(g_file_load_contents(file, NULL, &script, &script_len, NULL, &error))) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY) &&
@@ -281,7 +278,7 @@ import_file(JSContext *context,
full_path = g_file_get_parse_name (file);
if (!gjs_eval_with_scope(context, module_obj, script, script_len,
- full_path, NULL))
+ full_path, &ignored))
goto out;
ret = true;
@@ -492,9 +489,7 @@ do_import(JSContext *context,
JS::RootedValue obj_val(context);
if (JS_GetProperty(context, module_obj, name, &obj_val)) {
if (!obj_val.isUndefined() &&
- JS_DefineProperty(context, obj,
- name, obj_val,
- NULL, NULL,
+ JS_DefineProperty(context, obj, name, obj_val,
GJS_MODULE_PROP_FLAGS & ~JSPROP_PERMANENT)) {
result = true;
goto out;
@@ -758,7 +753,13 @@ importer_new_enumerate(JSContext *context,
g_free(dirname);
}
- statep.get().setPrivate(iter);
+ /* FIXME: setPrivate() is not in js::MutableValueOperations (see
+ * Value.h) and now SpiderMonkey is stricter with const for
+ * Handle::get(); how to do this correctly? This code might allow
+ * statep_private to get GC'd before going into statep. */
+ JS::Value statep_private;
+ statep_private.setPrivate(iter);
+ statep.set(statep_private);
idp.set(INT_TO_JSID(iter->elements->len));
@@ -1074,7 +1075,6 @@ gjs_define_importer(JSContext *context,
JS::RootedValue v_importer(context, JS::ObjectValue(*importer));
if (!JS_DefineProperty(context, in_object, importer_name, v_importer,
- NULL, NULL,
GJS_MODULE_PROP_FLAGS))
g_error("no memory to define importer property");
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 559cfec..9db3833 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -106,17 +106,19 @@ gjs_init_class_dynamic(JSContext *context,
if (static_fs && !JS_DefineFunctions(context, constructor, static_fs))
goto out;
- if (!JS_DefineProperty(context, constructor, "prototype", JS::ObjectValue(*prototype),
- JS_PropertyStub, JS_StrictPropertyStub, JSPROP_PERMANENT | JSPROP_READONLY))
+ if (!JS_DefineProperty(context, constructor, "prototype", prototype,
+ JSPROP_PERMANENT | JSPROP_READONLY,
+ JS_PropertyStub, JS_StrictPropertyStub))
goto out;
- if (!JS_DefineProperty(context, prototype, "constructor", JS::ObjectValue(*constructor),
- JS_PropertyStub, JS_StrictPropertyStub, 0))
+ if (!JS_DefineProperty(context, prototype, "constructor", constructor,
+ 0, JS_PropertyStub, JS_StrictPropertyStub))
goto out;
/* The constructor defined by JS_InitClass has no property attributes, but this
is a more useful default for gjs */
- if (!JS_DefineProperty(context, in_object, class_name, JS::ObjectValue(*constructor),
- JS_PropertyStub, JS_StrictPropertyStub, GJS_MODULE_PROP_FLAGS))
+ if (!JS_DefineProperty(context, in_object, class_name, constructor,
+ GJS_MODULE_PROP_FLAGS,
+ JS_PropertyStub, JS_StrictPropertyStub))
goto out;
res = true;
diff --git a/gjs/jsapi-util-args.h b/gjs/jsapi-util-args.h
index 87f7901..3229350 100644
--- a/gjs/jsapi-util-args.h
+++ b/gjs/jsapi-util-args.h
@@ -246,8 +246,7 @@ parse_call_args_helper(JSContext *cx,
}
try {
- /* COMPAT: JS::CallArgs::operator[] will yield Handle in mozjs31 */
- assign(cx, *fchar, nullable, args.handleOrUndefinedAt(param_ix), param_ref);
+ assign(cx, *fchar, nullable, args[param_ix], param_ref);
} catch (char *message) {
/* Our error messages are going to be more useful than whatever was
* thrown by the various conversion functions */
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index 7f194e6..bea2694 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -76,10 +76,11 @@ gjs_throw_valist(JSContext *context,
JS::RootedObject constructor(context);
JS::RootedObject global(context, JS::CurrentGlobalOrNull(context));
- JS::RootedValue v_constructor(context), v_message(context), new_exc(context);
+ JS::RootedValue v_constructor(context), new_exc(context);
+ JS::AutoValueArray<1> error_args(context);
result = false;
- if (!gjs_string_from_utf8(context, s, -1, &v_message)) {
+ if (!gjs_string_from_utf8(context, s, -1, error_args[0])) {
JS_ReportError(context, "Failed to copy exception string");
goto out;
}
@@ -92,7 +93,7 @@ gjs_throw_valist(JSContext *context,
/* throw new Error(message) */
constructor = &v_constructor.toObject();
- new_exc.setObjectOrNull(JS_New(context, constructor, 1, v_message.address()));
+ new_exc.setObjectOrNull(JS_New(context, constructor, error_args));
JS_SetPendingException(context, new_exc);
result = true;
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index e8338ef..db643ff 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -91,7 +91,7 @@ gjs_init_context_standard (JSContext *context,
compartment_options.setVersion(JSVERSION_LATEST);
global.set(JS_NewGlobalObject(context, &global_class, NULL,
- compartment_options));
+ JS::FireOnNewGlobalHook, compartment_options));
if (global == NULL)
return false;
@@ -317,7 +317,7 @@ gjs_build_string_array(JSContext *context,
elems.append(element);
}
- return JS_NewArrayObject(context, elems.length(), &elems[0]);
+ return JS_NewArrayObject(context, elems);
}
JSObject*
@@ -335,8 +335,7 @@ gjs_define_string_array(JSContext *context,
if (array != NULL) {
JS::RootedValue v_array(context, JS::ObjectValue(*array));
- if (!JS_DefineProperty(context, in_object, array_name, v_array,
- NULL, NULL, attrs))
+ if (!JS_DefineProperty(context, in_object, array_name, v_array, attrs))
array = NULL;
}
@@ -864,7 +863,7 @@ gjs_eval_with_scope(JSContext *context,
JS::CompileOptions options(context);
options.setUTF8(true)
.setFileAndLine(filename, start_line_number)
- .setSourcePolicy(JS::CompileOptions::LAZY_SOURCE);
+ .setSourceIsLazy(true);
if (!JS::Evaluate(context, eval_obj, options, script, script_len, retval))
return false;
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 6fc7fa1..bfc274c 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -224,7 +224,7 @@ gjs_##cname##_create_proto(JSContext *context, \
return JS::NullValue(); \
} \
if (!JS_DefineProperty(context, module, proto_name, \
- rval, NULL, NULL, GJS_MODULE_PROP_FLAGS)) \
+ rval, GJS_MODULE_PROP_FLAGS)) \
return JS::NullValue(); \
if (gtype != G_TYPE_NONE) { \
JS::RootedObject rval_obj(context, &rval.toObject()); \
@@ -232,7 +232,7 @@ gjs_##cname##_create_proto(JSContext *context, \
JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context, \
gtype))); \
JS_DefineProperty(context, rval_obj, "$gtype", value, \
- NULL, NULL, JSPROP_PERMANENT); \
+ JSPROP_PERMANENT); \
} \
} \
return rval; \
@@ -267,7 +267,7 @@ gjs_##name##_constructor(JSContext *context, \
gjs_throw_constructor_error(context); \
return false; \
} \
- object = JS_NewObjectForConstructor(context, &gjs_##name##_class, vp); \
+ object = JS_NewObjectForConstructor(context, &gjs_##name##_class, argv); \
if (object == NULL) \
return false; \
}
diff --git a/gjs/stack.cpp b/gjs/stack.cpp
index c99201f..7dba9b1 100644
--- a/gjs/stack.cpp
+++ b/gjs/stack.cpp
@@ -63,7 +63,8 @@ gjs_context_get_frame_info(JSContext *context,
error_id, &constructor))
return false;
- JS::RootedObject err_obj(context, JS_New(context, constructor, 0, NULL));
+ JS::RootedObject err_obj(context, JS_New(context, constructor,
+ JS::HandleValueArray::empty()));
if (!stack.empty() &&
!gjs_object_get_property_const(context, err_obj, GJS_STRING_STACK,
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index d239624..cf5efa5 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -82,7 +82,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
cfunc(cr, &arg1, &arg2); \
if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) { \
JS::RootedObject array(context, \
- JS_NewArrayObject(context, 0, NULL)); \
+ JS_NewArrayObject(context, JS::HandleValueArray::empty())); \
if (!array) \
return false; \
JS::RootedValue r(context, JS::NumberValue(arg1)); \
@@ -100,7 +100,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
cfunc(cr, &arg1, &arg2); \
if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) { \
JS::RootedObject array(context, \
- JS_NewArrayObject(context, 0, NULL)); \
+ JS_NewArrayObject(context, JS::HandleValueArray::empty())); \
if (!array) \
return false; \
JS::RootedValue r(context, JS::NumberValue(arg1)); \
@@ -118,7 +118,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
cfunc(cr, &arg1, &arg2, &arg3, &arg4); \
{ \
JS::RootedObject array(context, \
- JS_NewArrayObject(context, 0, NULL)); \
+ JS_NewArrayObject(context, JS::HandleValueArray::empty())); \
if (!array) \
return false; \
JS::RootedValue r(context, JS::NumberValue(arg1)); \
diff --git a/modules/system.cpp b/modules/system.cpp
index 462bfdd..c76afc6 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -180,16 +180,16 @@ gjs_js_define_system_stuff(JSContext *context,
if (!JS_DefineProperty(context, module,
"programInvocationName",
value,
+ GJS_MODULE_PROP_FLAGS | JSPROP_READONLY,
JS_PropertyStub,
- JS_StrictPropertyStub,
- GJS_MODULE_PROP_FLAGS | JSPROP_READONLY))
+ JS_StrictPropertyStub))
goto out;
if (!JS_DefineProperty(context, module,
"version", gjs_version,
+ GJS_MODULE_PROP_FLAGS | JSPROP_READONLY,
JS_PropertyStub,
- JS_StrictPropertyStub,
- GJS_MODULE_PROP_FLAGS | JSPROP_READONLY))
+ JS_StrictPropertyStub))
goto out;
retval = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]