majorly cleaned up the CoffeeScript that defines the Narwhal integration

This commit is contained in:
Jeremy Ashkenas
2009-12-24 23:28:01 -08:00
parent 2d57ee693b
commit 7a0de52c96
4 changed files with 83 additions and 90 deletions

View File

@@ -1,23 +1,20 @@
(function(){
// This (javascript) file is generated from lib/coffee_script/narwhal/loader.cs
var coffeescript = null;
var CoffeeScriptLoader = function() {
var loader = {
};
var factories = {
};
loader.reload = function(topId, path) {
coffeescript = coffeescript || require('coffee-script');
// print("loading objective-j: " + topId + " (" + path + ")");
factories[topId] = coffeescript.make_narwhal_factory(path);
return factories[topId];
};
loader.load = function(topId, path) {
if (!(factories.hasOwnProperty(topId))) {
loader.reload(topId, path);
}
return factories[topId];
};
return loader;
var factories = {
};
require.loader.loaders.unshift([".cs", CoffeeScriptLoader()]);
var loader = {
// Reload the coffee-script environment from source.
reload: function(topId, path) {
coffeescript = coffeescript || require('coffee-script');
factories[topId] = coffeescript.makeNarwhalFactory(path);
return factories[topId];
},
// Ensure that the coffee-script environment is loaded.
load: function(topId, path) {
return factories[topId] = factories[topId] || this.reload(topId, path);
}
};
require.loader.loaders.unshift([".cs", loader]);
})();