︙ | | | ︙ | |
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject
arguments: (va_list)arguments
{
self = [self init];
@try {
id object;
[_array addItem: &firstObject];
|
|
<
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
self = [self init];
@try {
id object;
[_array addItem: &firstObject];
|
︙ | | | ︙ | |
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
@throw e;
}
@try {
for (size_t i = 0; i < count; i++)
[objects[i] retain];
[_array addItems: objects
count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
/* Prevent double-release of objects */
[_array release];
_array = nil;
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects
count: (size_t)count
{
self = [self init];
@try {
bool ok = true;
for (size_t i = 0; i < count; i++) {
if (objects[i] == nil)
ok = false;
[objects[i] retain];
}
if (!ok)
@throw [OFInvalidArgumentException exception];
[_array addItems: objects
count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
[self release];
@throw e;
}
|
|
<
|
<
|
<
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
@throw e;
}
@try {
for (size_t i = 0; i < count; i++)
[objects[i] retain];
[_array addItems: objects count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
/* Prevent double-release of objects */
[_array release];
_array = nil;
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
self = [self init];
@try {
bool ok = true;
for (size_t i = 0; i < count; i++) {
if (objects[i] == nil)
ok = false;
[objects[i] retain];
}
if (!ok)
@throw [OFInvalidArgumentException exception];
[_array addItems: objects count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
[self release];
@throw e;
}
|
︙ | | | ︙ | |
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
}
- (id)objectAtIndexedSubscript: (size_t)idx
{
return *((id *)[_array itemAtIndex: idx]);
}
- (void)getObjects: (id *)buffer
inRange: (of_range_t)range
{
id const *objects = _array.items;
size_t count = _array.count;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > count)
@throw [OFOutOfRangeException exception];
|
|
<
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
}
- (id)objectAtIndexedSubscript: (size_t)idx
{
return *((id *)[_array itemAtIndex: idx]);
}
- (void)getObjects: (id *)buffer inRange: (of_range_t)range
{
id const *objects = _array.items;
size_t count = _array.count;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > count)
@throw [OFOutOfRangeException exception];
|
︙ | | | ︙ | |
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
@throw [OFOutOfRangeException exception];
if ([self isKindOfClass: [OFMutableArray class]])
return [OFArray
arrayWithObjects: (id *)_array.items + range.location
count: range.length];
return [OFAdjacentSubarray arrayWithArray: self
range: range];
}
- (bool)isEqual: (id)object
{
OFArray *otherArray;
id const *objects, *otherObjects;
size_t count;
|
|
<
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
@throw [OFOutOfRangeException exception];
if ([self isKindOfClass: [OFMutableArray class]])
return [OFArray
arrayWithObjects: (id *)_array.items + range.location
count: range.length];
return [OFAdjacentSubarray arrayWithArray: self range: range];
}
- (bool)isEqual: (id)object
{
OFArray *otherArray;
id const *objects, *otherObjects;
size_t count;
|
︙ | | | ︙ | |