ObjFW  Diff

Differences From Artifact [d6653b4737]:

To Artifact [8a91f0e096]:


81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95







-
+







		[self release];
		@throw e;
	}

	return self;
}

- initWithArray: (OFArray*)array
- initWithArray: (OFArray *)array
{
	id const *objects;
	size_t count;

	self = [super init];

	if (array == nil)
123
124
125
126
127
128
129
130

131
132
133
134
135
136
137
123
124
125
126
127
128
129

130
131
132
133
134
135
136
137







-
+







		[self release];
		@throw e;
	}

	return self;
}

- initWithObjects: (id const*)objects
- initWithObjects: (id const *)objects
	    count: (size_t)count
{
	self = [self init];

	@try {
		bool ok = true;

154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168







-
+







		[self release];
		@throw e;
	}

	return self;
}

- initWithSerialization: (OFXMLElement*)element
- initWithSerialization: (OFXMLElement *)element
{
	self = [self init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if ((![[element name] isEqual: @"OFArray"] &&
192
193
194
195
196
197
198
199

200
201
202
203
204
205
206

207
208
209
210
211

212
213
214

215
216
217
218
219
220
221
192
193
194
195
196
197
198

199
200
201
202
203
204
205

206
207
208
209
210

211
212
213

214
215
216
217
218
219
220
221







-
+






-
+




-
+


-
+







}

- (size_t)count
{
	return [_array count];
}

- (id const*)objects
- (id const *)objects
{
	return [_array items];
}

- (id)objectAtIndex: (size_t)index
{
	return *((id*)[_array itemAtIndex: index]);
	return *((id *)[_array itemAtIndex: index]);
}

- (id)objectAtIndexedSubscript: (size_t)index
{
	return *((id*)[_array itemAtIndex: index]);
	return *((id *)[_array itemAtIndex: index]);
}

- (void)getObjects: (id*)buffer
- (void)getObjects: (id *)buffer
	   inRange: (of_range_t)range
{
	id *objects = [_array items];
	size_t count = [_array count];

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > count)
258
259
260
261
262
263
264
265

266
267
268
269
270
271
272
273

274
275
276
277
278
279
280
258
259
260
261
262
263
264

265
266
267
268
269
270
271
272

273
274
275
276
277
278
279
280







-
+







-
+







		if (objects[i] == object)
			return i;

	return OF_NOT_FOUND;
}


- (OFArray*)objectsInRange: (of_range_t)range
- (OFArray *)objectsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [_array count])
		@throw [OFOutOfRangeException exception];

	if ([self isKindOfClass: [OFMutableArray class]])
		return [OFArray
		    arrayWithObjects: (id*)[_array items] + range.location
		    arrayWithObjects: (id *)[_array items] + range.location
			       count: range.length];

	return [OFArray_adjacentSubarray arrayWithArray: self
						  range: range];
}

- (bool)isEqual: (id)object
316
317
318
319
320
321
322
323
324


325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343

344
345
346
347
348
349
350
316
317
318
319
320
321
322


323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342

343
344
345
346
347
348
349
350







-
-
+
+


















-
+







		OF_HASH_ADD_HASH(hash, [objects[i] hash]);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state
			   objects: (id *)objects
			     count: (int)count_
{
	size_t count = [_array count];

	if (count > INT_MAX)
		/*
		 * Use the implementation from OFArray, which is slower, but can
		 * enumerate in chunks.
		 */
		return [super countByEnumeratingWithState: state
						  objects: objects
						    count: count_];

	if (state->state >= count)
		return 0;

	state->state = (unsigned long)count;
	state->itemsPtr = [_array items];
	state->mutationsPtr = (unsigned long*)self;
	state->mutationsPtr = (unsigned long *)self;

	return (int)count;
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{