ObjFW  Diff

Differences From Artifact [4286c92f40]:

To Artifact [49e6ad1d3f]:


208
209
210
211
212
213
214
215


216
217
218
219
220
221
222
208
209
210
211
212
213
214

215
216
217
218
219
220
221
222
223







-
+
+







	void *pool = objc_autoreleasePoolPush();
	OFFile *file = [OFFile fileWithPath: path
				       mode: @"w"];

	[file writeString: COPYRIGHT
	    @"#include \"config.h\"\n"
	    @"\n"
	    @"#import \"OFString.h\"\n\n"
	    @"#import \"unicode.h\"\n"
	    @"\n"
	    @"static const OFUnichar emptyPage[0x100] = { 0 };\n"
	    @"\n"];

	/* Write uppercasePage%u */
	for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

379
380
381
382
383
384
385
386

387
388

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407

408
409

410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428

429
430

431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451

452
453

454
455
456
457
458
459
460
380
381
382
383
384
385
386

387
388

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407

408
409

410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428

429
430

431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451

452
453

454
455
456
457
458
459
460
461







-
+

-
+


















-
+

-
+


















-
+

-
+




















-
+

-
+







	 * But from now on, we need the size.
	 */
	_uppercaseTableSize++;
	_lowercaseTableSize++;
	_titlecaseTableSize++;
	_caseFoldingTableSize++;

	/* Write OFUnicodeUppercaseTable */
	/* Write _OFUnicodeUppercaseTable */
	[file writeFormat: @"const OFUnichar *const "
			   @"OFUnicodeUppercaseTable[0x%X] = {\n\t",
			   @"_OFUnicodeUppercaseTable[0x%X] = {\n\t",
			   _uppercaseTableSize];

	for (OFUnichar i = 0; i < _uppercaseTableSize; i++) {
		if (_uppercaseTableUsed[i])
			[file writeFormat: @"uppercasePage%u", i];
		else
			[file writeString: @"emptyPage"];

		if (i + 1 < _uppercaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write OFUnicodeLowercaseTable */
	/* Write _OFUnicodeLowercaseTable */
	[file writeFormat: @"const OFUnichar *const "
			   @"OFUnicodeLowercaseTable[0x%X] = {\n\t",
			   @"_OFUnicodeLowercaseTable[0x%X] = {\n\t",
			   _lowercaseTableSize];

	for (OFUnichar i = 0; i < _lowercaseTableSize; i++) {
		if (_lowercaseTableUsed[i])
			[file writeFormat: @"lowercasePage%u", i];
		else
			[file writeString: @"emptyPage"];

		if (i + 1 < _lowercaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write OFUnicodeTitlecaseTable */
	/* Write _OFUnicodeTitlecaseTable */
	[file writeFormat: @"const OFUnichar *const "
			   @"OFUnicodeTitlecaseTable[0x%X] = {\n\t",
			   @"_OFUnicodeTitlecaseTable[0x%X] = {\n\t",
			   _titlecaseTableSize];

	for (OFUnichar i = 0; i < _titlecaseTableSize; i++) {
		if (_titlecaseTableUsed[i] == 1)
			[file writeFormat: @"titlecasePage%u", i];
		else if (_titlecaseTableUsed[i] == 2)
			[file writeFormat: @"uppercasePage%u", i];
		else
			[file writeString: @"emptyPage"];

		if (i + 1 < _titlecaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write OFUnicodeCaseFoldingTable */
	/* Write _OFUnicodeCaseFoldingTable */
	[file writeFormat: @"const OFUnichar *const "
			   @"OFUnicodeCaseFoldingTable[0x%X] = {\n\t",
			   @"_OFUnicodeCaseFoldingTable[0x%X] = {\n\t",
			   _caseFoldingTableSize];

	for (OFUnichar i = 0; i < _caseFoldingTableSize; i++) {
		if (_caseFoldingTableUsed[i] == 1)
			[file writeFormat: @"caseFoldingPage%u", i];
		else if (_caseFoldingTableUsed[i] == 2)
			[file writeFormat: @"lowercasePage%u", i];
480
481
482
483
484
485
486
487
488
489
490




491
492
493
494
495
496
497
498
499


500
501


502
503


504
505


506
507
508
509
510
511
512
481
482
483
484
485
486
487




488
489
490
491
492
493
494
495
496
497
498
499

500
501
502

503
504
505

506
507
508

509
510
511
512
513
514
515
516
517







-
-
-
-
+
+
+
+








-
+
+

-
+
+

-
+
+

-
+
+







	OFFile *file = [OFFile fileWithPath: path
				       mode: @"w"];

	[file writeString: COPYRIGHT
	    @"#import \"OFString.h\"\n\n"];

	[file writeFormat:
	    @"#define OFUnicodeUppercaseTableSize 0x%X\n"
	    @"#define OFUnicodeLowercaseTableSize 0x%X\n"
	    @"#define OFUnicodeTitlecaseTableSize 0x%X\n"
	    @"#define OFUnicodeCaseFoldingTableSize 0x%X\n\n",
	    @"#define _OFUnicodeUppercaseTableSize 0x%X\n"
	    @"#define _OFUnicodeLowercaseTableSize 0x%X\n"
	    @"#define _OFUnicodeTitlecaseTableSize 0x%X\n"
	    @"#define _OFUnicodeCaseFoldingTableSize 0x%X\n\n",
	    _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize,
	    _caseFoldingTableSize];

	[file writeString:
	    @"#ifdef __cplusplus\n"
	    @"extern \"C\" {\n"
	    @"#endif\n"
	    @"extern const OFUnichar *const _Nonnull\n"
	    @"    OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize];\n"
	    @"    _OFUnicodeUppercaseTable[_OFUnicodeUppercaseTableSize] "
	    @"OF_VISIBILITY_HIDDEN;\n"
	    @"extern const OFUnichar *const _Nonnull\n"
	    @"    OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize];\n"
	    @"    _OFUnicodeLowercaseTable[_OFUnicodeLowercaseTableSize] "
	    @"OF_VISIBILITY_HIDDEN;\n"
	    @"extern const OFUnichar *const _Nonnull\n"
	    @"    OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize];\n"
	    @"    _OFUnicodeTitlecaseTable[_OFUnicodeTitlecaseTableSize] "
	    @"OF_VISIBILITY_HIDDEN;\n"
	    @"extern const OFUnichar *const _Nonnull\n"
	    @"    OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize];\n"
	    @"    _OFUnicodeCaseFoldingTable[_OFUnicodeCaseFoldingTableSize]\n"
	    @"    OF_VISIBILITY_HIDDEN;\n"
	    @"#ifdef __cplusplus\n"
	    @"}\n"
	    @"#endif\n"];

	objc_autoreleasePoolPop(pool);
}
@end