[gjs/wip/ptomato/mozjs38: 4/4] WIP - stuff



commit 3b27543eea4f219ac460d65bf4499b5eaeeaf121
Author: Philip Chimento <philip endlessm com>
Date:   Fri Jan 6 17:35:06 2017 -0800

    WIP - stuff

 configure.ac        |    2 +-
 gjs/byteArray.cpp   |   19 +++++++++--------
 gjs/context.cpp     |    4 +-
 gjs/importer.cpp    |   52 ++++++++++++++++++++------------------------------
 gjs/jsapi-wrapper.h |    2 +-
 5 files changed, 35 insertions(+), 44 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 84adfe7..61ae200 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,7 +58,7 @@ GOBJECT_INTROSPECTION_REQUIRE([1.41.4])
 
 GOBJECT_REQUIREMENT="gobject-2.0 >= glib_required_version"
 gjs_base_packages="$GOBJECT_REQUIREMENT gio-2.0"
-common_packages="gthread-2.0 gio-2.0 >= glib_required_version mozjs-31"
+common_packages="gthread-2.0 gio-2.0 >= glib_required_version mozjs-38"
 gjs_packages="gobject-introspection-1.0 libffi $common_packages"
 gjs_cairo_packages="cairo cairo-gobject $common_packages"
 gjs_gtk_packages="gtk+-3.0 >= 3.20"
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 78e6a18..f60d4bf 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -57,13 +57,13 @@ struct JSClass gjs_byte_array_class = {
     "ByteArray",
     JSCLASS_HAS_PRIVATE |
     JSCLASS_BACKGROUND_FINALIZE,
-    JS_PropertyStub,
-    JS_DeletePropertyStub,
+    NULL,  /* addProperty */
+    NULL,  /* deleteProperty */
     (JSPropertyOp)byte_array_get_prop,
     (JSStrictPropertyOp)byte_array_set_prop,
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub,
+    NULL,  /* enumerate */
+    NULL,  /* resolve */
+    NULL,  /* convert */
     byte_array_finalize
 };
 
@@ -531,7 +531,7 @@ byte_array_new(JSContext *context)
 
     JS::RootedObject proto(context, byte_array_get_prototype(context));
     JS::RootedObject array(context,
-        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto, JS::NullPtr()));
+        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto));
 
     priv = g_slice_new0(ByteArrayInstance);
 
