[gjs/wip/require: 2/6] bootstrap: Hack up the native import system to work well with the trad one



commit 497aae6c426dc5caa533b5ad6eae48281d7929f1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jun 16 10:52:45 2015 -0700

    bootstrap: Hack up the native import system to work well with the trad one

 modules/bootstrap.js |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/modules/bootstrap.js b/modules/bootstrap.js
index 77d167d..dba61ce 100644
--- a/modules/bootstrap.js
+++ b/modules/bootstrap.js
@@ -1,13 +1,33 @@
-(function(exports, importNativeModule) {
+(function(exports, _importNativeModule) {
     "use strict";
 
+    let _exports = {};
+
+    // This is where "unknown namespace" classes live, where we don't
+    // have info for them. One common example is GLocalFile.
+    _exports['gi/__gjsPrivateNS'] = {};
+
+    function importNativeModule(moduleID) {
+        if (!_exports[moduleID])
+            _exports[moduleID] = _importNativeModule(moduleID);
+
+        return _exports[moduleID];
+    }
+
     const Importer = importNativeModule('_importer');
     const Gio = Importer.importGIModule('Gio', '2.0');
 
-    let _exports = {};
-
     function loadNativeModule(moduleID) {
-        _exports[moduleID] = importNativeModule(moduleID);
+        // _exports[moduleID] = importNativeModule(moduleID);
+
+        // XXX: In order to not double-register modules, we need
+        // to do this. As soon as we implement the importer on
+        // top of the new system, revert this.
+
+        try {
+            _exports[moduleID] = imports[moduleID];
+        } catch(e) {
+        }
     }
 
     function runOverridesForGIModule(module, moduleID) {


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