ObjFW  Check-in [4f8251772c]

Overview
Comment:TableGenerator: Process files on-the-fly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4f8251772c4e3c48c3a9d5235605a461ac535e9478b05a512d3ec584ce6ce98a
User & Date: js on 2013-01-28 14:29:05
Other Links: manifest | tags
Context
2013-01-28
20:06
Remove AI_ADDRCONFIG, as it's buggy in glibc. check-in: cdfe025f85 user: js tags: trunk
14:29
TableGenerator: Process files on-the-fly. check-in: 4f8251772c user: js tags: trunk
2013-01-26
00:13
Make OFHTTPRequestReply a stream. check-in: bdf9c4d96b user: js tags: trunk
Changes

Modified generators/TableGenerator.h from [2f305428a6] to [a38ddb6bd9].

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

#import "OFObject.h"

@class OFString;

@interface TableGenerator: OFObject
{
	OFString *unicodeData, *caseFolding;
	of_unichar_t uppercaseTable[0x110000];
	of_unichar_t lowercaseTable[0x110000];
	of_unichar_t titlecaseTable[0x110000];
	of_unichar_t casefoldingTable[0x110000];
	BOOL uppercaseTableUsed[0x1100];
	BOOL lowercaseTableUsed[0x1100];
	char titlecaseTableUsed[0x1100];
	char casefoldingTableUsed[0x1100];
	size_t uppercaseTableSize;
	size_t lowercaseTableSize;
	size_t titlecaseTableSize;
	size_t casefoldingTableSize;
}

- (void)downloadFiles;
- (void)parseUnicodeData;
- (void)parseCaseFolding;
- (void)writeTablesToFile: (OFString*)path;
- (void)writeHeaderToFile: (OFString*)path;
@end







<














<





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

#import "OFObject.h"

@class OFString;

@interface TableGenerator: OFObject
{

	of_unichar_t uppercaseTable[0x110000];
	of_unichar_t lowercaseTable[0x110000];
	of_unichar_t titlecaseTable[0x110000];
	of_unichar_t casefoldingTable[0x110000];
	BOOL uppercaseTableUsed[0x1100];
	BOOL lowercaseTableUsed[0x1100];
	char titlecaseTableUsed[0x1100];
	char casefoldingTableUsed[0x1100];
	size_t uppercaseTableSize;
	size_t lowercaseTableSize;
	size_t titlecaseTableSize;
	size_t casefoldingTableSize;
}


- (void)parseUnicodeData;
- (void)parseCaseFolding;
- (void)writeTablesToFile: (OFString*)path;
- (void)writeHeaderToFile: (OFString*)path;
@end

Modified generators/TableGenerator.m from [169ecc0832] to [2bd483c89b].

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

#include <string.h>

#import "OFString.h"
#import "OFArray.h"
#import "OFApplication.h"
#import "OFURL.h"



#import "OFFile.h"

#import "autorelease.h"

#import "TableGenerator.h"
#import "copyright.h"

#define UNICODE_DATA_URL \
	@"http://unicode.org/Public/UNIDATA/UnicodeData.txt"
#define CASE_FOLDING_URL \
	@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt"

OF_APPLICATION_DELEGATE(TableGenerator)

@implementation TableGenerator
- init
{
	self = [super init];

	uppercaseTableSize   = SIZE_MAX;
	lowercaseTableSize   = SIZE_MAX;
	titlecaseTableSize   = SIZE_MAX;
	casefoldingTableSize = SIZE_MAX;

	return self;
}

- (void)applicationDidFinishLaunching
{
	[self downloadFiles];

	[self parseUnicodeData];
	[self parseCaseFolding];

	[of_stdout writeString: @"Writing files..."];

	[self writeTablesToFile: @"../src/unicode.m"];
	[self writeHeaderToFile: @"../src/unicode.h"];

	[of_stdout writeLine: @" done"];

	[OFApplication terminate];
}

- (void)downloadFiles
{
	[of_stdout writeString: @"Downloading " UNICODE_DATA_URL @"..."];
	unicodeData = [[OFString alloc] initWithContentsOfURL:
	    [OFURL URLWithString: UNICODE_DATA_URL]];
	[of_stdout writeLine: @" done"];

	[of_stdout writeString: @"Downloading " CASE_FOLDING_URL @"..."];
	caseFolding = [[OFString alloc] initWithContentsOfURL:
	    [OFURL URLWithString: CASE_FOLDING_URL]];
	[of_stdout writeLine: @" done"];
}

