[gjs: 17/21] global: Lazy-define standard environment



commit efc297c0c3b085ff74e79c3871f8fd4cdb6ff193
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Jun 1 12:30:53 2019 -0700

    global: Lazy-define standard environment
    
    In SpiderMonkey 68, using lazy-define for the standard global properties
    will be the only option, since JS_InitStandardClasses() will go away.
    This should not change anything, only that global properties such as
    String and Number will be defined on demand instead of in advance.

 gjs/global.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gjs/global.cpp b/gjs/global.cpp
index 5e90da46..0214bf85 100644
--- a/gjs/global.cpp
+++ b/gjs/global.cpp
@@ -210,18 +210,20 @@ gjs_printerr(JSContext *context,
 }
 
 class GjsGlobal {
+    // clang-format off
     static constexpr JSClassOps class_ops = {
         nullptr,  // addProperty
         nullptr,  // deleteProperty
         nullptr,  // enumerate
-        nullptr,  // newEnumerate
-        nullptr,  // resolve
-        nullptr,  // mayResolve
+        JS_NewEnumerateStandardClasses,
+        JS_ResolveStandardClass,
+        JS_MayResolveStandardClass,
         nullptr,  // finalize
         nullptr,  // call
         nullptr,  // hasInstance
         nullptr,  // construct
         JS_GlobalObjectTraceHook};
+    // clang-format on
 
     static constexpr JSClass klass = {
         "GjsGlobal",
@@ -250,8 +252,7 @@ class GjsGlobal {
 
         JSAutoCompartment ac(cx, global);
 
-        if (!JS_InitStandardClasses(cx, global) ||
-            !JS_InitReflectParse(cx, global) ||
+        if (!JS_InitReflectParse(cx, global) ||
             !JS_DefineDebuggerObject(cx, global))
             return nullptr;
 


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