Overview
Comment: | Improve documentation. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
146db53e4a3158b85015648137226eb2 |
User & Date: | js on 2009-08-26 19:40:11 |
Other Links: | manifest | tags |
Context
2009-08-26
| ||
19:54 | More documentation improvements. check-in: d6b9b175b7 user: js tags: trunk | |
19:40 | Improve documentation. check-in: 146db53e4a user: js tags: trunk | |
15:00 | Add support for comments to OFXMLParser. check-in: 6f61176375 user: js tags: trunk | |
Changes
Modified src/OFList.h from [fdd2b6ed1c] to [493af3623a].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFObject.h" typedef struct __of_list_object { struct __of_list_object *next; struct __of_list_object *prev; id object; } of_list_object_t; /** * The OFList class provides easy to use double-linked lists. */ @interface OFList: OFObject <OFCopying> | > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFObject.h" /** * A struct that contains a pointer to the next list object, the previous list * object and the object. */ typedef struct __of_list_object { /// A pointer to the next list object in the list struct __of_list_object *next; /// A pointer to the previous list object in the list struct __of_list_object *prev; /// The object for the list object id object; } of_list_object_t; /** * The OFList class provides easy to use double-linked lists. */ @interface OFList: OFObject <OFCopying> |
︙ | ︙ | |||
44 45 46 47 48 49 50 | * * \param listobj_size The size of a list object * \return An initialized OFList with the specified list object size */ - initWithListObjectSize: (size_t)listobj_size; /** | | | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | * * \param listobj_size The size of a list object * \return An initialized OFList with the specified list object size */ - initWithListObjectSize: (size_t)listobj_size; /** * Initializes an already allocated OFList that does not retain/release objects * added to it. * * \return An initialized OFList */ - initWithoutRetainAndRelease; /** * \return The first list object in the list */ - (of_list_object_t*)first; /** * \return The last list object in the list */ - (of_list_object_t*)last; /** * Appends an object to the list. * * \param obj The object to append |
︙ | ︙ | |||
106 107 108 109 110 111 112 | * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ - (of_list_object_t*)insert: (id)obj after: (of_list_object_t*)listobj; /** | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ - (of_list_object_t*)insert: (id)obj after: (of_list_object_t*)listobj; /** * Removes the object with the specified list object from the list. * * \param listobj The list object returned by append / prepend */ - remove: (of_list_object_t*)listobj; /** * Get the number of items in the list. Use with caution, as this means one * iteration through the whole list! * * \return The number of items in the list. */ - (size_t)count; @end |
Modified src/OFObject.h from [6180a99265] to [5cc0fd9342].
︙ | ︙ | |||
23 24 25 26 27 28 29 | #endif /** * The OFObject class is the base class for all other classes inside ObjFW. */ @interface OFObject { | > | > | > | | > | > < > | | | < | | < < < | > | | | | | | | | > | | | | > > > < < < < < | > > > > > > > > > | < > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | #endif /** * The OFObject class is the base class for all other classes inside ObjFW. */ @interface OFObject { /// The class of the object Class isa; } /** * This code is executed once when a method of the class is called for the first * time. * * Derived classes can override this to execute their own code on * initialization. */ + (void)initialize; /** * Allocates memory for an instance of the class and sets up the memory pool for * the object. * * alloc will never return nil, instead, it will throw an * OFAllocFailedException. * * \return The allocated object. */ + alloc; /** * \return The class */ + (Class)class; /** * \return The name of the class as a C string */ + (const char*)className; /** * Checks whether instances of the class respond to a given selector. * * \param selector The selector which should be checked for respondance * \return A boolean whether instances of the class respond to the specified * selector */ + (BOOL)instancesRespondToSelector: (SEL)selector; /** * Checks whether the class conforms to a given protocol. * * \param protocol The protocol which should be checked for conformance * \return A boolean whether the class conforms to the specified protocol */ + (BOOL)conformsToProtocol: (Protocol*)protocol; /** * \param selector The selector for which the method should be returned * \return The implementation of the instance method for the specified selector * or nil if it isn't implemented */ + (IMP)instanceMethodForSelector: (SEL)selector; /** * Replaces a method implementation with another implementation. * * \param selector The selector of the method to replace * \param imp The new implementation for the method * \return The old implementation */ + (IMP)setImplementation: (IMP)newimp forMethod: (SEL)selector; /** * Replaces a method with a method from another class. * * \param selector The selector of the method to replace * \param class The class from which the new method should be taken * \return The old implementation */ + (IMP)replaceMethod: (SEL)selector withMethodFromClass: (Class)class; /** * Initializes an already allocated object. * * Derived classes may override this, but need to do self = [super init] before * they do any initialization themselves. init may never return nil, instead * an exception (for example OFInitializationFailed) should be thrown. * * \return An initialized object */ - init; /** * \return The class of the object */ - (Class)class; /** * \return The name of the object's class as a C string */ - (const char*)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; /** * \param selector The selector for which the method should be returned * * \return The implementation for the specified selector */ - (IMP)methodForSelector: (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; /** * Adds a pointer to the object's memory pool. * * This is useful to add memory allocated by functions such as asprintf to the * pool so it gets free'd automatically when the object is deallocated. * * \param ptr A pointer to add to the memory pool */ - addMemoryToPool: (void*)ptr; /** * Allocates memory and stores it in the object's memory pool so it can be * free'd automatically when the object is deallocated. * * \param size The size of the memory to allocate * \return A pointer to the allocated memory */ - (void*)allocMemoryWithSize: (size_t)size; /** * Allocates memory for the specified number of items and stores it in the * object's memory pool so it can be free'd automatically when the object is * deallocated. * * \param nitems The number of items to allocate * \param size The size of each item to allocate * \return A pointer to the allocated memory */ - (void*)allocMemoryForNItems: (size_t)nitems withSize: (size_t)size; /** * Resizes memory in the object's memory pool to the specified size. * * \param ptr A pointer to the already allocated memory * \param size The new size for the memory chunk * \return A pointer to the resized memory chunk */ - (void*)resizeMemory: (void*)ptr toSize: (size_t)size; /** * Resizes memory in the object's memory pool to the specific number of items of * the specified size. * * \param ptr A pointer to the already allocated memory * \param nitems The number of items to resize to * \param size The size of each item to resize to * \return A pointer to the resized memory chunk */ - (void*)resizeMemory: (void*)ptr toNItems: (size_t)nitems withSize: (size_t)size; /** * Frees allocated memory and removes it from the object's memory pool. * * \param ptr A pointer to the allocated memory */ - 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. */ - (void)dealloc; /* * Those are needed as the root class is the superclass of the root class's * metaclass and thus instance methods can be sent to class objects as well. */ |
︙ | ︙ |
Modified src/OFObject.m from [344bd01fa3] to [02f24ce790].
︙ | ︙ | |||
432 433 434 435 436 437 438 | - retain { PRE_IVAR->retain_count++; return self; } | < < < < < < < > > > > > > > | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | - retain { PRE_IVAR->retain_count++; return self; } - (size_t)retainCount { return PRE_IVAR->retain_count; } - (void)release { if (!--PRE_IVAR->retain_count) [self dealloc]; } - autorelease { [OFAutoreleasePool addObjectToTopmostPool: self]; return self; } - (void)dealloc { void **iter = PRE_IVAR->memchunks + PRE_IVAR->memchunks_size; while (iter-- > PRE_IVAR->memchunks) free(*iter); |
︙ | ︙ |