Differences From Artifact [6537d810e0]:
- File src/OFObject.m — part of check-in [6083048589] at 2011-07-30 23:14:22 on branch trunk — +[addClassMethod:withTypeEncoding:implementation:] to OFObject. (user: js, size: 23379) [annotate] [blame] [check-ins using]
To Artifact [3cd936beff]:
- File
src/OFObject.m
— part of check-in
[2828853e17]
at
2011-07-30 23:31:56
on branch trunk
— More enhancements in +[OFObject inheritMethodsFromClass:].
Inherits class and instance methods now, handles superclasses, etc. (user: js, size: 24354) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
472 473 474 475 476 477 478 | typeEncoding); #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; #endif } | | | | > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > | | > > | 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 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | typeEncoding); #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; #endif } + (void)inheritMethodsFromClass: (Class)class { OFAutoreleasePool *pool; OFMutableSet *classMethods, *instanceMethods; OFIntrospection *introspection; OFMethod **cArray; size_t i, count; if ([self isSubclassOfClass: class]) return; pool = [[OFAutoreleasePool alloc] init]; classMethods = [OFMutableSet set]; instanceMethods = [OFMutableSet set]; introspection = [OFIntrospection introspectionWithClass: self]; cArray = [[introspection classMethods] cArray]; count = [[introspection classMethods] count]; for (i = 0; i < count; i++) [classMethods addObject: [cArray[i] name]]; cArray = [[introspection instanceMethods] cArray]; count = [[introspection instanceMethods] count]; for (i = 0; i < count; i++) [instanceMethods addObject: [cArray[i] name]]; introspection = [OFIntrospection introspectionWithClass: class]; cArray = [[introspection classMethods] cArray]; count = [[introspection classMethods] count]; for (i = 0; i < count; i++) { SEL selector; IMP implementation; if ([classMethods containsObject: [cArray[i] name]]) continue; selector = [cArray[i] selector]; implementation = [class methodForSelector: selector]; if ([self respondsToSelector: selector]) [self setImplementation: implementation forClassMethod: selector]; else [self addClassMethod: selector withTypeEncoding: [cArray[i] typeEncoding] implementation: implementation]; } cArray = [[introspection instanceMethods] cArray]; count = [[introspection instanceMethods] count]; for (i = 0; i < count; i++) { SEL selector; IMP implementation; if ([instanceMethods containsObject: [cArray[i] name]]) continue; selector = [cArray[i] selector]; implementation = [class instanceMethodForSelector: selector]; if ([self instancesRespondToSelector: selector]) [self setImplementation: implementation forInstanceMethod: selector]; else [self addInstanceMethod: selector withTypeEncoding: [cArray[i] typeEncoding] implementation: implementation]; } [pool release]; [self inheritMethodsFromClass: [class superclass]]; } - init { return self; } |
︙ | ︙ |