[gjs/wip/ptomato/mozjs31: 12/12] WIP - stuff
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31: 12/12] WIP - stuff
- Date: Fri, 21 Oct 2016 00:30:00 +0000 (UTC)
commit 98900c3d744d83289edf25200d586df5c8bd47c6
Author: Philip Chimento <philip chimento gmail com>
Date: Wed Oct 5 21:44:25 2016 -0700
WIP - stuff
gjs/byteArray.cpp | 31 ++++++++++++++-----------------
gjs/context.cpp | 9 ++++-----
gjs/importer.cpp | 9 +--------
gjs/jsapi-util-args.h | 3 +--
gjs/jsapi-util.h | 2 +-
5 files changed, 21 insertions(+), 33 deletions(-)
---
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 9b5e235..5f3586d 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -64,8 +64,7 @@ struct JSClass gjs_byte_array_class = {
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
- byte_array_finalize,
- JSCLASS_NO_OPTIONAL_MEMBERS
+ byte_array_finalize
};
bool
@@ -201,7 +200,7 @@ byte_array_get_prop(JSContext *context,
return true; /* prototype, not an instance. */
JS::RootedValue id_value(context);
- if (!JS_IdToValue(context, id, id_value.address()))
+ if (!JS_IdToValue(context, id, &id_value))
return false;
/* First handle array indexing */
@@ -251,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;
@@ -310,7 +307,7 @@ byte_array_set_prop(JSContext *context,
return true; /* prototype, not an instance. */
JS::RootedValue id_value(context);
- if (!JS_IdToValue(context, id, id_value.address()))
+ if (!JS_IdToValue(context, id, &id_value))
return false;
/* First handle array indexing */
@@ -534,9 +531,9 @@ byte_array_new(JSContext *context)
{
ByteArrayInstance *priv;
+ JS::RootedObject proto(context, byte_array_get_prototype(context));
JS::RootedObject array(context,
- JS_NewObject(context, &gjs_byte_array_class,
- byte_array_get_prototype(context), NULL));
+ JS_NewObject(context, &gjs_byte_array_class, proto, JS::NullPtr()));
priv = g_slice_new0(ByteArrayInstance);
@@ -664,13 +661,14 @@ from_array_func(JSContext *context,
priv->array = gjs_g_byte_array_new(0);
- if (!JS_IsArrayObject(context, &argv[0].toObject())) {
+ JS::RootedObject array_obj(context, &argv[0].toObject());
+ if (!JS_IsArrayObject(context, array_obj)) {
gjs_throw(context,
"byteArray.fromArray() called with non-array as first arg");
return false;
}
- if (!JS_GetArrayLength(context, &argv[0].toObject(), &len)) {
+ if (!JS_GetArrayLength(context, array_obj, &len)) {
gjs_throw(context,
"byteArray.fromArray() can't get length of first array arg");
return false;
@@ -683,7 +681,7 @@ from_array_func(JSContext *context,
guint8 b;
elem = JS::UndefinedValue();
- if (!JS_GetElement(context, &argv[0].toObject(), i, elem.address())) {
+ if (!JS_GetElement(context, array_obj, i, &elem)) {
/* this means there was an exception, while elem.isUndefined()
* means no element found
*/
@@ -743,9 +741,9 @@ gjs_byte_array_from_byte_array (JSContext *context,
g_return_val_if_fail(context != NULL, NULL);
g_return_val_if_fail(array != NULL, NULL);
+ JS::RootedObject proto(context, byte_array_get_prototype(context));
JS::RootedObject object(context,
- JS_NewObject(context, &gjs_byte_array_class,
- byte_array_get_prototype(context), NULL));
+ JS_NewObject(context, &gjs_byte_array_class, proto, JS::NullPtr()));
if (!object) {
gjs_throw(context, "failed to create byte array");
return NULL;
@@ -832,10 +830,9 @@ gjs_define_byte_array_stuff(JSContext *context,
{
JSObject *prototype;
- module.set(JS_NewObject(context, NULL, NULL, NULL));
+ module.set(JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
- prototype = JS_InitClass(context, module,
- NULL,
+ prototype = JS_InitClass(context, module, JS::NullPtr(),
&gjs_byte_array_class,
gjs_byte_array_constructor,
0,
diff --git a/gjs/context.cpp b/gjs/context.cpp
index af4b1ec..61938e1 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -339,7 +339,7 @@ gjs_context_dispose(GObject *object)
JS_BeginRequest(js_context->context);
- JS_RemoveObjectRoot(js_context->context, js_context->global.unsafeGet());
+ JS::RemoveObjectRoot(js_context->context, &js_context->global);
js_context->global.set(NULL);
/* Do a full GC here before tearing down, since once we do
@@ -437,7 +437,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'");
@@ -445,8 +444,8 @@ gjs_context_constructed(GObject *object)
g_error("Failed to define properties on the global object");
js_context->global.set(global);
- JS_AddNamedObjectRoot(js_context->context, js_context->global.unsafeGet(),
- "global object");
+ JS::AddNamedObjectRoot(js_context->context, &js_context->global,
+ "global object");
/* We create the global-to-runtime root importer with the
* passed-in search path. If someone else already created
@@ -763,7 +762,7 @@ gjs_object_get_property_const(JSContext *cx,
JS::MutableHandleValue value_p)
{
JS::RootedId pname(cx, gjs_context_get_const_string(cx, property_name));
- return JS_GetPropertyById(cx, obj, pname, value_p.address());
+ return JS_GetPropertyById(cx, obj, pname, value_p);
}
/**
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index dcdebe3..fd23979 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -75,7 +75,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.
*/
@@ -92,7 +91,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.
*/
@@ -101,7 +99,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.
*/
@@ -139,7 +136,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",
@@ -516,7 +512,6 @@ do_import(JSContext *context,
if (!obj_val.isUndefined() &&
JS_DefineProperty(context, obj,
name, obj_val,
- NULL, NULL,
GJS_MODULE_PROP_FLAGS & ~JSPROP_PERMANENT)) {
result = true;
goto out;
@@ -924,8 +919,7 @@ struct JSClass gjs_importer_class = {
(JSEnumerateOp) importer_new_enumerate, /* needs cast since it's the new enumerate signature */
(JSResolveOp) importer_new_resolve, /* needs cast since it's the new resolve signature */
JS_ConvertStub,
- importer_finalize,
- JSCLASS_NO_OPTIONAL_MEMBERS
+ importer_finalize
};
JSPropertySpec gjs_importer_proto_props[] = {
@@ -1104,7 +1098,6 @@ gjs_define_importer(JSContext *context,
if (!JS_DefineProperty(context, in_object,
importer_name, JS::ObjectValue(*importer),
- NULL, NULL,
GJS_MODULE_PROP_FLAGS))
g_error("no memory to define importer property");
diff --git a/gjs/jsapi-util-args.h b/gjs/jsapi-util-args.h
index a3bad22..2e0cf95 100644
--- a/gjs/jsapi-util-args.h
+++ b/gjs/jsapi-util-args.h
@@ -245,8 +245,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.h b/gjs/jsapi-util.h
index b406570..1a29cce 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -265,7 +265,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; \
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]