Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPaolo Molaro <lupus@oddwiz.org>2004-08-09 14:23:38 +0400
committerPaolo Molaro <lupus@oddwiz.org>2004-08-09 14:23:38 +0400
commita90972a1271d5e63634ceed1f5f0d63b9785fe67 (patch)
tree05f0618a128c65095f7b7f62a22ad57438344cf2 /tools
parent0abe4411e7cc0f7e49d8b011c6e8a28b7240bf28 (diff)
Mon Aug 9 13:24:09 CEST 2004 Paolo Molaro <lupus@ximian.com>
* Driver.cs, Entry.cs, CultureInfoEntry.cs, DateTimeFormatEntry.cs, NumberFormatEntry.cs: create a more compact representation of the data. svn path=/trunk/mono/; revision=32061
Diffstat (limited to 'tools')
-rw-r--r--tools/locale-builder/ChangeLog7
-rw-r--r--tools/locale-builder/CultureInfoEntry.cs12
-rw-r--r--tools/locale-builder/DateTimeFormatEntry.cs28
-rw-r--r--tools/locale-builder/Driver.cs7
-rw-r--r--tools/locale-builder/Entry.cs47
-rw-r--r--tools/locale-builder/NumberFormatEntry.cs32
6 files changed, 92 insertions, 41 deletions
diff --git a/tools/locale-builder/ChangeLog b/tools/locale-builder/ChangeLog
index c05aa261b60..7c9de0a198e 100644
--- a/tools/locale-builder/ChangeLog
+++ b/tools/locale-builder/ChangeLog
@@ -1,3 +1,10 @@
+
+Mon Aug 9 13:24:09 CEST 2004 Paolo Molaro <lupus@ximian.com>
+
+ * Driver.cs, Entry.cs, CultureInfoEntry.cs, DateTimeFormatEntry.cs,
+ NumberFormatEntry.cs: create a more compact representation of the
+ data.
+
2004-06-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* Driver.cs: handle single quotes in the pattern. We used to fail for,
diff --git a/tools/locale-builder/CultureInfoEntry.cs b/tools/locale-builder/CultureInfoEntry.cs
index 9a13d306f5b..cf36ae8c240 100644
--- a/tools/locale-builder/CultureInfoEntry.cs
+++ b/tools/locale-builder/CultureInfoEntry.cs
@@ -61,15 +61,15 @@ namespace Mono.Tools.LocaleBuilder {
{
builder.Append ("\t{");
builder.AppendFormat ("{0}, {1}, {2}, " +
- "\"{3}\", \"{4}\", \"{5}\", " +
- "\"{6}\", \"{7}\", \"{8}\", " +
- "\"{9}\", \"{10}\", " +
+ "{3}, {4}, {5}, " +
+ "{6}, {7}, {8}, " +
+ "{9}, {10}, " +
"{11}, " +
"{12}, {13}",
Lcid, ParentLcid, SpecificLcid,
- EncodeString (Name), EncodeString (IcuName), EncodeString (EnglishName),
- EncodeString (DisplayName), EncodeString (NativeName), EncodeString (Win3Lang),
- EncodeString (ISO3Lang), EncodeString (ISO2Lang),
+ EncodeStringIdx (Name), EncodeStringIdx (IcuName), EncodeStringIdx (EnglishName),
+ EncodeStringIdx (DisplayName), EncodeStringIdx (NativeName), EncodeStringIdx (Win3Lang),
+ EncodeStringIdx (ISO3Lang), EncodeStringIdx (ISO2Lang),
ValuesString (CalendarData),
DateTimeFormatEntry == null ? -1 : DateTimeFormatEntry.Row,
NumberFormatEntry == null ? -1 : NumberFormatEntry.Row);
diff --git a/tools/locale-builder/DateTimeFormatEntry.cs b/tools/locale-builder/DateTimeFormatEntry.cs
index f834ea8fe61..03a7101b3aa 100644
--- a/tools/locale-builder/DateTimeFormatEntry.cs
+++ b/tools/locale-builder/DateTimeFormatEntry.cs
@@ -45,18 +45,18 @@ namespace Mono.Tools.LocaleBuilder {
public void AppendTableRow (StringBuilder builder)
{
builder.Append ("\t{");
- builder.Append ("\"" + EncodeString (FullDateTimePattern) + "\", ");
- builder.Append ("\"" + EncodeString (LongDatePattern) + "\", ");
- builder.Append ("\"" + EncodeString (ShortDatePattern) + "\", ");
+ builder.Append (EncodeStringIdx (FullDateTimePattern) + ", ");
+ builder.Append (EncodeStringIdx (LongDatePattern) + ", ");
+ builder.Append (EncodeStringIdx (ShortDatePattern) + ", ");
- builder.Append ("\"" + EncodeString (LongTimePattern) + "\", ");
- builder.Append ("\"" + EncodeString (ShortTimePattern) + "\", ");
+ builder.Append (EncodeStringIdx (LongTimePattern) + ", ");
+ builder.Append (EncodeStringIdx (ShortTimePattern) + ", ");
- builder.Append ("\"" + EncodeString (YearMonthPattern) + "\", ");
- builder.Append ("\"" + EncodeString (MonthDayPattern) + "\", ");
+ builder.Append (EncodeStringIdx (YearMonthPattern) + ", ");
+ builder.Append (EncodeStringIdx (MonthDayPattern) + ", ");
- builder.Append ("\"" + EncodeString (AMDesignator) + "\", ");
- builder.Append ("\"" + EncodeString (PMDesignator) + "\", ");
+ builder.Append (EncodeStringIdx (AMDesignator) + ", ");
+ builder.Append (EncodeStringIdx (PMDesignator) + ", ");
AppendNames (builder, DayNames);
builder.Append (", ");
@@ -72,8 +72,8 @@ namespace Mono.Tools.LocaleBuilder {
builder.Append (CalendarWeekRule + ", ");
builder.Append (FirstDayOfWeek + ", ");
- builder.Append ("\"" + EncodeString (DateSeparator) + "\", ");
- builder.Append ("\"" + EncodeString (TimeSeparator) + "\", ");
+ builder.Append (EncodeStringIdx (DateSeparator) + ", ");
+ builder.Append (EncodeStringIdx (TimeSeparator) + ", ");
AppendPatterns (builder, ShortDatePatterns);
builder.Append (',');
@@ -91,10 +91,8 @@ namespace Mono.Tools.LocaleBuilder {
string [] patterns = al.ToArray (typeof (string)) as string [];
builder.Append ('{');
for (int i = 0; i < patterns.Length; i++) {
- string s = EncodeString (patterns [i]);
- builder.Append ('\"');
+ string s = EncodeStringIdx (patterns [i]);
builder.Append (s);
- builder.Append ('\"');
if (i + 1 < patterns.Length)
builder.Append (',');
}
@@ -114,7 +112,7 @@ namespace Mono.Tools.LocaleBuilder {
{
builder.Append ('{');
for (int i=0; i<names.Count; i++) {
- builder.Append ("\"" + EncodeString (names [i].ToString ()) + "\"");
+ builder.Append (EncodeStringIdx (names [i].ToString ()));
if (i+1 < names.Count)
builder.Append (", ");
}
diff --git a/tools/locale-builder/Driver.cs b/tools/locale-builder/Driver.cs
index 90d8e40a4d2..384b25ff7e4 100644
--- a/tools/locale-builder/Driver.cs
+++ b/tools/locale-builder/Driver.cs
@@ -97,6 +97,7 @@ namespace Mono.Tools.LocaleBuilder {
using (StreamWriter writer = new StreamWriter (HeaderFileName, false, new UTF8Encoding (false, true))) {
writer.WriteLine ();
+ writer.WriteLine ("/* This is a generated file. Do not edit. See tools/locale-builder. */");
writer.WriteLine ("#ifndef MONO_METADATA_CULTURE_INFO_TABLES");
writer.WriteLine ("#define MONO_METADATA_CULTURE_INFO_TABLES 1");
writer.WriteLine ("\n");
@@ -161,7 +162,7 @@ namespace Mono.Tools.LocaleBuilder {
builder = new StringBuilder ();
for (int i = 0; i < count; i++) {
CultureInfoEntry ci = (CultureInfoEntry) cultures [i];
- builder.Append ("\t{\"" + ci.Name.ToLower () + "\", ");
+ builder.Append ("\t{" + Entry.EncodeStringIdx (ci.Name.ToLower ()) + ", ");
builder.Append (ci.Row + "}");
if (i + 1 < count)
builder.Append (',');
@@ -172,6 +173,10 @@ namespace Mono.Tools.LocaleBuilder {
writer.Write (builder);
writer.WriteLine ("};\n\n");
+ writer.WriteLine ("static const char locale_strings [] = {");
+ writer.Write (Entry.GetStrings ());
+ writer.WriteLine ("};\n\n");
+
writer.WriteLine ("#endif\n");
}
}
diff --git a/tools/locale-builder/Entry.cs b/tools/locale-builder/Entry.cs
index baf37d2893a..07beccdb53e 100644
--- a/tools/locale-builder/Entry.cs
+++ b/tools/locale-builder/Entry.cs
@@ -4,15 +4,55 @@
using System;
using System.Text;
+using System.Collections;
namespace Mono.Tools.LocaleBuilder {
public class Entry {
- protected static String EncodeString (string str)
+ // maps strings to indexes
+ static Hashtable hash;
+ static ArrayList string_order;
+ // idx 0 is reserved to indicate null
+ static int curpos = 1;
+
+ // serialize the strings in Hashtable.
+ public static string GetStrings () {
+ Console.WriteLine ("Total string data size: {0}", curpos);
+ if (curpos > UInt16.MaxValue)
+ throw new Exception ("need to increase idx size in culture-info.h");
+ StringBuilder ret = new StringBuilder ();
+ // the null entry
+ ret.Append ("\"\\0\"\n");
+ foreach (string s in string_order) {
+ ret.Append ("\t\"");
+ ret.Append (s);
+ ret.Append ("\\0\"\n");
+ }
+ return ret.ToString ();
+ }
+ static Entry () {
+ hash = new Hashtable ();
+ string_order = new ArrayList ();
+ }
+ static int AddString (string s, int size) {
+ object o = hash [s];
+ if (o == null) {
+ int ret;
+ string_order.Add (s);
+ ret = curpos;
+ hash [s] = curpos;
+ curpos += size + 1; // null terminator
+ return ret;
+ } else {
+ return (int)o;
+ }
+ }
+
+ protected static String EncodeStringIdx (string str)
{
if (str == null)
- return String.Empty;
+ return "0";
StringBuilder ret = new StringBuilder ();
byte [] ba = new UTF8Encoding ().GetBytes (str);
@@ -28,7 +68,8 @@ namespace Mono.Tools.LocaleBuilder {
in_hex = false;
}
}
- return ret.ToString ();
+ int res = AddString (ret.ToString (), ba.Length);
+ return res.ToString ();
}
private static bool is_hex (int e)
diff --git a/tools/locale-builder/NumberFormatEntry.cs b/tools/locale-builder/NumberFormatEntry.cs
index 2d72028771a..5c74fcfcd5a 100644
--- a/tools/locale-builder/NumberFormatEntry.cs
+++ b/tools/locale-builder/NumberFormatEntry.cs
@@ -54,22 +54,22 @@ namespace Mono.Tools.LocaleBuilder {
{
builder.Append ("\t{");
- builder.Append ("\"" + EncodeString (CurrencyDecimalSeparator) + "\", ");
- builder.Append ("\"" + EncodeString (CurrencyGroupSeparator) + "\", ");
- builder.Append ("\"" + EncodeString (PercentDecimalSeparator) + "\", ");
- builder.Append ("\"" + EncodeString (PercentGroupSeparator) + "\", ");
- builder.Append ("\"" + EncodeString (NumberDecimalSeparator) + "\", ");
- builder.Append ("\"" + EncodeString (NumberGroupSeparator) + "\", ");
-
- builder.Append ("\"" + EncodeString (CurrencySymbol) + "\", ");
- builder.Append ("\"" + EncodeString (PercentSymbol) + "\", ");
- builder.Append ("\"" + EncodeString (NaNSymbol) + "\", ");
- builder.Append ("\"" + EncodeString (PerMilleSymbol) + "\", ");
- builder.Append ("\"" + EncodeString (NegativeInfinitySymbol) + "\", ");
- builder.Append ("\"" + EncodeString (PositiveInfinitySymbol) + "\", ");
-
- builder.Append ("\"" + EncodeString (NegativeSign) + "\", ");
- builder.Append ("\"" + EncodeString (PositiveSign) + "\", ");
+ builder.Append (EncodeStringIdx (CurrencyDecimalSeparator) + ", ");
+ builder.Append (EncodeStringIdx (CurrencyGroupSeparator) + ", ");
+ builder.Append (EncodeStringIdx (PercentDecimalSeparator) + ", ");
+ builder.Append (EncodeStringIdx (PercentGroupSeparator) + ", ");
+ builder.Append (EncodeStringIdx (NumberDecimalSeparator) + ", ");
+ builder.Append (EncodeStringIdx (NumberGroupSeparator) + ", ");
+
+ builder.Append (EncodeStringIdx (CurrencySymbol) + ", ");
+ builder.Append (EncodeStringIdx (PercentSymbol) + ", ");
+ builder.Append (EncodeStringIdx (NaNSymbol) + ", ");
+ builder.Append (EncodeStringIdx (PerMilleSymbol) + ", ");
+ builder.Append (EncodeStringIdx (NegativeInfinitySymbol) + ", ");
+ builder.Append (EncodeStringIdx (PositiveInfinitySymbol) + ", ");
+
+ builder.Append (EncodeStringIdx (NegativeSign) + ", ");
+ builder.Append (EncodeStringIdx (PositiveSign) + ", ");
builder.Append (CurrencyNegativePattern + ", ");
builder.Append (CurrencyPositivePattern + ", ");