Differences From Artifact [7aef2cee7c]:
- File src/OFIntrospection.m — part of check-in [0509d7a844] at 2019-01-03 19:13:03 on branch trunk — Update copyright (user: js, size: 13260) [annotate] [blame] [check-ins using]
To Artifact [cd6beb50c0]:
- File
src/OFIntrospection.m
— part of check-in
[ef6d69931e]
at
2019-02-07 00:46:41
on branch trunk
— Make style consistent between ObjFW and ObjFW_RT
ObjFW_RT used to be a separate project that followed the BSD style, as
it was written in pure C, while ObjFW's style is based on the BSD style
with changes to make it a better fit for Objective-C. This commit
changes ObjFW_RT to use the same style as ObjFW. (user: js, size: 13284) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
35 36 37 38 39 40 41 | #if defined(OF_OBJFW_RUNTIME) - (instancetype)of_initWithMethod: (struct objc_method *)method { self = [super init]; @try { | | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #if defined(OF_OBJFW_RUNTIME) - (instancetype)of_initWithMethod: (struct objc_method *)method { self = [super init]; @try { _selector = (SEL)&method->selector; _name = [[OFString alloc] initWithUTF8String: sel_getName(_selector)]; _typeEncoding = method->selector.typeEncoding; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
147 148 149 150 151 152 153 | - (instancetype)of_initWithProperty: (struct objc_property *)property { self = [super init]; @try { _name = [[OFString alloc] initWithUTF8String: property->name]; _attributes = | | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | - (instancetype)of_initWithProperty: (struct objc_property *)property { self = [super init]; @try { _name = [[OFString alloc] initWithUTF8String: property->name]; _attributes = property->attributes | (property->extendedAttributes << 8); if (property->getter.name != NULL) _getter = [[OFString alloc] initWithUTF8String: property->getter.name]; if (property->setter.name != NULL) _setter = [[OFString alloc] initWithUTF8String: property->setter.name]; |
︙ | ︙ | |||
385 386 387 388 389 390 391 | - (instancetype)init { OF_INVALID_INIT_METHOD } #if defined(OF_OBJFW_RUNTIME) | | | | | | | | | | | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | - (instancetype)init { OF_INVALID_INIT_METHOD } #if defined(OF_OBJFW_RUNTIME) - (instancetype)of_initWithIVar: (struct objc_ivar *)iVar { self = [super init]; @try { if (iVar->name != NULL) _name = [[OFString alloc] initWithUTF8String: iVar->name]; _typeEncoding = iVar->typeEncoding; _offset = iVar->offset; } @catch (id e) { [self release]; @throw e; } return self; } #elif defined(OF_APPLE_RUNTIME) - (instancetype)of_initWithIVar: (Ivar)iVar { self = [super init]; @try { const char *name = ivar_getName(iVar); if (name != NULL) _name = [[OFString alloc] initWithUTF8String: name]; _typeEncoding = ivar_getTypeEncoding(iVar); _offset = ivar_getOffset(iVar); } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
467 468 469 470 471 472 473 | @try { #if defined(OF_OBJFW_RUNTIME) struct objc_method_list *methodList; struct objc_property_list *propertyList; #elif defined(OF_APPLE_RUNTIME) Method *methodList; objc_property_t *propertyList; | | | | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | @try { #if defined(OF_OBJFW_RUNTIME) struct objc_method_list *methodList; struct objc_property_list *propertyList; #elif defined(OF_APPLE_RUNTIME) Method *methodList; objc_property_t *propertyList; Ivar *iVarList; unsigned count; #endif void *pool; _classMethods = [[OFMutableArray alloc] init]; _instanceMethods = [[OFMutableArray alloc] init]; _properties = [[OFMutableArray alloc] init]; _instanceVariables = [[OFMutableArray alloc] init]; #if defined(OF_OBJFW_RUNTIME) for (methodList = object_getClass(class)->methodList; methodList != NULL; methodList = methodList->next) { pool = objc_autoreleasePoolPush(); for (unsigned int i = 0; i < methodList->count; i++) [_classMethods addObject: [[[OFMethod alloc] of_initWithMethod: &methodList->methods[i]] autorelease]]; objc_autoreleasePoolPop(pool); } for (methodList = class->methodList; methodList != NULL; methodList = methodList->next) { pool = objc_autoreleasePoolPush(); for (unsigned int i = 0; i < methodList->count; i++) [_instanceMethods addObject: [[[OFMethod alloc] of_initWithMethod: &methodList->methods[i]] autorelease]]; |
︙ | ︙ | |||
514 515 516 517 518 519 520 | [_properties addObject: [[[OFProperty alloc] of_initWithProperty: &propertyList->properties[i]] autorelease]]; objc_autoreleasePoolPop(pool); } | | | | | | 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | [_properties addObject: [[[OFProperty alloc] of_initWithProperty: &propertyList->properties[i]] autorelease]]; objc_autoreleasePoolPop(pool); } if (class->iVars != NULL) { pool = objc_autoreleasePoolPush(); for (unsigned int i = 0; i < class->iVars->count; i++) [_instanceVariables addObject: [[[OFInstanceVariable alloc] of_initWithIVar: &class->iVars->iVars[i]] autorelease]]; objc_autoreleasePoolPop(pool); } #elif defined(OF_APPLE_RUNTIME) methodList = class_copyMethodList(object_getClass(class), &count); @try { |
︙ | ︙ | |||
569 570 571 572 573 574 575 | autorelease]]; objc_autoreleasePoolPop(pool); } @finally { free(propertyList); } | | | | | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | autorelease]]; objc_autoreleasePoolPop(pool); } @finally { free(propertyList); } iVarList = class_copyIvarList(class, &count); @try { pool = objc_autoreleasePoolPush(); for (unsigned int i = 0; i < count; i++) [_instanceVariables addObject: [[[OFInstanceVariable alloc] of_initWithIVar: iVarList[i]] autorelease]]; objc_autoreleasePoolPop(pool); } @finally { free(iVarList); } #else # error Invalid ObjC runtime! #endif [_classMethods makeImmutable]; [_instanceMethods makeImmutable]; |
︙ | ︙ |