mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-09 20:27:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
182f6a0030 |
+30
-14
@@ -973,9 +973,10 @@ CPRunContinuesResponse = -1002;
|
||||
[self endSheet:sheet returnCode:0];
|
||||
}
|
||||
|
||||
|
||||
- (CPArray)arguments
|
||||
{
|
||||
if(_fullArgsString !== window.location.hash)
|
||||
if(_fullArgsString != window.location.hash)
|
||||
[self _reloadArguments];
|
||||
|
||||
return _args;
|
||||
@@ -1008,18 +1009,12 @@ CPRunContinuesResponse = -1002;
|
||||
- (void)_reloadArguments
|
||||
{
|
||||
_fullArgsString = window.location.hash;
|
||||
var args = _fullArgsString.replace("#", "").split("/").slice(0);
|
||||
|
||||
if (_fullArgsString.length)
|
||||
{
|
||||
var args = _fullArgsString.substring(1).split("/");
|
||||
|
||||
for (var i = 0, count = args.length; i < count; i++)
|
||||
args[i] = decodeURIComponent(args[i]);
|
||||
|
||||
_args = args;
|
||||
}
|
||||
else
|
||||
_args = [];
|
||||
for(var i=0, count = args.length; i<count; i++)
|
||||
args[i] = decodeURIComponent(args[i]);
|
||||
|
||||
_args = args;
|
||||
}
|
||||
|
||||
- (CPDictionary)namedArguments
|
||||
@@ -1148,8 +1143,29 @@ function CPApplicationMain(args, namedArgs)
|
||||
|
||||
[principalClass sharedApplication];
|
||||
|
||||
if ([args containsObject:"debug"])
|
||||
CPLogRegister(CPLogPopup);
|
||||
//FIXME?
|
||||
if (!args)
|
||||
{
|
||||
var args = [CPApp arguments];
|
||||
|
||||
if([args containsObject:"debug"])
|
||||
CPLogRegister(CPLogPopup);
|
||||
}
|
||||
|
||||
if (!namedArgs)
|
||||
{
|
||||
var searchParams = window.location.search.substring(1).split("&");
|
||||
namedArgs = [CPDictionary dictionary];
|
||||
|
||||
for(var i=0; i<searchParams.length; i++)
|
||||
{
|
||||
var index = searchParams[i].indexOf('=');
|
||||
if(index == -1)
|
||||
[namedArgs setObject: "" forKey:searchParams[i]];
|
||||
else
|
||||
[namedArgs setObject: searchParams[i].substring(index+1) forKey: searchParams[i].substring(0, index)];
|
||||
}
|
||||
}
|
||||
|
||||
CPApp._args = args;
|
||||
CPApp._namedArgs = namedArgs;
|
||||
|
||||
+3
-13
@@ -52,10 +52,9 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
|
||||
|
||||
var CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_ = 1 << 1,
|
||||
CPOutlineViewDelegate_outlineView_shouldSelectItem_ = 1 << 2,
|
||||
CPOutlineViewDelegate_outlineView_shouldSelectItem_ = 1 << 2;
|
||||
CPOutlineViewDelegate_outlineView_heightOfRowByItem_ = 1 << 3,
|
||||
CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ = 1 << 4,
|
||||
CPOutlineViewDelegate_outlineView_isGroupItem_ = 1 << 5;
|
||||
CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ = 1 << 4;
|
||||
|
||||
CPOutlineViewDropOnItemIndex = -1;
|
||||
|
||||
@@ -469,10 +468,7 @@ CPOutlineViewDropOnItemIndex = -1;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:willDisplayView:forTableColumn:item:)])
|
||||
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:isGroupItem:)])
|
||||
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_isGroupItem_;
|
||||
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewColumnDidMove:)])
|
||||
[defaultCenter
|
||||
addObserver:_outlineViewDelegate
|
||||
@@ -1024,13 +1020,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView isGroupRow:(int)row
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_isGroupItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView isGroupItem:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -878,11 +878,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
}
|
||||
}
|
||||
|
||||
- (int)selectedColumn
|
||||
{
|
||||
[_selectedColumnIndexes lastIndex];
|
||||
}
|
||||
|
||||
- (CPIndexSet)selectedColumnIndexes
|
||||
{
|
||||
return _selectedColumnIndexes;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ appKitTask = framework ("AppKit", function(appKitTask)
|
||||
appKitTask.setEmail("feedback @nospam@ 280north.com");
|
||||
appKitTask.setSummary("AppKit classes for Cappuccino");
|
||||
appKitTask.setIdentifier("com.280n.AppKit");
|
||||
appKitTask.setVersion(getCappuccinoVersion());
|
||||
appKitTask.setVersion("0.8.0");
|
||||
appKitTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
appKitTask.setSources(AppKitFiles);
|
||||
appKitTask.setResources(new FileList("Resources/**/*"));
|
||||
|
||||
@@ -10,7 +10,7 @@ blendKitTask = framework ("BlendKit", function(blendKitTask)
|
||||
blendKitTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
|
||||
|
||||
blendKitTask.setIdentifier("com.280n.BlendKit");
|
||||
blendKitTask.setVersion(getCappuccinoVersion());
|
||||
blendKitTask.setVersion("0.8.0");
|
||||
blendKitTask.setAuthor("280 North, Inc.");
|
||||
blendKitTask.setEmail("feedback @nospam@ 280north.com");
|
||||
blendKitTask.setSummary("BlendKit classes for Cappuccino");
|
||||
|
||||
+1
-5
@@ -8,7 +8,7 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
|
||||
if (!FILE.isFile(aFilename))
|
||||
return;
|
||||
|
||||
var buildFilename = FILE.join($BUILD_CJS_CAPPUCCINO, aFilename);
|
||||
var buildFilename = FILE.join($BUILD_CONFIGURATION_DIR, "CommonJS", "cappuccino", aFilename);
|
||||
|
||||
filedir (buildFilename, [aFilename], function ()
|
||||
{
|
||||
@@ -27,7 +27,3 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
|
||||
task ("build", buildFilename);
|
||||
CLOBBER.include(buildFilename);
|
||||
});
|
||||
|
||||
task ("build", function() {
|
||||
setPackageMetadata(FILE.join($BUILD_CJS_CAPPUCCINO, "package.json"));
|
||||
});
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
var FILE = require("file");
|
||||
var sprintf = require("printf").sprintf;
|
||||
|
||||
var pkg = null;
|
||||
function getPackage() {
|
||||
if (!pkg)
|
||||
pkg = JSON.parse(FILE.path(module.path).dirname().dirname().join("package.json").read({ charset : "UTF-8" }));
|
||||
return pkg;
|
||||
}
|
||||
|
||||
exports.version = function() { return getPackage()["version"]; }
|
||||
exports.revision = function() { return getPackage()["cappuccino-revision"]; }
|
||||
exports.timestamp = function() { return new Date(getPackage()["cappuccino-timestamp"]); }
|
||||
|
||||
exports.fullVersionString = function() {
|
||||
return sprintf("cappuccino %s (%04d-%02d-%02d %s)",
|
||||
exports.version(),
|
||||
exports.timestamp().getUTCFullYear(),
|
||||
exports.timestamp().getUTCMonth()+1,
|
||||
exports.timestamp().getUTCDate(),
|
||||
exports.revision().slice(0,6)
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
"description": "Cappuccino module",
|
||||
"keywords": ["objective-j", "objj", "objective j", "capp", "cappuccino"],
|
||||
"author": "280 North, Inc. (http://280north.com/)",
|
||||
"version": "0.8.0",
|
||||
"objj-frameworks": ["Frameworks"],
|
||||
"objj-debug-frameworks": ["Frameworks/Debug"],
|
||||
"contributors": [
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ foundationTask = framework ("Foundation", function(foundationTask)
|
||||
foundationTask.setEmail("feedback @nospam@ 280north.com");
|
||||
foundationTask.setSummary("Foundation classes for Cappuccino");
|
||||
foundationTask.setIdentifier("com.280n.Foundation");
|
||||
foundationTask.setVersion(getCappuccinoVersion());
|
||||
foundationTask.setVersion("0.8.0");
|
||||
foundationTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
foundationTask.setSources(new FileList("**/*.j"));
|
||||
foundationTask.setResources(new FileList("Resources/**/*"));
|
||||
|
||||
@@ -280,23 +280,21 @@ task("push-objective-j", function() {
|
||||
function pushPackage(path, remote, branch)
|
||||
{
|
||||
branch = branch || "master";
|
||||
|
||||
var pushPackagesPath = FILE.path(".push-package")
|
||||
|
||||
pushPackagesPath.mkdirs();
|
||||
|
||||
var packagePath = pushPackagesPath.join(remote.replace(/[^\w]/g, "_"));
|
||||
|
||||
|
||||
stream.print("Pushing \0blue(" + path + "\0) to "+branch+" of \0blue(" + remote + "\0)");
|
||||
|
||||
if (packagePath.isDirectory())
|
||||
OS.system(buildCmd([["cd", packagePath], ["git", "fetch"]]));
|
||||
else
|
||||
OS.system(["git", "clone", remote, packagePath]);
|
||||
FILE.mkdirs(".push-package");
|
||||
|
||||
if (OS.system(buildCmd([["cd", packagePath], ["git", "checkout", "origin/"+branch]]))) {
|
||||
var pushPackageDir = FILE.join(".push-package", remote.replace(/[^\w]/g, "_"));
|
||||
|
||||
if (FILE.exists(pushPackageDir))
|
||||
OS.system(buildCmd([["cd", pushPackageDir], ["git", "fetch"]]));
|
||||
else
|
||||
OS.system(["git", "clone", remote, pushPackageDir]);
|
||||
|
||||
if (OS.system(buildCmd([["cd", pushPackageDir], ["git", "checkout", "origin/"+branch]]))) {
|
||||
if (OS.system(buildCmd([
|
||||
["cd", packagePath],
|
||||
["cd", pushPackageDir],
|
||||
["git", "symbolic-ref", "HEAD", "refs/heads/"+branch],
|
||||
["rm", ".git/index"],
|
||||
["git", "clean", "-fdx"]
|
||||
@@ -304,30 +302,20 @@ function pushPackage(path, remote, branch)
|
||||
throw "pushPackage failed";
|
||||
}
|
||||
|
||||
if (OS.system("cd "+OS.enquote(packagePath)+" && git rm --ignore-unmatch -r * && rm -rf *"))
|
||||
if (OS.system("cd "+OS.enquote(pushPackageDir)+" && git rm --ignore-unmatch -r * && rm -rf *"))
|
||||
throw "pushPackage failed";
|
||||
if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(packagePath)+"/."))
|
||||
if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(pushPackageDir)+"/."))
|
||||
throw "pushPackage failed";
|
||||
|
||||
var pkg = JSON.parse(packagePath.join("package.json").read({ charset : "UTF-8" }));
|
||||
|
||||
stream.print(" Version: \0purple(" + pkg["version"] + "\0)");
|
||||
stream.print(" Revision: \0purple(" + pkg["cappuccino-revision"] + "\0)");
|
||||
stream.print(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
|
||||
|
||||
var cmd = [
|
||||
["cd", packagePath],
|
||||
OS.system(buildCmd([
|
||||
["cd", pushPackageDir],
|
||||
["git", "add", "."],
|
||||
["git", "commit", "-m", "version="+pkg.version+"; revision="+pkg["cappuccino-revision"]+"; timestamp="+pkg["cappuccino-timestamp"]+";"]
|
||||
];
|
||||
if (pkg["cappuccino-revision"])
|
||||
cmd.push(["git", "tag", "rev-"+pkg["cappuccino-revision"].slice(0,6)]);
|
||||
|
||||
OS.system(buildCmd(cmd));
|
||||
["git", "commit", "-m", "Pushed on " + new Date()]
|
||||
]));
|
||||
|
||||
if (OS.system(buildCmd([
|
||||
["cd", packagePath],
|
||||
["git", "push", "--tags", "origin", "HEAD:"+branch]
|
||||
["cd", pushPackageDir],
|
||||
["git", "push", "origin", "HEAD:"+branch]
|
||||
])))
|
||||
throw "pushPackage failed";
|
||||
}
|
||||
|
||||
@@ -81,36 +81,7 @@ function resolveMainBundleURL()
|
||||
Executable.fileImporterForURL(mainBundleURL)(mainFileURL.lastPathComponent(), YES, function()
|
||||
{
|
||||
disableCFURLCaching();
|
||||
afterDocumentLoad(function()
|
||||
{
|
||||
var hashString = window.location.hash.substring(1),
|
||||
args = [];
|
||||
|
||||
if (hashString.length)
|
||||
{
|
||||
args = hashString.split("/");
|
||||
for (var i = 0, count = args.length; i < count; i++)
|
||||
args[i] = decodeURIComponent(args[i]);
|
||||
}
|
||||
|
||||
var namedArgsArray = window.location.search.substring(1).split("&"),
|
||||
namedArgs = new CFMutableDictionary();
|
||||
|
||||
for (var i = 0, count = namedArgsArray.length; i < count; i++)
|
||||
{
|
||||
var thisArg = namedArgsArray[i].split("=");
|
||||
|
||||
if (!thisArg[0])
|
||||
continue;
|
||||
|
||||
if (thisArg[1] == null)
|
||||
thisArg[1] = true;
|
||||
|
||||
namedArgs.setValueForKey(decodeURIComponent(thisArg[0]), decodeURIComponent(thisArg[1]));
|
||||
}
|
||||
|
||||
main(args, namedArgs);
|
||||
});
|
||||
afterDocumentLoad(main);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+4
-57
@@ -49,7 +49,6 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
|
||||
this._resourcesDirectoryURL = new CFURL("Resources/", aURL);
|
||||
|
||||
this._staticResource = NULL;
|
||||
this._isValid = NO;
|
||||
|
||||
this._loadStatus = CFBundleUnloaded;
|
||||
this._loadRequests = [];
|
||||
@@ -59,47 +58,34 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
|
||||
this._eventDispatcher = new EventDispatcher(this);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle);
|
||||
|
||||
CFBundle.environments = function()
|
||||
{
|
||||
// Passed in by GCC.
|
||||
return ENVIRONMENTS;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.environments);
|
||||
|
||||
CFBundle.bundleContainingURL = function(/*CFURL|String*/ aURL)
|
||||
{
|
||||
aURL = new CFURL(".", makeAbsoluteURL(aURL));
|
||||
|
||||
var previousURLString,
|
||||
URLString = aURL.absoluteString();
|
||||
|
||||
while (!previousURLString || previousURLString !== URLString)
|
||||
while (aURL.path() !== "/")
|
||||
{
|
||||
var bundle = CFBundlesForURLStrings[URLString];
|
||||
var bundle = CFBundlesForURLStrings[aURL.absoluteString()];
|
||||
|
||||
if (bundle && bundle._isValid)
|
||||
if (bundle)
|
||||
return bundle;
|
||||
|
||||
aURL = new CFURL("..", aURL);
|
||||
previousURLString = URLString;
|
||||
URLString = aURL.absoluteString();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.bundleContainingURL);
|
||||
|
||||
CFBundle.mainBundle = function()
|
||||
{
|
||||
return new CFBundle(mainBundleURL);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.mainBundle);
|
||||
|
||||
function addClassToBundle(aClass, aBundle)
|
||||
{
|
||||
if (aBundle)
|
||||
@@ -111,22 +97,16 @@ CFBundle.bundleForClass = function(/*Class*/ aClass)
|
||||
return CFBundlesForClasses[aClass.name] || CFBundle.mainBundle();
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.bundleForClass);
|
||||
|
||||
CFBundle.prototype.bundleURL = function()
|
||||
{
|
||||
return this._bundleURL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.bundleURL);
|
||||
|
||||
CFBundle.prototype.resourcesDirectoryURL = function()
|
||||
{
|
||||
return this._resourcesDirectoryURL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.resourcesDirectoryURL);
|
||||
|
||||
CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ aType, /*String*/ aSubDirectory)
|
||||
{
|
||||
if (aType)
|
||||
@@ -140,8 +120,6 @@ CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ a
|
||||
return resourceURL.absoluteURL();
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.resourceURL);
|
||||
|
||||
CFBundle.prototype.mostEligibleEnvironmentURL = function()
|
||||
{
|
||||
if (this._mostEligibleEnvironmentURL === undefined)
|
||||
@@ -150,8 +128,6 @@ CFBundle.prototype.mostEligibleEnvironmentURL = function()
|
||||
return this._mostEligibleEnvironmentURL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.mostEligibleEnvironmentURL);
|
||||
|
||||
CFBundle.prototype.executableURL = function()
|
||||
{
|
||||
if (this._executableURL === undefined)
|
||||
@@ -167,22 +143,16 @@ CFBundle.prototype.executableURL = function()
|
||||
return this._executableURL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.executableURL);
|
||||
|
||||
CFBundle.prototype.infoDictionary = function()
|
||||
{
|
||||
return this._infoDictionary;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.infoDictionary);
|
||||
|
||||
CFBundle.prototype.valueForInfoDictionaryKey = function(/*String*/ aKey)
|
||||
{
|
||||
return this._infoDictionary.valueForKey(aKey);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.valueForInfoDictionaryKey);
|
||||
|
||||
CFBundle.prototype.hasSpritedImages = function()
|
||||
{
|
||||
var environments = this._infoDictionary.valueForKey("CPBundleEnvironmentsWithImageSprites") || [],
|
||||
@@ -196,15 +166,11 @@ CFBundle.prototype.hasSpritedImages = function()
|
||||
return NO;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.hasSpritedImages);
|
||||
|
||||
CFBundle.prototype.environments = function()
|
||||
{
|
||||
return this._infoDictionary.valueForKey("CPBundleEnvironments") || ["ObjJ"];
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.environments);
|
||||
|
||||
CFBundle.prototype.mostEligibleEnvironment = function(/*Array*/ environments)
|
||||
{
|
||||
environments = environments || this.environments();
|
||||
@@ -228,15 +194,11 @@ CFBundle.prototype.mostEligibleEnvironment = function(/*Array*/ environments)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.mostEligibleEnvironment);
|
||||
|
||||
CFBundle.prototype.isLoading = function()
|
||||
{
|
||||
return this._loadStatus & CFBundleLoading;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.isLoading);
|
||||
|
||||
CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
{
|
||||
if (this._loadStatus !== CFBundleUnloaded)
|
||||
@@ -261,13 +223,7 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
function onsuccess(/*Event*/ anEvent)
|
||||
{
|
||||
self._loadStatus &= ~CFBundleLoadingInfoPlist;
|
||||
|
||||
var infoDictionary = anEvent.request.responsePropertyList();
|
||||
|
||||
self._isValid = !!infoDictionary || CFBundle.mainBundle() === self;
|
||||
|
||||
if (infoDictionary)
|
||||
self._infoDictionary = infoDictionary;
|
||||
self._infoDictionary = anEvent.request.responsePropertyList();
|
||||
|
||||
if (!self._infoDictionary)
|
||||
{
|
||||
@@ -284,7 +240,6 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
|
||||
function onfailure()
|
||||
{
|
||||
self._isValid = CFBundle.mainBundle() === self;
|
||||
self._loadStatus = CFBundleUnloaded;
|
||||
|
||||
finishBundleLoadingWithError(self, new Error("Could not load bundle at \"" + self.bundleURL() + "\""));
|
||||
@@ -294,8 +249,6 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
|
||||
});
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.load);
|
||||
|
||||
function finishBundleLoadingWithError(/*CFBundle*/ aBundle, /*Event*/ anError)
|
||||
{
|
||||
resolveStaticResource(aBundle._staticResource);
|
||||
@@ -662,22 +615,16 @@ CFBundle.prototype.addEventListener = function(/*String*/ anEventName, /*Functio
|
||||
this._eventDispatcher.addEventListener(anEventName, anEventListener);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.addEventListener);
|
||||
|
||||
CFBundle.prototype.removeEventListener = function(/*String*/ anEventName, /*Function*/ anEventListener)
|
||||
{
|
||||
this._eventDispatcher.removeEventListener(anEventName, anEventListener);
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.removeEventListener);
|
||||
|
||||
CFBundle.prototype.onerror = function(/*Event*/ anEvent)
|
||||
{
|
||||
throw anEvent.error;
|
||||
}
|
||||
|
||||
DISPLAY_NAME(CFBundle.prototype.onerror);
|
||||
|
||||
CFBundle.prototype.bundlePath = function()
|
||||
{
|
||||
return this._bundleURL.absoluteURL().path();
|
||||
|
||||
+254
-183
@@ -20,107 +20,175 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
GLOBAL(CPLogDisable) = false;
|
||||
|
||||
var CPLogDefaultTitle = "Cappuccino";
|
||||
|
||||
var CPLogLevels = ["fatal", "error", "warn", "info", "debug", "trace"];
|
||||
var CPLogDefaultLevel = CPLogLevels[3];
|
||||
|
||||
var _CPLogLevelsInverted = {};
|
||||
for (var i = 0; i < CPLogLevels.length; i++)
|
||||
_CPLogLevelsInverted[CPLogLevels[i]] = i;
|
||||
|
||||
var _CPLogRegistrations = {};
|
||||
// defaults:
|
||||
|
||||
// Register Functions:
|
||||
|
||||
// Register a logger for all levels, or up to an optional max level
|
||||
GLOBAL(CPLogRegister) = function(aProvider, aMaxLevel)
|
||||
var CPLogDefaultTitle = "Cappuccino";
|
||||
var CPLogDefaultLevel = CPLogLevels[3];
|
||||
var CPLogDefaultFormatter = function(aParameters, aLevel, aTitle, useColor)
|
||||
{
|
||||
CPLogRegisterRange(aProvider, CPLogLevels[0], aMaxLevel || CPLogLevels[CPLogLevels.length-1]);
|
||||
}
|
||||
var color = useColor && defaultFormatterColorMap[aLevel];
|
||||
var important = {"fatal":true,"error":true,"warn":true}[aLevel];
|
||||
|
||||
// Register a logger for a range of levels
|
||||
GLOBAL(CPLogRegisterRange) = function(aProvider, aMinLevel, aMaxLevel)
|
||||
{
|
||||
var min = _CPLogLevelsInverted[aMinLevel];
|
||||
var max = _CPLogLevelsInverted[aMaxLevel];
|
||||
// for unimportant messages colorize just the level
|
||||
if (!important && color)
|
||||
aLevel = "\0"+color+"(" + aLevel + "\0)";
|
||||
|
||||
if (min !== undefined && max !== undefined)
|
||||
for (var i = 0; i <= max; i++)
|
||||
CPLogRegisterSingle(aProvider, CPLogLevels[i]);
|
||||
}
|
||||
aLevel = aLevel ? ' [' + aLevel + ']' : '';
|
||||
|
||||
// Register a logger for a single level
|
||||
GLOBAL(CPLogRegisterSingle) = function(aProvider, aLevel)
|
||||
{
|
||||
if (!_CPLogRegistrations[aLevel])
|
||||
_CPLogRegistrations[aLevel] = [];
|
||||
|
||||
// prevent duplicate registrations
|
||||
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
|
||||
if (_CPLogRegistrations[aLevel][i] === aProvider)
|
||||
return;
|
||||
|
||||
_CPLogRegistrations[aLevel].push(aProvider);
|
||||
}
|
||||
|
||||
GLOBAL(CPLogUnregister) = function(aProvider) {
|
||||
for (var aLevel in _CPLogRegistrations)
|
||||
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
|
||||
if (_CPLogRegistrations[aLevel][i] === aProvider)
|
||||
_CPLogRegistrations[aLevel].splice(i--, 1); // decrement since we're removing an element
|
||||
}
|
||||
|
||||
// Main CPLog, which dispatches to individual loggers
|
||||
function _CPLogDispatch(parameters, aLevel, aTitle)
|
||||
{
|
||||
if (aTitle == undefined)
|
||||
aTitle = CPLogDefaultTitle;
|
||||
if (aLevel == undefined)
|
||||
aLevel = CPLogDefaultLevel;
|
||||
|
||||
// use sprintf if param 0 is a string and there is more than one param. otherwise just convert param 0 to a string
|
||||
var message = (typeof parameters[0] == "string" && parameters.length > 1) ? exports.sprintf.apply(null, parameters) : String(parameters[0]);
|
||||
|
||||
if (_CPLogRegistrations[aLevel])
|
||||
for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
|
||||
_CPLogRegistrations[aLevel][i](message, aLevel, aTitle);
|
||||
}
|
||||
var aString = (typeof aParameters[0] === "string" && aParameters.length > 1) ? exports.sprintf.apply(null, aParameters) : String(aParameters[0]);
|
||||
|
||||
// Setup CPLog() and CPLog.xxx() aliases
|
||||
|
||||
GLOBAL(CPLog) = function() { _CPLogDispatch(arguments); }
|
||||
|
||||
for (var i = 0; i < CPLogLevels.length; i++)
|
||||
CPLog[CPLogLevels[i]] = (function(level) { return function() { _CPLogDispatch(arguments, level); }; })(CPLogLevels[i]);
|
||||
|
||||
// Helpers functions:
|
||||
|
||||
var _CPFormatLogMessage = function(aString, aLevel, aTitle)
|
||||
{
|
||||
var now = new Date();
|
||||
aLevel = ( aLevel == null ? '' : ' [' + aLevel + ']' );
|
||||
var message = exports.sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s: %s",
|
||||
now.getFullYear(), now.getMonth(), now.getDate(),
|
||||
now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds(),
|
||||
aTitle, aLevel, aString);
|
||||
|
||||
if (typeof exports.sprintf == "function")
|
||||
return exports.sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s: %s",
|
||||
now.getFullYear(), now.getMonth(), now.getDate(),
|
||||
now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds(),
|
||||
aTitle, aLevel, aString);
|
||||
else
|
||||
return now + " " + aTitle + aLevel + ": " + aString;
|
||||
// for important messages colorize entire message
|
||||
if (important && color)
|
||||
message = "\0"+color+"(" + message + "\0)";
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
// Loggers:
|
||||
var defaultFormatterColorMap = {
|
||||
"fatal": "red",
|
||||
"error": "red",
|
||||
"warn" : "yellow",
|
||||
"info" : "green",
|
||||
"debug": "cyan",
|
||||
"trace": "blue"
|
||||
};
|
||||
|
||||
#if COMMONJS
|
||||
// attempt to get a better default title based on the command line name
|
||||
try {
|
||||
if (require("system").args[0])
|
||||
CPLogDefaultTitle = require("file").basename(require("system").args[0]);
|
||||
} catch (e) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// main Logger constructor / API:
|
||||
function CreateLogger(aTitle)
|
||||
{
|
||||
// public
|
||||
|
||||
var self = function() { self._dispatch(arguments, null, _title); };
|
||||
|
||||
// logger.error, logger.info, logger.warn
|
||||
for (var i = 0; i < CPLogLevels.length; i++)
|
||||
self[CPLogLevels[i]] = (function(level) { return function() { self._dispatch(arguments, level, _title); }; })(CPLogLevels[i]);
|
||||
|
||||
self.createLogger = function()
|
||||
{
|
||||
return CreateLogger.apply(this, arguments);;
|
||||
}
|
||||
|
||||
// Register a logger for all levels, or up to an optional max level
|
||||
self.register = function(aProvider, aMaxLevel)
|
||||
{
|
||||
if (aMaxLevel === undefined) aMaxLevel = CPLogLevels.length;
|
||||
|
||||
self.registerRange(aProvider, 0, aMaxLevel);
|
||||
}
|
||||
|
||||
// Register a logger for a range of levels
|
||||
self.registerRange = function(aProvider, aMinLevel, aMaxLevel)
|
||||
{
|
||||
if (typeof aMinLevel !== "number") aMinLevel = _CPLogLevelsInverted[aMinLevel];
|
||||
if (typeof aMaxLevel !== "number") aMaxLevel = _CPLogLevelsInverted[aMaxLevel];
|
||||
|
||||
if (aMinLevel !== undefined && aMaxLevel !== undefined)
|
||||
for (var level = aMinLevel; level <= aMaxLevel; level++)
|
||||
self.registerSingle(aProvider, level);
|
||||
}
|
||||
|
||||
// Register a logger for a single level
|
||||
self.registerSingle = function(aProvider, aLevel)
|
||||
{
|
||||
if (typeof aLevel === "number") aLevel = CPLogLevels[aLevel];
|
||||
|
||||
if (!_registrations[aLevel])
|
||||
_registrations[aLevel] = [];
|
||||
|
||||
// prevent duplicate _registrations
|
||||
for (var i = 0; i < _registrations[aLevel].length; i++)
|
||||
if (_registrations[aLevel][i] === aProvider)
|
||||
return;
|
||||
|
||||
_registrations[aLevel].push(aProvider);
|
||||
}
|
||||
|
||||
// Unregister a logger for all levels
|
||||
self.unregister = function(aProvider)
|
||||
{
|
||||
for (var aLevel in _registrations)
|
||||
for (var i = 0; i < _registrations[aLevel].length; i++)
|
||||
if (_registrations[aLevel][i] === aProvider)
|
||||
_registrations[aLevel].splice(i--, 1); // decrement since we're removing an element
|
||||
}
|
||||
|
||||
self.setDefaultTitle = function(aTitle)
|
||||
{
|
||||
CPLogDefaultTitle = aTitle;
|
||||
}
|
||||
|
||||
self.setDefaultLevel = function(aLevel)
|
||||
{
|
||||
CPLogDefaultLevel = aLevel;
|
||||
}
|
||||
|
||||
self.setDefaultFormatter = function(aFormatter)
|
||||
{
|
||||
CPLogDefaultFormatter = aFormatter;
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
var _registrations = {};
|
||||
var _title = aTitle;
|
||||
|
||||
self._dispatch = function(aParameters, aLevel, aTitle)
|
||||
{
|
||||
aParameters = Array.prototype.slice.call(aParameters);
|
||||
|
||||
if (aTitle == undefined) aTitle = CPLogDefaultTitle;
|
||||
if (aLevel == undefined) aLevel = CPLogDefaultLevel;
|
||||
|
||||
if (_registrations[aLevel])
|
||||
for (var i = 0; i < _registrations[aLevel].length; i++)
|
||||
_registrations[aLevel][i](aParameters, aLevel, aTitle);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// Default CPLog:
|
||||
GLOBAL(CPLog) = CreateLogger();
|
||||
|
||||
// Deprecated global registration functions
|
||||
GLOBAL(CPLogRegister) = function() { CPLog.register.apply(CPLog, arguments); CPLog("CPLogRegister() is deprecated, use CPLog.register()"); };
|
||||
GLOBAL(CPLogRegisterRange) = function() { CPLog.registerRange.apply(CPLog, arguments); CPLog("CPLogRegisterRange() is deprecated, use CPLog.registerRange()"); };
|
||||
GLOBAL(CPLogRegisterSingle) = function() { CPLog.registerSingle.apply(CPLog, arguments); CPLog("CPLogRegisterSingle() is deprecated, use CPLog.registerSingle()"); };
|
||||
|
||||
// Included loggers:
|
||||
|
||||
// CPLogConsole uses the built in "console" object
|
||||
GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle)
|
||||
// (possibly available in CommonJS environments?)
|
||||
function CPLogConsoleCreate(formatter)
|
||||
{
|
||||
if (typeof console != "undefined")
|
||||
{
|
||||
var message = _CPFormatLogMessage(aString, aLevel, aTitle);
|
||||
|
||||
return function(aString, aLevel, aTitle) {
|
||||
if (typeof console === "undefined")
|
||||
return;
|
||||
|
||||
var message = (formatter || CPLogDefaultFormatter)(aString, aLevel, aTitle, false);
|
||||
|
||||
var logger = {
|
||||
"fatal": "error",
|
||||
"error": "error",
|
||||
@@ -128,107 +196,109 @@ GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle)
|
||||
"info": "info",
|
||||
"debug": "debug",
|
||||
"trace": "debug"
|
||||
}[aLevel];
|
||||
|
||||
if (logger && console[logger])
|
||||
}[aLevel] || "log";
|
||||
|
||||
if (console[logger])
|
||||
console[logger](message);
|
||||
else if (console.log)
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
|
||||
GLOBAL(CPLogConsole) = CPLogConsoleCreate();
|
||||
CPLogConsole.create = CPLogConsoleCreate;
|
||||
|
||||
// CommonJS specific loggers
|
||||
#if COMMONJS
|
||||
|
||||
var levelColorMap = {
|
||||
"fatal": "red",
|
||||
"error": "red",
|
||||
"warn" : "yellow",
|
||||
"info" : "green",
|
||||
"debug": "cyan",
|
||||
"trace": "blue"
|
||||
}
|
||||
|
||||
try {
|
||||
var SYSTEM = require("system");
|
||||
var FILE = require("file");
|
||||
if (SYSTEM.args[0])
|
||||
CPLogDefaultTitle = FILE.basename(SYSTEM.args[0]);
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
var stream;
|
||||
|
||||
GLOBAL(CPLogPrint) = function(aString, aLevel, aTitle)
|
||||
// CPLogPrint uses STDOUT to print to console
|
||||
function CPLogPrintCreate(formatter, stream, useColor)
|
||||
{
|
||||
if (stream === undefined) {
|
||||
if (!stream) {
|
||||
try {
|
||||
stream = require("term").stream;
|
||||
useColor = true;
|
||||
} catch (e) {
|
||||
stream = null;
|
||||
useColor = false;
|
||||
if (typeof print != "undefined")
|
||||
stream = { print : print };
|
||||
}
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
if (aLevel == "fatal" || aLevel == "error" || aLevel == "warn")
|
||||
stream.print("\0"+levelColorMap[aLevel]+"(" + _CPFormatLogMessage(aString, aLevel, aTitle) + "\0)");
|
||||
else
|
||||
stream.print(_CPFormatLogMessage(aString, "\0"+levelColorMap[aLevel]+"(" + aLevel + "\0)", aTitle));
|
||||
} else if (typeof print != "undefined") {
|
||||
print(_CPFormatLogMessage(aString, aLevel, aTitle))
|
||||
return function(aParameters, aLevel, aTitle) {
|
||||
var message = (formatter || CPLogDefaultFormatter)(aParameters, aLevel, aTitle, useColor);
|
||||
stream.print(message);
|
||||
}
|
||||
}
|
||||
|
||||
GLOBAL(CPLogPrint) = CPLogPrintCreate();
|
||||
CPLogPrint.create = CPLogPrintCreate;
|
||||
|
||||
// Browser specific loggers
|
||||
#else
|
||||
|
||||
// CPLogAlert uses basic browser alert() functions
|
||||
GLOBAL(CPLogAlert) = function(aString, aLevel, aTitle)
|
||||
{
|
||||
if (typeof alert != "undefined" && !CPLogDisable)
|
||||
{
|
||||
var message = _CPFormatLogMessage(aString, aLevel, aTitle);
|
||||
CPLogDisable = !confirm(message + "\n\n(Click cancel to stop log alerts)");
|
||||
}
|
||||
}
|
||||
// TODO: should this not be global?
|
||||
GLOBAL(CPLogDisable) = false;
|
||||
|
||||
// CPLogPopup uses a slick popup window in the browser:
|
||||
var CPLogWindow = null;
|
||||
GLOBAL(CPLogPopup) = function(aString, aLevel, aTitle)
|
||||
// CPLogAlert uses basic browser confirm()
|
||||
function CPLogAlertCreate(formatter)
|
||||
{
|
||||
try {
|
||||
if (CPLogDisable || window.open == undefined)
|
||||
return;
|
||||
|
||||
if (!CPLogWindow || !CPLogWindow.document)
|
||||
{
|
||||
CPLogWindow = window.open("", "_blank", "width=600,height=400,status=no,resizable=yes,scrollbars=yes");
|
||||
|
||||
if (!CPLogWindow) {
|
||||
CPLogDisable = !confirm(aString + "\n\n(Disable pop-up blocking for CPLog window; Click cancel to stop log alerts)");
|
||||
return;
|
||||
}
|
||||
|
||||
_CPLogInitPopup(CPLogWindow);
|
||||
return function(aParameters, aLevel, aTitle) {
|
||||
if (typeof confirm != "undefined" && !CPLogDisable) {
|
||||
var message = (formatter || CPLogDefaultFormatter)(aParameters, aLevel, aTitle);
|
||||
CPLogDisable = !confirm(message + "\n\n(Click cancel to stop log alerts)");
|
||||
}
|
||||
|
||||
var logDiv = CPLogWindow.document.createElement("div");
|
||||
logDiv.setAttribute("class", aLevel || "fatal");
|
||||
|
||||
var message = _CPFormatLogMessage(aString, null, aTitle);
|
||||
|
||||
logDiv.appendChild(CPLogWindow.document.createTextNode(message));
|
||||
CPLogWindow.log.appendChild(logDiv);
|
||||
|
||||
if (CPLogWindow.focusEnabled.checked)
|
||||
CPLogWindow.focus();
|
||||
if (CPLogWindow.blockEnabled.checked)
|
||||
CPLogWindow.blockEnabled.checked = CPLogWindow.confirm(message+"\nContinue blocking?");
|
||||
if (CPLogWindow.scrollEnabled.checked)
|
||||
CPLogWindow.scrollToBottom();
|
||||
} catch(e) {
|
||||
// TODO: some error handling/reporting
|
||||
}
|
||||
}
|
||||
|
||||
GLOBAL(CPLogAlert) = CPLogAlertCreate();
|
||||
CPLogAlert.create = CPLogAlertCreate;
|
||||
|
||||
// CPLogPopup uses a slick popup window in the browser
|
||||
// TODO: move this into DebugKit
|
||||
function CPLogPopupCreate(formatter)
|
||||
{
|
||||
var logWindow = null;
|
||||
return function(aParameters, aLevel, aTitle) {
|
||||
var message = (formatter || CPLogDefaultFormatter)(aString, null, aTitle);
|
||||
|
||||
try {
|
||||
if (CPLogDisable || window.open == undefined)
|
||||
return;
|
||||
|
||||
if (!logWindow || !logWindow.document)
|
||||
{
|
||||
logWindow = window.open("", "_blank", "width=600,height=400,status=no,resizable=yes,scrollbars=yes");
|
||||
|
||||
if (!logWindow) {
|
||||
CPLogDisable = !confirm(message + "\n\n(Disable pop-up blocking for CPLog window; Click cancel to stop log alerts)");
|
||||
return;
|
||||
}
|
||||
|
||||
_CPLogPopupInit(logWindow);
|
||||
}
|
||||
|
||||
var logDiv = logWindow.document.createElement("div");
|
||||
logDiv.setAttribute("class", aLevel || "fatal");
|
||||
|
||||
logDiv.appendChild(logWindow.document.createTextNode(message));
|
||||
logWindow.log.appendChild(logDiv);
|
||||
|
||||
if (logWindow.focusEnabled.checked)
|
||||
logWindow.focus();
|
||||
if (logWindow.blockEnabled.checked)
|
||||
logWindow.blockEnabled.checked = logWindow.confirm(message+"\nContinue blocking?");
|
||||
if (logWindow.scrollEnabled.checked)
|
||||
logWindow.scrollToBottom();
|
||||
} catch(e) {
|
||||
// TODO: some error handling/reporting
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GLOBAL(CPLogPopup) = CPLogPopupCreate();
|
||||
CPLogPopup.create = CPLogPopupCreate;
|
||||
|
||||
// private CPLogPopup
|
||||
|
||||
var CPLogPopupStyle ='<style type="text/css" media="screen"> \
|
||||
body{font:10px Monaco,Courier,"Courier New",monospace,mono;padding-top:15px;} \
|
||||
div > .fatal,div > .error,div > .warn,div > .info,div > .debug,div > .trace{display:none;overflow:hidden;white-space:pre;padding:0px 5px 0px 5px;margin-top:2px;-moz-border-radius:5px;-webkit-border-radius:5px;} \
|
||||
@@ -248,30 +318,24 @@ ul#options{display:inline-block;margin:0 15px 0px 15px;padding:0 0px;} \
|
||||
ul#options li{margin:0 0 0 0;padding:0 0 0 0;display:inline;} \
|
||||
</style>';
|
||||
|
||||
function _CPLogInitPopup(logWindow)
|
||||
function _CPLogPopupInit(logWindow)
|
||||
{
|
||||
var doc = logWindow.document;
|
||||
|
||||
// HACK so that head is available below:
|
||||
doc.writeln("<html><head><title></title>"+CPLogPopupStyle+"</head><body></body></html>");
|
||||
|
||||
|
||||
doc.title = CPLogDefaultTitle + " Run Log";
|
||||
|
||||
var head = doc.getElementsByTagName("head")[0];
|
||||
|
||||
var body = doc.getElementsByTagName("body")[0];
|
||||
|
||||
var base = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
||||
base = base.substring(0,base.lastIndexOf("/")+1);
|
||||
|
||||
|
||||
var div = doc.createElement("div");
|
||||
div.setAttribute("id", "header");
|
||||
body.appendChild(div);
|
||||
|
||||
|
||||
// Enablers
|
||||
var ul = doc.createElement("ul");
|
||||
ul.setAttribute("id", "enablers");
|
||||
div.appendChild(ul);
|
||||
|
||||
|
||||
for (var i = 0; i < CPLogLevels.length; i++) {
|
||||
var li = doc.createElement("li");
|
||||
li.setAttribute("id", "en"+CPLogLevels[i]);
|
||||
@@ -281,35 +345,35 @@ function _CPLogInitPopup(logWindow)
|
||||
li.appendChild(doc.createTextNode(CPLogLevels[i]));
|
||||
ul.appendChild(li);
|
||||
}
|
||||
|
||||
|
||||
// Options
|
||||
var ul = doc.createElement("ul");
|
||||
ul.setAttribute("id", "options");
|
||||
div.appendChild(ul);
|
||||
|
||||
|
||||
var options = {"focus":["Focus",false], "block":["Block",false], "wrap":["Wrap",false], "scroll":["Scroll",true], "close":["Close",true]};
|
||||
for (o in options) {
|
||||
var li = doc.createElement("li");
|
||||
ul.appendChild(li);
|
||||
|
||||
|
||||
logWindow[o+"Enabled"] = doc.createElement("input");
|
||||
logWindow[o+"Enabled"].setAttribute("id", o);
|
||||
logWindow[o+"Enabled"].setAttribute("type", "checkbox");
|
||||
if (options[o][1])
|
||||
if (options[o][1])
|
||||
logWindow[o+"Enabled"].setAttribute("checked", "checked");
|
||||
li.appendChild(logWindow[o+"Enabled"]);
|
||||
|
||||
|
||||
var label = doc.createElement("label");
|
||||
label.setAttribute("for", o);
|
||||
label.appendChild(doc.createTextNode(options[o][0]));
|
||||
li.appendChild(label);
|
||||
}
|
||||
|
||||
|
||||
// Log
|
||||
logWindow.log = doc.createElement("div");
|
||||
logWindow.log.setAttribute("class", "enerror endebug enwarn eninfo enfatal entrace");
|
||||
body.appendChild(logWindow.log);
|
||||
|
||||
|
||||
logWindow.toggle = function(elem) {
|
||||
var enabled = (elem.getAttribute("enabled") == "yes") ? "no" : "yes";
|
||||
elem.setAttribute("enabled", enabled);
|
||||
@@ -319,17 +383,17 @@ function _CPLogInitPopup(logWindow)
|
||||
else
|
||||
logWindow.log.className = logWindow.log.className.replace(new RegExp("[\\s]*"+elem.id, "g"), "");
|
||||
}
|
||||
|
||||
|
||||
// Scroll
|
||||
logWindow.scrollToBottom = function() {
|
||||
logWindow.scrollTo(0, body.offsetHeight);
|
||||
}
|
||||
|
||||
|
||||
// Wrap
|
||||
logWindow.wrapEnabled.addEventListener("click", function() {
|
||||
logWindow.log.setAttribute("wrap", logWindow.wrapEnabled.checked ? "yes" : "no");
|
||||
}, false);
|
||||
|
||||
|
||||
// Clear
|
||||
logWindow.addEventListener("keydown", function(e) {
|
||||
var e = e || logWindow.event;
|
||||
@@ -340,7 +404,7 @@ function _CPLogInitPopup(logWindow)
|
||||
e.preventDefault();
|
||||
}
|
||||
}, "false");
|
||||
|
||||
|
||||
// Parent closing
|
||||
window.addEventListener("unload", function() {
|
||||
if (logWindow && logWindow.closeEnabled && logWindow.closeEnabled.checked) {
|
||||
@@ -348,7 +412,7 @@ function _CPLogInitPopup(logWindow)
|
||||
logWindow.close();
|
||||
}
|
||||
}, false);
|
||||
|
||||
|
||||
// Log popup closing
|
||||
logWindow.addEventListener("unload", function() {
|
||||
if (!CPLogDisable) {
|
||||
@@ -357,3 +421,10 @@ function _CPLogInitPopup(logWindow)
|
||||
}, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
// guess a good default logger:
|
||||
#if COMMONJS
|
||||
GLOBAL(CPLogDefault) = CPLogPrint;
|
||||
#else
|
||||
GLOBAL(CPLogDefault) = (typeof console !== "undefined") ? CPLogConsole : CPLogPopup;
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
var FILE = require("file");
|
||||
var sprintf = require("printf").sprintf;
|
||||
|
||||
var window = exports.window = require("browser/window");
|
||||
|
||||
if (system.engine === "rhino")
|
||||
@@ -9,7 +7,7 @@ if (system.engine === "rhino")
|
||||
window.__parent__ = null;
|
||||
window.__proto__ = global;
|
||||
}
|
||||
|
||||
|
||||
// setup OBJJ_HOME, OBJJ_INCLUDE_PATHS, etc
|
||||
window.OBJJ_HOME = exports.OBJJ_HOME = FILE.resolve(module.path, "..");
|
||||
|
||||
@@ -79,12 +77,6 @@ exports.run = function(args)
|
||||
// copy the args since we're going to modify them
|
||||
var argv = args.slice(1);
|
||||
|
||||
if (argv[0] === "--version")
|
||||
{
|
||||
print(exports.fullVersionString());
|
||||
return;
|
||||
}
|
||||
|
||||
while (argv.length && argv[0].indexOf('-I') === 0)
|
||||
OBJJ_INCLUDE_PATHS.unshift.apply(OBJJ_INCLUDE_PATHS, argv.shift().substr(2).split(':'));
|
||||
}
|
||||
@@ -186,26 +178,5 @@ exports.make_narwhal_factory = function(path)
|
||||
|
||||
} // end "with"
|
||||
|
||||
var pkg = null;
|
||||
function getPackage() {
|
||||
if (!pkg)
|
||||
pkg = JSON.parse(FILE.path(module.path).dirname().dirname().join("package.json").read({ charset : "UTF-8" }));
|
||||
return pkg;
|
||||
}
|
||||
|
||||
exports.version = function() { return getPackage()["version"]; }
|
||||
exports.revision = function() { return getPackage()["cappuccino-revision"]; }
|
||||
exports.timestamp = function() { return new Date(getPackage()["cappuccino-timestamp"]); }
|
||||
|
||||
exports.fullVersionString = function() {
|
||||
return sprintf("objective-j %s (%04d-%02d-%02d %s)",
|
||||
exports.version(),
|
||||
exports.timestamp().getUTCFullYear(),
|
||||
exports.timestamp().getUTCMonth()+1,
|
||||
exports.timestamp().getUTCDate(),
|
||||
exports.revision().slice(0,6)
|
||||
);
|
||||
}
|
||||
|
||||
if (require.main == module.id)
|
||||
exports.run(system.args);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"description": "Objective-J and Cappuccino module",
|
||||
"keywords": ["objective-j", "objj", "objective j", "cappuccino"],
|
||||
"author": "280 North, Inc. (http://280north.com/)",
|
||||
"version": "0.8.0",
|
||||
"contributors": [
|
||||
"Francisco Tolmasky (http://tolmasky.com/)",
|
||||
"Ross Boucher (http://rossboucher.com/)",
|
||||
|
||||
@@ -137,7 +137,6 @@ Executable.prototype.execute = function()
|
||||
#endif
|
||||
var oldContextBundle = CONTEXT_BUNDLE;
|
||||
|
||||
// FIXME: Should we have stored this?
|
||||
CONTEXT_BUNDLE = CFBundle.bundleContainingURL(this.URL());
|
||||
|
||||
var result = this._function.apply(global, this.functionArguments());
|
||||
@@ -281,18 +280,15 @@ function fileExecutableSearchFinished(/*FileExecutable*/ aFileExecutable)
|
||||
|
||||
function fileExecutableDependencyLoadFinished()
|
||||
{
|
||||
var executables = fileDependencyExecutables,
|
||||
index = 0,
|
||||
count = executables.length;
|
||||
|
||||
fileDependencyExecutables = [];
|
||||
var index = 0,
|
||||
count = fileDependencyExecutables.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
executables[index]._fileDependencyStatus = ExecutableLoadedFileDependencies;
|
||||
fileDependencyExecutables[index]._fileDependencyStatus = ExecutableLoadedFileDependencies;
|
||||
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
var executable = executables[index],
|
||||
var executable = fileDependencyExecutables[index],
|
||||
callbacks = executable._fileDependencyCallbacks,
|
||||
callbackIndex = 0,
|
||||
callbackCount = callbacks.length;
|
||||
|
||||
@@ -87,10 +87,6 @@ new FileList("CommonJS/**/*").forEach(function(aFilename)
|
||||
CLOBBER.include(buildFilename);
|
||||
});
|
||||
|
||||
task ("build", function() {
|
||||
setPackageMetadata(FILE.join($BUILD_CJS_OBJECTIVE_J, "package.json"));
|
||||
});
|
||||
|
||||
$BUILD_CJS_OBJECTIVE_J_FRAMEWORK = FILE.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Objective-J");
|
||||
|
||||
filedir($BUILD_CJS_OBJECTIVE_J_FRAMEWORK, function()
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
@implementation CPLogTest : OJTestCase
|
||||
|
||||
- (void)testCPLogAll
|
||||
{
|
||||
var last = null;
|
||||
var testLogger = function(message, level, title) { last = arguments; }
|
||||
|
||||
var log = CPLog.createLogger("asdf");
|
||||
|
||||
log.register(testLogger);
|
||||
|
||||
["fatal", "error", "warn", "info", "debug", "trace"].forEach(function(level) {
|
||||
last = null;
|
||||
log[level](level);
|
||||
[self assert:last[0] equals:[level]];
|
||||
[self assert:last[1] equals:level];
|
||||
[self assert:last[2] equals:"asdf"];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)testCPLogSingle
|
||||
{
|
||||
var last = null;
|
||||
var testLogger = function(message, level, title) { last = arguments; }
|
||||
|
||||
var log = CPLog.createLogger();
|
||||
|
||||
log.registerSingle(testLogger, "info");
|
||||
|
||||
["fatal", "error", "warn", "info", "debug", "trace"].forEach(function(level) {
|
||||
last = null;
|
||||
log[level](level);
|
||||
if (level === "info")
|
||||
[self assert:last[0] equals:[level]];
|
||||
else
|
||||
[self assert:last equals:null];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)testCPLogRange
|
||||
{
|
||||
var last = null;
|
||||
var testLogger = function(message, level, title) { last = arguments; }
|
||||
|
||||
var log = CPLog.createLogger();
|
||||
|
||||
log.registerRange(testLogger, "warn", "debug");
|
||||
|
||||
["fatal", "error", "warn", "info", "debug", "trace"].forEach(function(level) {
|
||||
last = null;
|
||||
log[level](level);
|
||||
if (level === "warn" || level === "info" || level === "debug")
|
||||
[self assert:last[0] equals:[level]];
|
||||
else
|
||||
[self assert:last equals:null];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)testCPLogUnregister
|
||||
{
|
||||
var last = null;
|
||||
var testLogger = function(message, level, title) { last = arguments; }
|
||||
|
||||
var log = CPLog.createLogger();
|
||||
|
||||
log.register(testLogger);
|
||||
log.unregister(testLogger);
|
||||
|
||||
["fatal", "error", "warn", "info", "debug", "trace"].forEach(function(level) {
|
||||
last = null;
|
||||
log[level](level);
|
||||
[self assert:last equals:null];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
- (void)testCPLogSetTitle
|
||||
{
|
||||
var last = null;
|
||||
var testLogger = function(message, level, title) { last = arguments; }
|
||||
|
||||
var log = CPLog.createLogger();
|
||||
log.register(testLogger);
|
||||
|
||||
CPLog.setDefaultTitle("A")
|
||||
log("");
|
||||
[self assert:last[2] equals:"A"];
|
||||
|
||||
CPLog.setDefaultTitle("B")
|
||||
log("");
|
||||
[self assert:last[2] equals:"B"];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
+1
-1
@@ -14,7 +14,7 @@ app ("capp", function(cappTask)
|
||||
cappTask.setSummary("Setup up Cappuccino projects");
|
||||
cappTask.setIdentifier("com.280n.capp");
|
||||
cappTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
cappTask.setVersion(getCappuccinoVersion());
|
||||
cappTask.setVersion("0.8.0");
|
||||
cappTask.setSources(new FileList("*.j"));
|
||||
cappTask.setResources(new FileList("Resources/*"));
|
||||
cappTask.setIncludesNibsAndXibs(true);
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ function main(args)
|
||||
switch (argument)
|
||||
{
|
||||
case "version":
|
||||
case "--version": return print(require("cappuccino").fullVersionString());
|
||||
case "--version": return print("capp version 0.8.0");
|
||||
|
||||
case "-h":
|
||||
case "--help": return printUsage();
|
||||
|
||||
@@ -13,7 +13,7 @@ app ("nib2cib", function(nib2cibTask)
|
||||
|
||||
nib2cibTask.setIdentifier("com.280n.nib2cib");
|
||||
nib2cibTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
nib2cibTask.setVersion(getCappuccinoVersion());
|
||||
nib2cibTask.setVersion("0.8.0");
|
||||
nib2cibTask.setAuthor("280 North, Inc.");
|
||||
nib2cibTask.setEmail("feedback @nospam@ 280north.com");
|
||||
nib2cibTask.setSummary("nib2cib converts Cocoa nib and xibs to Cappuccino cibs");
|
||||
|
||||
-26
@@ -2,7 +2,6 @@ var SYSTEM = require("system");
|
||||
var FILE = require("file");
|
||||
var OS = require("os");
|
||||
var UTIL = require("util");
|
||||
var stream = require("term").stream;
|
||||
|
||||
var requiresSudo = false;
|
||||
|
||||
@@ -289,31 +288,6 @@ global.symlink_executable = function(source)
|
||||
FILE.symlink(relative, destination);
|
||||
}
|
||||
|
||||
global.getCappuccinoVersion = function() {
|
||||
var versionFile = FILE.path(module.path).dirname().join("version.json");
|
||||
return JSON.parse(versionFile.read({ charset : "UTF-8" })).version;
|
||||
}
|
||||
|
||||
global.setPackageMetadata = function(packagePath) {
|
||||
var pkg = JSON.parse(FILE.read(packagePath, { charset : "UTF-8" }));
|
||||
|
||||
var p = OS.popen(["git", "rev-parse", "--verify", "HEAD"]);
|
||||
if (p.wait() === 0) {
|
||||
var sha = p.stdout.read().split("\n")[0];
|
||||
if (sha.length === 40)
|
||||
pkg["cappuccino-revision"] = sha;
|
||||
}
|
||||
|
||||
pkg["cappuccino-timestamp"] = new Date().getTime();
|
||||
pkg["version"] = getCappuccinoVersion();
|
||||
|
||||
stream.print(" Version: \0purple(" + pkg["version"] + "\0)");
|
||||
stream.print(" Revision: \0purple(" + pkg["cappuccino-revision"] + "\0)");
|
||||
stream.print(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
|
||||
|
||||
FILE.write(packagePath, JSON.stringify(pkg, null, 4), { charset : "UTF-8" });
|
||||
}
|
||||
|
||||
global.subtasks = function(subprojects, taskNames)
|
||||
{
|
||||
taskNames.forEach(function(aTaskName)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"version": "0.8.0"
|
||||
}
|
||||
Reference in New Issue
Block a user