Differences From Artifact [79c29da2a3]:
- File src/OFBlock.m — part of check-in [616b4e0dd2] at 2012-11-03 22:18:56 on branch trunk — Blocks: Only use the lower 2 bytes as retain count (user: js, size: 11785) [annotate] [blame] [check-ins using] [more...]
To Artifact [90b4a8e14a]:
- File
src/OFBlock.m
— part of check-in
[2bedfac177]
at
2012-11-20 20:40:08
on branch trunk
— OFBlock: Make use of objc_initializeClassPair().
This way, we don't need the mach_alias_list anymore. (user: js, size: 11835) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
16 17 18 19 20 21 22 | #include "config.h" #include <stdint.h> #include <stdlib.h> #include <string.h> | | | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include "config.h" #include <stdint.h> #include <stdlib.h> #include <string.h> #if defined(OF_OBJFW_RUNTIME) # import "runtime-private.h" #elif defined(OF_APPLE_RUNTIME) # import <objc/runtime.h> #endif #import "OFBlock.h" #import "OFAllocFailedException.h" #import "OFInitializationFailedException.h" #import "OFNotImplementedException.h" |
︙ | ︙ | |||
68 69 70 71 72 73 74 | }; @protocol RetainRelease - retain; - (void)release; @end | | < < < < < < < < < | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | }; @protocol RetainRelease - retain; - (void)release; @end #ifdef OF_OBJFW_RUNTIME /* Begin of ObjC module */ static struct objc_abi_class _NSConcreteStackBlock_metaclass = { (struct objc_abi_class*)(void*)"OFBlock", "OFBlock", "OFStackBlock", 8, OBJC_CLASS_INFO_METACLASS, sizeof(struct objc_abi_class), NULL, NULL }; struct objc_abi_class _NSConcreteStackBlock = { |
︙ | ︙ | |||
126 127 128 129 130 131 132 133 134 135 136 137 138 | } }; static struct objc_abi_module module = { 8, sizeof(module), NULL, (struct objc_abi_symtab*)&symtab }; static void __attribute__((constructor)) constructor(void) { __objc_exec_class(&module); } /* End of ObjC module */ | > > | > > | | | | > | 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 | } }; static struct objc_abi_module module = { 8, sizeof(module), NULL, (struct objc_abi_symtab*)&symtab }; extern void __objc_exec_class(struct objc_abi_module*); static void __attribute__((constructor)) constructor(void) { __objc_exec_class(&module); } /* End of ObjC module */ #elif defined(OF_APPLE_RUNTIME) extern Class objc_initializeClassPair(Class, const char*, Class, Class); struct class { struct class *isa, *super_class; const char *name; long version, info, instance_size; struct ivar_list *ivars; struct method_list **methodLists; struct cache *cache; struct protocol_list *protocols; const char *ivar_layout; struct class_ext *ext; }; struct class _NSConcreteStackBlock; struct class _NSConcreteGlobalBlock; struct class _NSConcreteMallocBlock; # ifdef __OBJC2__ struct class _NSConcreteStackBlock_metaclass; struct class _NSConcreteGlobalBlock_metaclass; struct class _NSConcreteMallocBlock_metaclass; # endif #endif static struct { Class isa; } alloc_failed_exception; #if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) |
︙ | ︙ | |||
315 316 317 318 319 320 321 | free(obj); } break; } } @implementation OFBlock | | > > > > > > > > > > > > > > > > > > > > > > > > > | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | free(obj); } break; } } @implementation OFBlock #ifdef OF_APPLE_RUNTIME + (void)load { Class tmp; #ifdef __OBJC2__ tmp = objc_initializeClassPair(self, "OFStackBlock", (Class)&_NSConcreteStackBlock, (Class)&_NSConcreteStackBlock_metaclass); if (tmp == Nil) @throw [OFInitializationFailedException exceptionWithClass: self]; objc_registerClassPair(tmp); tmp = objc_initializeClassPair(self, "OFGlobalBlock", (Class)&_NSConcreteGlobalBlock, (Class)&_NSConcreteGlobalBlock_metaclass); if (tmp == Nil) @throw [OFInitializationFailedException exceptionWithClass: self]; objc_registerClassPair(tmp); tmp = objc_initializeClassPair([OFBlock class], "OFMallocBlock", (Class)&_NSConcreteMallocBlock, (Class)&_NSConcreteMallocBlock_metaclass); if (tmp == Nil) @throw [OFInitializationFailedException exceptionWithClass: self]; objc_registerClassPair(tmp); # else /* * There is no objc_initializeClassPair in 10.5. * However, objc_allocateClassPair does not register the new class with * the subclass in the ObjC1 runtime like the ObjC2 runtime does, so * this workaround should be fine. */ if ((tmp = objc_allocateClassPair(self, "OFStackBlock", 0)) == NULL) |
︙ | ︙ | |||
346 347 348 349 350 351 352 353 354 355 356 357 358 359 | if ((tmp = objc_allocateClassPair(self, "OFMallocBlock", 0)) == NULL) @throw [OFInitializationFailedException exceptionWithClass: self]; memcpy(&_NSConcreteMallocBlock, tmp, sizeof(_NSConcreteMallocBlock)); free(tmp); objc_registerClassPair((Class)&_NSConcreteMallocBlock); } #endif #if !defined(OF_ATOMIC_OPS) + (void)initialize { size_t i; | > | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | if ((tmp = objc_allocateClassPair(self, "OFMallocBlock", 0)) == NULL) @throw [OFInitializationFailedException exceptionWithClass: self]; memcpy(&_NSConcreteMallocBlock, tmp, sizeof(_NSConcreteMallocBlock)); free(tmp); objc_registerClassPair((Class)&_NSConcreteMallocBlock); # endif } #endif #if !defined(OF_ATOMIC_OPS) + (void)initialize { size_t i; |
︙ | ︙ | |||
450 451 452 453 454 455 456 | - (void)dealloc { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; [super dealloc]; /* Get rid of a stupid warning */ } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 472 473 474 475 476 477 478 | - (void)dealloc { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; [super dealloc]; /* Get rid of a stupid warning */ } @end |