discuss-gnustep
[Top][All Lists]
Advanced

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

Re: _e_info in NSException.h


From: Richard Frith-Macdonald
Subject: Re: _e_info in NSException.h
Date: Mon, 14 Jan 2008 08:17:00 +0000


On 14 Jan 2008, at 07:35, Sebastian Reitenbach wrote:

Hi,

Richard Frith-Macdonald <richard@tiptree.demon.co.uk> wrote:

On 13 Jan 2008, at 21:20, Sebastian Reitenbach wrote:

Hi,

after I got sope and sogo working with gnustep-make 2 and gnustep- base
1.14.1, I tried to compile against gnustep-base1.15.2.

sope compilation ended in an error:
Structure has no member named: _e_info
there is a line:
ASSIGN(self->_e_info, _userInfo);

after a bit digging I figured out that it was removed not long ago
from
NSException.h:

http://svn.gna.org/viewcvs/gnustep?rev=25681&view=rev
after adding again:
NSDictionary *_e_info;

sope compiled again.

I wonder why was it removed? or is it an error to set it, in the first
place?

It's an error to try to set it in the first place  ... the leading
underscore in the name if the instance variable tells you that this
is a private instance variable intended for internal use only.  In
1.15.2 it has been replaced by _reserved (which is used only when
necessary to store additional information .... user info and/or
stacktrace ... in an exception).
ah, thanks, understood.

NSException has no external instance variables ... I guess if the
sope code wants to store extra information in an exception it should
create a new exception based on the values returned by the methods of
the original one.


In sope I find this:

#if GNUSTEP_BASE_LIBRARY
/* FIXME: TODO: move someplace better (hh: NGExtensions...) */
@implementation NSException(setUserInfo)

- (id)setUserInfo:(NSDictionary *)_userInfo {
  ASSIGN(self->_e_info, _userInfo);
  return self;
}

@end /* NSException(setUserInfo) */
#endif

and then later in the file, setUserInfo is used.
I took a quick look and found setUserInfo available in libFoundation, and there is no #if COCOOA, so I assume it is there available too, (I have no
MAC to make sure).

I checked the MacOS foundation headers ... no such method.
I then write a small test program:

        NSException *e;
        
e = [NSException exceptionWithName: @"aaa" reason: @"bbb" userInfo: nil];
        [e setUserInfo: [NSDictionary dictionary]];

Running this produced

2008-01-14 08:08:05.166 TestTool[2478] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSException setUserInfo:]: selector not recognized [self = 0x303000]

So the method definitely does not exist in Cocoa.

In my eyes it would make most sense to add
setUserInfo to NSException in gnustep-base, and then remove all the #if GNUSTEP_BASE_LIBRARY stuff from sope, or at least replace it for now with
sth. that checks for the GNUSTEP_BASE version.

Would that make sense, or is a too bad idea?

Given that the method does not exist except in libFoundation, it seems to me that the correct thing to do is to go through the sope code and remove all uses of it. Actually if the code does not contain an implementation for Cocoa, maybe sope does not actually use it and all you need to do is remove the code which attempts to implement it for GNUstep.






reply via email to

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