[gjs/wip/ptomato/mozjs31: 11/11] WIP - stuff
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31: 11/11] WIP - stuff
- Date: Thu, 20 Oct 2016 21:29:21 +0000 (UTC)
commit a89863a184f293a2fef5b62ceaa47e70bcb50f9f
Author: Philip Chimento <philip chimento gmail com>
Date: Wed Oct 5 21:44:25 2016 -0700
WIP - stuff
gjs/byteArray.cpp | 37 +++++++++++++++++--------------------
gjs/context.cpp | 9 ++++-----
gjs/jsapi-util-args.h | 3 +--
gjs/jsapi-util.h | 2 +-
4 files changed, 23 insertions(+), 28 deletions(-)
---
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index e1e5c38..831e8c8 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;
@@ -770,9 +768,9 @@ gjs_byte_array_from_bytes (JSContext *context,
g_return_val_if_fail(context != NULL, NULL);
g_return_val_if_fail(bytes != 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;
@@ -855,13 +853,12 @@ bool
gjs_define_byte_array_stuff(JSContext *context,
JSObject **module_out)
{
- JSObject *module;
JSObject *prototype;
-
- module = JS_NewObject (context, NULL, NULL, NULL);
+ JS::RootedObject module(context,
+ JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
prototype = JS_InitClass(context, module,
- NULL,
+ 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/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 e835299..9ca4db9 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -264,7 +264,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]