78 - (id)performSelector:(
SEL)aSelector;
79 - (id)performSelector:(
SEL)aSelector withObject:(
id)object;
80 - (id)performSelector:(
SEL)aSelector withObject:(
id)object1 withObject:(
id)object2;
84 - (BOOL)isKindOfClass:(Class)aClass;
85 - (BOOL)isMemberOfClass:(Class)aClass;
86 - (BOOL)conformsToProtocol:(Protocol)aProtocol;
88 - (BOOL)respondsToSelector:(
SEL)aSelector;
98 - (void)encodeWithCoder:(
CPCoder)aCoder;
99 - (id)initWithCoder:(
CPCoder)aDecoder;
123 return [[
self alloc] init];
132 return class_createInstance(
self);
135 + (id)allocWithCoder:(
CPCoder)aCoder
196 return self.super_class;
203 + (BOOL)isSubclassOfClass:(Class)aClass
207 for (; theClass; theClass = theClass.super_class)
208 if (theClass === aClass)
218 - (BOOL)isKindOfClass:(Class)aClass
220 return [isa isSubclassOfClass:aClass];
223 + (BOOL)isKindOfClass:(Class)aClass
232 - (BOOL)isMemberOfClass:(Class)aClass
234 return self.isa === aClass;
237 + (BOOL)isMemberOfClass:(Class)aClass
239 return self === aClass;
257 + (BOOL)instancesRespondToSelector:(
SEL)aSelector
259 return !!class_getInstanceMethod(
self, aSelector);
267 - (BOOL)respondsToSelector:(
SEL)aSelector
270 return !!class_getInstanceMethod(
isa, aSelector);
278 - (BOOL)implementsSelector:(
SEL)aSelector
280 var methods = class_copyMethodList(
isa),
281 count = methods.length;
284 if (method_getName(methods[count]) === aSelector)
295 + (BOOL)conformsToProtocol:(Protocol)aProtocol
297 return class_conformsToProtocol(
self, aProtocol);
305 - (BOOL)conformsToProtocol:(Protocol)aProtocol
307 return class_conformsToProtocol(
isa, aProtocol);
317 - (IMP)methodForSelector:(
SEL)aSelector
319 return class_getMethodImplementation(
isa, aSelector);
327 + (IMP)instanceMethodForSelector:(
SEL)aSelector
329 return class_getMethodImplementation(
self, aSelector);
337 - (CPMethodSignature)methodSignatureForSelector:(
SEL)aSelector
354 return class_getName(
self.
isa);
363 - (id)performSelector:(
SEL)aSelector
365 return self.isa.objj_msgSend0(
self, aSelector);
374 - (id)performSelector:(
SEL)aSelector withObject:(id)anObject
376 return self.isa.objj_msgSend1(
self, aSelector, anObject);
386 - (id)performSelector:(
SEL)aSelector withObject:(id)anObject withObject:(
id)anotherObject
388 return self.isa.objj_msgSend2(
self, aSelector, anObject, anotherObject);
397 - (id)performSelector:(
SEL)aSelector withObjects:(id)anObject, ...
399 var params = [
self, aSelector].concat(Array.prototype.slice.apply(arguments, [3]));
400 return objj_msgSend.apply(
this, params);
403 - (id)forwardingTargetForSelector:(
SEL)aSelector
426 - (void)doesNotRecognizeSelector:(
SEL)aSelector
429 (class_isMetaClass(isa) ? "+" : "-") + " [" + [
self className] + " " + aSelector + "] unrecognized selector sent to " +
442 - (id)awakeAfterUsingCoder:(
CPCoder)aCoder
470 - (id)replacementObjectForArchiver:(CPArchiver)anArchiver
490 - (id)replacementObjectForCoder:(
CPCoder)aCoder
499 + (void)setVersion:(
int)aVersion
501 class_setVersion(
self, aVersion);
509 return class_getVersion(
self);
543 if (typeof
self._UID ===
"undefined")
544 self._UID = objj_generateObjectUID();
546 return self._UID +
"";
555 return self === anObject || [
self UID] === [anObject UID];
587 return isa.super_class;
594 if (anObject === nil)
597 if (anObject === undefined)
600 if (anObject === window)
603 if (maximumRecursionDepth === 0)
608 if ([anObject isKindOfClass:
CPString])
609 return '@"' + [anObject description] +
'"';
611 if ([anObject respondsToSelector:
@selector(_descriptionWithMaximumDepth:)])
612 return [anObject _descriptionWithMaximumDepth:maximumRecursionDepth !== undefined ? maximumRecursionDepth - 1 : maximumRecursionDepth];
614 return [anObject description];
617 if (typeof(anObject) !==
"object")
618 return String(anObject);
623 for (var property in anObject)
624 if (anObject.hasOwnProperty(property))
625 properties.push(property);
629 if (properties.length === 2 && anObject.hasOwnProperty(
"width") && anObject.hasOwnProperty(
"height"))
630 desc = [
CPString stringWithFormat:
@"CGSize: (%f, %f)", anObject.width, anObject.height];
631 else if (properties.length === 2 && anObject.hasOwnProperty(
"x") && anObject.hasOwnProperty(
"y"))
632 desc = [
CPString stringWithFormat:
@"CGPoint: (%f, %f)", anObject.x, anObject.y];
633 else if (properties.length === 2 && anObject.hasOwnProperty(
"origin") && anObject.hasOwnProperty(
"size"))
634 desc = [
CPString stringWithFormat:
@"CGRect: (%f, %f), (%f, %f)", anObject.origin.x, anObject.origin.y, anObject.size.width, anObject.size.height];
635 else if (properties.length === 4 && anObject.hasOwnProperty(
"top") && anObject.hasOwnProperty(
"right") && anObject.hasOwnProperty(
"bottom") && anObject.hasOwnProperty(
"left"))
636 desc = [
CPString stringWithFormat:
@"CGInset: { top:%f, right:%f, bottom:%f, left:%f }", anObject.top, anObject.right, anObject.bottom, anObject.left];
641 for (var i = 0; i < properties.length; ++i)
646 var value = anObject[properties[i]],
647 valueDescription =
CPDescriptionOfObject(value, maximumRecursionDepth !== undefined ? maximumRecursionDepth - 1 : maximumRecursionDepth).split(
"\n").join(
"\n ");
649 desc +=
" " + properties[i] +
": " + valueDescription;
651 if (i < properties.length - 1)
void doesNotRecognizeSelector:(SEL aSelector)
Used to implement exception handling (creating & raising).
function CPDescriptionOfObject(anObject, maximumRecursionDepth)
void raise:reason:(CPString aName, [reason] CPString aReason)
CPInvalidArgumentException
An object representation of a message.
Implements keyed archiving of object graphs (e.g. for storing data).
An immutable string (collection of characters).
if(CPFeatureIsCompatible(CPHTMLCanvasFeature))
Class classForKeyedArchiver()
id stringWithHash:(unsigned aHash)
BOOL isSubclassOfClass:(Class aClass)
Defines methods for use when archiving & restoring (enc/decoding).
id replacementObjectForCoder:(CPCoder aCoder)