gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: [GDL2] NSAutoreleasePool/EOFault


From: Manuel Guesdon
Subject: Re[2]: [GDL2] NSAutoreleasePool/EOFault
Date: Sun, 13 Mar 2005 18:46:42 +0100 (CET)

On Sat, 12 Mar 2005 21:43:15 +0100 David Ayers <address@hidden> wrote:

 >| David Ayers wrote:
 >| 
 >| > David Ayers wrote:
 >| > 
 >| >> Manuel Guesdon wrote:
 >| >>
 >| >>> + (IMP) instanceMethodForSelector: (SEL)aSelector
 >| >>> {
 >| >>>  if (aSelector == 0)
 >| >>>    [NSException raise: NSInvalidArgumentException
 >| >>>                format: @"%@ null selector given", 
 >| >>> NSStringFromSelector(_cmd)];
 >| >>>  /*
 >| >>>   *        Since 'self' is an class, get_imp() will get the instance 
 >| >>> method.
 >| >>>   */
 >| >>>  return get_imp((Class)self, aSelector);
 >| >>> }
 >| >>>
 >| > [snip]
 >| > 
 >| > I guess all methods which currently wouldn't fire the fault, could 
 >| > return EOFault's implementation (like release) and the others should 
 >| > return the fault handler's targetClass implementation... but if 
 >| 
 >| [snip]
 >| 
 >| actually that's moot, as the EOFault class doesn't know about the 
 >| instance, so we have no fault handler.
 >| 
 >| But back to NSAutoreleasePool, it currently uses GSObjCClass which will 
 >| give it the EOFault class.  If it would have used -class, it would have 
 >| obtained the object's class.  In this case EOFault is indeed preferable 
 >| as it intends get the faults implementation of release and invoke it. 
 >| If this release happens to dealloc the object, the fault will be cleared 
 >| and dealloc is then called with the original isa.  So I guess we're safe.
 >| 
 >| I think I'll add some comments in NSAutoreleasePool explaining that 
 >| GSObjCClass is actually not merely a performance issue but that sending 
 >| -class would break GDL2.

Another idea is to return NULL in (instance)methodForSelector: to tell the 
caller should not use imp or cache the method.
It should be clean and safe isn't it ?
The drawback is that callers should verify returned IMP and handle the 
case...






reply via email to

[Prev in Thread] Current Thread [Next in Thread]