Permalink
Browse files

Add support for property aliases

  • Loading branch information...
sorear committed Dec 19, 2011
1 parent d9e5c69 commit 60d6d0d9e0ba70b7044c9c69442fe9ede9083bb3
Showing with 25 additions and 4 deletions.
  1. +25 −4 lib/UCD.cs
View
@@ -84,6 +84,7 @@ static class DataSet {
static Dictionary<string,object> cache;
static byte[] bits;
static Dictionary<string,int[]> directory;
static Dictionary<string,string> aliases;
static bool Trace;
const int FILES = 4;
@@ -145,6 +146,21 @@ static class DataSet {
if (Trace) Console.WriteLine("done.");
}
static void InflateAliases() {
int[] loc = directory["!PropertyAlias"];
aliases = new Dictionary<string, string>();
int rpos = loc[2];
while (rpos < loc[3]) {
string main = AsciiZ(ref rpos);
string alias;
while ((alias = AsciiZ(ref rpos)).Length != 0) {
aliases[alias] = main;
if (Trace) Console.WriteLine("Alias {0} -> {1}", alias, main);
}
}
}
static object InflateBinary(int[] loc) {
List<int> vec = new List<int>();
int rpos = loc[2];
@@ -184,15 +200,20 @@ static class DataSet {
public static object GetTable(string name) {
if (cache == null)
cache = new Dictionary<string,object>();
object r;
if (cache.TryGetValue(name, out r))
return r;
if (bits == null) {
bits = File.ReadAllBytes("unidata");
InflateDirectory();
InflateAliases();
}
object r;
string a;
if (aliases.TryGetValue(name, out a))
name = a;
if (cache.TryGetValue(name, out r))
return r;
int[] loc;
if (!directory.TryGetValue(name, out loc))
throw new NieczaException(name + " does not exist as a UCD table");

0 comments on commit 60d6d0d

Please sign in to comment.