]> err.no Git - sope/blob - sope-core/NGExtensions/FdExt.subproj/NSException+misc.m
fixed gcc 4.1 warnings
[sope] / sope-core / NGExtensions / FdExt.subproj / NSException+misc.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include "NSException+misc.h"
23 #import <Foundation/NSNull.h>
24 #include "common.h"
25
26 @implementation NSObject(NSExceptionNGMiscellaneous)
27
28 - (BOOL)isException {
29   return NO;
30 }
31 - (BOOL)isExceptionOrNull {
32   return NO;
33 }
34
35 @end /* NSObject(NSExceptionNGMiscellaneous) */
36
37 @implementation NSNull(NSExceptionNGMiscellaneous)
38
39 - (BOOL)isException {
40   return NO;
41 }
42 - (BOOL)isExceptionOrNull {
43   return YES;
44 }
45
46 @end /* NSNull(NSExceptionNGMiscellaneous) */
47
48 @implementation NSException(NGMiscellaneous)
49
50 - (BOOL)isException {
51   return YES;
52 }
53 - (BOOL)isExceptionOrNull {
54   return YES;
55 }
56
57 - (id)initWithReason:(NSString *)_reason {
58   return [self initWithReason:_reason userInfo:nil];
59 }
60 - (id)initWithReason:(NSString *)_reason userInfo:(id)_userInfo {
61   return [self initWithName:NSStringFromClass([self class])
62                reason:_reason
63                userInfo:_userInfo];
64 }
65
66 - (id)initWithFormat:(NSString *)_format,... {
67   NSString *tmp = nil;
68   va_list  ap;
69   
70   if (_format == nil)
71     NSLog(@"ERROR(%s): missing format!", __PRETTY_FUNCTION__);
72   
73   va_start(ap, _format);
74   tmp = [[NSString alloc] initWithFormat:
75                             _format ? _format : (NSString *)@"Exception"
76                           arguments:ap];
77   va_end(ap);
78
79   self = [self initWithReason:tmp userInfo:nil];
80   [tmp release]; tmp = nil;
81   return self;
82 }
83
84 /* NSCopying */
85
86 - (id)copyWithZone:(NSZone *)_zone {
87   // TODO: should make a real copy?
88   return [self retain];
89 }
90
91 @end /* NSException(NGMiscellaneous) */
92
93 #if COCOA_Foundation_LIBRARY || NeXT_Foundation_LIBRARY
94
95 @implementation NSException (NGLibFoundationCompatibility)
96 - (void)setReason:(NSString *)_reason {
97   [_reason retain];
98   [self->reason release];
99   self->reason = _reason;
100 }
101 @end
102
103 #elif GNUSTEP_BASE_LIBRARY
104
105 @implementation NSException (NGLibFoundationCompatibility)
106 - (void)setReason:(NSString *)_reason {
107   [_reason retain];
108   [self->_e_reason release];
109   self->_e_reason = _reason;
110 }
111 @end
112
113 #endif
114
115 void __link_NGExtensions_NSExceptionMisc() {
116   __link_NGExtensions_NSExceptionMisc();
117 }