Added loader.js

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I
2009-09-26 01:31:52 -07:00
parent 72d4675ec4
commit ef41abec97
2 changed files with 26 additions and 2 deletions
@@ -0,0 +1,23 @@
var objj = null;
function ObjectiveJLoader() {
var loader = {};
var factories = {};
loader.reload = function(topId, path) {
if (!objj) objj = require("objj/objj");
//print("loading objective-j: " + topId + " (" + path + ")");
factories[topId] = objj.make_narwhal_factory(system.fs.read(path), path);
}
loader.load = function(topId, path) {
if (!factories.hasOwnProperty(topId))
loader.reload(topId, path);
return factories[topId];
}
return loader;
};
require.loader.loaders.unshift([".j", ObjectiveJLoader()]);
@@ -2,9 +2,10 @@
"name": "objective-j",
"dependencies": ["narwhal", "jack", "browserjs"],
"lib": "lib-js",
"author": "280 North, Inc. (http://280north.com/)",
"description": "Objective-J module",
"preload": ["objective-j/loader"],
"description": "Objective-J and Cappuccino module",
"keywords": ["objective-j", "objj", "objective j", "cappuccino"],
"author": "280 North, Inc. (http://280north.com/)",
"contributors": [
"Francisco Tolmasky (http://tolmasky.com/)",
"Ross Boucher (http://rossboucher.com/)",