Overview
Comment: | TableGenerator: Don't depend on wget anymore. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7e2ee1bbf24075c31c827d6e61db054f |
User & Date: | js on 2013-01-23 21:57:39 |
Other Links: | manifest | tags |
Context
2013-01-25
| ||
22:39 | Make -[OFStream setBlocking:] more robust. check-in: 436f274d65 user: js tags: trunk | |
2013-01-23
| ||
21:57 | TableGenerator: Don't depend on wget anymore. check-in: 7e2ee1bbf2 user: js tags: trunk | |
21:53 | autorelease.h: Add documentation. check-in: 13c5836ad2 user: js tags: trunk | |
Changes
Modified .gitignore from [018fa8d873] to [08a5bca3ec].
︙ | ︙ | |||
17 18 19 20 21 22 23 | config.status configure DerivedData docs extra.mk generators/gen_tables generators/gen_tables.exe | < < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | config.status configure DerivedData docs extra.mk generators/gen_tables generators/gen_tables.exe Info.plist ObjFW.xcodeproj/*.mode1v3 ObjFW.xcodeproj/*.pbxuser ObjFW.xcodeproj/project.xcworkspace ObjFW.xcodeproj/xcuserdata src/objfw-defs.h src/ObjFW tests/tests tests/tests.exe tests/EBOOT.PBP tests/PARAM.SFO tests/objc_sync/objc_sync utils/objfw-config |
Modified generators/Makefile from [4c75e82c1d] to [eba8d44ad9].
1 2 3 4 5 6 | include ../extra.mk PROG_NOINST = gen_tables${PROG_SUFFIX} SRCS = TableGenerator.m .PHONY: run | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | include ../extra.mk PROG_NOINST = gen_tables${PROG_SUFFIX} SRCS = TableGenerator.m .PHONY: run run: all rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f 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}; \ ${LN_S} ../src/libobjfw.so \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ |
︙ | ︙ | |||
28 29 30 31 32 33 34 | LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ ${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} libobjfw.dll \ rm -f libobjfw.dylib; \ exit $$EXIT | < < < < < < | 28 29 30 31 32 33 34 35 36 37 38 39 | LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ ${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} libobjfw.dll \ rm -f libobjfw.dylib; \ exit $$EXIT include ../buildsys.mk CPPFLAGS += -I../src -I../src/runtime -I.. LIBS := -L../src -lobjfw ${LIBS} LD = ${OBJC} |
Modified generators/TableGenerator.h from [44a9be8785] to [2f305428a6].
︙ | ︙ | |||
10 11 12 13 14 15 16 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ | | > > > > | | | | | 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 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #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 |
Modified generators/TableGenerator.m from [9c99753454] to [169ecc0832].
︙ | ︙ | |||
16 17 18 19 20 21 22 | #include "config.h" #include <string.h> #import "OFString.h" #import "OFArray.h" | | | | > > > > > > > | | > | > | | > > | > | > > | > > > > > | > > > > > > | > > > | > > > > > > | > | > | | < < > > > | > > > | > > > | > | > | < | < > < < > > | > > | > > | > > | | 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 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 102 103 104 105 106 107 108 109 110 111 112 113 114 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 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 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 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 | #include "config.h" #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; pool2 = objc_autoreleasePoolPush(); split = [line componentsSeparatedByString: @";"]; if ([split count] != 15) { of_log(@"Invalid line: %@\n", line); [OFApplication terminateWithStatus: 1]; } splitObjects = [split objects]; codep = (of_unichar_t)[splitObjects[0] hexadecimalValue]; uppercaseTable[codep] = (of_unichar_t)[splitObjects[12] hexadecimalValue]; lowercaseTable[codep] = (of_unichar_t)[splitObjects[13] hexadecimalValue]; titlecaseTable[codep] = (of_unichar_t)[splitObjects[14] hexadecimalValue]; objc_autoreleasePoolPop(pool2); } [of_stdout writeLine: @" done"]; 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; pool2 = objc_autoreleasePoolPush(); split = [line componentsSeparatedByString: @"; "]; if ([split count] != 4) { of_log(@"Invalid line: %s\n", line); [OFApplication terminateWithStatus: 1]; } splitObjects = [split objects]; if (![splitObjects[1] isEqual: @"S"] && ![splitObjects[1] isEqual: @"C"]) continue; codep = (of_unichar_t)[splitObjects[0] hexadecimalValue]; casefoldingTable[codep] = (of_unichar_t)[splitObjects[2] hexadecimalValue]; objc_autoreleasePoolPop(pool2); } [of_stdout writeLine: @" done"]; objc_autoreleasePoolPop(pool); } - (void)writeTablesToFile: (OFString*)path { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"wb"]; of_unichar_t i, j; [file writeString: COPYRIGHT @"#include \"config.h\"\n" @"\n" @"#import \"OFString.h\"\n\n" @"static const of_unichar_t nop_page[0x100] = {};\n\n"]; /* Write uppercase_page_%u */ for (i = 0; i < 0x110000; i += 0x100) { BOOL isEmpty = YES; for (j = i; j < i + 0x100; j++) { if (uppercaseTable[j] != 0) { isEmpty = NO; uppercaseTableSize = i >> 8; uppercaseTableUsed[uppercaseTableSize] = YES; break; } } if (!isEmpty) { void *pool2 = objc_autoreleasePoolPush(); [file writeString: [OFString stringWithFormat: @"static const of_unichar_t " @"uppercase_page_%u[0x100] = {\n", i >> 8]]; for (j = i; j < i + 0x100; j += 8) [file writeString: [OFString stringWithFormat: @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", uppercaseTable[j], uppercaseTable[j + 1], uppercaseTable[j + 2], uppercaseTable[j + 3], uppercaseTable[j + 4], uppercaseTable[j + 5], uppercaseTable[j + 6], uppercaseTable[j + 7]]]; [file writeString: @"};\n\n"]; objc_autoreleasePoolPop(pool2); } } /* Write lowercase_page_%u */ for (i = 0; i < 0x110000; i += 0x100) { BOOL isEmpty = YES; for (j = i; j < i + 0x100; j++) { if (lowercaseTable[j] != 0) { isEmpty = NO; lowercaseTableSize = i >> 8; lowercaseTableUsed[lowercaseTableSize] = YES; break; } } if (!isEmpty) { void *pool2 = objc_autoreleasePoolPush(); [file writeString: [OFString stringWithFormat: @"static const of_unichar_t " @"lowercase_page_%u[0x100] = {\n", i >> 8]]; for (j = i; j < i + 0x100; j += 8) [file writeString: [OFString stringWithFormat: @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", lowercaseTable[j], lowercaseTable[j + 1], lowercaseTable[j + 2], lowercaseTable[j + 3], lowercaseTable[j + 4], lowercaseTable[j + 5], lowercaseTable[j + 6], lowercaseTable[j + 7]]]; [file writeString: @"};\n\n"]; objc_autoreleasePoolPop(pool2); } } /* Write titlecase_page_%u if it does NOT match uppercase_page_%u */ for (i = 0; i < 0x110000; i += 0x100) { BOOL isEmpty = YES; for (j = i; j < i + 0x100; j++) { if (titlecaseTable[j] != 0) { isEmpty = (memcmp(uppercaseTable + i, titlecaseTable + i, 256 * sizeof(of_unichar_t)) ? NO : YES); titlecaseTableSize = i >> 8; titlecaseTableUsed[titlecaseTableSize] = (isEmpty ? 2 : 1); break; } } if (!isEmpty) { void *pool2 = objc_autoreleasePoolPush(); [file writeString: [OFString stringWithFormat: @"static const of_unichar_t " @"titlecase_page_%u[0x100] = {\n", i >> 8]]; for (j = i; j < i + 0x100; j += 8) [file writeString: [OFString stringWithFormat: @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", titlecaseTable[j], titlecaseTable[j + 1], titlecaseTable[j + 2], titlecaseTable[j + 3], titlecaseTable[j + 4], titlecaseTable[j + 5], titlecaseTable[j + 6], titlecaseTable[j + 7]]]; [file writeString: @"};\n\n"]; objc_autoreleasePoolPop(pool2); } } /* Write casefolding_page_%u if it does NOT match lowercase_page_%u */ for (i = 0; i < 0x110000; i += 0x100) { BOOL isEmpty = YES; for (j = i; j < i + 0x100; j++) { if (casefoldingTable[j] != 0) { isEmpty = (memcmp(lowercaseTable + i, casefoldingTable + i, 256 * sizeof(of_unichar_t)) ? NO : YES); casefoldingTableSize = i >> 8; casefoldingTableUsed[casefoldingTableSize] = (isEmpty ? 2 : 1); break; } } if (!isEmpty) { void *pool2 = objc_autoreleasePoolPush(); [file writeString: [OFString stringWithFormat: @"static const of_unichar_t " @"casefolding_page_%u[0x100] = {\n", i >> 8]]; for (j = i; j < i + 0x100; j += 8) [file writeString: [OFString stringWithFormat: @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", casefoldingTable[j], casefoldingTable[j + 1], casefoldingTable[j + 2], casefoldingTable[j + 3], casefoldingTable[j + 4], casefoldingTable[j + 5], casefoldingTable[j + 6], casefoldingTable[j + 7]]]; [file writeString: @"};\n\n"]; objc_autoreleasePoolPop(pool2); } } /* * Those are currently set to the last index. * But from now on, we need the size. */ |
︙ | ︙ | |||
306 307 308 309 310 311 312 | @"const of_unichar_t* const of_unicode_uppercase_table[0x%X] = " @"{\n\t", uppercaseTableSize]]; for (i = 0; i < uppercaseTableSize; i++) { if (uppercaseTableUsed[i]) { [file writeString: [OFString stringWithFormat: @"uppercase_page_%u", i]]; | < | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | @"const of_unichar_t* const of_unicode_uppercase_table[0x%X] = " @"{\n\t", uppercaseTableSize]]; for (i = 0; i < uppercaseTableSize; i++) { if (uppercaseTableUsed[i]) { [file writeString: [OFString stringWithFormat: @"uppercase_page_%u", i]]; } else [file writeString: @"nop_page"]; if (i + 1 < uppercaseTableSize) { if ((i + 1) % 4 == 0) [file writeString: @",\n\t"]; else |
︙ | ︙ | |||
329 330 331 332 333 334 335 | @"const of_unichar_t* const of_unicode_lowercase_table[0x%X] = " @"{\n\t", lowercaseTableSize]]; for (i = 0; i < lowercaseTableSize; i++) { if (lowercaseTableUsed[i]) { [file writeString: [OFString stringWithFormat: @"lowercase_page_%u", i]]; | < | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | @"const of_unichar_t* const of_unicode_lowercase_table[0x%X] = " @"{\n\t", lowercaseTableSize]]; for (i = 0; i < lowercaseTableSize; i++) { if (lowercaseTableUsed[i]) { [file writeString: [OFString stringWithFormat: @"lowercase_page_%u", i]]; } else [file writeString: @"nop_page"]; if (i + 1 < lowercaseTableSize) { if ((i + 1) % 4 == 0) [file writeString: @",\n\t"]; else |
︙ | ︙ | |||
352 353 354 355 356 357 358 | @"const of_unichar_t* const of_unicode_titlecase_table[0x%X] = {" @"\n\t", titlecaseTableSize]]; for (i = 0; i < titlecaseTableSize; i++) { if (titlecaseTableUsed[i] == 1) { [file writeString: [OFString stringWithFormat: @"titlecase_page_%u", i]]; | < | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | @"const of_unichar_t* const of_unicode_titlecase_table[0x%X] = {" @"\n\t", titlecaseTableSize]]; for (i = 0; i < titlecaseTableSize; i++) { if (titlecaseTableUsed[i] == 1) { [file writeString: [OFString stringWithFormat: @"titlecase_page_%u", i]]; } else if (titlecaseTableUsed[i] == 2) { [file writeString: [OFString stringWithFormat: @"uppercase_page_%u", i]]; } else [file writeString: @"nop_page"]; if (i + 1 < titlecaseTableSize) { |
︙ | ︙ | |||
378 379 380 381 382 383 384 | @"const of_unichar_t* const of_unicode_casefolding_table[0x%X] = " @"{\n\t", casefoldingTableSize]]; for (i = 0; i < casefoldingTableSize; i++) { if (casefoldingTableUsed[i] == 1) { [file writeString: [OFString stringWithFormat: @"casefolding_page_%u", i]]; | < | | | | 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 | @"const of_unichar_t* const of_unicode_casefolding_table[0x%X] = " @"{\n\t", casefoldingTableSize]]; for (i = 0; i < casefoldingTableSize; i++) { if (casefoldingTableUsed[i] == 1) { [file writeString: [OFString stringWithFormat: @"casefolding_page_%u", i]]; } else if (casefoldingTableUsed[i] == 2) { [file writeString: [OFString stringWithFormat: @"lowercase_page_%u", i]]; } else [file writeString: @"nop_page"]; if (i + 1 < casefoldingTableSize) { if ((i + 1) % 3 == 0) [file writeString: @",\n\t"]; else [file writeString: @", "]; } } [file writeString: @"\n};\n"]; objc_autoreleasePoolPop(pool); } - (void)writeHeaderToFile: (OFString*)path { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"wb"]; [file writeString: COPYRIGHT @"#import \"OFString.h\"\n\n"]; [file writeString: [OFString stringWithFormat: |
︙ | ︙ | |||
435 436 437 438 439 440 441 | @"extern const of_unichar_t* const\n" @" of_unicode_casefolding_table[" @"OF_UNICODE_CASEFOLDING_TABLE_SIZE];\n" @"#ifdef __cplusplus\n" @"}\n" @"#endif\n"]; | | | 481 482 483 484 485 486 487 488 489 490 | @"extern const of_unichar_t* const\n" @" of_unicode_casefolding_table[" @"OF_UNICODE_CASEFOLDING_TABLE_SIZE];\n" @"#ifdef __cplusplus\n" @"}\n" @"#endif\n"]; objc_autoreleasePoolPop(pool); } @end |