80 - (id)performSelector:(
SEL)aSelector;
81 - (id)performSelector:(
SEL)aSelector withObject:(
id)object;
82 - (id)performSelector:(
SEL)aSelector withObject:(
id)object1 withObject:(
id)object2;
86 - (BOOL)isKindOfClass:(Class)aClass;
87 - (BOOL)isMemberOfClass:(Class)aClass;
88 - (BOOL)conformsToProtocol:(Protocol)aProtocol;
90 - (BOOL)respondsToSelector:(
SEL)aSelector;
100 - (void)encodeWithCoder:(
CPCoder)aCoder;
101 - (id)initWithCoder:(
CPCoder)aDecoder;
125 return [[
self alloc] init];
134 return class_createInstance(
self);
137 + (id)allocWithCoder:(
CPCoder)aCoder
198 return self.super_class;
205 + (BOOL)isSubclassOfClass:(Class)aClass
209 for (; theClass; theClass = theClass.super_class)
210 if (theClass === aClass)
220 - (BOOL)isKindOfClass:(Class)aClass
222 return [isa isSubclassOfClass:aClass];
225 + (BOOL)isKindOfClass:(Class)aClass
227 return [
self isSubclassOfClass:aClass];
234 - (BOOL)isMemberOfClass:(Class)aClass
236 return self.isa === aClass;
239 + (BOOL)isMemberOfClass:(Class)aClass
241 return self === aClass;
259 + (BOOL)instancesRespondToSelector:(
SEL)aSelector
261 return !!class_getInstanceMethod(
self, aSelector);
269 - (BOOL)respondsToSelector:(
SEL)aSelector
272 return !!class_getInstanceMethod(
isa, aSelector);
280 - (BOOL)implementsSelector:(
SEL)aSelector
282 var methods = class_copyMethodList(
isa),
283 count = methods.length;
286 if (method_getName(methods[count]) === aSelector)
297 + (BOOL)conformsToProtocol:(Protocol)aProtocol
299 return class_conformsToProtocol(
self, aProtocol);
307 - (BOOL)conformsToProtocol:(Protocol)aProtocol
309 return class_conformsToProtocol(
isa, aProtocol);
319 - (IMP)methodForSelector:(
SEL)aSelector
321 return class_getMethodImplementation(
isa, aSelector);
329 + (IMP)instanceMethodForSelector:(
SEL)aSelector
331 return class_getMethodImplementation(
self, aSelector);
339 - (CPMethodSignature)methodSignatureForSelector:(
SEL)aSelector
351 return "<" + class_getName(
isa) + " 0x" + [
CPString stringWithHash:[self UID]] + ">";
356 return class_getName(
self.
isa);
365 - (id)performSelector:(
SEL)aSelector
367 return objj_msgSend(
self, aSelector);
376 - (id)performSelector:(
SEL)aSelector withObject:(
id)anObject
378 return objj_msgSend(
self, aSelector, anObject);
388 - (id)performSelector:(
SEL)aSelector withObject:(
id)anObject withObject:(
id)anotherObject
390 return objj_msgSend(
self, aSelector, anObject, anotherObject);
399 - (id)performSelector:(
SEL)aSelector withObjects:(
id)anObject, ...
401 var params = [
self, aSelector].concat(Array.prototype.slice.apply(arguments, [3]));
402 return objj_msgSend.apply(
this, params);
405 - (id)forwardingTargetForSelector:(
SEL)aSelector
419 [
self doesNotRecognizeSelector:[anInvocation
selector]];
428 - (void)doesNotRecognizeSelector:(
SEL)aSelector
431 (class_isMetaClass(isa) ? "+" : "-") + " [" + [
self className] + " " + aSelector + "] unrecognized selector sent to " +
432 (class_isMetaClass(isa) ? "class " + class_getName(isa) : "instance 0x" + [
CPString stringWithHash:[
self UID]])];
444 - (id)awakeAfterUsingCoder:(
CPCoder)aCoder
453 - (Class)classForKeyedArchiver
455 return [
self classForCoder];
462 - (Class)classForCoder
472 - (id)replacementObjectForArchiver:(CPArchiver)anArchiver
474 return [
self replacementObjectForCoder:anArchiver];
484 return [
self replacementObjectForCoder:anArchiver];
492 - (id)replacementObjectForCoder:(
CPCoder)aCoder
501 + (void)setVersion:(
int)aVersion
503 class_setVersion(
self, aVersion);
511 return class_getVersion(
self);
545 if (typeof
self._UID ===
"undefined")
546 self._UID = objj_generateObjectUID();
548 return self._UID + "";
557 return self === anObject || [
self UID] === [anObject UID];
589 return isa.super_class;
594 function CPDescriptionOfObject(anObject, maximumRecursionDepth)
596 if (anObject === nil)
599 if (anObject === undefined)
602 if (anObject === window)
605 if (maximumRecursionDepth === 0)
610 if ([anObject isKindOfClass:
CPString])
611 return '@"' + [anObject description] + '"';
613 if ([anObject respondsToSelector:
@selector(_descriptionWithMaximumDepth:)])
614 return [anObject _descriptionWithMaximumDepth:maximumRecursionDepth !== undefined ? maximumRecursionDepth - 1 : maximumRecursionDepth];
616 return [anObject description];
619 if (typeof(anObject) !==
"object")
620 return String(anObject);
625 for (var property in anObject)
626 if (anObject.hasOwnProperty(property))
627 properties.push(property);
631 if (properties.length === 2 && anObject.hasOwnProperty(
"width") && anObject.hasOwnProperty(
"height"))
632 desc = [CPString stringWithFormat:
@"CGSize: (%f, %f)", anObject.width, anObject.height];
633 else if (properties.length === 2 && anObject.hasOwnProperty(
"x") && anObject.hasOwnProperty(
"y"))
634 desc = [CPString stringWithFormat:
@"CGPoint: (%f, %f)", anObject.x, anObject.y];
635 else if (properties.length === 2 && anObject.hasOwnProperty(
"origin") && anObject.hasOwnProperty(
"size"))
636 desc = [CPString stringWithFormat:
@"CGRect: (%f, %f), (%f, %f)", anObject.origin.x, anObject.origin.y, anObject.size.width, anObject.size.height];
637 else if (properties.length === 4 && anObject.hasOwnProperty(
"top") && anObject.hasOwnProperty(
"right") && anObject.hasOwnProperty(
"bottom") && anObject.hasOwnProperty(
"left"))
638 desc = [CPString stringWithFormat:
@"CGInset: { top:%f, right:%f, bottom:%f, left:%f }", anObject.top, anObject.right, anObject.bottom, anObject.left];
643 for (var i = 0; i < properties.length; ++i)
648 var value = anObject[properties[i]],
649 valueDescription = CPDescriptionOfObject(value, maximumRecursionDepth !== undefined ? maximumRecursionDepth - 1 : maximumRecursionDepth).split(
"\n").join(
"\n ");
651 desc += " " + properties[i] + ": " + valueDescription;
653 if (i < properties.length - 1)