diff --git a/Foundation/Jakefile b/Foundation/Jakefile index 472478a16..a6bd966dd 100644 --- a/Foundation/Jakefile +++ b/Foundation/Jakefile @@ -9,15 +9,20 @@ $BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, "Foundation"); task ("build", ["Foundation"]); -framework ("Foundation", function(foundationTask) +framework ("Foundation", function(FoundationTask) { - foundationTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Foundation.build", $CONFIGURATION)) - foundationTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION)); + FoundationTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Foundation.build", $CONFIGURATION)) + FoundationTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION)); - foundationTask.setIdentifier("com.280n.Foundation"); - foundationTask.setLicense(BundleTask.License.LGPL_v2_1); - foundationTask.setSources(FILE.glob("**/*.j").concat(FILE.glob("*.j")));//terrible! - foundationTask.setResources(FILE.glob("Resources/*")); + FoundationTask.setIdentifier("com.280n.Foundation"); + FoundationTask.setLicense(BundleTask.License.LGPL_v2_1); + FoundationTask.setSources(FILE.glob("**/*.j").concat(FILE.glob("*.j")));//terrible! + FoundationTask.setResources(FILE.glob("Resources/*")); + + if ($CONFIGURATION === "Release") + FoundationTask.setCompilerFlags("-O"); + else + FoundationTask.setCompilerFlags("-DDEBUG -g"); }); //CLOBBER.include($ENVIRONMENT_PRODUCT) diff --git a/Jakefile b/Jakefile index fa36e88ab..e479bfe8e 100644 --- a/Jakefile +++ b/Jakefile @@ -7,7 +7,7 @@ var FILE = require("file"), require(FILE.absolute("common.jake")); -var subprojects = ["External", "Objective-J", "Foundation", "AppKit", "Tools", "External/ojunit"]; +var subprojects = [/*"External", */"Objective-J", "Foundation", "AppKit", "Tools", "External/ojunit"]; ["build", "clean", "clobber"].forEach(function(/*String*/ aTaskName) { diff --git a/Objective-J/CommonJS/Jakefile b/Objective-J/CommonJS/Jakefile index 806ded5bd..11ccdda9e 100644 --- a/Objective-J/CommonJS/Jakefile +++ b/Objective-J/CommonJS/Jakefile @@ -4,14 +4,20 @@ var FILE = require("file"); require("../../common.jake"); -$COMMON_JS_PRODUCT = FILE.join($BUILD_DIR, "objective-j"); +$COMMONJS_PRODUCT = FILE.join($BUILD_DIR, $CONFIGURATION, "objective-j"), +$COMMONJS_OBJECTIVE_J_PRODUCT = FILE.join($COMMONJS_PRODUCT, "lib", "Frameworks", "Objective-J"); -task ("build", [$COMMON_JS_PRODUCT]); +task ("build", [$COMMONJS_PRODUCT, $COMMONJS_OBJECTIVE_J_PRODUCT]); -filedir ($COMMON_JS_PRODUCT, FILE.glob("objective-j/**/*"), function() +filedir ($COMMONJS_PRODUCT, FILE.glob("objective-j/**/*"), function() { - rm_rf($COMMON_JS_PRODUCT); - cp_r('objective-j', $COMMON_JS_PRODUCT); + rm_rf($COMMONJS_PRODUCT); + cp_r('objective-j', $COMMONJS_PRODUCT); +}); + +filedir ($COMMONJS_OBJECTIVE_J_PRODUCT, function() +{ + cp_r(FILE.join($BUILD_DIR, $CONFIGURATION, "Objective-J"), $COMMONJS_OBJECTIVE_J_PRODUCT); }); //CLOBBER.include($ENVIRONMENT_OBJJ_PRODUCT) diff --git a/Objective-J/CommonJS/objective-j/lib-js/objective-j.js b/Objective-J/CommonJS/objective-j/lib-js/objective-j.js new file mode 100644 index 000000000..7add2575d --- /dev/null +++ b/Objective-J/CommonJS/objective-j/lib-js/objective-j.js @@ -0,0 +1,183 @@ +var file = require("file"), + readline = require("readline").readline; + +var window = require("browser/window"); +window.isRhino = true + +if (window.isRhino) { + window.__parent__ = null; + window.__proto__ = global; +} + +// setup OBJJ_HOME, OBJJ_INCLUDE_PATHS, etc +window.OBJJ_HOME = exports.OBJJ_HOME = file.resolve(module.path, ".."); + +var frameworksPath = file.resolve(window.OBJJ_HOME, "lib/", "Frameworks/"), + objectivejPath = file.resolve(frameworksPath, "Objective-J/", "rhino.platform/", "Objective-J.js"); + +window.OBJJ_INCLUDE_PATHS = [frameworksPath]; +if (system.env["OBJJ_INCLUDE_PATHS"]) + window.OBJJ_INCLUDE_PATHS = system.env["OBJJ_INCLUDE_PATHS"].split(":").concat(window.OBJJ_INCLUDE_PATHS); + +// bring the "window" object into scope. +// TODO: somehow make window object the top scope? +with (window) +{ + // read and eval Objective-J.js with the module's scope + if (window.isRhino) + Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(window, file.read(objectivejPath, { charset:"UTF-8" }), "Objective-J.js", 0, null); + else + eval(file.read(objectivejPath, { charset:"UTF-8" })); + + // 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); } + +/* + objj_set_evaluator(function(code) { + return function(OBJJ_CURRENT_BUNDLE) { + with (window) { + return eval("function(OBJJ_CURRENT_BUNDLE){"+code+"}"); + } + } + }); +*/ + +// runs the objj repl or file provided in args +exports.run = function(args) +{ + args = args || []; + window.args = args; + + // FIXME: ARGS + args.shift(); + + if (args.length > 0) + { + while (args.length && args[0].indexOf('-I') === 0) + OBJJ_INCLUDE_PATHS = args.shift().substr(2).split(':').concat(OBJJ_INCLUDE_PATHS); + + var mainFilePath = file.canonical(args.shift()); + + objj_import(mainFilePath, YES, function() { + if (typeof main === "function") + main.apply(main, args); + }); + } + else + { + while (true) + { + try { + system.stdout.write("objj> ").flush(); + + var input = readline(), + result = objj_eval(input); + + if (result !== undefined) + print(result); + + } catch (e) { + print(e); + } + + require("browser/timeout").serviceTimeouts(); + } + } + + require("browser/timeout").serviceTimeouts(); +} + +// synchronously evals Objective-J code +var objj_eval = exports.objj_eval = function(code) +{ + if (window.isRhino) + 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 +var 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"); +} + +// synchronously perform an import +var 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(); +} + +// 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})"; + + if (window.isRhino) + return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, factoryText, path, 0, null); + else + return eval(factoryText); +} + +} // end "with" + +if (require.main == module.id) + exports.run(system.args); diff --git a/Objective-J/CommonJS/objective-j/lib-js/objective-j/compiler.js b/Objective-J/CommonJS/objective-j/lib-js/objective-j/compiler.js new file mode 100644 index 000000000..4aab5baa7 --- /dev/null +++ b/Objective-J/CommonJS/objective-j/lib-js/objective-j/compiler.js @@ -0,0 +1,177 @@ +var FILE = require("file"), + OS = require("os"), + objj = require("objective-j"), + objj_preprocess = objj.objj_preprocess, + IS_FILE = objj.IS_FILE, + GET_CODE = objj.GET_CODE, + IS_LOCAL = objj.IS_LOCAL, + MARKER_IMPORT_STD = objj.MARKER_IMPORT_STD, + MARKER_IMPORT_LOCAL = objj.MARKER_IMPORT_LOCAL, + MARKER_CODE = objj.MARKER_CODE, + GET_PATH = objj.GET_PATH; + +require("objective-j/rhino/regexp-rhino-patch"); + +var OBJJ_PREPROCESSOR_DEBUG_SYMBOLS = exports.OBJJ_PREPROCESSOR_DEBUG_SYMBOLS = objj.OBJJ_PREPROCESSOR_DEBUG_SYMBOLS; +var OBJJ_PREPROCESSOR_TYPE_SIGNATURES = exports.OBJJ_PREPROCESSOR_TYPE_SIGNATURES = objj.OBJJ_PREPROCESSOR_TYPE_SIGNATURES; +var OBJJ_PREPROCESSOR_PREPROCESS = exports.OBJJ_PREPROCESSOR_PREPROCESS = 1 << 10; +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") + +function compress(/*String*/ aCode, /*String*/ FIXME) +{ + // FIXME: figure out why this doesn't work on Windows/Cygwin + //var tmpFile = java.io.File.createTempFile("OBJJC", ""); + var tmpFile = new java.io.File("/tmp/" + FIXME + Math.random() + ".tmp"); + tmpFile.deleteOnExit(); + tmpFile = tmpFile.getAbsolutePath(); + + FILE.write(tmpFile, aCode, { charset:"UTF-8" }); + + return OS.command(["java", "-Dfile.encoding=UTF-8", "-classpath", [RHINO_PATH, SHRINKSAFE_PATH].join(":"), "org.dojotoolkit.shrinksafe.Main", tmpFile]); +} + +function compileWithResolvedFlags(aFilePath, objjcFlags, gccFlags) +{ + var shouldObjjPreprocess = objjcFlags & OBJJ_PREPROCESSOR_PREPROCESS, + shouldCheckSyntax = objjcFlags & OBJJ_PREPROCESSOR_SYNTAX, + shouldCompress = objjcFlags & OBJJ_PREPROCESSOR_COMPRESS; + + // GCC preprocess the file. + var gcc = OS.popen("gcc -E -x c -P " + (gccFlags ? gccFlags.join(" ") : "") + " " + aFilePath), + fileContents = "", + chunk = ""; + + while (chunk = gcc.stdout.read()) + fileContents += chunk; + + if (!shouldObjjPreprocess) + return fileContents; + + // Preprocess contents into fragments. + var fragments = objj_preprocess(fileContents, { path : "/x" }, { path: FILE.basename(aFilePath) }, objjcFlags), + preprocessed = ""; + + // Writer preprocessed fragments out. + for (var index = 0; index < fragments.length; index++) + { + var fragment = fragments[index]; + + if (IS_FILE(fragment)) + preprocessed += (IS_LOCAL(fragment) ? MARKER_IMPORT_LOCAL : MARKER_IMPORT_STD) + ';' + GET_PATH(fragment).length + ';' + GET_PATH(fragment); + else + { + var code = GET_CODE(fragment); + + if (shouldCheckSyntax) + { + try + { + new Function(GET_CODE(fragment)); + } + catch (e) + { + var lines = code.split("\n"), + PAD = 3; + + print("Syntax error in "+GET_FILE(fragment).path+ + " on preprocessed line number "+e.lineNumber+"\n"+ + "\t"+lines.slice(Math.max(0, e.lineNumber - 1 - PAD), e.lineNumber+PAD).join("\n\t")); + + OS.exit(1); + } + } + + if (shouldCompress) + { + code = compress("function(){" + code + '}', FILE.basename(aFilePath)); + + code = code.substr("function(){".length, code.length - "function(){};\n\n".length); + } + + preprocessed += MARKER_CODE + ';' + code.length + ';' + code; + } + } + + return preprocessed; +} + +function resolveFlags(args) +{ + var filePaths = [], + outputFilePaths = [], + + index = 0, + count = args.length, + + gccFlags = [], + objjcFlags = OBJJ_PREPROCESSOR_PREPROCESS | OBJJ_PREPROCESSOR_SYNTAX; + + for (; index < count; ++index) + { + var argument = args[index]; + + if (argument === "-o") + { + if (++index < count) + outputFilePaths.push(args[index]); + } + + else if (argument.indexOf("-D") === 0) + gccFlags.push(argument) + + else if (argument.indexOf("-U") === 0) + gccFlags.push(argument); + + else if (argument.indexOf("-E") === 0) + objjcFlags &= ~OBJJ_PREPROCESSOR_PREPROCESS; + + else if (argument.indexOf("-S") === 0) + objjcFlags &= ~OBJJ_PREPROCESSOR_SYNTAX; + + else if (argument.indexOf("-g") === 0) + objjcFlags |= OBJJ_PREPROCESSOR_DEBUG_SYMBOLS; + + else if (argument.indexOf("-O") === 0) + objjcFlags |= OBJJ_PREPROCESSOR_COMPRESS; + + else + filePaths.push(argument); + } + + return { filePaths:filePaths, outputFilePaths:outputFilePaths, objjcFlags:objjcFlags, gccFlags:gccFlags }; +} + +exports.compile = function(aFilePath, flags) +{ + if (flags.split) + flags = flags.split(/\s+/); + + var resolvedFlags = resolveFlags(flags); + + return compileWithResolvedFlags(aFilePath, resolvedFlags.objjcFlags, resolvedFlags.gccFlags); +} + +exports.main = function(args) +{ + // FIXME: ARGS + args.shift(); + + var resolved = resolveFlags(args), + outputFilePaths = resolved.outputFilePaths, + objjcFlags = resolved.objjFlags, + gccFlags = resolved.gccFlags; + + resolved.filePaths.forEach(function(filePath, index) + { + print("Statically Compiling " + filePath); + + FILE.write(outputFilePaths[index], compileWithResolvedFlags(filePath, objjcFlags, gccFlags), { charset: "UTF-8" }); + }); +} + +if (require.main == module.id) + exports.main(system.args); \ No newline at end of file diff --git a/Objective-J/CommonJS/objective-j/lib/objective-j/jake.js b/Objective-J/CommonJS/objective-j/lib-js/objective-j/jake.js similarity index 100% rename from Objective-J/CommonJS/objective-j/lib/objective-j/jake.js rename to Objective-J/CommonJS/objective-j/lib-js/objective-j/jake.js diff --git a/Objective-J/CommonJS/objective-j/lib/objective-j/jake/LICENSES/LGPL-v2.1 b/Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/LICENSES/LGPL-v2.1 similarity index 100% rename from Objective-J/CommonJS/objective-j/lib/objective-j/jake/LICENSES/LGPL-v2.1 rename to Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/LICENSES/LGPL-v2.1 diff --git a/Objective-J/CommonJS/objective-j/lib/objective-j/jake/LICENSES/MIT b/Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/LICENSES/MIT similarity index 100% rename from Objective-J/CommonJS/objective-j/lib/objective-j/jake/LICENSES/MIT rename to Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/LICENSES/MIT diff --git a/Objective-J/CommonJS/objective-j/lib/objective-j/jake/bundletask.js b/Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/bundletask.js similarity index 94% rename from Objective-J/CommonJS/objective-j/lib/objective-j/jake/bundletask.js rename to Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/bundletask.js index a3d150b1a..5e48733af 100644 --- a/Objective-J/CommonJS/objective-j/lib/objective-j/jake/bundletask.js +++ b/Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/bundletask.js @@ -2,9 +2,9 @@ var FILE = require("file"), OS = require("os"), Jake = require("jake"), - objj = require("objj/objj"), - objjc = require("objj/objjc"), - plist = require("objj/plist"); + objj_dictionary = require("objective-j").objj_dictionary, + compiler = require("objective-j/compiler"), + plist = require("objective-j/plist"); var Task = Jake.Task, filedir = Jake.filedir; @@ -25,6 +25,7 @@ function BundleTask(aName, anApplication) this._resources = null; this._identifier = null; this._version = 0.1; + this._compilerFlags = null; this._productName = this.name(); @@ -210,6 +211,16 @@ BundleTask.prototype.productName = function() return this._productName; } +BundleTask.prototype.setCompilerFlags = function(flags) +{ + this._compilerFlags = flags; +} + +BundleTask.prototype.compilerFlags = function() +{ + return this._compilerFlags; +} + BundleTask.prototype.setLicense = function(aLicense) { this._license = aLicense; @@ -272,7 +283,7 @@ BundleTask.prototype.packageType = function() BundleTask.prototype.infoPlist = function() { - var infoPlist = new objj.objj_dictionary(); + var infoPlist = new objj_dictionary(); //util = require("util"), infoPlist.setValue("CPBundleInfoDictionaryVersion", 6.0); infoPlist.setValue("CPBundleName", this.productName()); @@ -469,8 +480,7 @@ BundleTask.prototype.defineStaticTask = function() { print("Creating static file..."); - // No newline! - OS.system("echo -n \"@STATIC;1.0;\" > " + staticPath); + FILE.write(staticPath, "@STATIC;1.0;", { charset:"UTF-8" }); aTask.prerequisites().forEach(function(aFilename) { @@ -491,12 +501,20 @@ BundleTask.prototype.defineSourceTasks = function() if (!sources) return; + var compilerFlags = this.compilerFlags(); + + if (!compilerFlags) + compilerFlags = ""; + + else if (compilerFlags.join) + compilerFlags = compilerFlags.join(" "); + this.platforms().forEach(function(/*String*/ aPlatform) { var platformSources = sources, platformBuildIntermediatesPath = FILE.join(this.buildIntermediatesProductPath(), BundleTask.PLATFORM_DIRECTORIES[aPlatform]), staticPath = this.buildProductStaticPathForPlatform(aPlatform), - flags = BundleTask.PLATFORM_DEFAULT_FLAGS[aPlatform]; + flags = BundleTask.PLATFORM_DEFAULT_FLAGS[aPlatform].join(" "); if (!Array.isArray(platformSources)) platformSources = platformSources[aPlatform]; @@ -510,8 +528,9 @@ BundleTask.prototype.defineSourceTasks = function() var compiledPlatformSource = FILE.join(platformBuildIntermediatesPath, FILE.basename(aFilename)); filedir (compiledPlatformSource, [aFilename], function() - {//#{flags.join(' ')} #{PLATFORM_FLAGS[platform].join(' ')} - objjc.preprocess(aFilename, compiledPlatformSource, flags); + { + print("Compiling " + aFilename + "..."); + FILE.write(compiledPlatformSource, compiler.compile(aFilename, flags + " " + compilerFlags), { charset:"UTF-8" }); }); filedir (staticPath, [compiledPlatformSource]); diff --git a/Objective-J/CommonJS/objective-j/lib/objective-j/jake/frameworktask.js b/Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/frameworktask.js similarity index 100% rename from Objective-J/CommonJS/objective-j/lib/objective-j/jake/frameworktask.js rename to Objective-J/CommonJS/objective-j/lib-js/objective-j/jake/frameworktask.js diff --git a/Objective-J/CommonJS/objective-j/lib-js/objective-j/plist.js b/Objective-J/CommonJS/objective-j/lib-js/objective-j/plist.js new file mode 100644 index 000000000..119a7fe0d --- /dev/null +++ b/Objective-J/CommonJS/objective-j/lib-js/objective-j/plist.js @@ -0,0 +1,15 @@ +var file = require("file"), + objj = require("objective-j"), + CPPropertyListCreateData = objj.CPPropertyListCreateData, + kCFPropertyListXMLFormat_v1_0 = objj.kCFPropertyListXMLFormat_v1_0; + +exports.readPlist = function(path) { + var plistData = new objj.objj_data(); + plistData.string = file.read(path); + return objj.CPPropertyListCreateFromData(plistData); +} + +exports.writePlist = function(path, plist, format) { + format = format || objj.kCFPropertyListXMLFormat_v1_0; + file.write(path, objj.CPPropertyListCreateData(plist, format).string); +} diff --git a/Objective-J/CommonJS/objective-j/lib-js/objective-j/rhino/regexp-rhino-patch.js b/Objective-J/CommonJS/objective-j/lib-js/objective-j/rhino/regexp-rhino-patch.js new file mode 100644 index 000000000..c8bf0d6f3 --- /dev/null +++ b/Objective-J/CommonJS/objective-j/lib-js/objective-j/rhino/regexp-rhino-patch.js @@ -0,0 +1,73 @@ +var CachedRegexData = []; + +function regexDataFromRegex(aRegex) +{ + var source = "", + flags = ""; + + if (typeof aRegex == "string") + { + if (CachedRegexData[aRegex]) + return CachedRegexData[aRegex]; + + string = aRegex; + source = aRegex; + } + else + { + string = aRegex.toString(); + + if (CachedRegexData[string]) + return CachedRegexData[string]; + + var index = string.lastIndexOf('/'); + + source = string.substr(0, index); + flags = string.substr(index + 1); + } + + source = source.replace("\\[\\^\\\\\\d\\]", ".", "g"); + source = source.replace("\\[([^\\]]*)\\\\b([^\\]]*)\\]", "[$1\\\\cH$2]", "g") // [...\b...] -> [...\cH...] + source = source.replace("(? " + OS.enquote(path)); + OS.system("cat Runtime/header.txt > " + OS.enquote(path)); OS.system("cat " + Files.filter(function(aName) { @@ -79,32 +73,9 @@ function build_product(path, flags) }).map(function(aName) { return OS.enquote(aName); - }).join(' ') + " | gcc -E -x c -P - >> " + OS.enquote(path)); + }).join(' ') + " | gcc " + flags + " -E -x c -P - >> " + OS.enquote(path)); // rake abort if ($? != 0) } -task ("build", ["Products", "build_subprojects", $ENVIRONMENT_PRODUCT]); - -task ("clean", ["clean_suprojects"]); - -task ("clobber", ["clobber_subprojects"]); - -subprojects = ["CommonJS"]; - -task ("build_subprojects", function() -{ - subjake(subprojects, "build"); -}); - -task ("clean_suprojects", function() -{ - subjake(subprojects, "clean"); -}); - -task ("clobber_subprojects", function() -{ - subjake(subprojects, "clobber"); -}); - //CLEAN.include() no temporary files. //CLOBBER.include($PRODUCT, $ENVIRONMENT_PRODUCT); diff --git a/Objective-J/Object.j b/Objective-J/Runtime/Object.j similarity index 100% rename from Objective-J/Object.j rename to Objective-J/Runtime/Object.j diff --git a/Objective-J/bootstrap.js b/Objective-J/Runtime/bootstrap.js similarity index 100% rename from Objective-J/bootstrap.js rename to Objective-J/Runtime/bootstrap.js diff --git a/Objective-J/constants.js b/Objective-J/Runtime/constants.js similarity index 100% rename from Objective-J/constants.js rename to Objective-J/Runtime/constants.js diff --git a/Objective-J/debug.js b/Objective-J/Runtime/debug.js similarity index 100% rename from Objective-J/debug.js rename to Objective-J/Runtime/debug.js diff --git a/Objective-J/dictionary.js b/Objective-J/Runtime/dictionary.js similarity index 100% rename from Objective-J/dictionary.js rename to Objective-J/Runtime/dictionary.js diff --git a/Objective-J/evaluate.js b/Objective-J/Runtime/evaluate.js similarity index 100% rename from Objective-J/evaluate.js rename to Objective-J/Runtime/evaluate.js diff --git a/Objective-J/exception.js b/Objective-J/Runtime/exception.js similarity index 100% rename from Objective-J/exception.js rename to Objective-J/Runtime/exception.js diff --git a/Objective-J/file.js b/Objective-J/Runtime/file.js similarity index 100% rename from Objective-J/file.js rename to Objective-J/Runtime/file.js diff --git a/Objective-J/header.txt b/Objective-J/Runtime/header.txt similarity index 100% rename from Objective-J/header.txt rename to Objective-J/Runtime/header.txt diff --git a/Objective-J/json2.js b/Objective-J/Runtime/json2.js similarity index 100% rename from Objective-J/json2.js rename to Objective-J/Runtime/json2.js diff --git a/Objective-J/plist.js b/Objective-J/Runtime/plist.js similarity index 100% rename from Objective-J/plist.js rename to Objective-J/Runtime/plist.js diff --git a/Objective-J/preprocess.js b/Objective-J/Runtime/preprocess.js similarity index 100% rename from Objective-J/preprocess.js rename to Objective-J/Runtime/preprocess.js diff --git a/Objective-J/runtime.js b/Objective-J/Runtime/runtime.js similarity index 100% rename from Objective-J/runtime.js rename to Objective-J/Runtime/runtime.js diff --git a/Objective-J/utilities.js b/Objective-J/Runtime/utilities.js similarity index 100% rename from Objective-J/utilities.js rename to Objective-J/Runtime/utilities.js diff --git a/common.jake b/common.jake index dcc2ba773..c377d0343 100644 --- a/common.jake +++ b/common.jake @@ -66,11 +66,11 @@ global.$ENVIRONMENT_FRAMEWORKS_DIR = FILE.join($ENVIRONMENT_LIB_DIR, 'Frameworks global.$HOME_DIR = FILE.absolute(FILE.dirname(module.path)); global.$LICENSE_FILE = FILE.absolute(FILE.join(FILE.dirname(module.path), 'LICENSE')); -var objectiveJLib = FILE.join($BUILD_DIR, "objective-j", "lib"); +var objectiveJLibJS = FILE.join($BUILD_DIR, $CONFIGURATION, "CommonJS", "objective-j", "lib-js"); -if (FILE.exists(objectiveJLib)) +if (FILE.exists(objectiveJLibJS)) { - require.paths.unshift(objectiveJLib); + require.paths.unshift(objectiveJLibJS); var OBJECTIVE_J_JAKE = require("objective-j/jake");