[gjs/wip/ptomato/jasper-imports: 6/6] WIP - fix



commit b9a3c335350b165d4a2c6690024027f4e69e9add
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Jan 24 00:08:18 2017 -0800

    WIP - fix

 gjs/coverage.cpp     |   14 +++++++++-----
 modules/bootstrap.js |   19 +++++++++++++------
 2 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 3304141..d03d011 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -25,7 +25,6 @@
 
 #include "coverage.h"
 #include "coverage-internal.h"
-#include "importer.h"
 #include "jsapi-util-args.h"
 #include "util/error.h"
 
@@ -1557,9 +1556,13 @@ gjs_wrap_root_importer_in_compartment(JSContext *context,
 {
     JSAutoRequest ar(context);
     JSAutoCompartment ac(context, compartment);
-    JS::RootedValue importer (JS_GetRuntime(context),
-                              gjs_get_global_slot(context,
-                                                  GJS_GLOBAL_SLOT_IMPORTS));
+
+    JS::RootedValue importer(context);
+    JS::RootedObject global(context, gjs_get_import_global(context));
+    {
+        JSAutoCompartment ac(context, global);
+        JS_GetProperty(context, global, "imports", &importer);
+    }
 
     g_assert (!importer.isUndefined());
 
@@ -1631,7 +1634,8 @@ bootstrap_coverage(GjsCoverage *coverage)
         /* Now copy the global root importer (which we just created,
          * if it didn't exist) to our global object
          */
-        if (!gjs_define_root_importer_object(context, debugger_compartment, wrapped_importer)) {
+        if (!JS_DefineProperty(context, debugger_compartment, "imports",
+                               wrapped_importer, GJS_MODULE_PROP_FLAGS)) {
             gjs_throw(context, "Failed to set 'imports' on debugger compartment");
             return false;
         }
diff --git a/modules/bootstrap.js b/modules/bootstrap.js
index 7e27a5f..d2606c3 100644
--- a/modules/bootstrap.js
+++ b/modules/bootstrap.js
@@ -54,12 +54,20 @@
             return module;
         }
 
+        function defineMetaProperties(module, parent, name) {
+            module.__moduleName__ = name;
+            module.__parentModule__ = parent;
+            if (!parent || !parent.__modulePath__)
+                module.__modulePath__ = name;
+            else
+                module.__modulePath__ = parent.__modulePath__ + '.' + name;
+        }
+
         function importFile(parent, name, file) {
             let module = {};
             parent[name] = module;
             module.__file__ = file.get_parse_name();
-            module.__moduleName__ = name;
-            module.__parentModule__ = parent;
+            defineMetaProperties(module, parent, name);
             importModule(module, file);
         }
 
@@ -75,9 +83,7 @@
             let module = createSearchPathImporter();
             parent[name] = module;
             module.searchPath = searchPath;
-            module.__moduleName__ = name;
-            module.__parentModule__ = parent;
-
+            defineMetaProperties(module, parent, name);
             tryImport(module, '__init__');
         }
 
@@ -123,13 +129,14 @@
 
         let rootDirectoryImporter = createSearchPathImporter();
         rootDirectoryImporter.searchPath = Importer.getBuiltinSearchPath();
+        defineMetaProperties(rootDirectoryImporter, null, null);
 
         // root importer, checks for native modules
         let rootImporter = new Proxy(rootDirectoryImporter, {
             get: function(target, name) {
                 if (!target[name])
                     target[name] = importNativeModule(name);
-                if (!target[name])
+                if (!target.hasOwnProperty(name))
                     target[name] = rootDirectoryImporter[name];
                 return target[name];
             },


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