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



commit 9bdfa0b3876d86a78810c951072dd64f504a60a6
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 a8c307f..9d6ba4b 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]