diff --git a/ChangeLog b/ChangeLog index 578fa835f..ac3a46d8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ * Source/NSString.m: ([stringByDeletingPathExtension]) rewrite to conform to MacOS-X documentation. ([pathComponents]) ditto. + * Headers/Foundation/NSInvocation.h: Added extra methods for + setting an invocation to invoke super implementation of method. + * Source/NSInvocation.m: Added extra methods for + setting an invocation to invoke super implementation of method. + * Source/GSFFCallInvocation.m: support invoke of super implementation. 2001-05-14 Adam Fedor diff --git a/Headers/gnustep/base/NSInvocation.h b/Headers/gnustep/base/NSInvocation.h index f43eca8b6..1047a9183 100644 --- a/Headers/gnustep/base/NSInvocation.h +++ b/Headers/gnustep/base/NSInvocation.h @@ -39,6 +39,7 @@ NSArgumentInfo *_info; BOOL _argsRetained; BOOL _validReturn; + BOOL _sendToSuper; } /* @@ -86,6 +87,8 @@ - (id) initWithSelector: (SEL)aSelector; - (id) initWithTarget: target selector: (SEL)aSelector, ...; - (void*) returnFrame: (arglist_t)argFrame; +- (BOOL) sendsToSuper; +- (void) setSendsToSuper: (BOOL)flag; @end #endif diff --git a/Source/GSFFCallInvocation.m b/Source/GSFFCallInvocation.m index b5058976e..cc591e159 100644 --- a/Source/GSFFCallInvocation.m +++ b/Source/GSFFCallInvocation.m @@ -323,16 +323,30 @@ GSFFCallInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp) callframe_set_arg((callframe_t *)_cframe, 0, &_target, _info[1].size); callframe_set_arg((callframe_t *)_cframe, 1, &_selector, _info[2].size); - imp = method_get_imp(object_is_instance(_target) ? - class_get_instance_method( + if (_sendToSuper == YES) + { + Super s; + + s.self = _target; + if (GSObjCIsInstance(_target)) + s.class = class_get_super_class(GSObjCClass(_target)); + else + s.class = class_get_super_class((Class)_target); + imp = objc_msg_lookup_super(&s, _selector); + } + else + { + imp = method_get_imp(object_is_instance(_target) ? + class_get_instance_method( ((struct objc_class*)_target)->class_pointer, _selector) - : class_get_class_method( + : class_get_class_method( ((struct objc_class*)_target)->class_pointer, _selector)); - /* - * If fast lookup failed, we may be forwarding or something ... - */ - if (imp == 0) - imp = objc_msg_lookup(_target, _selector); + /* + * If fast lookup failed, we may be forwarding or something ... + */ + if (imp == 0) + imp = objc_msg_lookup(_target, _selector); + } [self setTarget: old_target]; RELEASE(old_target); diff --git a/Source/NSInvocation.m b/Source/NSInvocation.m index 47b7c5758..6a01e7fd9 100644 --- a/Source/NSInvocation.m +++ b/Source/NSInvocation.m @@ -437,17 +437,30 @@ _arg_addr(NSInvocation *inv, int index) _set_arg(self, 0, &_target); _set_arg(self, 1, &_selector); - imp = method_get_imp(object_is_instance(_target) ? - class_get_instance_method( - ((struct objc_class*)_target)->class_pointer, _selector) - : class_get_class_method( - ((struct objc_class*)_target)->class_pointer, _selector)); - /* - * If fast lookup failed, we may be forwarding or something ... - */ - if (imp == 0) - imp = objc_msg_lookup(_target, _selector); + if (_sendToSuper == YES) + { + Super s; + s.self = _target; + if (GSObjCIsInstance(_target)) + s.class = class_get_super_class(GSObjCClass(_target)); + else + s.class = class_get_super_class((Class)_target); + imp = objc_msg_lookup_super(&s, _selector); + } + else + { + imp = method_get_imp(object_is_instance(_target) ? + class_get_instance_method( + ((struct objc_class*)_target)->class_pointer, _selector) + : class_get_class_method( + ((struct objc_class*)_target)->class_pointer, _selector)); + /* + * If fast lookup failed, we may be forwarding or something ... + */ + if (imp == 0) + imp = objc_msg_lookup(_target, _selector); + } [self setTarget: old_target]; RELEASE(old_target); @@ -717,6 +730,17 @@ _arg_addr(NSInvocation *inv, int index) [self subclassResponsibility: _cmd]; return NULL; } + +- (BOOL) sendsToSuper +{ + return _sendToSuper; +} + +- (void) setSendsToSuper: (BOOL)flag +{ + _sendToSuper = flag; +} + @end @implementation NSInvocation (BackwardCompatibility)