diff --git a/Foundation/Foundation.j b/Foundation/Foundation.j
index 928420510..352d06662 100755
--- a/Foundation/Foundation.j
+++ b/Foundation/Foundation.j
@@ -24,6 +24,7 @@ import "CPArray.j"
import "CPBundle.j"
import "CPCoder.j"
import "CPData.j"
+import "CPDate.j"
import "CPDictionary.j"
import "CPEnumerator.j"
import "CPException.j"
diff --git a/Objective-J/evaluate.js b/Objective-J/evaluate.js
index bef0bcab2..adbd163e1 100644
--- a/Objective-J/evaluate.js
+++ b/Objective-J/evaluate.js
@@ -25,8 +25,7 @@ var objj_included_files = { };
var FRAGMENT_CODE = 1,
FRAGMENT_FILE = 1 << 2,
- FRAGMENT_LOCAL = 1 << 3,
- FRAGMENT_IMPORT = 1 << 4;
+ FRAGMENT_LOCAL = 1 << 3;
function objj_fragment()
{
diff --git a/Objective-J/preprocess.js b/Objective-J/preprocess.js
index df246bce9..f5966cd7c 100644
--- a/Objective-J/preprocess.js
+++ b/Objective-J/preprocess.js
@@ -496,7 +496,7 @@ function objj_preprocess_tokens(tokens, terminator, instigator, segment)
else
objj_exception_throw(new objj_exception(OBJJParseException, "*** Expecting '<' or '\"', found \"" + token + "\"."));
- fragments.push(fragment_create_file(path, NULL, isLocal, YES, tokens.file));
+ fragments.push(fragment_create_file(path, NULL, isLocal, tokens.file));
}
// Safari can't handle function declarations of the form function [name]([arguments]) { }
// in evals. It requires them to be in the form [name] = function([arguments]) { }. So we
diff --git a/Objective-J/static.js b/Objective-J/static.js
index c25353e48..215b10fc4 100644
--- a/Objective-J/static.js
+++ b/Objective-J/static.js
@@ -59,9 +59,9 @@ function objj_decompile(aString, bundle)
break;
case MARKER_CODE: file.fragments.push(fragment_create_code(text, bundle, file));
break;
- case MARKER_IMPORT_STD: file.fragments.push(fragment_create_file(text, bundle, NO, YES, file));
+ case MARKER_IMPORT_STD: file.fragments.push(fragment_create_file(text, bundle, NO, file));
break;
- case MARKER_IMPORT_LOCAL: file.fragments.push(fragment_create_file(text, bundle, YES, YES, file));
+ case MARKER_IMPORT_LOCAL: file.fragments.push(fragment_create_file(text, bundle, YES, file));
break;
}
}
diff --git a/Tools/Install/install-tools b/Tools/Install/install-tools
index 6173d3ef6..afce0496e 100755
--- a/Tools/Install/install-tools
+++ b/Tools/Install/install-tools
@@ -32,12 +32,14 @@ ln -sf $INSTALL_DIR/share/objj/bin/objj $INSTALL_DIR/bin/objj
ln -sf $INSTALL_DIR/share/objj/bin/objjc $INSTALL_DIR/bin/objjc
ln -sf $INSTALL_DIR/share/objj/bin/steam $INSTALL_DIR/bin/steam
ln -sf $INSTALL_DIR/share/objj/bin/bake $INSTALL_DIR/bin/bake
+ln -sf $INSTALL_DIR/share/objj/bin/press $INSTALL_DIR/bin/press
chmod +x $INSTALL_DIR/bin/nib2cib
chmod +x $INSTALL_DIR/bin/objj
chmod +x $INSTALL_DIR/bin/objjc
chmod +x $INSTALL_DIR/bin/steam
chmod +x $INSTALL_DIR/bin/bake
+chmod +x $INSTALL_DIR/bin/press
chmod +x $INSTALL_DIR/share/objj/bin/*
chmod +x $INSTALL_DIR/share/objj/lib/cat
diff --git a/Tools/build.xml b/Tools/build.xml
index 19e76ab2c..abc52c86a 100644
--- a/Tools/build.xml
+++ b/Tools/build.xml
@@ -10,6 +10,7 @@
+
diff --git a/Tools/objj/objj.js b/Tools/objj/objj.js
index 58188d62f..c12ba184d 100644
--- a/Tools/objj/objj.js
+++ b/Tools/objj/objj.js
@@ -36,7 +36,7 @@ try {
if (debug)
print("Loading: " + main_file);
- objj_import(main_file, NO);
+ objj_import(main_file, YES);
serviceTimeouts();
diff --git a/Tools/press/build.xml b/Tools/press/build.xml
new file mode 100644
index 000000000..0618262c1
--- /dev/null
+++ b/Tools/press/build.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tools/press/objj-analysis-tools.j b/Tools/press/objj-analysis-tools.j
old mode 100644
new mode 100755
index e073e4363..e672a2a90
--- a/Tools/press/objj-analysis-tools.j
+++ b/Tools/press/objj-analysis-tools.j
@@ -78,7 +78,7 @@ function traverseDependencies(context, file)
}
}
}
- else if (fragment.type & FRAGMENT_IMPORT)
+ else if (fragment.type & FRAGMENT_FILE)
{
if (ignoreImports)
{
@@ -152,7 +152,7 @@ function findImportInObjjFiles(scope, fragment)
importPath = searchPath;
}
}
- else if (fragment.type & FRAGMENT_FILE)
+ else
{
//CPLog.debug("Importing search-path file: " + fragment.info);
@@ -167,8 +167,6 @@ function findImportInObjjFiles(scope, fragment)
}
}
}
- else
- CPLog.warn("Import fragment not local or file");
return importPath;
}
@@ -192,15 +190,48 @@ function findGlobalDefines(context, scope, rootPath)
//
// return result;
//}
+
+ var needsPatch = true;
+
+ var fragment_evaluate_file_original = scope.fragment_evaluate_file;
+ scope.fragment_evaluate_file = function(aFragment)
+ {
+ // patch Foundation.j (HACK for Rhino bug #374918)
+ if (needsPatch && aFragment.file && (/Foundation\.j$/).test(aFragment.file.path))
+ {
+ CPLog.error("Patching Foundation.j");
+
+ var patchFragment = new objj_fragment();
+ patchFragment.info = "__RHINO_FIRST_SCOPE.String.prototype.isa=CPString;__RHINO_FIRST_SCOPE.Number.prototype.isa=CPNumber;__RHINO_FIRST_SCOPE.Boolean.prototype.isa=CPNumber;print('PATCHED!');";
+ patchFragment.type = FRAGMENT_CODE;
+ patchFragment.file = aFragment.file;
+ patchFragment.bundle = aFragment.bundle;
+ patchFragment.context = aFragment.context;
+
+ for (var i = 0; i < aFragment.context.fragments.length; i++)
+ {
+ if ((aFragment.context.fragments[i].type & FRAGMENT_FILE) && (/Foundation\//).test(aFragment.context.fragments[i].info))
+ {
+ CPLog.error("Inserting patch");
+ aFragment.context.fragments.splice(i, 0, patchFragment);
+ break;
+ }
+ }
+
+ needsPatch = false;
+ }
+
+ return fragment_evaluate_file_original(aFragment);
+ }
- scope.fragment_evaluate_code_original = scope.fragment_evaluate_code;
+ var fragment_evaluate_code_original = scope.fragment_evaluate_code;
scope.fragment_evaluate_code = function(aFragment)
{
CPLog.debug("Evaling "+aFragment.file.path + " / " + aFragment.bundle.path);
var before = cloneProperties(scope);
-
- var result = scope.fragment_evaluate_code_original(aFragment);
+
+ var result = fragment_evaluate_code_original(aFragment);
var definedGlobals = {};
diff(before, scope, ignore, definedGlobals, definedGlobals, null);
@@ -257,14 +288,18 @@ function makeObjjScope(context, debug)
}
// give the scope "print"
- scope.print = function(value) { Packages.java.lang.System.out.println(value); };
+ scope.print = function(value) { Packages.java.lang.System.out.println(String(value)); };
+
+ // HACK for Rhino bug #374918 (fix toll free bridging)
+ scope.__RHINO_FIRST_SCOPE = this;
+ CPLog.info("__RHINO_FIRST_SCOPE="+scope.__RHINO_FIRST_SCOPE);
// load and eval fake browser environment
- var envSource = readFile(envPath);
- if (envSource)
- context.evaluateString(scope, envSource, "env.js", 1, null);
- else
- CPLog.warn("Missing env.js");
+ //var envSource = readFile(envPath);
+ //if (envSource)
+ // context.evaluateString(scope, envSource, "env.js", 1, null);
+ //else
+ // CPLog.warn("Missing env.js");
// load and eval the bridge
var bridgeSource = readFile(bridgePath);
diff --git a/Tools/press/press b/Tools/press/press
new file mode 100644
index 000000000..7d4d3d34f
--- /dev/null
+++ b/Tools/press/press
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# if OBJJ_HOME isn't set, try to determine it
+if [ -z $OBJJ_HOME ]; then
+ # get path of the executable
+ SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
+
+ # resolve symlinks
+ if [ -h $SELF_PATH ]; then
+ SELF_PATH=`readlink $SELF_PATH`
+ fi
+
+ # get second ancestor directory
+ SELF_DIR=`dirname $SELF_PATH`
+ export OBJJ_HOME=`dirname $SELF_DIR`
+
+ # check to ensure it exists, print message
+ if [ -d $OBJJ_HOME ]; then
+ echo "OBJJ_HOME not set, defaulting to $OBJJ_HOME" 1>&2
+ else
+ echo "OBJJ_HOME not set, default at $OBJJ_HOME doesn't exist, exiting" 1>&2
+ exit 2
+ fi
+fi
+
+OBJJ_LIB="$OBJJ_HOME/lib"
+
+PRESS="$OBJJ_LIB/press.j"
+
+# convert paths for Cygwin
+if [[ `uname` == CYGWIN* ]]; then
+ OBJJ_HOME=`cygpath -w "$OBJJ_HOME"`
+ PRESS=`cygpath -w "$PRESS"`
+fi
+
+objj $PRESS $@
diff --git a/Tools/press/press.j b/Tools/press/press.j
index 45283d5ed..6802ac5dc 100644
--- a/Tools/press/press.j
+++ b/Tools/press/press.j
@@ -4,7 +4,6 @@ import "objj-analysis-tools.j"
CPLogRegister(CPLogPrint);
-
function main()
{
var rootPath = null,
@@ -33,7 +32,6 @@ function main()
print("Usage: press input_base_file.j output_directory");
return;
}
-
var rootPath = args[0],
sourceDirectory = dirname(rootPath) || ".",
@@ -44,11 +42,9 @@ function main()
var frameworks = rootPath.substring(0, rootPath.lastIndexOf("/")+1) + "Frameworks/";
scope.OBJJ_INCLUDE_PATHS = [frameworks];
-
CPLog.info("OBJJ_INCLUDE_PATHS="+scope.OBJJ_INCLUDE_PATHS);
// phase 1: get global defines
-
var globals = findGlobalDefines(cx, scope, rootPath);
// coalesce the results
@@ -73,6 +69,7 @@ function main()
}
}
+ requiredFiles[rootPath] = true;
traverseDependencies(context, scope.objj_files[rootPath]);
var count = 0,
@@ -140,7 +137,7 @@ function main()
outputFiles[staticPath].push(file.fragments[i].info.length+";");
outputFiles[staticPath].push(file.fragments[i].info);
}
- else if (file.fragments[i].type & FRAGMENT_IMPORT)
+ else if (file.fragments[i].type & FRAGMENT_FILE)
{
var ignoreFragment = false;
if (file.fragments[i].conditionallyIgnore)
@@ -162,7 +159,7 @@ function main()
outputFiles[staticPath].push(relativePath.length+";");
outputFiles[staticPath].push(relativePath);
}
- else if (file.fragments[i].type & FRAGMENT_FILE)
+ else
{
outputFiles[staticPath].push("I;");
outputFiles[staticPath].push(file.fragments[i].info.length+";");
@@ -272,7 +269,7 @@ function pathRelativeTo(target, relativeTo)
{
var components = [],
targetParts = target.split("/"),
- relativeParts = relativeTo.split("/");
+ relativeParts = relativeTo ? relativeTo.split("/") : [];
var i = 0;
while (i < targetParts.length)
@@ -287,12 +284,16 @@ function pathRelativeTo(target, relativeTo)
for (var j = i; j < targetParts.length; j++)
components.push(targetParts[j]);
-
- return components.join("/");
+
+ var result = components.join("/");
+
+ return result;
}
function exec()
{
+ var printOutput = false;
+
var runtime = Packages.java.lang.Runtime.getRuntime()
var p = runtime.exec.apply(runtime, arguments);
@@ -308,13 +309,15 @@ function exec()
if (s = stdout.readLine())
{
stdoutString += s;
- CPLog.info("exec: " + s);
+ if (printOutput)
+ CPLog.info("exec: " + s);
done = false;
}
if (s = stderr.readLine())
{
stderrString += s;
- CPLog.warn("exec: " + s);
+ //if (printOutput)
+ CPLog.warn("exec: " + s);
done = false;
}
}