ObjFW
src/OFObject.h
00001 /*
00002  * Copyright (c) 2008, 2009, 2010, 2011
00003  *   Jonathan Schleifer <js@webkeks.org>
00004  *
00005  * All rights reserved.
00006  *
00007  * This file is part of ObjFW. It may be distributed under the terms of the
00008  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
00009  * the packaging of this file.
00010  *
00011  * Alternatively, it may be distributed under the terms of the GNU General
00012  * Public License, either version 2 or 3, which can be found in the file
00013  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
00014  * file.
00015  */
00016 
00017 #import "objfw-defs.h"
00018 
00019 #ifndef __STDC_LIMIT_MACROS
00020 # define __STDC_LIMIT_MACROS
00021 #endif
00022 #ifndef __STDC_CONSTANT_MACROS
00023 # define __STDC_CONSTANT_MACROS
00024 #endif
00025 
00026 #include <stddef.h>
00027 #include <stdint.h>
00028 #include <limits.h>
00029 
00030 #ifdef OF_OBJFW_RUNTIME
00031 # import <objfw-rt.h>
00032 #else
00033 # import <objc/objc.h>
00034 #endif
00035 
00036 #define OF_RETAIN_COUNT_MAX UINT_MAX
00037 #define OF_INVALID_INDEX SIZE_MAX
00038 
00042 typedef enum of_comparison_result_t {
00044         OF_ORDERED_ASCENDING = -1,
00046         OF_ORDERED_SAME = 0,
00048         OF_ORDERED_DESCENDING = 1
00049 } of_comparison_result_t;
00050 
00054 typedef struct of_range_t {
00056         size_t start;
00058         size_t length;
00059 } of_range_t;
00060 
00061 @class OFString;
00062 
00066 @protocol OFObject
00070 - (Class)class;
00071 
00076 - (BOOL)isKindOfClass: (Class)class_;
00077 
00082 - (BOOL)respondsToSelector: (SEL)selector;
00083 
00090 - (id)performSelector: (SEL)selector;
00091 
00099 - (id)performSelector: (SEL)selector
00100            withObject: (id)obj;
00101 
00112 - (id)performSelector: (SEL)selector
00113            withObject: (id)obj1
00114            withObject: (id)obj2;
00115 
00125 - (BOOL)isEqual: (id)obj;
00126 
00135 - (uint32_t)hash;
00136 
00143 - retain;
00144 
00148 - (unsigned int)retainCount;
00149 
00156 - (void)release;
00157 
00162 - autorelease;
00163 @end
00164 
00168 @interface OFObject <OFObject>
00169 {
00170 @public
00172         Class isa;
00173 }
00174 
00181 + (void)load;
00182 
00190 + (void)initialize;
00191 
00201 + alloc;
00202 
00206 + (Class)class;
00207 
00211 + (OFString*)className;
00212 
00218 + (BOOL)isSubclassOfClass: (Class)class_;
00219 
00223 + (Class)superclass;
00224 
00232 + (BOOL)instancesRespondToSelector: (SEL)selector;
00233 
00240 + (BOOL)conformsToProtocol: (Protocol*)protocol;
00241 
00247 + (IMP)instanceMethodForSelector: (SEL)selector;
00248 
00253 + (const char*)typeEncodingForInstanceSelector: (SEL)selector;
00254 
00260 + (OFString*)description;
00261 
00269 + (IMP)setImplementation: (IMP)newimp
00270           forClassMethod: (SEL)selector;
00271 
00279 + (IMP)replaceClassMethod: (SEL)selector
00280       withMethodFromClass: (Class)class_;
00281 
00289 + (IMP)setImplementation: (IMP)newimp
00290        forInstanceMethod: (SEL)selector;
00291 
00299 + (IMP)replaceInstanceMethod: (SEL)selector
00300          withMethodFromClass: (Class)class_;
00301 
00311 - init;
00312 
00316 - (OFString*)className;
00317 
00322 - (BOOL)conformsToProtocol: (Protocol*)protocol;
00323 
00329 - (IMP)methodForSelector: (SEL)selector;
00330 
00336 - (const char*)typeEncodingForSelector: (SEL)selector;
00337 
00343 - (OFString*)description;
00344 
00353 - (void)addMemoryToPool: (void*)ptr;
00354 
00362 - (void*)allocMemoryWithSize: (size_t)size;
00363 
00373 - (void*)allocMemoryForNItems: (size_t)nitems
00374                      withSize: (size_t)size;
00375 
00383 - (void*)resizeMemory: (void*)ptr
00384                toSize: (size_t)size;
00385 
00395 - (void*)resizeMemory: (void*)ptr
00396              toNItems: (size_t)nitems
00397              withSize: (size_t)size;
00398 
00405 - (void)freeMemory: (void*)ptr;
00406 
00412 - (void)dealloc;
00413 @end
00414 
00418 @protocol OFCopying
00422 - copy;
00423 @end
00424 
00431 @protocol OFMutableCopying
00435 - mutableCopy;
00436 @end
00437 
00443 @protocol OFComparing
00450 - (of_comparison_result_t)compare: (id)obj;
00451 @end
00452 
00453 #ifdef __cplusplus
00454 extern "C" {
00455 #endif
00456 extern id objc_getProperty(id, SEL, ptrdiff_t, BOOL);
00457 extern void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, BOOL);
00458 extern size_t of_pagesize;
00459 #ifdef __cplusplus
00460 }
00461 #endif
 All Classes Functions Variables