Removed now unecessary CommonJS files.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2010-01-29 16:37:53 -08:00
1 parent 02cb054b71
commit 79cd8603a2
5 files changed
+28 -119

No files matched your search

+20 -107
View File
@@ -1,5 +1,5 @@
var FILE = require("file");
var FILE = require("file");
var window = exports.window = require("browser/window");
if (system.engine === "rhino")
@@ -11,10 +11,11 @@ if (system.engine === "rhino")
// setup OBJJ_HOME, OBJJ_INCLUDE_PATHS, etc
window.OBJJ_HOME = exports.OBJJ_HOME = FILE.resolve(module.path, "..");
var frameworksPath = FILE.resolve(window.OBJJ_HOME, "Frameworks/"),
objectivejPath = FILE.resolve(frameworksPath, "Objective-J/", "CommonJS.environment/", "Objective-J.js");
var frameworksPath = FILE.resolve(window.OBJJ_HOME, "Frameworks/");
var OBJJ_INCLUDE_PATHS = window.OBJJ_INCLUDE_PATHS = exports.OBJJ_INCLUDE_PATHS = [];
var OBJJ_INCLUDE_PATHS = global.OBJJ_INCLUDE_PATHS = exports.OBJJ_INCLUDE_PATHS = [frameworksPath];
#include "Includes.js"
// Find all narwhal packages with Objective-J frameworks.
exports.objj_frameworks = [];
@@ -62,51 +63,6 @@ if (system.env["OBJJ_INCLUDE_PATHS"])
// TODO: somehow make window object the top scope?
with (window)
{
var objectivejSource = FILE.read(objectivejPath, { charset:"UTF-8" });
// read and eval Objective-J.js with the module's scope
if (system.engine === "rhino")
Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(window, objectivejSource, objectivejPath, 0, null);
else
eval(objectivejSource);
// export desired variables. must eval variable name to obtain a reference.
[
"objj_preprocess",
"FRAGMENT_FILE", "FRAGMENT_LOCAL",
"MARKER_CODE", "MARKER_IMPORT_STD", "MARKER_IMPORT_LOCAL",
"OBJJ_PREPROCESSOR_DEBUG_SYMBOLS",
"objj_data",
"CPPropertyListCreateData", "CPPropertyListCreateFromData",
"kCFPropertyListXMLFormat_v1_0", "kCFPropertyList280NorthFormat_v1_0",
"objj_dictionary"
].forEach(function(v) {
exports[v] = eval(v);
});
// extra macros
exports.SET_CONTEXT = function(aFragment, aContext) { aFragment.context = aContext; }
exports.GET_CONTEXT = function(aFragment) { return aFragment.context; }
exports.SET_TYPE = function(aFragment, aType) { aFragment.type = aType; }
exports.GET_TYPE = function(aFragment) { return aFragment.type; }
exports.GET_CODE = function(aFragment) { return aFragment.info; }
exports.SET_CODE = function(aFragment, aCode) { aFragment.info = aCode; }
exports.GET_PATH = function(aFragment) { return aFragment.info; }
exports.SET_PATH = function(aFragment, aPath) { aFragment.info = aPath; }
exports.GET_BUNDLE = function(aFragment) { return aFragment.bundle; }
exports.SET_BUNDLE = function(aFragment, aBundle) { aFragment.bundle = aBundle; }
exports.GET_FILE = function(aFragment) { return aFragment.file; }
exports.SET_FILE = function(aFragment, aFile) { aFragment.file = aFile; }
exports.IS_FILE = function(aFragment) { return (aFragment.type & FRAGMENT_FILE); }
exports.IS_LOCAL = function(aFragment) { return (aFragment.type & FRAGMENT_LOCAL); }
exports.IS_IMPORT = function(aFragment) { return (aFragment.type & FRAGMENT_IMPORT); }
// runs the objj repl or file provided in args
exports.run = function(args)
{
@@ -120,10 +76,10 @@ exports.run = function(args)
var arg0 = argv.shift();
var mainFilePath = FILE.canonical(arg0);
objj_import(mainFilePath, YES, function() {
if (typeof main === "function")
main([arg0].concat(argv));
});
exports.make_narwhal_factory(mainFilePath)(require, { }, module, system, print, window);
if (typeof main === "function")
main([arg0].concat(argv));
require("browser/timeout").serviceTimeouts();
}
@@ -148,63 +104,20 @@ exports.run = function(args)
}
}
// synchronously evals Objective-J code
var objj_eval = exports.objj_eval = function(code)
{
if (system.engine === "rhino")
var result = Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(window, objj_preprocess_sync(code), "objj_eval", 0, null);
else
var result = eval(objj_preprocess_sync(code));
//require("browser/timeout").serviceTimeouts();
return result;
}
// prepocesses Objective-J code into JavaScript, which will perform imports synchronously when eval'd
window.objj_preprocess_sync = function(code, path)
{
var fragments = objj_preprocess(code, new objj_bundle(), new objj_file(), OBJJ_PREPROCESSOR_DEBUG_SYMBOLS)
var preprocessed = [];
fragments.forEach(function(fragment) {
if (fragment.type & FRAGMENT_CODE)
preprocessed.push(fragment.info);
else if (fragment.type & FRAGMENT_LOCAL)
preprocessed.push("objj_import_sync('"+(path ? FILE.join(FILE.dirname(path), fragment.info) : fragment.info)+"',YES);");
else
preprocessed.push("objj_import_sync('"+fragment.info+"',NO);");
});
return preprocessed.join("\n");
}
// FIXME: Why does this need to be global?
// synchronously perform an import
window.objj_import_sync = function(pathOrPaths, isLocal)
{
var context = new objj_context();
context.pushFragment(fragment_create_file(pathOrPaths, new objj_bundle(), isLocal, NULL));
context.evaluate();
// HACK: need a real synchronous require
// FIXME: this is bad. not really synchronous. shouldn't have to call serviceTimeouts.
require("browser/timeout").serviceTimeouts();
}
Executable.setCommonJSParameters("require", "exports", "module", "system", "print", "window");
// creates a narwhal factory function in the objj module scope
exports.make_narwhal_factory = function(code, path) {
var OBJJ_CURRENT_BUNDLE = new objj_bundle();
var factoryText = "function(require,exports,module,system,print){" + objj_preprocess_sync(code, path) + "/**/\n}";
exports.make_narwhal_factory = function(path)
{
return function(require, exports, module, system, print)
{
Executable.setCommonJSArguments(require, exports, module, system, print, window);
if (system.engine === "rhino")
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, factoryText, path, 0, null);
// eval requires parenthesis, but parenthesis break compileFunction.
else
return eval("(" + factoryText + ")");
fileImporterForPath(path)(FILE.basename(path), function()
{
print("all done");
});
}
}
} // end "with"
@@ -1,8 +1,7 @@
var FILE = require("file"),
OS = require("os"),
objj = require("objective-j"),
ObjectiveJ = require("objective-j/core");
ObjectiveJ = require("objective-j");
require("objective-j/rhino/regexp-rhino-patch");
@@ -12,8 +11,8 @@ var OBJJ_PREPROCESSOR_PREPROCESS = exports.OBJJ_PREPROCESSOR_PREPROCESS
var OBJJ_PREPROCESSOR_COMPRESS = exports.OBJJ_PREPROCESSOR_COMPRESS = 1 << 11;
var OBJJ_PREPROCESSOR_SYNTAX = exports.OBJJ_PREPROCESSOR_SYNTAX = 1 << 12;
var SHRINKSAFE_PATH = FILE.join(objj.OBJJ_HOME, "shrinksafe", "shrinksafe.jar"),
RHINO_PATH = FILE.join(objj.OBJJ_HOME, "shrinksafe", "js.jar")
var SHRINKSAFE_PATH = FILE.join(ObjectiveJ.OBJJ_HOME, "shrinksafe", "shrinksafe.jar"),
RHINO_PATH = FILE.join(ObjectiveJ.OBJJ_HOME, "shrinksafe", "js.jar");
var compressor = null;
@@ -1,4 +0,0 @@
var window = require("browser/window");
#include "Includes.js"
@@ -8,8 +8,10 @@ var FILE = require("file"),
CLOBBER = require("jake/clean").CLOBBER,
base64 = require("base64"),
environment = require("objective-j/jake/environment"),
CFPropertyList = require("objective-j/core").CFPropertyList,
CFMutableDictionary = require("objective-j/core").CFMutableDictionary;
ObjectiveJ = require("objective-j");
var CFPropertyList = require("objective-j").CFPropertyList,
CFMutableDictionary = require("objective-j").CFMutableDictionary;
var Task = Jake.Task,
filedir = Jake.filedir;
+1 -2
View File
@@ -5,8 +5,7 @@
var FILE = require("file"),
SYSTEM = require("system"),
CFPropertyList = require("objective-j/core").CFPropertyList;
CFPropertyList = require("objective-j").CFPropertyList;
var DefaultDictionary = nil,
DefaultConfiguration = nil,