- (void)parseUnicodeData
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *lines;
	OFEnumerator *enumerator;

	OFString *line;

	[of_stdout writeString: @"Parsing UnicodeData.txt..."];


	lines = [unicodeData componentsSeparatedByString: @"\n"];
	enumerator = [lines objectEnumerator];


	while ((line = [enumerator nextObject]) != nil) {
		void *pool2;
		OFArray *split;
		OFString **splitObjects;
		of_unichar_t codep;

		if ([line length] == 0)
			continue;







>
>
>








|




















<
<













<
<
<
<
<
<
<
<
<
<
<
<
<



|
|
>


|

>
|
|
>

|







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

#include <string.h>

#import "OFString.h"
#import "OFArray.h"
#import "OFApplication.h"
#import "OFURL.h"
#import "OFHTTPRequest.h"
#import "OFHTTPRequestReply.h"
#import "OFHTTPClient.h"
#import "OFFile.h"

#import "autorelease.h"

#import "TableGenerator.h"
#import "copyright.h"

#define UNICODE_DATA_URL \
	@"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt"
#define CASE_FOLDING_URL \
	@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt"

OF_APPLICATION_DELEGATE(TableGenerator)

@implementation TableGenerator
- init
{
	self = [super init];

	uppercaseTableSize   = SIZE_MAX;
	lowercaseTableSize   = SIZE_MAX;
	titlecaseTableSize   = SIZE_MAX;
	casefoldingTableSize = SIZE_MAX;

	return self;
}

- (void)applicationDidFinishLaunching
{


	[self parseUnicodeData];
	[self parseCaseFolding];

	[of_stdout writeString: @"Writing files..."];

	[self writeTablesToFile: @"../src/unicode.m"];
	[self writeHeaderToFile: @"../src/unicode.h"];

	[of_stdout writeLine: @" done"];

	[OFApplication terminate];
}














- (void)parseUnicodeData
{
	void *pool = objc_autoreleasePoolPush();
	OFHTTPRequest *request;
	OFHTTPClient *client;
	OFHTTPRequestReply *reply;
	OFString *line;

	[of_stdout writeString: @"Downloading and parsing UnicodeData.txt..."];

	request = [OFHTTPRequest requestWithURL:
	    [OFURL URLWithString: UNICODE_DATA_URL]];
	client = [OFHTTPClient client];
	reply = [client performRequest: request];

	while ((line = [reply readLine]) != nil) {
		void *pool2;
		OFArray *split;
		OFString **splitObjects;
		of_unichar_t codep;

		if ([line length] == 0)
			continue;
124
125
126
127
128
129
130
131
132

133
134
135
136

137
138

139
140
141
142
143
144
145
146
147

	objc_autoreleasePoolPop(pool);
}

- (void)parseCaseFolding
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *lines;
	OFEnumerator *enumerator;

	OFString *line;

	[of_stdout writeString: @"Parsing CaseFolding.txt..."];


	lines = [caseFolding componentsSeparatedByString: @"\n"];
	enumerator = [lines objectEnumerator];


	while ((line = [enumerator nextObject]) != nil) {
		void *pool2;
		OFArray *split;
		OFString **splitObjects;
		of_unichar_t codep;

		if ([line length] == 0 || [line hasPrefix: @"#"])
			continue;







|
|
>


|

>
|
|
>

|







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

	objc_autoreleasePoolPop(pool);
}

- (void)parseCaseFolding
{
	void *pool = objc_autoreleasePoolPush();
	OFHTTPRequest *request;
	OFHTTPClient *client;
	OFHTTPRequestReply *reply;
	OFString *line;

	[of_stdout writeString: @"Downloading and parsing CaseFolding.txt..."];

	request = [OFHTTPRequest requestWithURL:
	    [OFURL URLWithString: CASE_FOLDING_URL]];
	client = [OFHTTPClient client];
	reply = [client performRequest: request];

	while ((line = [reply readLine]) != nil) {
		void *pool2;
		OFArray *split;
		OFString **splitObjects;
		of_unichar_t codep;

		if ([line length] == 0 || [line hasPrefix: @"#"])
			continue;