PageRenderTime 1416ms CodeModel.GetById 1411ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Objective-J/CommonJS/lib/objective-j/loader.js

http://github.com/cacaodev/cappuccino
JavaScript | 24 lines | 17 code | 6 blank | 1 comment | 2 complexity | 474d95bacb6c61e6d9ac6fdf16d85f92 MD5 | raw file
 1
 2function ObjectiveJLoader() {
 3    var loader = {};
 4    var factories = {};
 5    
 6    loader.reload = function(topId, path) {
 7        if (!global.ObjectiveJ) 
 8            global.ObjectiveJ = require("objective-j");
 9        
10        //print("loading objective-j: " + topId + " (" + path + ")");
11        factories[topId] = ObjectiveJ.make_narwhal_factory(path);
12        factories[topId].path = path;
13    }
14    
15    loader.load = function(topId, path) {
16        if (!factories.hasOwnProperty(topId))
17            loader.reload(topId, path);
18        return factories[topId];
19    }
20    
21    return loader;
22};
23
24require.loader.loaders.unshift([".j", ObjectiveJLoader()]);