Differences From Artifact [7af9301010]:
- File src/OFObject.m — part of check-in [6e19bd47ee] at 2013-11-23 01:27:40 on branch trunk — Add OF_UNRECOGNIZED_SELECTOR. (user: js, size: 25551) [annotate] [blame] [check-ins using]
To Artifact [585ebe6665]:
- File
src/OFObject.m
— part of check-in
[fa6496efc7]
at
2013-12-05 17:48:11
on branch trunk
— Make coding style consistent.
A file documenting the coding style will be written soon. This will
hopefully prevent conflicts in the future, such as whether static
functions are written in camelCase or_with_underscores, like was the
case here. (user: js, size: 25518) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
88 89 90 91 92 93 94 | #define PRE_MEM_ALIGN ((sizeof(struct pre_mem) + \ (__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1)) #define PRE_MEM(mem) ((struct pre_mem*)(void*)((char*)mem - PRE_MEM_ALIGN)) static struct { Class isa; | | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | #define PRE_MEM_ALIGN ((sizeof(struct pre_mem) + \ (__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1)) #define PRE_MEM(mem) ((struct pre_mem*)(void*)((char*)mem - PRE_MEM_ALIGN)) static struct { Class isa; } allocFailedException; uint32_t of_hash_seed; #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) static void uncaughtExceptionHandler(id exception) { OFString *description = [exception description]; OFArray *backtrace = nil; fprintf(stderr, "\nRuntime error: Unhandled exception:\n%s\n", [description cStringWithEncoding: OF_STRING_ENCODING_NATIVE]); |
︙ | ︙ | |||
116 117 118 119 120 121 122 | } abort(); } #endif static void | | | | 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 | } abort(); } #endif static void enumerationMutationHandler(id object) { @throw [OFEnumerationMutationException exceptionWithObject: object]; } void of_method_not_found(id obj, SEL sel) { [obj doesNotRecognizeSelector: sel]; /* * Just in case doesNotRecognizeSelector: returned, even though it must * never return. */ abort(); } #ifdef OF_OBJFW_RUNTIME static IMP commonForwardHandler(id obj, SEL sel, IMP (*lookup)(id, SEL), IMP forward) { /* Try resolveClassMethod:/resolveInstanceMethod: */ if (class_isMetaClass(object_getClass(obj))) { if ([obj respondsToSelector: @selector(resolveClassMethod:)] && [obj resolveClassMethod: sel]) { if (![obj respondsToSelector: sel]) { fprintf(stderr, "Runtime error: [%s " |
︙ | ︙ | |||
184 185 186 187 188 189 190 | #endif of_method_not_found(obj, sel); return NULL; } static IMP | | < | | | | | | | 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 | #endif of_method_not_found(obj, sel); return NULL; } static IMP forwardHandler(id obj, SEL sel) { return commonForwardHandler(obj, sel, objc_msg_lookup, (IMP)of_forward); } static IMP forwardHandlerStret(id obj, SEL sel) { return commonForwardHandler(obj, sel, objc_msg_lookup_stret, (IMP)of_forward_stret); } #endif #ifndef HAVE_OBJC_ENUMERATIONMUTATION void objc_enumerationMutation(id object) { enumerationMutationHandler(object); } #endif id of_alloc_object(Class class, size_t extraSize, size_t extraAlignment, void **extra) { OFObject *instance; size_t instanceSize; instanceSize = class_getInstanceSize(class); if OF_UNLIKELY (extraAlignment > 1) extraAlignment = ((instanceSize + extraAlignment - 1) & ~(extraAlignment - 1)) - extraAlignment; instance = malloc(PRE_IVARS_ALIGN + instanceSize + extraAlignment + extraSize); if OF_UNLIKELY (instance == nil) { allocFailedException.isa = [OFAllocFailedException class]; @throw (id)&allocFailedException; } ((struct pre_ivar*)instance)->retainCount = 1; ((struct pre_ivar*)instance)->firstMem = NULL; ((struct pre_ivar*)instance)->lastMem = NULL; #if !defined(OF_HAVE_ATOMIC_OPS) && defined(OF_HAVE_THREADS) |
︙ | ︙ | |||
273 274 275 276 277 278 279 | _OFObject_Serialization_reference = 1; } @implementation OFObject + (void)load { #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) | | | | | | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | _OFObject_Serialization_reference = 1; } @implementation OFObject + (void)load { #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) objc_setUncaughtExceptionHandler(uncaughtExceptionHandler); #endif #if defined(OF_OBJFW_RUNTIME) objc_forward_handler = forwardHandler; objc_forward_handler_stret = forwardHandlerStret; #elif defined(OF_APPLE_RUNTIME) && \ defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR) objc_setForwardHandler(of_forward, of_forward_stret); #endif #ifdef HAVE_OBJC_ENUMERATIONMUTATION objc_setEnumerationMutationHandler(enumerationMutationHandler); #endif #if defined(HAVE_ARC4RANDOM) of_hash_seed = arc4random(); #elif defined(HAVE_RANDOM) struct timeval t; gettimeofday(&t, NULL); |
︙ | ︙ |