From 28770b75bc07a420e70d0d49c57309bde5308622 Mon Sep 17 00:00:00 2001 From: handa Date: Thu, 16 Apr 2009 05:55:04 +0000 Subject: [PATCH] *** empty log message *** --- M17N.cs | 66 +++++++++++++++++------------------------------------------ MText.cs | 63 ++++++++++++++++++++++++++++++++++---------------------- Makefile | 15 +++++++------- symbol.cs | 4 ++++ textprop.cs | 3 +++ 5 files changed, 73 insertions(+), 78 deletions(-) diff --git a/M17N.cs b/M17N.cs index 31eb4fe..2e13847 100644 --- a/M17N.cs +++ b/M17N.cs @@ -1,53 +1,25 @@ using System; -using M17N.Core; -public class Test +namespace M17N { - static void symbol_test () + public class M17N { - MSymbol sym1, sym2; - - Console.WriteLine ("### Symbol test ###"); - sym1 = new MSymbol ("abc"); - Console.WriteLine (sym1.ToString ()); - sym2 = new MSymbol ("abc"); - Console.WriteLine (sym2.ToString ()); - Console.WriteLine (sym1 == sym2 ? "OK" : "NO"); - sym1.Put (MSymbol.nil, MSymbol.t); - - MPlist p = new MPlist (); - - p.Put (MSymbol.t, sym1); - p.Push (MSymbol.t, sym2); - - MPlist pp = new MPlist (); - pp.Put (MSymbol.t, p); - Console.WriteLine (pp.ToString ()); - Console.WriteLine (p.Get (MSymbol.t)); - } - - static void mtext_test () - { - MText mt; - - Console.WriteLine ("### MText test ###"); - mt = new MText ("abc"); - Console.WriteLine (mt); - Console.WriteLine (mt + new MText ("def")); - mt += new MText ("ghi"); - Console.WriteLine (mt); + public static readonly int MajorVersion = 0; + public static readonly int MinorVersion = 0; + public static readonly int ReleaseNumber = 0; + + public static bool debug = false; + + public static void DebugPrint (string fmt, object arg) + { + if (debug) + Console.Write (fmt, arg); + } + + public static void DebugPrint (string fmt, object arg1, object arg2) + { + if (debug) + Console.Write (fmt, arg1, arg2); + } } - - static void mtext_property_test () - { - Console.WriteLine ("### MTextProperty test ###"); - } - - public static void Main() - { - symbol_test (); - mtext_test (); - mtext_property_test (); - } - } diff --git a/MText.cs b/MText.cs index dddb24d..4264023 100644 --- a/MText.cs +++ b/MText.cs @@ -2,6 +2,7 @@ using System; using System.Text; using System.Collections; using System.Collections.Generic; +using M17N; using M17N.Core; namespace M17N.Core @@ -434,7 +435,7 @@ namespace M17N.Core { Console.Write ("("); foreach (MPlist p in intervals) - ((MInterval) p.Val).Dump (); + ((MInterval) p.Val).Dump (true); Console.WriteLine (")"); } @@ -740,7 +741,7 @@ namespace M17N.Core { MInterval interval = new MInterval (Key, mtext, To - pos, Stack); - Console.Write ("divide-right({0}) at ", pos); DumpOne (false, true); + M17N.DebugPrint ("divide-right({0}) at ", pos); DumpOne (false, true); To = pos; if (Right != null) { @@ -760,7 +761,7 @@ namespace M17N.Core { MInterval interval = new MInterval (Key, mtext, pos - From, Stack); - Console.Write ("divide-left({0}) at ", pos); DumpOne (false, true); + M17N.DebugPrint ("divide-left({0}) at ", pos); DumpOne (false, true); From = pos; if (Left != null) { @@ -921,7 +922,7 @@ namespace M17N.Core public void Insert (int pos, MInterval interval) { update_from_to (); - Console.Write ("insert({0}) at {1} in ", interval.Length, pos); + M17N.DebugPrint ("insert({0}) at {1} in ", interval.Length, pos); DumpOne (false, true); interval.set_mtext (mtext); @@ -1045,7 +1046,7 @@ namespace M17N.Core private void vacate_node (MInterval interval) { - Console.WriteLine ("vacate #{0} to #{1}", ID, interval.ID); + M17N.DebugPrint ("vacate #{0} to #{1}", ID, interval.ID); if (interval != null) interval.Parent = Parent; if (Parent == null) @@ -1071,7 +1072,7 @@ namespace M17N.Core public void Delete (int start, int end) { update_from_to (); - Console.Write ("delete({0} {1}) from ", start, end); DumpOne (false, true); + M17N.DebugPrint ("delete({0} {1}) from ", start, end); DumpOne (false, true); if (start < From) { if (end <= From) @@ -1127,7 +1128,7 @@ namespace M17N.Core public void Push (int start, int end, MTextProperty prop) { update_from_to (); - Console.Write ("push({0} {1}) at ", start, end); DumpOne (false, true); + M17N.DebugPrint ("push({0} {1}) at ", start, end); DumpOne (false, true); if (start < From) { if (end <= From) @@ -1211,7 +1212,7 @@ namespace M17N.Core public void Pop (int start, int end) { update_from_to (); - Console.Write ("pop({0} {1}) at ", start, end); DumpOne (false, true); + M17N.DebugPrint ("pop({0} {1}) at ", start, end); DumpOne (false, true); if (start < From) { if (end <= From) @@ -1261,26 +1262,40 @@ namespace M17N.Core private void DumpOne (bool with_prop, bool newline) { - Console.Write ("#{0}({1} {2} {3}", ID, Length, From, To); - if (with_prop) - foreach (MPlist p in Stack) - Console.Write (" " + p.Val); - Console.Write (")"); - if (newline) - Console.WriteLine (); + DumpOne (with_prop, newline, false); } - public void Dump () + private void DumpOne (bool with_prop, bool newline, bool force) { - update_from_to (); + if (force || M17N.debug) + { + Console.Write ("#{0}({1} {2} {3}", ID, Length, From, To); + if (with_prop) + foreach (MPlist p in Stack) + Console.Write (" " + p.Val); + Console.Write (")"); + if (newline) + Console.WriteLine (); + } + } - if (Left != null) - Left.Dump (); - if (From > 0) - Console.Write (" "); - DumpOne (true, false); - if (Right != null) - Right.Dump (); + public void Dump () { Dump (false); } + + + public void Dump (bool force) + { + if (force || M17N.debug) + { + update_from_to (); + + if (Left != null) + Left.Dump (force); + if (From > 0) + Console.Write (" "); + DumpOne (true, false, force); + if (Right != null) + Right.Dump (force); + } } } diff --git a/Makefile b/Makefile index 7dfec74..6068ec5 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,26 @@ +M17N_SRC = M17N.cs CORE_SRC = MSymbol.cs MPlist.cs MText.cs CS=gmcs -all: M17N.exe symbol.exe plist.exe mtext.exe textprop.exe +all: M17N.dll symbol.exe plist.exe mtext.exe textprop.exe -M17NCore.dll: ${CORE_SRC} - $(CS) /out:$@ /t:library ${CORE_SRC} +M17N.dll: ${M17N_SRC} + $(CS) /out:$@ /t:library ${M17N_SRC} -M17N.exe: M17N.cs M17NCore.dll - $(CS) /r:M17NCore M17N.cs +M17NCore.dll: M17N.dll ${CORE_SRC} + $(CS) /out:$@ /t:library /r:M17N.dll ${CORE_SRC} mtext.exe: mtext.cs M17NCore.dll $(CS) -codepage:65001 /r:M17NCore mtext.cs symbol.exe: symbol.cs M17NCore.dll - $(CS) -codepage:65001 /r:M17NCore symbol.cs + $(CS) -codepage:65001 /r:M17N.dll /r:M17NCore symbol.cs plist.exe: plist.cs M17NCore.dll $(CS) -codepage:65001 /r:M17NCore plist.cs textprop.exe: textprop.cs M17NCore.dll - $(CS) -codepage:65001 /r:M17NCore textprop.cs + $(CS) -codepage:65001 /r:M17N.dll /r:M17NCore textprop.cs clean: rm -f *.dll *.exe diff --git a/symbol.cs b/symbol.cs index b92921f..60d9439 100644 --- a/symbol.cs +++ b/symbol.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using M17N; using M17N.Core; public class Test @@ -10,6 +11,9 @@ public class Test MSymbol sym2 = new MSymbol ("symbol"); MSymbol sym3 = new MSymbol ("another sym:bol"); + Console.WriteLine ("version {0}-{1}-{2}", M17N.M17N.MajorVersion, + M17N.M17N.MinorVersion, M17N.M17N.ReleaseNumber); + Console.WriteLine ("sym1 = {0}", sym1); Console.WriteLine ("sym2 = {0}", sym2); Console.WriteLine ("sym3 = {0}", sym3); diff --git a/textprop.cs b/textprop.cs index e0971d7..c0502ef 100644 --- a/textprop.cs +++ b/textprop.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using M17N; using M17N.Core; public class Test @@ -12,6 +13,8 @@ public class Test MTextProperty prop1 = new MTextProperty (sym, "test1"); MTextProperty prop2 = new MTextProperty (sym, "test2"); + M17N.M17N.debug = true; + mt.PushProp (2, 5, prop1); mt.DumpProp (); mt.PushProp (3, 6, prop2); -- 1.7.10.4