2005-07-04 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 4 Jul 2005 11:53:27 +0000 (11:53 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 4 Jul 2005 11:53:27 +0000 (11:53 -0000)
* MSCompatUnicodeTable.cs : renamed from MSCompatUnicodeTable.template
  (now it is working as a standalone file).
* Makefile : renamed generated file as MSCompatUnicodeTableGenerated.cs
  (the generator now creates both binary resources and C# source).

svn path=/trunk/mcs/; revision=46905

1  2 
mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.cs
mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
mcs/class/corlib/Mono.Globalization.Unicode/Makefile

index 162e1dd635d66e8ab2c4830fb35dfc71560458d2,162e1dd635d66e8ab2c4830fb35dfc71560458d2..5a845b6b79e77ea76afb02cf9ace0b61d47b99e4
@@@ -1,3 -1,3 +1,10 @@@
++2005-07-04  Atsushi Enomoto  <atsushi@ximian.com>
++
++      * MSCompatUnicodeTable.cs : renamed from MSCompatUnicodeTable.template
++        (now it is working as a standalone file).
++      * Makefile : renamed generated file as MSCompatUnicodeTableGenerated.cs
++        (the generator now creates both binary resources and C# source).
++
  2005-07-04  Atsushi Enomoto  <atsushi@ximian.com>
  
        * create-mscompat-collation-table.cs : Now it generates binary
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..80ba583e14e2dd289b736eaa41b4c9343525f2f6
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,301 @@@
++using System;
++using System.Globalization;
++
++using UUtil = Mono.Globalization.Unicode.MSCompatUnicodeTableUtil;
++
++namespace Mono.Globalization.Unicode
++{
++      internal class TailoringInfo
++      {
++              public readonly int LCID;
++              public readonly int TailoringIndex;
++              public readonly int TailoringCount;
++              public readonly bool FrenchSort;
++
++              public TailoringInfo (int lcid, int tailoringIndex, int tailoringCount, bool frenchSort)
++              {
++                      LCID = lcid;
++                      TailoringIndex = tailoringIndex;
++                      TailoringCount = tailoringCount;
++                      FrenchSort = frenchSort;
++              }
++      }
++
++      internal class MSCompatUnicodeTable
++      {
++              public static char [] TailoringValues {
++                      get { return tailorings; }
++              }
++
++              public static ushort [] CjkCHS {
++                      get { return cjkCHS; }
++              }
++
++              public static ushort [] CjkCHT {
++                      get { return cjkCHT; }
++              }
++
++              public static ushort [] CjkJA {
++                      get { return cjkJA; }
++              }
++
++              public static ushort [] CjkKO {
++                      get { return cjkKO; }
++              }
++
++              public static byte [] CjkKOLv2 {
++                      get { return cjkKOlv2; }
++              }
++
++              public static TailoringInfo GetTailoringInfo (int lcid)
++              {
++                      for (int i = 0; i < tailoringInfos.Length; i++)
++                              if (tailoringInfos [i].LCID == lcid)
++                                      return tailoringInfos [i];
++                      return null;
++              }
++
++              public static byte Categories (int cp)
++              {
++                      int idx = UUtil.Category.ToIndex (cp);
++                      return idx < 0 ? byte.MinValue : categories [idx];
++              }
++
++              public static byte Level1 (int cp)
++              {
++                      int idx = UUtil.Level1.ToIndex (cp);
++                      return idx < 0 ? byte.MinValue : level1 [idx];
++              }
++
++              public static byte Level2 (int cp)
++              {
++                      int idx = UUtil.Level2.ToIndex (cp);
++                      return idx < 0 ? byte.MinValue : level2 [idx];
++              }
++
++              public static byte Level3 (int cp)
++              {
++                      int idx = UUtil.Level3.ToIndex (cp);
++                      return idx < 0 ? byte.MinValue : level3 [idx];
++              }
++
++              public static bool IsIgnorable (int cp)
++              {
++                      UnicodeCategory uc = Char.GetUnicodeCategory ((char) cp);
++                      // This check eliminates some extraneous code areas
++                      if (uc == UnicodeCategory.OtherNotAssigned)
++                              return true;
++                      // Some characters in Surrogate area are ignored.
++                      if (0xD880 <= cp && cp < 0xDB80)
++                              return true;
++                      int i = UUtil.Ignorable.ToIndex (cp);
++                      return i >= 0 && ignorableFlags [i] == 7;
++              }
++              // Verifier:
++              // for (int i = 0; i <= char.MaxValue; i++)
++              //      if (Char.GetUnicodeCategory ((char) i)
++              //              == UnicodeCategory.OtherNotAssigned 
++              //              && ignorableFlags [i] != 7)
++              //              Console.WriteLine ("{0:X04}", i);
++
++              public static bool IsIgnorableSymbol (int cp)
++              {
++                      int i = UUtil.Ignorable.ToIndex (cp);
++                      return i >= 0 && (ignorableFlags [i] & 0x2) != 0;
++              }
++
++              public static bool IsIgnorableNonSpacing (int cp)
++              {
++                      int i = UUtil.Ignorable.ToIndex (cp);
++                      return i >= 0 && (ignorableFlags [i] & 0x4) != 0;
++              }
++
++              public static int ToKanaTypeInsensitive (int i)
++              {
++                      // Note that IgnoreKanaType does not treat half-width
++                      // katakana as equivalent to full-width ones.
++
++                      // Thus, it is so simple ;-)
++                      return (0x3041 <= i && i <= 0x3094) ? i + 0x60 : i;
++              }
++
++              public static int ToWidthCompat (int cp)
++              {
++                      int i = UUtil.WidthCompat.ToIndex (cp);
++                      int v = i >= 0 ? (int) widthCompat [i] : 0;
++                      return v != 0 ? v : cp;
++              }
++
++              #region Level 4 properties (Kana)
++
++              public static bool HasSpecialWeight (char c)
++              {
++                      if (c < '\u3041')
++                              return false;
++                      else if (c < '\u3100')
++                              return true;
++                      else if (c < '\u32D0')
++                              return false;
++                      else if (c < '\u32FF')
++                              return true;
++                      else if (c < '\uFF66')
++                              return false;
++                      else if (c < '\uFF9F')
++                              return true;
++                      return false;
++              }
++
++              public static byte GetJapaneseDashType (char c)
++              {
++                      switch (c) {
++                      case '\u309D':
++                      case '\u309E':
++                      case '\u30FD':
++                      case '\u30FE':
++                      case '\uFF70':
++                              return 4;
++                      case '\u30FC':
++                              return 5;
++                      }
++                      return 3;
++              }
++
++              public static bool IsHalfWidthKana (char c)
++              {
++                      return '\uFF66' <= c && c <= '\uFF9D';
++              }
++
++              public static bool IsHiragana (char c)
++              {
++                      return '\u3041' <= c && c <= '\u3094';
++              }
++
++              public static bool IsJapaneseSmallLetter (char c)
++              {
++                      if ('\uFF67' <= c && c <= '\uFF6F')
++                              return true;
++                      if ('\u3040' < c && c < '\u30FA') {
++                              switch (c) {
++                              case '\u3041':
++                              case '\u3043':
++                              case '\u3045':
++                              case '\u3047':
++                              case '\u3049':
++                              case '\u3063':
++                              case '\u3083':
++                              case '\u3085':
++                              case '\u3087':
++                              case '\u308E':
++                              case '\u30A1':
++                              case '\u30A3':
++                              case '\u30A5':
++                              case '\u30A7':
++                              case '\u30A9':
++                              case '\u30C3':
++                              case '\u30E3':
++                              case '\u30E5':
++                              case '\u30E7':
++                              case '\u30EE':
++                                      return true;
++                              }
++                      }
++                      return false;
++              }
++
++              #endregion
++
++
++              // For "categories", 0 means no primary weight. 6 means 
++              // variable weight
++              // For expanded character the value is never filled (i.e. 0).
++              // Those arrays will be split into blocks (<3400 and >F800)
++              // level 4 is computed.
++
++              // public static bool HasSpecialWeight (char c)
++              // { return level1 [(int) c] == 6; }
++
++              //
++              // 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
diff --cc mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
index 80ba583e14e2dd289b736eaa41b4c9343525f2f6,80ba583e14e2dd289b736eaa41b4c9343525f2f6..0000000000000000000000000000000000000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,301 -1,301 +1,0 @@@
--using System;
--using System.Globalization;
--
--using UUtil = Mono.Globalization.Unicode.MSCompatUnicodeTableUtil;
--
--namespace Mono.Globalization.Unicode
--{
--      internal class TailoringInfo
--      {
--              public readonly int LCID;
--              public readonly int TailoringIndex;
--              public readonly int TailoringCount;
--              public readonly bool FrenchSort;
--
--              public TailoringInfo (int lcid, int tailoringIndex, int tailoringCount, bool frenchSort)
--              {
--                      LCID = lcid;
--                      TailoringIndex = tailoringIndex;
--                      TailoringCount = tailoringCount;
--                      FrenchSort = frenchSort;
--              }
--      }
--
--      internal class MSCompatUnicodeTable
--      {
--              public static char [] TailoringValues {
--                      get { return tailorings; }
--              }
--
--              public static ushort [] CjkCHS {
--                      get { return cjkCHS; }
--              }
--
--              public static ushort [] CjkCHT {
--                      get { return cjkCHT; }
--              }
--
--              public static ushort [] CjkJA {
--                      get { return cjkJA; }
--              }
--
--              public static ushort [] CjkKO {
--                      get { return cjkKO; }
--              }
--
--              public static byte [] CjkKOLv2 {
--                      get { return cjkKOlv2; }
--              }
--
--              public static TailoringInfo GetTailoringInfo (int lcid)
--              {
--                      for (int i = 0; i < tailoringInfos.Length; i++)
--                              if (tailoringInfos [i].LCID == lcid)
--                                      return tailoringInfos [i];
--                      return null;
--              }
--
--              public static byte Categories (int cp)
--              {
--                      int idx = UUtil.Category.ToIndex (cp);
--                      return idx < 0 ? byte.MinValue : categories [idx];
--              }
--
--              public static byte Level1 (int cp)
--              {
--                      int idx = UUtil.Level1.ToIndex (cp);
--                      return idx < 0 ? byte.MinValue : level1 [idx];
--              }
--
--              public static byte Level2 (int cp)
--              {
--                      int idx = UUtil.Level2.ToIndex (cp);
--                      return idx < 0 ? byte.MinValue : level2 [idx];
--              }
--
--              public static byte Level3 (int cp)
--              {
--                      int idx = UUtil.Level3.ToIndex (cp);
--                      return idx < 0 ? byte.MinValue : level3 [idx];
--              }
--
--              public static bool IsIgnorable (int cp)
--              {
--                      UnicodeCategory uc = Char.GetUnicodeCategory ((char) cp);
--                      // This check eliminates some extraneous code areas
--                      if (uc == UnicodeCategory.OtherNotAssigned)
--                              return true;
--                      // Some characters in Surrogate area are ignored.
--                      if (0xD880 <= cp && cp < 0xDB80)
--                              return true;
--                      int i = UUtil.Ignorable.ToIndex (cp);
--                      return i >= 0 && ignorableFlags [i] == 7;
--              }
--              // Verifier:
--              // for (int i = 0; i <= char.MaxValue; i++)
--              //      if (Char.GetUnicodeCategory ((char) i)
--              //              == UnicodeCategory.OtherNotAssigned 
--              //              && ignorableFlags [i] != 7)
--              //              Console.WriteLine ("{0:X04}", i);
--
--              public static bool IsIgnorableSymbol (int cp)
--              {
--                      int i = UUtil.Ignorable.ToIndex (cp);
--                      return i >= 0 && (ignorableFlags [i] & 0x2) != 0;
--              }
--
--              public static bool IsIgnorableNonSpacing (int cp)
--              {
--                      int i = UUtil.Ignorable.ToIndex (cp);
--                      return i >= 0 && (ignorableFlags [i] & 0x4) != 0;
--              }
--
--              public static int ToKanaTypeInsensitive (int i)
--              {
--                      // Note that IgnoreKanaType does not treat half-width
--                      // katakana as equivalent to full-width ones.
--
--                      // Thus, it is so simple ;-)
--                      return (0x3041 <= i && i <= 0x3094) ? i + 0x60 : i;
--              }
--
--              public static int ToWidthCompat (int cp)
--              {
--                      int i = UUtil.WidthCompat.ToIndex (cp);
--                      int v = i >= 0 ? (int) widthCompat [i] : 0;
--                      return v != 0 ? v : cp;
--              }
--
--              #region Level 4 properties (Kana)
--
--              public static bool HasSpecialWeight (char c)
--              {
--                      if (c < '\u3041')
--                              return false;
--                      else if (c < '\u3100')
--                              return true;
--                      else if (c < '\u32D0')
--                              return false;
--                      else if (c < '\u32FF')
--                              return true;
--                      else if (c < '\uFF66')
--                              return false;
--                      else if (c < '\uFF9F')
--                              return true;
--                      return false;
--              }
--
--              public static byte GetJapaneseDashType (char c)
--              {
--                      switch (c) {
--                      case '\u309D':
--                      case '\u309E':
--                      case '\u30FD':
--                      case '\u30FE':
--                      case '\uFF70':
--                              return 4;
--                      case '\u30FC':
--                              return 5;
--                      }
--                      return 3;
--              }
--
--              public static bool IsHalfWidthKana (char c)
--              {
--                      return '\uFF66' <= c && c <= '\uFF9D';
--              }
--
--              public static bool IsHiragana (char c)
--              {
--                      return '\u3041' <= c && c <= '\u3094';
--              }
--
--              public static bool IsJapaneseSmallLetter (char c)
--              {
--                      if ('\uFF67' <= c && c <= '\uFF6F')
--                              return true;
--                      if ('\u3040' < c && c < '\u30FA') {
--                              switch (c) {
--                              case '\u3041':
--                              case '\u3043':
--                              case '\u3045':
--                              case '\u3047':
--                              case '\u3049':
--                              case '\u3063':
--                              case '\u3083':
--                              case '\u3085':
--                              case '\u3087':
--                              case '\u308E':
--                              case '\u30A1':
--                              case '\u30A3':
--                              case '\u30A5':
--                              case '\u30A7':
--                              case '\u30A9':
--                              case '\u30C3':
--                              case '\u30E3':
--                              case '\u30E5':
--                              case '\u30E7':
--                              case '\u30EE':
--                                      return true;
--                              }
--                      }
--                      return false;
--              }
--
--              #endregion
--
--
--              // For "categories", 0 means no primary weight. 6 means 
--              // variable weight
--              // For expanded character the value is never filled (i.e. 0).
--              // Those arrays will be split into blocks (<3400 and >F800)
--              // level 4 is computed.
--
--              // public static bool HasSpecialWeight (char c)
--              // { return level1 [(int) c] == 6; }
--
--              //
--              // 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
index 45fda9de58e4d9daf1fc87113576bd2db05fa8d4,45fda9de58e4d9daf1fc87113576bd2db05fa8d4..e4c2f07747bd269567672003752d308f5d8a1add
@@@ -16,13 -16,13 +16,13 @@@ COLL_ELEM_FILENAME = create-collation-e
  COMBINING_FILENAME = create-combining-class-source
  CANON_EQUIV_FILENAME = create-char-mapping-source
  MSTABLEGEN = create-mscompat-collation-table
--MSCOMPAT_FILENAME = MSCompatUnicodeTable.cs
++MSCOMPAT_FILENAME = MSCompatUnicodeTableGenerated.cs
  
  all : collation normalization
  
  normalization: Normalization.cs
  
--collation : MSCompatUnicodeTable.cs 
++collation : $(MSCOMPAT_FILENAME)
  
  distclean :
        make clean
@@@ -37,7 -37,7 +37,7 @@@ clean-normalization 
        rm -f Normalization.cs $(NORM_FILENAME).exe* $(COMBINING_FILENAME).exe* $(CANON_EQUIV_FILENAME).exe*
  
  clean-mscompat :
--      rm -f MSCompatUnicodeTable.cs $(MSTABLEGEN).exe*
++      rm -f $(MSCOMPAT_FILENAME) $(MSTABLEGEN).exe*
  
  
  # collation element table
@@@ -147,7 -147,7 +147,7 @@@ $(UCA_DATA) 
        touch core.zip
  
  
--#MSCompatUnicodeTable.cs
++#MSCompatUnicodeTableGenerated.cs
  
  $(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)