9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
* the packaging of this file.
*/
#import <stdio.h>
#import "OFExceptions.h"
@implementation OFException
+ new: (id)obj
{
return [[OFException alloc] init: obj];
}
- init: (id)obj
{
return [super init];
}
@end
@implementation OFNoMemException
+ new: (id)obj
withSize: (size_t)size
{
return [[OFNoMemException alloc] init: obj
withSize: size];
}
- init: (id)obj
withSize: (size_t)size
{
fprintf(stderr, "ERROR: Could not allocate %zu bytes for object %s!\n",
size, [obj name]);
return [super init];
}
@end
@implementation OFNotImplementedException
+ new: (id)obj
withMethod: (const char*)method
{
return [[OFNotImplementedException alloc] init: obj
withMethod: method];
}
- init: (id)obj
withMethod: (const char*)method
{
fprintf(stderr, "ERROR: Requested method %s not implemented in %s!\n",
method, [obj name]);
return [super init];
}
@end
@implementation OFMemNotPartOfObjException
+ new: (id)obj
withPtr: (void*)ptr
{
return [[OFMemNotPartOfObjException alloc] init: obj
withPtr: ptr];
}
- init: (id)obj
withPtr: (void*)ptr
{
fprintf(stderr, "ERROR: Memory at %p was not allocated as part of "
"object %s!\n"
"ERROR: -> Not changing memory allocation!\n"
"ERROR: (Hint: It is possible that you tried to free the same "
"memory twice!)\n", ptr, [obj name]);
return [super init];
}
@end
|
|
|
|
>
|
|
|
|
|
|
>
>
|
|
|
|
|
|
>
>
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
* the packaging of this file.
*/
#import <stdio.h>
#import "OFExceptions.h"
@implementation OFException
+ newWithObject: (id)obj
{
return [[OFException alloc] initWithObject: obj];
}
- initWithObject: (id)obj
{
@throw self;
return [super init];
}
@end
@implementation OFNoMemException
+ newWithObject: (id)obj
andSize: (size_t)size
{
return [[OFNoMemException alloc] initWithObject: obj
andSize: size];
}
- initWithObject: (id)obj
andSize: (size_t)size
{
fprintf(stderr, "ERROR: Could not allocate %zu bytes for object %s!\n",
size, [obj name]);
@throw self;
return [super init];
}
@end
@implementation OFNotImplementedException
+ newWithObject: (id)obj
andMethod: (const char*)method
{
return [[OFNotImplementedException alloc] initWithObject: obj
andMethod: method];
}
- initWithObject: (id)obj
andMethod: (const char*)method
{
fprintf(stderr, "ERROR: Requested method %s not implemented in %s!\n",
method, [obj name]);
@throw self;
return [super init];
}
@end
@implementation OFMemNotPartOfObjException
+ newWithObject: (id)obj
andPointer: (void*)ptr
{
return [[OFMemNotPartOfObjException alloc] initWithObject: obj
andPointer: ptr];
}
- initWithObject: (id)obj
andPointer: (void*)ptr
{
fprintf(stderr, "ERROR: Memory at %p was not allocated as part of "
"object %s!\n"
"ERROR: -> Not changing memory allocation!\n"
"ERROR: (Hint: It is possible that you tried to free the same "
"memory twice!)\n", ptr, [obj name]);
@throw self;
return [super init];
}
@end
@implementation OFOverflowException
+ newWithObject: (id)obj
{
return [[OFOverflowException alloc] initWithObject: obj];
}
- initWithObject: (id)obj
{
fprintf(stderr, "ERROR: Overflow in object %s!\n", [obj name]);
@throw self;
return [super init];
}
@end
@implementation OFReadFailedException
+ newWithObject: (id)obj
andSize: (size_t)size
andNItems: (size_t)nitems
{
return [[OFReadFailedException alloc] initWithObject: obj
andSize: size
andNItems: nitems];
}
- initWithObject: (id)obj
andSize: (size_t)size
andNItems: (size_t)nitems
{
fprintf(stderr, "ERROR: Failed to read %zu items of size %zu in "
"object %s!\n", nitems, size, [obj name]);
@throw self;
return [super init];
}
@end
|