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

This commit is contained in:
Alexander Ljungberg
2011-07-06 13:32:46 -04:00
8 changed files with 386 additions and 9 deletions
+38
View File
@@ -1458,6 +1458,44 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
userInfo:[CPDictionary dictionaryWithObject:item forKey:"CPObject"]];
}
- (void)keyDown:(CPEvent)anEvent
{
var character = [anEvent charactersIgnoringModifiers],
modifierFlags = [anEvent modifierFlags];
// Check for the key events manually, as opposed to waiting for CPWindow to sent the actual action message
// in _processKeyboardUIKey:, because we might not want to handle the arrow events.
if (character !== CPRightArrowFunctionKey && character !== CPLeftArrowFunctionKey)
return [super keyDown:anEvent];
var rows = [self selectedRowIndexes],
indexes = [],
items = [];
[rows getIndexes:indexes maxCount:-1 inIndexRange:nil];
var i = 0,
c = [indexes count];
for (; i < c; i++)
items.push([self itemAtRow:indexes[i]]);
if (character === CPRightArrowFunctionKey)
{
for (var i = 0; i < c; i++)
[self expandItem:items[i]];
}
else if (character === CPLeftArrowFunctionKey)
{
for (var i = 0; i < c; i++)
[self collapseItem:items[i]];
}
[super keyDown:anEvent];
}
@end
// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever...
+1 -1
View File
@@ -2770,7 +2770,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
*/
- (BOOL)canDragRowsWithIndexes:(CPIndexSet)rowIndexes atPoint:(CGPoint)mouseDownPoint
{
return YES;
return [rowIndexes count] > 0 && [self numberOfRows] > 0;
}
/*!
+1 -1
View File
@@ -1015,7 +1015,7 @@ var TOP_MARGIN = 5.0,
_labelSize = [_labelField frame].size;
_minSize = CGSizeMake(MAX(_labelSize.width, minSize.width), _labelSize.height + minSize.height + LABEL_MARGIN + TOP_MARGIN);
_maxSize = CGSizeMake(MAX(_labelSize.width, minSize.width), 100000000.0);
_maxSize = CGSizeMake(MIN(_labelSize.width, maxSize.width), 100000000.0);
[_toolbar tile];
}
+1 -1
View File
@@ -225,7 +225,7 @@ var ItemSizes = { },
}
}
+ (void)registerThemeValues:(CPArray)themeValues forView:aView inherit:(CPArray)inheritedValues
+ (void)registerThemeValues:(CPArray)themeValues forView:(CPView)aView inherit:(CPArray)inheritedValues
{
// Register inherited values first, then override those with the subtheme values.
if (inheritedValues)
@@ -836,8 +836,7 @@ BundleTask.prototype.defineSourceTasks = function()
environmentSources.forEach(function(/*String*/ aFilename)
{
// if this file doesn't exist or isn't a .j file, don't preprocess it.
if (!FILE.exists(aFilename) || FILE.extension(aFilename) !== '.j')
if (!FILE.exists(aFilename))
return;
var relativePath = aFilename.substring(basePathLength ? basePathLength + 1 : basePathLength),
@@ -845,8 +844,19 @@ BundleTask.prototype.defineSourceTasks = function()
filedir (compiledEnvironmentSource, [aFilename], function()
{
TERM.stream.write("Compiling [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)").flush();
var compiled = require("objective-j/compiler").compile(aFilename, environmentCompilerFlags);
var compile
// if this file doesn't exist or isn't a .j file, don't preprocess it.
if (FILE.extension(aFilename) !== ".j")
{
TERM.stream.write("Including [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)").flush();
var compiled = FILE.read(aFilename, { charset:"UTF-8" });
}
else
{
TERM.stream.write("Compiling [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)").flush();
var compiled = require("objective-j/compiler").compile(aFilename, environmentCompilerFlags);
}
TERM.stream.print(Array(Math.round(compiled.length / 1024) + 3).join("."));
FILE.write(compiledEnvironmentSource, compiled, { charset:"UTF-8" });
});
+326
View File
@@ -0,0 +1,326 @@
@import <Foundation/Foundation.j>
@implementation RootClass
{
}
+ (id)alloc
{
return class_createInstance(self);
}
@end
@implementation RootClassWithDoesNotRecognizeSelector
{
}
+ (id)alloc
{
return class_createInstance(self);
}
- (void)doesNotRecognizeSelector:(SEL)aSelector
{
throw "ERROR";
}
@end
@implementation Subclass : CPObject
{
}
@end
@implementation RootClassWithForwardingTarget
{
}
+ (void)initialize
{
}
+ (id)alloc
{
return class_createInstance(self);
}
- (id)forwardingTargetForSelector:(SEL)aSelector
{
if (aSelector !== @selector(doesNotExist))
return nil;
if (class_isMetaClass(isa))
return GlobalMethodDispatchTest;
return GlobalMethodDispatchTest;
}
@end
@implementation SubclassWithForwardingTarget : CPObject
{
}
+ (id)forwardingTargetForSelector:(SEL)aSelector
{
if (aSelector !== @selector(doesNotExist))
return [super forwardingTargetForSelector:aSelector];
return GlobalMethodDispatchTest;
}
- (id)forwardingTargetForSelector:(SEL)aSelector
{
if (aSelector !== @selector(doesNotExist))
return [super forwardingTargetForSelector:aSelector];
return GlobalMethodDispatchTest;
}
@end
@implementation RootClassWithForwardInvocation
{
}
+ (void)initialize
{
}
+ (id)alloc
{
return class_createInstance(self);
}
- (CPMethodSignature)methodSignatureForSelector:(SEL)aSelector
{
if (aSelector === @selector(doesNotExist))
return 1;
return nil;
}
- (void)forwardInvocation:(CPInvocation)anInvocation
{
[anInvocation setTarget:GlobalMethodDispatchTest];
[anInvocation invoke];
}
@end
@implementation SubclassWithForwardInvocation : CPObject
{
}
+ (CPMethodSignature)methodSignatureForSelector:(SEL)aSelector
{
if (aSelector === @selector(doesNotExist))
return 1;
return nil;
}
+ (void)forwardInvocation:(CPInvocation)anInvocation
{
[anInvocation setTarget:GlobalMethodDispatchTest];
[anInvocation invoke];
}
- (CPMethodSignature)methodSignatureForSelector:(SEL)aSelector
{
if (aSelector === @selector(doesNotExist))
return 1;
return nil;
}
- (void)forwardInvocation:(CPInvocation)anInvocation
{
[anInvocation setTarget:GlobalMethodDispatchTest];
[anInvocation invoke];
}
@end
var GlobalMethodDispatchTest;
@implementation MethodDispatchTest : OJTestCase
{
}
- (id)init
{
self = [super init];
if (self)
GlobalMethodDispatchTest = self;
return self;
}
- (BOOL)doesNotExist
{
return YES;
}
- (void)test_RootClass_class_doesNotRecognizeSelector_
{
try
{
[RootClass doesNotExist];
}
catch (anException)
{
[self assert:anException equals:"RootClass does not implement doesNotRecognizeSelector:. Did you forget a superclass for RootClass?"];
}
}
- (void)test_RootClass_instance_doesNotRecognizeSelector_
{
var object = [RootClass alloc];
try
{
[object doesNotExist];
}
catch (anException)
{
[self assert:anException equals:"RootClass does not implement doesNotRecognizeSelector:. Did you forget a superclass for RootClass?"];
}
}
- (void)test_RootClassWithDoesNotRecognizeSelector_class_doesNotRecognizeSelector_
{
try
{
[RootClassWithDoesNotRecognizeSelector doesNotExist];
}
catch (anException)
{
[self assert:anException equals:"ERROR"];
}
}
- (void)test_RootClassWithDoesNotRecognizeSelector_instance_doesNotRecognizeSelector_
{
var object = [RootClassWithDoesNotRecognizeSelector alloc];
try
{
[object doesNotExist];
}
catch (anException)
{
[self assert:anException equals:"ERROR"];
}
}
- (void)test_CPObject_class_doesNotRecognizeSelector_
{
try
{
[CPObject doesNotExist];
}
catch (anException)
{
[self assert:[anException name] equals:CPInvalidArgumentException];
[self assert:[anException reason] equals:@"+ [CPObject doesNotExist] unrecognized selector sent to class CPObject"];
}
}
- (void)test_CPObject_instance_doesNotRecognizeSelector_
{
var object = [CPObject alloc];
try
{
[object doesNotExist];
}
catch (anException)
{
[self assert:[anException name] equals:CPInvalidArgumentException];
[self assert:[anException reason] equals:@"- [CPObject doesNotExist] unrecognized selector sent to instance 0x" + [CPString stringWithHash:[object UID]]];
}
}
- (void)test_Subclass_class_doesNotRecognizeSelector_
{
try
{
[Subclass doesNotExist];
}
catch (anException)
{
[self assert:[anException name] equals:CPInvalidArgumentException];
[self assert:[anException reason] equals:@"+ [Subclass doesNotExist] unrecognized selector sent to class Subclass"];
}
}
- (void)test_Subclass_instance_doesNotRecognizeSelector_
{
var object = [Subclass alloc];
try
{
[object doesNotExist];
}
catch (anException)
{
[self assert:[anException name] equals:CPInvalidArgumentException];
[self assert:[anException reason] equals:@"- [Subclass doesNotExist] unrecognized selector sent to instance 0x" + [CPString stringWithHash:[object UID]]];
}
}
- (void)test_RootClassWithForwardingTarget_class_forwardingTargetForSelector_
{
[self assert:YES equals:[RootClassWithForwardingTarget doesNotExist]];
}
- (void)test_RootClassWithForwardingTarget_instance_forwardingTargetForSelector_
{
var object = [RootClassWithForwardingTarget alloc];
[self assert:YES equals:[object doesNotExist]];
}
- (void)test_SubclassWithForwardingTarget_class_forwardingTargetForSelector_
{
[self assert:YES equals:[SubclassWithForwardingTarget doesNotExist]];
}
- (void)test_SubclassWithForwardingTarget_instance_forwardingTargetForSelector_
{
var object = [[SubclassWithForwardingTarget alloc] init];
[self assert:YES equals:[object doesNotExist]];
}
- (void)test_RootClassWithForwardInvocation_class_forwardInvocation_
{
[self assert:YES equals:[RootClassWithForwardInvocation doesNotExist]];
}
- (void)test_RootClassWithForwardInvocation_instance_forwardInvocation_
{
var object = [RootClassWithForwardInvocation alloc];
[self assert:YES equals:[object doesNotExist]];
}
- (void)test_SubclassWithForwardInvocation_class_forwardInvocation_
{
[self assert:YES equals:[SubclassWithForwardInvocation doesNotExist]];
}
- (void)test_SubclassWithForwardInvocation_instance_forwardInvocation_
{
var object = [[SubclassWithForwardInvocation alloc] init];
[self assert:YES equals:[object doesNotExist]];
}
@end
+5 -2
View File
@@ -51,18 +51,21 @@ function main(args)
{
try
{
var options = parseOptions(args);
var options = parseOptions(args),
ret = 0;
if (options.watch)
watch(options);
else
convert(options);
if (!convert(options))
ret = 2;
}
catch (anException)
{
CPLog.fatal(exceptionReason(anException));
OS.exit(1);
}
OS.exit(ret);
}
function convert(options, inputFile)
Regular → Executable
View File