mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
std.uni: replace dstring case table with uint[] hexstring (#8904)
This commit is contained in:
parent
1c5b6f8406
commit
f3ec8b767d
2 changed files with 863 additions and 641 deletions
File diff suppressed because it is too large
Load diff
|
@ -1034,13 +1034,21 @@ void writeGraphemeTries(File sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a function that returns a dchar[] with data stored in `table`
|
/// Write a function that returns a dchar[] with data stored in `table`
|
||||||
void writeDstringTable(T:dchar)(File sink, string name, const T[] table)
|
void writeDstringTable(File sink, string name, const dchar[] table)
|
||||||
{
|
{
|
||||||
sink.writefln("dstring %s() nothrow @nogc pure @safe {\nstatic immutable dchar[%d] t =", name, table.length);
|
sink.writefln("dstring %s() nothrow @nogc pure @safe {\nstatic immutable dchar[%d] t =", name, table.length);
|
||||||
sink.writeDstring(table);
|
sink.writeDstring(table);
|
||||||
sink.writeln(";\nreturn t[];\n}");
|
sink.writeln(";\nreturn t[];\n}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Write a function that returns a uint[] with data stored in `table`
|
||||||
|
void writeUintTable(File sink, string name, const uint[] table)
|
||||||
|
{
|
||||||
|
sink.writefln("immutable(uint)[] %s() nothrow @nogc pure @safe {\nstatic immutable uint[] t =", name, );
|
||||||
|
sink.writeUintArray(table);
|
||||||
|
sink.writeln(";\nreturn t;\n}");
|
||||||
|
}
|
||||||
|
|
||||||
void writeCaseCoversion(File sink)
|
void writeCaseCoversion(File sink)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -1063,10 +1071,9 @@ void writeCaseCoversion(File sink)
|
||||||
writeBest3Level(sink, "toTitleSimpleIndex", toTitleSimpleIndex, ushort.max);
|
writeBest3Level(sink, "toTitleSimpleIndex", toTitleSimpleIndex, ushort.max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeUintTable(sink, "toUpperTable", toUpperTab);
|
||||||
writeDstringTable(sink, "toUpperTable", toUpperTab);
|
writeUintTable(sink, "toLowerTable", toLowerTab);
|
||||||
writeDstringTable(sink, "toLowerTable", toLowerTab);
|
writeUintTable(sink, "toTitleTable", toTitleTab);
|
||||||
writeDstringTable(sink, "toTitleTable", toTitleTab);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeDecomposition(File sink)
|
void writeDecomposition(File sink)
|
||||||
|
@ -1124,8 +1131,8 @@ void writeDecomposition(File sink)
|
||||||
writeBest3Level(sink, "compatMapping", mappingCompat, cast(ushort) 0);
|
writeBest3Level(sink, "compatMapping", mappingCompat, cast(ushort) 0);
|
||||||
writeBest3Level(sink, "canonMapping", mappingCanon, cast(ushort) 0);
|
writeBest3Level(sink, "canonMapping", mappingCanon, cast(ushort) 0);
|
||||||
|
|
||||||
writeDstringTable(sink, "decompCanonTable", cast(const(uint)[]) decompCanonFlat);
|
writeDstringTable(sink, "decompCanonTable", decompCanonFlat);
|
||||||
writeDstringTable(sink, "decompCompatTable", cast(const(uint)[]) decompCompatFlat);
|
writeDstringTable(sink, "decompCompatTable", decompCompatFlat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeFunctions(File sink)
|
void writeFunctions(File sink)
|
||||||
|
@ -1151,6 +1158,21 @@ void writeFunctions(File sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Write a `dchar[]` as hex string
|
||||||
|
void writeUintArray(T:dchar)(File sink, const T[] tab)
|
||||||
|
{
|
||||||
|
size_t lineCount = 1;
|
||||||
|
sink.write("cast(immutable uint[]) x\"");
|
||||||
|
foreach (i, elem; tab)
|
||||||
|
{
|
||||||
|
if ((i % 12) == 0)
|
||||||
|
sink.write("\n");
|
||||||
|
|
||||||
|
sink.writef("%08X", elem);
|
||||||
|
}
|
||||||
|
sink.write("\"");
|
||||||
|
}
|
||||||
|
|
||||||
/// Write a `dchar[]` as a dstring ""d
|
/// Write a `dchar[]` as a dstring ""d
|
||||||
void writeDstring(T:dchar)(File sink, const T[] tab)
|
void writeDstring(T:dchar)(File sink, const T[] tab)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue