Exposed cross-references, and added them to the UI.

This commit is contained in:
GoldenCrystal
2014-11-24 00:24:55 +01:00
parent 95fd83cb6d
commit 4f03ba85d9
23 changed files with 169 additions and 55 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ namespace System.Unicode
[ValueName("CS"), ValueName("Common_Separator"), Display(Name = "Common_Separator", Description = "commas, colons, and slashes")]
CommonSeparator,
[ValueName("NSM"), ValueName("Nonspacing_Mark"), Display(Name = "Nonspacing_Mark", Description = "any nonspacing mark")]
NonspacingMark,
NonSpacingMark,
[ValueName("BN"), ValueName("Boundary_Neutral"), Display(Name = "Boundary_Neutral", Description = "most format characters, control codes, or noncharacters")]
BoundaryNeutral,
[ValueName("B"), ValueName("Paragraph_Separator"), Display(Name = "Paragraph_Separator", Description = "various newline characters")]
+1 -1
View File
@@ -36,6 +36,6 @@ namespace System.Unicode
ContributoryProperties = 8192,
CoreProperties = 16384,
RelatedCodePoints = 32768,
CrossRerefences = 32768,
}
}
+2 -1
View File
@@ -36,6 +36,7 @@ namespace System.Unicode
public string SimpleTitleCaseMapping { get { return unicodeCharacterData?.SimpleTitleCaseMapping; } }
public ContributoryProperties ContributoryProperties { get { return unicodeCharacterData?.ContributoryProperties ?? 0; } }
public CoreProperties CoreProperties { get { return unicodeCharacterData?.CoreProperties ?? 0; } }
public UnicodeCrossReferenceCollection CrossRerefences { get { return new UnicodeCrossReferenceCollection(unicodeCharacterData?.CrossRerefences); } }
public string Definition { get { return unihanCharacterData?.Definition; } }
public string MandarinReading { get { return unihanCharacterData?.MandarinReading; } }
@@ -53,7 +54,7 @@ namespace System.Unicode
{
this.codePoint = codePoint;
this.name = UnicodeInfo.GetName(codePoint, unicodeCharacterData);
this.unicodeCharacterData = unicodeCharacterData;
this.unicodeCharacterData = unicodeCharacterData;
this.unihanCharacterData = unihanCharacterData;
this.block = block;
}
+3 -3
View File
@@ -27,7 +27,7 @@ namespace System.Unicode
public readonly ContributoryProperties ContributoryProperties;
public readonly CoreProperties CoreProperties;
public readonly int[] RelatedCodePoints; // NB: It seems that parsing NamesList is required in order to provide data for this field ?
public readonly int[] CrossRerefences; // NB: It seems that parsing NamesList is required in order to provide data for this field ?
internal UnicodeCharacterData
(
@@ -48,7 +48,7 @@ namespace System.Unicode
string simpleTitleCaseMapping,
ContributoryProperties contributoryProperties,
CoreProperties coreProperties,
int[] relatedCodePoints
int[] crossRerefences
)
{
this.CodePointRange = codePointRange;
@@ -68,7 +68,7 @@ namespace System.Unicode
this.SimpleTitleCaseMapping = simpleTitleCaseMapping;
this.ContributoryProperties = contributoryProperties;
this.CoreProperties = coreProperties;
this.RelatedCodePoints = relatedCodePoints;
this.CrossRerefences = crossRerefences;
}
public UnicodeRationalNumber? NumericValue { get { return NumericType != UnicodeNumericType.None ? numericValue : null as UnicodeRationalNumber?; } }
@@ -0,0 +1,70 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace System.Unicode
{
public struct UnicodeCrossReferenceCollection : IList<int>
{
private static int[] EmptyArray = new int[0];
public struct Enumerator : IEnumerator<int>
{
private readonly int[] items;
private int index;
internal Enumerator(int[] items)
{
this.items = items;
this.index = -1;
}
public void Dispose() { }
public int Current { get { return items[index]; } }
object IEnumerator.Current { get { return Current; } }
public bool MoveNext() { return index < items.Length && ++index < items.Length; }
void IEnumerator.Reset() { this.index = -1; }
}
private readonly int[] items;
public UnicodeCrossReferenceCollection() { items = EmptyArray; }
internal UnicodeCrossReferenceCollection(int[] items) { this.items = items ?? EmptyArray; }
public int this[int index] { get { return items[index]; } }
int IList<int>.this[int index]
{
get { return items[index]; }
set { throw new NotSupportedException(); }
}
public int Count { get { return items.Length; } }
bool ICollection<int>.IsReadOnly { get { return true; } }
public void Add(int item) { throw new NotSupportedException(); }
public void Insert(int index, int item) { throw new NotSupportedException(); }
public bool Remove(int item) { throw new NotSupportedException(); }
public void RemoveAt(int index) { throw new NotSupportedException(); }
public void Clear() { throw new NotSupportedException(); }
public int IndexOf(int item) { return Array.IndexOf(items, item); }
public bool Contains(int item) { return IndexOf(item) >= 0; }
public void CopyTo(int[] array, int arrayIndex) { items.CopyTo(array, arrayIndex); }
public Enumerator GetEnumerator() { return new Enumerator(items); }
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
}
+12 -12
View File
@@ -14,7 +14,7 @@ namespace System.Unicode
{
public const string DefaultBlock = "No_Block";
private static readonly Version unicodeVersion;
private static readonly Version unicodeVersion;
private static readonly UnicodeCharacterData[] unicodeCharacterData;
private static readonly UnihanCharacterData[] unihanCharacterData;
private static readonly UnicodeBlock[] blocks;
@@ -34,7 +34,7 @@ namespace System.Unicode
{
int i;
if (reader.ReadByte() != 'U'
if (reader.ReadByte() != 'U'
| reader.ReadByte() != 'C'
| reader.ReadByte() != 'D')
throw new InvalidDataException();
@@ -57,7 +57,7 @@ namespace System.Unicode
++i;
break;
}
}
}
maxContiguousIndex = mci;
@@ -102,7 +102,7 @@ namespace System.Unicode
int length = reader.ReadByte();
byte @case = (byte)(length & 0xC0);
if (@case < 0x80) // Handles the case where only the name is present.
if (@case < 0x80) // Handles the case where only the name is present.
{
length = (length & 0x7F) + 1;
if (reader.Read(nameBuffer, 0, length) != length) throw new EndOfStreamException();
@@ -143,13 +143,13 @@ namespace System.Unicode
string simpleTitleCaseMapping = (fields & UcdFields.SimpleTitleCaseMapping) != 0 ? reader.ReadString() : null;
ContributoryProperties contributoryProperties = (fields & UcdFields.ContributoryProperties) != 0 ? (ContributoryProperties)reader.ReadInt32() : 0;
CoreProperties coreProperties = (fields & UcdFields.CoreProperties) != 0 ? (CoreProperties)ReadInt24(reader) : 0;
int[] relatedCodePoints = (fields & UcdFields.RelatedCodePoints) != 0 ? new int[reader.ReadByte() + 1] : null;
int[] crossReferences = (fields & UcdFields.CrossRerefences) != 0 ? new int[reader.ReadByte() + 1] : null;
if (relatedCodePoints != null)
if (crossReferences != null)
{
for (int i = 0; i < relatedCodePoints.Length; ++i)
relatedCodePoints[i] = ReadCodePoint(reader);
}
for (int i = 0; i < crossReferences.Length; ++i)
crossReferences[i] = ReadCodePoint(reader);
}
return new UnicodeCharacterData
(
@@ -170,7 +170,7 @@ namespace System.Unicode
simpleTitleCaseMapping,
contributoryProperties,
coreProperties,
relatedCodePoints
crossReferences
);
}
@@ -364,7 +364,7 @@ namespace System.Unicode
{
if (HangulInfo.IsHangul(codePoint)) return HangulInfo.GetHangulName((char)codePoint);
else return GetName(codePoint, FindUnicodeCodePoint(codePoint));
}
}
internal static string GetName(int codePoint, UnicodeCharacterData characterData)
{
@@ -372,7 +372,7 @@ namespace System.Unicode
else if (HangulInfo.IsHangul(codePoint)) return HangulInfo.GetHangulName((char)codePoint);
else if (characterData.Name != null) return characterData.Name + "-" + codePoint.ToString("X4");
else return null;
}
}
public static UnicodeBlock[] GetBlocks()
{
@@ -66,6 +66,7 @@
<Compile Include="CodePointEnumerator.cs" />
<Compile Include="CoreProperties.cs" />
<Compile Include="HangulInfo.cs" />
<Compile Include="UnicodeCrossReferenceCollection.cs" />
<Compile Include="UnicodeNameAliasCollection.cs" />
<Compile Include="UcdFields.cs" />
<Compile Include="EnumHelper.cs" />
@@ -58,10 +58,7 @@ namespace System.Unicode
public int IndexOf(UnicodeNameAlias item) { return Array.IndexOf(items, item); }
public bool Contains(UnicodeNameAlias item) { return IndexOf(item) >= 0; }
public void CopyTo(UnicodeNameAlias[] array, int arrayIndex)
{
throw new NotImplementedException();
}
public void CopyTo(UnicodeNameAlias[] array, int arrayIndex) { items.CopyTo(array, arrayIndex); }
public Enumerator GetEnumerator() { return new Enumerator(items); }