Overview
Comment: | Implement adding methods for the GNU runtime. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
db5f8c2c1b2c9d0d49b9da24b0bb2b11 |
User & Date: | js on 2011-07-31 02:07:17 |
Other Links: | manifest | tags |
Context
2011-07-31
| ||
19:45 | Cleaner -[setImplementation:...] for old GNU runtime. check-in: fbee44d38e user: js tags: trunk | |
02:07 | Implement adding methods for the GNU runtime. check-in: db5f8c2c1b user: js tags: trunk | |
2011-07-30
| ||
23:31 | More enhancements in +[OFObject inheritMethodsFromClass:]. check-in: 2828853e17 user: js tags: trunk | |
Changes
Modified src/OFObject.h from [0f97f0d9d0] to [5c52be14f5].
︙ | ︙ | |||
403 404 405 406 407 408 409 | * similar as if the specified class is the superclass of the receiver. * * All methods from the superclasses of the specified class will also be added. * * If the specified class is a superclass of the receiving class, nothing is * done. * | > | | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | * similar as if the specified class is the superclass of the receiver. * * All methods from the superclasses of the specified class will also be added. * * If the specified class is a superclass of the receiving class, nothing is * done. * * The methods which will be added from the specified class are not allowed to * use super or access instance variables, instead they have to use accessors. * * \param class The class from which the instance methods should be inherited */ + (void)inheritMethodsFromClass: (Class)class; /** * \brief Initializes an already allocated object. |
︙ | ︙ |
Modified src/OFObject.m from [3cd936beff] to [e350530160].
︙ | ︙ | |||
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | + (BOOL)addInstanceMethod: (SEL)selector withTypeEncoding: (const char*)typeEncoding implementation: (IMP)implementation { #if defined(OF_APPLE_RUNTIME) || defined(OF_GNU_RUNTIME) return class_addMethod(self, selector, implementation, typeEncoding); #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; #endif } + (BOOL)addClassMethod: (SEL)selector withTypeEncoding: (const char*)typeEncoding implementation: (IMP)implementation { #if defined(OF_APPLE_RUNTIME) || defined(OF_GNU_RUNTIME) return class_addMethod(((OFObject*)self)->isa, selector, implementation, typeEncoding); #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; #endif } + (void)inheritMethodsFromClass: (Class)class | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 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 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 | + (BOOL)addInstanceMethod: (SEL)selector withTypeEncoding: (const char*)typeEncoding implementation: (IMP)implementation { #if defined(OF_APPLE_RUNTIME) || defined(OF_GNU_RUNTIME) return class_addMethod(self, selector, implementation, typeEncoding); #elif defined(OF_OLD_GNU_RUNTIME) MethodList_t methodList; for (methodList = ((Class)self)->methods; methodList != NULL; methodList = methodList->method_next) { int i; for (i = 0; i < methodList->method_count; i++) if (sel_eq(methodList->method_list[i].method_name, selector)) return NO; } if ((methodList = malloc(sizeof(*methodList))) == NULL) @throw [OFOutOfMemoryException newWithClass: self requestedSize: sizeof(*methodList)]; methodList->method_next = ((Class)self)->methods; methodList->method_count = 1; methodList->method_list[0].method_name = selector; methodList->method_list[0].method_types = typeEncoding; methodList->method_list[0].method_imp = implementation; ((Class)self)->methods = methodList; /* Update the dtable */ sarray_at_put_safe(((Class)self)->dtable, (sidx)selector->sel_id, implementation); return YES; #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; #endif } + (BOOL)addClassMethod: (SEL)selector withTypeEncoding: (const char*)typeEncoding implementation: (IMP)implementation { #if defined(OF_APPLE_RUNTIME) || defined(OF_GNU_RUNTIME) return class_addMethod(((OFObject*)self)->isa, selector, implementation, typeEncoding); #elif defined(OF_OLD_GNU_RUNTIME) MethodList_t methodList; for (methodList = ((Class)self->class_pointer)->methods; methodList != NULL; methodList = methodList->method_next) { int i; for (i = 0; i < methodList->method_count; i++) if (sel_eq(methodList->method_list[i].method_name, selector)) return NO; } if ((methodList = malloc(sizeof(*methodList))) == NULL) @throw [OFOutOfMemoryException newWithClass: self requestedSize: sizeof(*methodList)]; methodList->method_next = ((Class)self->class_pointer)->methods; methodList->method_count = 1; methodList->method_list[0].method_name = selector; methodList->method_list[0].method_types = typeEncoding; methodList->method_list[0].method_imp = implementation; ((Class)self->class_pointer)->methods = methodList; /* Update the dtable */ sarray_at_put_safe(((Class)self->class_pointer)->dtable, (sidx)selector->sel_id, implementation); return YES; #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; #endif } + (void)inheritMethodsFromClass: (Class)class |
︙ | ︙ |