@@ -607,8 +607,9 @@ from_string_func(JSContext *context,
         GError *error;
         const char16_t *u16_chars;
         gsize u16_len;
+        JS::AutoCheckCannotGC nogc;
 
-        u16_chars = JS_GetStringCharsAndLength(context, argv[0].toString(), &u16_len);
+        u16_chars = JS_GetTwoByteStringCharsAndLength(context, nogc, argv[0].toString(), &u16_len);
         if (u16_chars == NULL)
             return false;
 
@@ -741,7 +742,7 @@ gjs_byte_array_from_byte_array (JSContext *context,
 
     JS::RootedObject proto(context, byte_array_get_prototype(context));
     JS::RootedObject object(context,
-        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto, JS::NullPtr()));
+        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto));
 
     if (!object) {
         gjs_throw(context, "failed to create byte array");
@@ -829,7 +830,7 @@ gjs_define_byte_array_stuff(JSContext              *context,
 {
     JSObject *prototype;
 
-    module.set(JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
+    module.set(JS_NewObject(context, NULL));
 
     prototype = JS_InitClass(context, module, JS::NullPtr(),
                              &gjs_byte_array_class,
diff --git a/gjs/context.cpp b/gjs/context.cpp
index f57aece..80fcc9e 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -369,7 +369,7 @@ static void
 gjs_context_tracer(JSTracer *trc, void *data)
 {
     GjsContext *gjs_context = reinterpret_cast<GjsContext *>(data);
-    JS_CallHeapObjectTracer(trc, &gjs_context->global, "GJS global object");
+    JS_CallObjectTracer(trc, &gjs_context->global, "GJS global object");
 }
 
 static void
@@ -488,7 +488,7 @@ gjs_context_constructed(GObject *object)
     if (!JS_DefineFunctions(js_context->context, global, &global_funcs[0]))
         g_error("Failed to define properties on the global object");
 
-    js_context->global.set(global);
+    js_context->global = global;
     JS_AddExtraGCRootsTracer(js_context->runtime, gjs_context_tracer, js_context);
 
     gjs_define_constructor_proxy_factory(js_context->context);
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index f0f8877..f9fd8d6 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -313,12 +313,6 @@ import_native_file(JSContext       *context,
                              GJS_MODULE_PROP_FLAGS);
 }
 
-static JSObject *
-create_module_object(JSContext *context)
-{
-    return JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr());
-}
-
 static bool
 import_file(JSContext       *context,
             const char      *name,
@@ -380,14 +374,13 @@ load_module_init(JSContext       *context,
         }
     }
 
-    JS::RootedObject module_obj(context, create_module_object(context));
+    JS::RootedObject module_obj(context, JS_NewObject(context, NULL));
     file = g_file_new_for_commandline_arg(full_path);
     if (!import_file (context, "__init__", file, module_obj))
         goto out;
 
     if (!JS_DefinePropertyById(context, in_object,
-                               module_init_name, JS::ObjectValue(*module_obj),
-                               NULL, NULL,
+                               module_init_name, module_obj,
                                GJS_MODULE_PROP_FLAGS & ~JSPROP_PERMANENT))
         goto out;
 
@@ -444,7 +437,7 @@ import_file_on_module(JSContext       *context,
     bool retval = false;
     char *full_path = NULL;
 
-    JS::RootedObject module_obj(context, create_module_object(context));
+    JS::RootedObject module_obj(context, JS_NewObject(context, NULL));
 
     if (!define_import(context, obj, module_obj, name))
         goto out;
@@ -712,11 +705,11 @@ importer_iterator_free(ImporterIterator *iter)
  *
  */
 static bool
-importer_new_enumerate(JSContext  *context,
-                       JS::HandleObject object,
-                       JSIterateOp enum_op,
-                       JS::MutableHandleValue statep,
-                       JS::MutableHandleId idp)
+importer_enumerate(JSContext             *context,
+                   JS::HandleObject       object,
+                   JSIterateOp            enum_op,
+                   JS::MutableHandleValue statep,
+                   JS::MutableHandleId    idp)
 {
     ImporterIterator *iter;
 
@@ -883,10 +876,10 @@ importer_new_enumerate(JSContext  *context,
  * if id was resolved.
  */
 static bool
-importer_new_resolve(JSContext *context,
-                     JS::HandleObject obj,
-                     JS::HandleId id,
-                     JS::MutableHandleObject objp)
+importer_resolve(JSContext              *context,
+                 JS::HandleObject        obj,
+                 JS::HandleId            id,
+                 JS::MutableHandleObject objp)
 {
     Importer *priv;
     char *name;
@@ -949,16 +942,14 @@ importer_finalize(JSFreeOp *fop,
  */
 struct JSClass gjs_importer_class = {
     "GjsFileImporter",
-    JSCLASS_HAS_PRIVATE |
-    JSCLASS_NEW_RESOLVE |
-    JSCLASS_NEW_ENUMERATE,
-    JS_PropertyStub,
-    JS_DeletePropertyStub,
-    JS_PropertyStub,
-    JS_StrictPropertyStub,
-    (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,
+    JSCLASS_HAS_PRIVATE,
+    NULL,  /* addProperty */
+    NULL,  /* deleteProperty */
+    NULL,  /* getProperty */
+    NULL,  /* setProperty */
+    importer_enumerate,
+    importer_resolve,
+    NULL,  /* convert */
     importer_finalize
 };
 
@@ -1015,7 +1006,7 @@ importer_new(JSContext *context,
     }
 
     JS::RootedObject importer(context,
-        JS_NewObject(context, &gjs_importer_class, JS::NullPtr(), global));
+        JS_NewObject(context, &gjs_importer_class, global));
     if (importer == NULL)
         g_error("No memory to create importer importer");
 
@@ -1192,7 +1183,6 @@ gjs_define_root_importer_object(JSContext        *context,
         gjs_context_get_const_string(context, GJS_STRING_IMPORTS));
     if (!JS_DefinePropertyById(context, in_object,
                                imports_name, importer,
-                               NULL, NULL,
                                GJS_MODULE_PROP_FLAGS)) {
         gjs_debug(GJS_DEBUG_IMPORTER, "DefineProperty imports on %p failed",
                   in_object.get());
diff --git a/gjs/jsapi-wrapper.h b/gjs/jsapi-wrapper.h
index f4f57e2..1b3cb3e 100644
--- a/gjs/jsapi-wrapper.h
+++ b/gjs/jsapi-wrapper.h
@@ -35,6 +35,6 @@
 #pragma GCC system_header
 #endif
 #include <jsapi.h>
-#include <js/OldDebugAPI.h>  /* Needed by some bits */
+#include <js/Conversions.h>
 
 #endif  /* GJS_JSAPI_WRAPPER_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]