ObjFW  Check-in [7a42ee8f11]

Overview
Comment:Rename -[OFXMLParser parseBuffer:withLength:].

It's -[parseBuffer:length:] now.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7a42ee8f119bbc78dec6622294c02a5c0177a9bab5a43ece8988ba7d3c91d156
User & Date: js on 2012-06-06 17:16:22
Other Links: manifest | tags
Context
2012-06-07
12:03
Rework OFStream API. check-in: 0d4059306a user: js tags: trunk
2012-06-06
17:16
Rename -[OFXMLParser parseBuffer:withLength:]. check-in: 7a42ee8f11 user: js tags: trunk
13:47
Slightly change the memory management API. check-in: f7576a66ce user: js tags: trunk
Changes

Modified src/OFXMLParser.h from [6be0e684f3] to [81cc682f41].

197
198
199
200
201
202
203
204

205
206
207
208
209
210
211
197
198
199
200
201
202
203

204
205
206
207
208
209
210
211







-
+







/**
 * \brief Parses the specified buffer with the specified size.
 *
 * \param buffer The buffer to parse
 * \param length The length of the buffer
 */
- (void)parseBuffer: (const char*)buffer
	 withLength: (size_t)length;
	     length: (size_t)length;

/**
 * \brief Parses the specified string.
 *
 * \param string The string to parse
 */
- (void)parseString: (OFString*)string;

Modified src/OFXMLParser.m from [2619682154] to [c6d94e0ddb].

231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245







-
+








- (void)setDelegate: (id <OFXMLParserDelegate>)delegate_
{
	delegate = delegate_;
}

- (void)parseBuffer: (const char*)buffer
	 withLength: (size_t)length
	     length: (size_t)length
{
	size_t i, last = 0;

	for (i = 0; i < length; i++) {
		size_t j = i;

		lookupTable[state](self, selectors[state], buffer, &i, &last);
259
260
261
262
263
264
265
266

267
268
269
270
271
272
273
274
275
276
277
278
279

280
281
282
283
284
285
286
259
260
261
262
263
264
265

266
267
268
269
270
271
272
273
274
275
276
277
278

279
280
281
282
283
284
285
286







-
+












-
+







	if (length - last > 0 && state != OF_XMLPARSER_IN_TAG)
		cache_append(cache, buffer + last, encoding, length - last);
}

- (void)parseString: (OFString*)string
{
	[self parseBuffer: [string UTF8String]
	       withLength: [string UTF8StringLength]];
		   length: [string UTF8StringLength]];
}

- (void)parseStream: (OFStream*)stream
{
	char *buffer = [self allocMemoryWithSize: of_pagesize];

	@try {
		while (![stream isAtEndOfStream]) {
			size_t length = [stream readNBytes: of_pagesize
						intoBuffer: buffer];

			[self parseBuffer: buffer
			       withLength: length];
				   length: length];
		}
	} @finally {
		[self freeMemory: buffer];
	}
}

- (void)parseFile: (OFString*)path

Modified tests/OFXMLParserTests.m from [56d6347fce] to [c34c13b545].

349
350
351
352
353
354
355
356

357
358
359

360
361
362
363
364
365
366
349
350
351
352
353
354
355

356
357
358

359
360
361
362
363
364
365
366







-
+


-
+








	for (j = 0; j < len; j+= 2) {
		if ([parser finishedParsing])
			abort();

		if (j + 2 > len)
			[parser parseBuffer: str + j
				 withLength: 1];
				     length: 1];
		else
			[parser parseBuffer: str + j
				 withLength: 2];
				     length: 2];
	}

	TEST(@"Checking if everything was parsed",
	    i == 32 && [parser lineNumber] == 18)

	TEST(@"-[finishedParsing]", [parser finishedParsing])