Merge branch 'master' of git@github.com:280north/cappuccino

This commit is contained in:
Francisco Ryan Tolmasky I
2008-10-03 13:20:30 -07:00
11 changed files with 146 additions and 30 deletions
+1
View File
@@ -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"
+1 -2
View File
@@ -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()
{
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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;
}
}
+2
View File
@@ -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
+1
View File
@@ -10,6 +10,7 @@
<file name = "objjc/build.xml" />
<file name = "steam/build.xml" />
<file name = "bake/build.xml" />
<file name = "press/build.xml" />
<file name = "Utilities/build.xml" />
<file name = "NewApplication/build.xml" />
</filelist>
+1 -1
View File
@@ -36,7 +36,7 @@ try {
if (debug)
print("Loading: " + main_file);
objj_import(main_file, NO);
objj_import(main_file, YES);
serviceTimeouts();
+39
View File
@@ -0,0 +1,39 @@
<?xml version = "1.0"?>
<project name = "press" default = "build" basedir = "." >
<import file = "../../common.xml" />
<property name = "Build.Intermediate" location = "${Build}/press.build/${Configuration}" />
<property name = "Build.press" location = "${Build}/${Configuration}/press" />
<target name = "clean">
<delete dir = "${Build.press}" verbose = "true" />
</target>
<target name = "build">
<mkdir dir = "${Build.press}" />
<copy file = "${basedir}/press.j" tofile = "${Build.press}/press.j" />
<copy file = "${basedir}/objj-analysis-tools.j" tofile = "${Build.press}/objj-analysis-tools.j" />
<copy file = "${basedir}/press" tofile = "${Build.press}/press" />
<chmod file = "${Build.press}/press" perm = "+x" />
</target>
<target name = "release" depends = "build">
<antcall target = "prepare-release" />
<copy file = "${Build.press}/press.j" tofile = "${Build.Cappuccino.Tools.Lib}/press.j" />
<copy file = "${Build.press}/objj-analysis-tools.j" tofile = "${Build.Cappuccino.Tools.Lib}/objj-analysis-tools.j" />
<copy file = "${Build.press}/press" tofile = "${Build.Cappuccino.Tools.Bin}/press" />
<chmod file = "${Build.Cappuccino.Tools.Bin}/press" perm = "+x" />
</target>
</project>
+48 -13
View File
@@ -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);
+36
View File
@@ -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 $@
+14 -11
View File
@@ -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;
}
}