ObjFW  Check-in [db6e3205fd]

Overview
Comment:Make TableGenerator an OFApplicationDelegate.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: db6e3205fd353b46049e1ba815bb7241601a2679b1d21cec95f5054724723c50
User & Date: js on 2010-04-08 21:14:07
Other Links: manifest | tags
Context
2010-04-08
21:22
Extra parentheses for OF_BSWAP{16,32,64}_CONST. check-in: 8fa3b3b737 user: js tags: trunk
21:14
Make TableGenerator an OFApplicationDelegate. check-in: db6e3205fd user: js tags: trunk
21:05
Rename -[itemsize] to -[itemSize]. check-in: 5b1280c863 user: js tags: trunk
Changes

Modified generators/Makefile from [e6f92c1afe] to [abb6a753db].

1
2
3
4
5
6
7
8
9
10
11
12
include ../extra.mk

PROG_NOINST = gen_tables${PROG_SUFFIX}
SRCS = main.o		\
       TableGenerator.m

.PHONY: run
run: all UnicodeData.txt CaseFolding.txt
	rm -f libobjfw.so.1 libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
	rm -f libobjfw.dll libobjfw.dylib
	if test -f ../src/libobjfw.so; then \
		ln -s ../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \



<
|







1
2
3

4
5
6
7
8
9
10
11
include ../extra.mk

PROG_NOINST = gen_tables${PROG_SUFFIX}

SRCS = TableGenerator.m

.PHONY: run
run: all UnicodeData.txt CaseFolding.txt
	rm -f libobjfw.so.1 libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
	rm -f libobjfw.dll libobjfw.dylib
	if test -f ../src/libobjfw.so; then \
		ln -s ../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \

Modified generators/TableGenerator.m from [d89cfa703e] to [baeef6024f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
/*
 * Copyright (c) 2008 - 2010
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#import "OFString.h"
#import "OFArray.h"
#import "OFFile.h"
#import "OFAutoreleasePool.h"

#import "OFExceptions.h"

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



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

	upper_size = SIZE_MAX;
	lower_size = SIZE_MAX;
	casefolding_size = SIZE_MAX;

	return self;
}










- (void)readUnicodeDataFile: (OFString*)path
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2;
	OFFile *file = [OFFile fileWithPath: path
				       mode: @"rb"];
	OFString *line;

	pool2 = [[OFAutoreleasePool alloc] init];
	while ((line = [file readLine])) {
		OFArray *splitted;
		OFString **splitted_carray;
		of_unichar_t codep;

		splitted = [line splitWithDelimiter: @";"];
		if ([splitted count] != 15) {
			fprintf(stderr, "Invalid line: %s\n", [line cString]);

			exit(1);
		}
		splitted_carray = [splitted cArray];

		codep = [splitted_carray[0] hexadecimalValueAsInteger];
		upper[codep] = [splitted_carray[12] hexadecimalValueAsInteger];
		lower[codep] = [splitted_carray[13] hexadecimalValueAsInteger];













<







>




>
>












>
>
>
>
>
>
>
>
>














|

|
>







1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
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
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
/*
 * Copyright (c) 2008 - 2010
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"


#include <stdlib.h>
#include <string.h>

#import "OFString.h"
#import "OFArray.h"
#import "OFFile.h"
#import "OFAutoreleasePool.h"
#import "OFApplication.h"
#import "OFExceptions.h"

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

OF_APPLICATION_DELEGATE(TableGenerator)

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

	upper_size = SIZE_MAX;
	lower_size = SIZE_MAX;
	casefolding_size = SIZE_MAX;

	return self;
}

- (void)applicationDidFinishLaunching
{
	TableGenerator *tgen = [[[TableGenerator alloc] init] autorelease];
	[tgen readUnicodeDataFile: @"UnicodeData.txt"];
	[tgen readCaseFoldingFile: @"CaseFolding.txt"];
	[tgen writeTablesToFile: @"../src/unicode.m"];
	[tgen writeHeaderToFile: @"../src/unicode.h"];
}

- (void)readUnicodeDataFile: (OFString*)path
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2;
	OFFile *file = [OFFile fileWithPath: path
				       mode: @"rb"];
	OFString *line;

	pool2 = [[OFAutoreleasePool alloc] init];
	while ((line = [file readLine])) {
		OFArray *splitted;
		OFString **splitted_carray;
		of_unichar_t codep;

		splitted = [line componentsSeparatedByString: @";"];
		if ([splitted count] != 15) {
			[of_stderr writeFormat: @"Invalid line: %s\n",
						[line cString]];
			exit(1);
		}
		splitted_carray = [splitted cArray];

		codep = [splitted_carray[0] hexadecimalValueAsInteger];
		upper[codep] = [splitted_carray[12] hexadecimalValueAsInteger];
		lower[codep] = [splitted_carray[13] hexadecimalValueAsInteger];
78
79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
		OFArray *splitted;
		OFString **splitted_carray;
		of_unichar_t codep;

		if ([line characterAtIndex: 0] == '#')
			continue;

		splitted = [line splitWithDelimiter: @"; "];
		if ([splitted count] != 4) {
			fprintf(stderr, "Invalid line: %s\n", [line cString]);

			exit(1);
		}
		splitted_carray = [splitted cArray];

		if (![splitted_carray[1] isEqual: @"S"] &&
		    ![splitted_carray[1] isEqual: @"C"])
			continue;







|

|
>







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
		OFArray *splitted;
		OFString **splitted_carray;
		of_unichar_t codep;

		if ([line characterAtIndex: 0] == '#')
			continue;

		splitted = [line componentsSeparatedByString: @"; "];
		if ([splitted count] != 4) {
			[of_stderr writeFormat: @"Invalid line: %s\n",
						[line cString]];
			exit(1);
		}
		splitted_carray = [splitted cArray];

		if (![splitted_carray[1] isEqual: @"S"] &&
		    ![splitted_carray[1] isEqual: @"C"])
			continue;

Deleted generators/main.m version [00dd64a59b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * Copyright (c) 2008 - 2010
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#import "OFAutoreleasePool.h"

#import "TableGenerator.h"

int
main()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	TableGenerator *tgen;

	tgen = [[[TableGenerator alloc] init] autorelease];
	[tgen readUnicodeDataFile: @"UnicodeData.txt"];
	[tgen readCaseFoldingFile: @"CaseFolding.txt"];
	[tgen writeTablesToFile: @"../src/unicode.m"];
	[tgen writeHeaderToFile: @"../src/unicode.h"];

	[pool release];

	return 0;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<