Merge remote branch 'refs/remotes/280north/master'

This commit is contained in:
Aparajita Fishman
2011-06-01 12:21:27 -07:00
5 changed files with 94 additions and 54 deletions
+2 -2
View File
@@ -386,7 +386,7 @@
_items = [];
if (!_itemPrototype || !_content)
if (!_itemPrototype)
return;
var index = 0;
@@ -412,7 +412,7 @@
{
var width = CGRectGetWidth([self bounds]);
if (![_content count] || width == _tileWidth)
if (width == _tileWidth)
return;
// We try to fit as many views per row as possible. Any remaining space is then
+6 -41
View File
@@ -329,6 +329,11 @@ CPLog(@"Got some class: %@", inst);
return objj_msgSend(self, aSelector, anObject, anotherObject);
}
- (id)forwardingTargetForSelector:(SEL)aSelector
{
return nil;
}
// Forwarding Messages
/*!
Subclasses can override this method to forward message to
@@ -341,36 +346,6 @@ CPLog(@"Got some class: %@", inst);
[self doesNotRecognizeSelector:[anInvocation selector]];
}
/*!
Used for forwarding of messages to other objects.
@ignore
*/
// FIXME: This should be moved to the runtime?
- (void)forward:(SEL)aSelector :(marg_list)args
{
var signature = [self methodSignatureForSelector:aSelector];
if (signature)
{
var invocation = [CPInvocation invocationWithMethodSignature:signature];
[invocation setTarget:self];
[invocation setSelector:aSelector];
var index = 2,
count = args.length;
for (; index < count; ++index)
[invocation setArgument:args[index] atIndex:index];
[self forwardInvocation:invocation];
return [invocation returnValue];
}
[self doesNotRecognizeSelector:aSelector];
}
// Error Handling
/*!
Called by the Objective-J runtime when an object can't respond to
@@ -381,7 +356,7 @@ CPLog(@"Got some class: %@", inst);
{
[CPException raise:CPInvalidArgumentException reason:
(class_isMetaClass(isa) ? "+" : "-") + " [" + [self className] + " " + aSelector + "] unrecognized selector sent to " +
(class_isMetaClass(isa) ? "class" : "instance") + " 0x" + [CPString stringWithHash:[self UID]]];
(class_isMetaClass(isa) ? "class " + class_getName(isa) : "instance 0x" + [CPString stringWithHash:[self UID]])];
}
// Archiving
@@ -542,13 +517,3 @@ CPLog(@"Got some class: %@", inst);
}
@end
// override toString on Objective-J objects so we get the actual description of the object
// when coerced to a string, instead of "[Object object]"
objj_class.prototype.toString = objj_object.prototype.toString = function()
{
if (this.isa && class_getInstanceMethod(this.isa, "description") != NULL)
return [this description];
else
return String(this) + " (-description not implemented)";
}
+80 -8
View File
@@ -71,7 +71,7 @@ GLOBAL(objj_class) = function(displayName)
this.method_dtable = this.method_store.prototype;
#if DEBUG
// naming the allocator allows the WebKit heap snapshot tool to display object class names correctly
// Naming the allocator allows the WebKit heap snapshot tool to display object class names correctly
// HACK: displayName property is not respected so we must eval a function to name it
eval("this.allocator = function " + (displayName || "OBJJ_OBJECT").replace(/\W/g, "_") + "() { }");
#else
@@ -342,10 +342,61 @@ var _class_initialize = function(/*Class*/ aClass)
}
}
var _objj_forward = new objj_method("forward", function(self, _cmd)
var _objj_forward = function(self, _cmd)
{
return objj_msgSend(self, "forward::", _cmd, arguments);
});
var isa = self.isa,
implementation = isa.method_dtable[SEL_forwardingTargetForSelector_];
if (implementation)
{
var target = implementation.method_imp.call(this, self, SEL_forwardingTargetForSelector_, _cmd);
if (target && target !== self)
{
arguments[0] = target;
return objj_msgSend.apply(this, arguments);
}
}
implementation = isa.method_dtable[SEL_methodSignatureForSelector_];
if (implementation)
{
var forwardInvocationImplementation = isa.method_dtable[SEL_forwardInvocation_];
if (forwardInvocationImplementation)
{
var signature = implementation.method_imp.call(this, self, SEL_methodSignatureForSelector_, _cmd);
if (signature)
{
var invocationClass = objj_lookUpClass("CPInvocation");
if (invocationClass)
{
var invocation = objj_msgSend(invocationClass, SEL_invocationWithMethodSignature_, signature),
index = 0,
count = arguments.length;
for (; index < count; ++index)
objj_msgSend(invocation, SEL_setArgument_atIndex_, arguments[index], index);
forwardInvocationImplementation.method_imp.call(this, self, SEL_forwardInvocation_, invocation);
return objj_msgSend(invocation, SEL_returnValue);
}
}
}
}
implementation = isa.method_dtable[SEL_doesNotRecognizeSelector_];
if (implementation)
return implementation.method_imp.call(this, self, SEL_doesNotRecognizeSelector_, _cmd);
throw class_getName(isa) + " does not implement doesNotRecognizeSelector:. Did you forget a superclass for " + class_getName(isa) + "?";
};
// I think this forward:: may need to be a common method, instead of defined in CPObject.
#define CLASS_GET_METHOD_IMPLEMENTATION(aMethodImplementation, aClass, aSelector)\
@@ -354,10 +405,7 @@ var _objj_forward = new objj_method("forward", function(self, _cmd)
\
var method = aClass.method_dtable[aSelector];\
\
if (!method)\
method = _objj_forward;\
\
aMethodImplementation = method.method_imp;
aMethodImplementation = method ? method.method_imp : _objj_forward;
GLOBAL(class_getMethodImplementation) = function(/*Class*/ aClass, /*SEL*/ aSelector)
{
@@ -657,3 +705,27 @@ GLOBAL(sel_registerName) = function(/*String*/ aName)
}
DISPLAY_NAME(sel_registerName);
objj_class.prototype.toString = objj_object.prototype.toString = function()
{
var isa = this.isa;
if (class_getInstanceMethod(isa, SEL_description))
return objj_msgSend(this, SEL_description);
if (class_isMetaClass(isa))
return this.name;
return "[" + isa.name + " Object](-description not implemented)";
}
var SEL_description = sel_getUid("description"),
SEL_forwardingTargetForSelector_ = sel_getUid("forwardingTargetForSelector:"),
SEL_methodSignatureForSelector_ = sel_getUid("methodSignatureForSelector:"),
SEL_forwardInvocation_ = sel_getUid("forwardInvocation:"),
SEL_doesNotRecognizeSelector_ = sel_getUid("doesNotRecognizeSelector:"),
SEL_invocationWithMethodSignature_ = sel_getUid("invocationWithMethodSignature:"),
SEL_setTarget_ = sel_getUid("setTarget:"),
SEL_setSelector_ = sel_getUid("setSelector:"),
SEL_setArgument_atIndex_ = sel_getUid("setArgument:atIndex:"),
SEL_returnValue = sel_getUid("returnValue");
+2
View File
@@ -199,6 +199,8 @@ var NSButtonIsBorderedMask = 0x00800000,
[self setImage:[cell normalImage]];
[self setImagePosition:[cell imagePosition]];
[self setEnabled:[cell isEnabled]];
return self;
}
+4 -3
View File
@@ -44,9 +44,10 @@
[self setFont:[cell font]];
[self setAlignment:[cell alignment]];
// The NSEnabled flag is never changed when changing the enabled state of a control
// Enabled state should is derived from the NSCellFlags decoded by NSCell
[self setEnabled:[cell isEnabled]];
// Enabled state is derived from the NSEnabled flag or the control's cell.
// For example NSTableView uses the NSEnabled flag, but NSButton uses it's cell isEnabled state.
// We use the NSEnabled flag here and override the behavior in controls using different logic (NSButton).
[self setEnabled:[aCoder decodeBoolForKey:@"NSEnabled"]];
[self setContinuous:[cell isContinuous]];
[self setTarget:[aCoder decodeObjectForKey:@"NSTarget"]];