Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -54,14 +54,84 @@ size_t length; } of_range_t; @class OFString; +/** + * \brief The protocol which all root classes implement. + */ +@protocol OFObject +/** + * \return The class of the object + */ +- (Class)class; + +/** + * \param class_ The class whose kind is checked + * \return A boolean whether the object is of the specified kind + */ +- (BOOL)isKindOfClass: (Class)class_; + +/** + * \param selector The selector which should be checked for respondance + * \return A boolean whether the objects responds to the specified selector + */ +- (BOOL)respondsToSelector: (SEL)selector; + +/** + * Checks two objects for equality. + * + * Classes containing data (like strings, arrays, lists etc.) should reimplement + * this! + * + * \param obj The object which should be tested for equality + * \return A boolean whether the object is equal to the specified object + */ +- (BOOL)isEqual: (id)obj; + +/** + * Calculates a hash for the object. + * + * Classes containing data (like strings, arrays, lists etc.) should reimplement + * this! + * + * \return A 32 bit hash for the object + */ +- (uint32_t)hash; + +/** + * Increases the retain count. + * + * Each time an object is released, the retain count gets decreased and the + * object deallocated if it reaches 0. + */ +- retain; + +/** + * \return The retain count + */ +- (size_t)retainCount; + +/** + * Decreases the retain count. + * + * Each time an object is released, the retain count gets decreased and the + * object deallocated if it reaches 0. + */ +- (void)release; + +/** + * Adds the object to the topmost OFAutoreleasePool of the thread's release pool + * stack. + */ +- autorelease; +@end + /** * \brief The root class for all other classes inside ObjFW. */ -@interface OFObject +@interface OFObject { @public /// The class of the object Class isa; } @@ -202,32 +272,15 @@ * * \return An initialized object */ - init; -/** - * \return The class of the object - */ -- (Class)class; - /** * \return The name of the object's class. */ - (OFString*)className; -/** - * \param class_ The class whose kind is checked - * \return A boolean whether the object is of the specified kind - */ -- (BOOL)isKindOfClass: (Class)class_; - -/** - * \param selector The selector which should be checked for respondance - * \return A boolean whether the objects responds to the specified selector - */ -- (BOOL)respondsToSelector: (SEL)selector; - /** * \param protocol The protocol which should be checked for conformance * \return A boolean whether the objects conforms to the specified protocol */ - (BOOL)conformsToProtocol: (Protocol*)protocol; @@ -244,31 +297,10 @@ * * \return The type encoding for the specified selector */ - (const char*)typeEncodingForSelector: (SEL)selector; -/** - * Checks two objects for equality. - * - * Classes containing data (like strings, arrays, lists etc.) should reimplement - * this! - * - * \param obj The object which should be tested for equality - * \return A boolean whether the object is equal to the specified object - */ -- (BOOL)isEqual: (id)obj; - -/** - * Calculates a hash for the object. - * - * Classes containing data (like strings, arrays, lists etc.) should reimplement - * this! - * - * \return A 32 bit hash for the object - */ -- (uint32_t)hash; - /** * Returns a description for the object. * * This is mostly for debugging purposes. */ @@ -334,37 +366,10 @@ * * \param ptr A pointer to the allocated memory */ - (void)freeMemory: (void*)ptr; -/** - * Increases the retain count. - * - * Each time an object is released, the retain count gets decreased and the - * object deallocated if it reaches 0. - */ -- retain; - -/** - * \return The retain count - */ -- (size_t)retainCount; - -/** - * Decreases the retain count. - * - * Each time an object is released, the retain count gets decreased and the - * object deallocated if it reaches 0. - */ -- (void)release; - -/** - * Adds the object to the topmost OFAutoreleasePool of the thread's release pool - * stack. - */ -- autorelease; - /** * Deallocates the object and also frees all memory in its memory pool. * * It is also called when the retain count reaches zero. */