Author: atsushi
Date: 2005-07-04 06:17:05 -0400 (Mon, 04 Jul 2005)
New Revision: 46902
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
trunk/mcs/class/corlib/Mono.Globalization.Unicode/Makefile
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
Log:
2005-07-04 Atsushi Enomoto <[EMAIL PROTECTED]>
* create-mscompat-collation-table.cs : Now it generates binary
resources (to parent directory).
* MSCompatUnicodeTable.template : added conditional code that fills
collation tables from manifest resources.
* Makefile : remove collation table binaries as well on "make clean".
Removed extraneous dependency.
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog 2005-07-04
07:44:22 UTC (rev 46901)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog 2005-07-04
10:17:05 UTC (rev 46902)
@@ -1,3 +1,12 @@
+2005-07-04 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * create-mscompat-collation-table.cs : Now it generates binary
+ resources (to parent directory).
+ * MSCompatUnicodeTable.template : added conditional code that fills
+ collation tables from manifest resources.
+ * Makefile : remove collation table binaries as well on "make clean".
+ Removed extraneous dependency.
+
2005-07-01 Atsushi Enomoto <[EMAIL PROTECTED]>
* MSCompatUnicodeTable.template,
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
===================================================================
---
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
2005-07-04 07:44:22 UTC (rev 46901)
+++
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
2005-07-04 10:17:05 UTC (rev 46902)
@@ -122,7 +122,7 @@
public static int ToWidthCompat (int cp)
{
int i = UUtil.WidthCompat.ToIndex (cp);
- int v = i >= 0 ? widthCompat [i] : 0;
+ int v = i >= 0 ? (int) widthCompat [i] : 0;
return v != 0 ? v : cp;
}
@@ -218,4 +218,84 @@
// autogenerated code or icall to fill array runs here
//
+#if !GENERATE_TABLE
+ static readonly static char [] tailorings;
+ static readonly TailoringInfo [] tailoringInfos;
+ static readonly byte [] ignorableFlags;
+ static readonly byte [] categories;
+ static readonly byte [] level1;
+ static readonly byte [] level2;
+ static readonly byte [] level3;
+ static readonly ushort [] widthCompat;
+ static static ushort [] cjkCHS;
+ static static ushort [] cjkCHT;
+ static static ushort [] cjkJA;
+ static static ushort [] cjkKO;
+ static static byte [] cjkKOlv2;
+
+ static MSCompatUnicodeTable ()
+ {
+ using (Stream s = Assembly.GetManifestResourceStream
("collation.core.bin")) {
+ BinaryReader reader = new BinaryReader (s);
+ FillTable (reader, ref ignorableFlags);
+ FillTable (reader, ref categories);
+ FillTable (reader, ref level1);
+ FillTable (reader, ref level2);
+ FillTable (reader, ref level3);
+
+ size = reader.ReadInt32 ();
+ widthCompat = new int [size];
+ for (int i = 0; i < size; i++)
+ widthCompat [i] = reader.ReadUInt16 ();
+ }
+ }
+
+ void FillTable (BinaryReader reader, ref byte [] bytes)
+ {
+ int size = reader.ReadInt32 ();
+ ignorableFlags = new byte [size];
+ reader.Read (ignorableFlags, 0, size);
+ }
+
+ static void FillCJK (string name)
+ {
+ ushort [] arr = null;
+ switch (name) {
+ case "zh-CHS":
+ name = "cjkCHS";
+ arr = cjkCHS;
+ break;
+ case "zh-CHT":
+ name = "cjkCHT";
+ arr = cjkCHT;
+ break;
+ case "ja":
+ name = "cjkJA";
+ arr = cjkJA;
+ break;
+ case "ko":
+ name = "cjkKO";
+ arr = cjkKO;
+ break;
+ }
+
+ using (Stream s = Assembly.GetManifestResourceStream
(String.Format ("collation.{0}.bin"), name)) {
+ BinaryReader reader = new BinaryReader (s);
+ size = reader.ReadInt32 ();
+ arr = new int [size];
+ for (int i = 0; i < size; i++)
+ arr [i] = reader.ReadUInt16 ();
+ }
+
+ if (name != "cjkKO")
+ return;
+
+ using (Stream s = Assembly.GetManifestResourceStream
(String.Format ("collation.cjkKOlv2.bin"), name)) {
+ BinaryReader reader = new BinaryReader (s);
+ FillTable (reader, ref cjkKOlv2);
+ }
+ }
+ }
+}
+#endif
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/Makefile
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/Makefile 2005-07-04
07:44:22 UTC (rev 46901)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/Makefile 2005-07-04
10:17:05 UTC (rev 46902)
@@ -31,7 +31,7 @@
clean : clean-collation clean-normalization clean-mscompat
clean-collation :
- rm -f CollationElementTable.cs $(COLL_ELEM_FILENAME).exe*
+ rm -f CollationElementTable.cs $(COLL_ELEM_FILENAME).exe*
../collation.*.bin
clean-normalization :
rm -f Normalization.cs $(NORM_FILENAME).exe* $(COMBINING_FILENAME).exe*
$(CANON_EQUIV_FILENAME).exe*
@@ -149,8 +149,9 @@
#MSCompatUnicodeTable.cs
-$(MSCOMPAT_FILENAME) : MSCompatUnicodeTable.template CollationElementTable.cs
$(MSTABLEGEN).cs $(MSTABLEGEN).exe $(SCRIPTS_TABLE) $(UCD_TABLE) $(UCA_TABLE)
$(CP932_TABLE) $(DERIV_CORE_PROP_TABLE) $(DERIV_AGE_TABLE) $(UCA_DATA)
+$(MSCOMPAT_FILENAME) : MSCompatUnicodeTable.template CollationElementTable.cs
$(MSTABLEGEN).exe $(SCRIPTS_TABLE) $(UCD_TABLE) $(UCA_TABLE) $(CP932_TABLE)
$(DERIV_CORE_PROP_TABLE) $(DERIV_AGE_TABLE) $(UCA_DATA)
echo "// WARNING: Do not edit this file. It is autogenerated." >
$(MSCOMPAT_FILENAME)
+ echo "#define GENERATE_TABLE" > $(MSCOMPAT_FILENAME)
cat MSCompatUnicodeTable.template >> $(MSCOMPAT_FILENAME)
$(RUNTIME) $(MSTABLEGEN).exe downloaded >> $(MSCOMPAT_FILENAME)
echo " }" >> $(MSCOMPAT_FILENAME)
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
===================================================================
---
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
2005-07-04 07:44:22 UTC (rev 46901)
+++
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
2005-07-04 10:17:05 UTC (rev 46902)
@@ -24,6 +24,7 @@
// If there are characters whose primary weight is 0, they are consumed
// and considered as a part of the character element.
//
+#define Binary
using System;
using System.IO;
@@ -277,7 +278,7 @@
byte [] level1 = new byte [map.Length];
byte [] level2 = new byte [map.Length];
byte [] level3 = new byte [map.Length];
- int [] widthCompat = new int [map.Length];
+ ushort [] widthCompat = new ushort [map.Length];
for (int i = 0; i < map.Length; i++) {
categories [i] = map [i].Category;
level1 [i] = map [i].Level1;
@@ -289,7 +290,7 @@
case DecompositionSuper:
case DecompositionSub:
// they are always 1 char
- widthCompat [i] = decompValues
[decompIndex [i]];
+ widthCompat [i] = (ushort) decompValues
[decompIndex [i]];
break;
}
}
@@ -305,8 +306,8 @@
MSCompatUnicodeTableUtil.Level2);
level3 = CompressArray (level3,
MSCompatUnicodeTableUtil.Level3);
- widthCompat = (int []) CodePointIndexer.CompressArray (
- widthCompat, typeof (int),
+ widthCompat = (ushort [])
CodePointIndexer.CompressArray (
+ widthCompat, typeof (ushort),
MSCompatUnicodeTableUtil.WidthCompat);
cjkCHS = CompressArray (cjkCHS,
MSCompatUnicodeTableUtil.CjkCHS);
@@ -321,12 +322,20 @@
// Ignorables
Result.WriteLine ("static byte [] ignorableFlags = new
byte [] {");
+#if Binary
+ MemoryStream ms = new MemoryStream ();
+ BinaryWriter binary = new BinaryWriter (ms);
+ binary.Write (ignorableFlags.Length);
+#endif
for (int i = 0; i < ignorableFlags.Length; i++) {
byte value = ignorableFlags [i];
if (value < 10)
Result.Write ("{0},", value);
else
Result.Write ("0x{0:X02},", value);
+#if Binary
+ binary.Write (value);
+#endif
if ((i & 0xF) == 0xF)
Result.WriteLine ("// {0:X04}", i -
0xF);
}
@@ -335,12 +344,18 @@
// Primary category
Result.WriteLine ("static byte [] categories = new byte
[] {");
+#if Binary
+ binary.Write (categories.Length);
+#endif
for (int i = 0; i < categories.Length; i++) {
byte value = categories [i];
if (value < 10)
Result.Write ("{0},", value);
else
Result.Write ("0x{0:X02},", value);
+#if Binary
+ binary.Write (value);
+#endif
if ((i & 0xF) == 0xF)
Result.WriteLine ("// {0:X04}", i -
0xF);
}
@@ -349,12 +364,18 @@
// Primary weight value
Result.WriteLine ("static byte [] level1 = new byte []
{");
+#if Binary
+ binary.Write (level1.Length);
+#endif
for (int i = 0; i < level1.Length; i++) {
byte value = level1 [i];
if (value < 10)
Result.Write ("{0},", value);
else
Result.Write ("0x{0:X02},", value);
+#if Binary
+ binary.Write (value);
+#endif
if ((i & 0xF) == 0xF)
Result.WriteLine ("// {0:X04}", i -
0xF);
}
@@ -363,12 +384,18 @@
// Secondary weight
Result.WriteLine ("static byte [] level2 = new byte []
{");
+#if Binary
+ binary.Write (level2.Length);
+#endif
for (int i = 0; i < level2.Length; i++) {
int value = level2 [i];
if (value < 10)
Result.Write ("{0},", value);
else
Result.Write ("0x{0:X02},", value);
+#if Binary
+ binary.Write (value);
+#endif
if ((i & 0xF) == 0xF)
Result.WriteLine ("// {0:X04}", i -
0xF);
}
@@ -377,12 +404,18 @@
// Thirtiary weight
Result.WriteLine ("static byte [] level3 = new byte []
{");
+#if Binary
+ binary.Write (level3.Length);
+#endif
for (int i = 0; i < level3.Length; i++) {
byte value = level3 [i];
if (value < 10)
Result.Write ("{0},", value);
else
Result.Write ("0x{0:X02},", value);
+#if Binary
+ binary.Write (value);
+#endif
if ((i & 0xF) == 0xF)
Result.WriteLine ("// {0:X04}", i -
0xF);
}
@@ -392,18 +425,30 @@
// Width insensitivity mappings
// (for now it is more lightweight than dumping the
// entire NFKD table).
- Result.WriteLine ("static int [] widthCompat = new int
[] {");
+ Result.WriteLine ("static ushort [] widthCompat = new
ushort [] {");
+#if Binary
+ binary.Write (widthCompat.Length);
+#endif
for (int i = 0; i < widthCompat.Length; i++) {
int value = widthCompat [i];
if (value < 10)
Result.Write ("{0},", value);
else
Result.Write ("0x{0:X02},", value);
+#if Binary
+ binary.Write (value);
+#endif
if ((i & 0xF) == 0xF)
Result.WriteLine ("// {0:X04}", i -
0xF);
}
Result.WriteLine ("};");
Result.WriteLine ();
+#if Binary
+ using (FileStream fs = File.Create
("../collation.core.bin")) {
+ byte [] array = ms.ToArray ();
+ fs.Write (array, 0, array.Length);
+ }
+#endif
// CJK
SerializeCJK ("cjkCHS", cjkCHS, char.MaxValue);
@@ -417,6 +462,10 @@
{
int offset = 0;//char.MaxValue - cjk.Length;
Result.WriteLine ("static ushort [] {0} = new ushort []
{{", name);
+#if Binary
+ MemoryStream ms = new MemoryStream ();
+ BinaryWriter binary = new BinaryWriter (ms);
+#endif
for (int i = 0; i < cjk.Length; i++) {
if (i + offset == max)
break;
@@ -425,17 +474,30 @@
Result.Write ("{0},", value);
else
Result.Write ("0x{0:X04},", value);
+#if Binary
+ binary.Write (value);
+#endif
if ((i & 0xF) == 0xF)
Result.WriteLine ("// {0:X04}", i - 0xF
+ offset);
}
Result.WriteLine ("};");
Result.WriteLine ();
+#if Binary
+ using (FileStream fs = File.Create (String.Format
("../collation.{0}.bin", name))) {
+ byte [] array = ms.ToArray ();
+ fs.Write (array, 0, array.Length);
+ }
+#endif
}
void SerializeCJK (string name, byte [] cjk, int max)
{
int offset = 0;//char.MaxValue - cjk.Length;
Result.WriteLine ("static byte [] {0} = new byte []
{{", name);
+#if Binary
+ MemoryStream ms = new MemoryStream ();
+ BinaryWriter binary = new BinaryWriter (ms);
+#endif
for (int i = 0; i < cjk.Length; i++) {
if (i + offset == max)
break;
@@ -444,11 +506,20 @@
Result.Write ("{0},", value);
else
Result.Write ("0x{0:X02},", value);
+#if Binary
+ binary.Write (value);
+#endif
if ((i & 0xF) == 0xF)
Result.WriteLine ("// {0:X04}", i - 0xF
+ offset);
}
Result.WriteLine ("};");
Result.WriteLine ();
+#if Binary
+ using (FileStream fs = File.Create (String.Format
("../collation.{0}.bin", name))) {
+ byte [] array = ms.ToArray ();
+ fs.Write (array, 0, array.Length);
+ }
+#endif
}
void SerializeTailorings ()
@@ -457,6 +528,10 @@
Hashtable counts = new Hashtable ();
Result.WriteLine ("static char [] tailorings = new char
[] {");
int count = 0;
+#if Binary
+ MemoryStream ms = new MemoryStream ();
+ BinaryWriter binary = new BinaryWriter (ms);
+#endif
foreach (Tailoring t in tailorings) {
if (t.Alias != 0)
continue;
@@ -468,6 +543,9 @@
Result.Write ("'\\x{0:X}', ", (int) c);
if (++count % 16 == 0)
Result.WriteLine (" //
{0:X04}", count - 16);
+#if Binary
+ binary.Write ((ushort) c);
+#endif
}
}
Result.WriteLine ("};");
@@ -487,8 +565,20 @@
if (t2.LCID == t.LCID)
french = t2.FrenchSort;
Result.WriteLine ("new TailoringInfo ({0},
0x{1:X}, {2}, {3}), ", t.LCID, idx, cnt, french ? "true" : "false");
+#if Binary
+ binary.Write (t.LCID);
+ binary.Write (idx);
+ binary.Write (cnt);
+ binary.Write (french);
+#endif
}
Result.WriteLine ("};");
+#if Binary
+ using (FileStream fs = File.Create
("../collation.tailoring.bin")) {
+ byte [] array = ms.ToArray ();
+ fs.Write (array, 0, array.Length);
+ }
+#endif
}
#region Parse
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches