From: handa Date: Thu, 22 Oct 2009 07:40:17 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5543e0aaf8f077fd584cbbdeaa7be8936269aa0;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/MInputMethod.cs b/MInputMethod.cs index 2b7ad2c..8bd03c4 100644 --- a/MInputMethod.cs +++ b/MInputMethod.cs @@ -2519,6 +2519,7 @@ namespace M17N.Input { if (DelSurroundingText != null) { + Console.WriteLine ("deleting the prev {0} chars", - pos); callback_arg.Set (MSymbol.integer, pos); if (DelSurroundingText (this, callback_arg)) { @@ -2540,6 +2541,8 @@ namespace M17N.Input { if (DelSurroundingText != null) { + Console.WriteLine ("deleting the next {0} chars", + pos - preedit.Length); callback_arg.Set (MSymbol.integer, pos - preedit.Length); if (DelSurroundingText (this, callback_arg)) { @@ -2912,6 +2915,7 @@ namespace M17N.Input private bool del_surrounding_text (Context ic, MPlist args) { int pos = this.pos + args.Integer; + Console.WriteLine ("del-surround: {0}-{1}", this.pos, pos); if (pos < this.pos) { mt.Del (pos, this.pos); diff --git a/XmlExpr.cs b/XmlExpr.cs index a82abde..d21a630 100644 --- a/XmlExpr.cs +++ b/XmlExpr.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; +using System.Reflection; using System.Xml; namespace System.Xml @@ -752,6 +753,21 @@ namespace System.Xml termtypes[name] = new TermType (name, parser); } + public void DefType (Type type) + { + if (! type.IsSubclassOf (typeof (TermValue))) + throw new Exception ("Not a subclass of TermValue: " + type); + BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic; + FieldInfo finfo = type.GetField ("name", flags); + if (finfo == null) + throw new Exception ("No \"name\" field: " + type); + Type[] types = new Type[] { typeof (Domain), typeof (XmlNode), + typeof (TermValue) }; + MethodInfo minfo = type.GetMethod ("Parser"); + if (minfo == null) + throw new Exception ("No \"Parser\" method: " + type); + } + public void DefSubr (Builtin builtin, string str, bool setvar, int min_arg, int max_arg, params string[] aliases) { @@ -1110,6 +1126,7 @@ namespace System.Xml { basic.DefTerm ("funcall", Funcall.parser); basic.DefTerm ("varref", Varref.parser); + basic.DefType (typeof (Funcall)); basic.DefSubr (Fset, "set", true, 1, 1, "="); basic.DefSubr (Fnot, "not", false, 1, 1, "!"); @@ -1649,14 +1666,17 @@ namespace System.Xml public class TermType { - public readonly Symbol type; - internal readonly TermParser parser; + private readonly Symbol name; + private readonly TermParser parser; - public TermType (Symbol type, TermParser parser) + public TermType (Symbol name, TermParser parser) { - this.type = type; + this.name = name; this.parser = parser; } + + public Symbol Name { get { return name; } } + internal TermParser Parser { get { return parser; } } } public abstract class TermValue @@ -1667,15 +1687,15 @@ namespace System.Xml private class Varref : TermValue { - private Symbol name; + private Symbol vname; private Variable vari; - public Varref (Symbol name) { this.name = name; } + public Varref (Symbol vname) { this.vname = vname; } public override Term Eval (Domain domain) { if (vari == null || vari.domain != domain) - vari = domain.GetVar (name, true); + vari = domain.GetVar (vname, true); return vari.Value; } @@ -1686,12 +1706,16 @@ namespace System.Xml public override string ToString () { - return ""; + return ""; } } private class Funcall : TermValue { + private static Symbol name = "funcall"; + + public static Symbol Name { get { return name; } } + internal Function func; internal Variable vari; internal Term[] args; @@ -1711,6 +1735,11 @@ namespace System.Xml this.args = args; } + public static TermValue Parser (Domain domain, XmlNode node) + { + return null; + } + internal static TermValue parser (Domain domain, XmlNode node) { Symbol fname = node.Name; @@ -1811,7 +1840,7 @@ namespace System.Xml TermType term_type; if (domain.termtypes.TryGetValue (name, out term_type)) - objval = term_type.parser (domain, node); + objval = term_type.Parser (domain, node); else { Funcall funcall = (Funcall) Funcall.parser (domain, node); diff --git a/xex.cs b/xex.cs index 60be5ed..741e4f2 100644 --- a/xex.cs +++ b/xex.cs @@ -2,18 +2,18 @@ using System; using System.Collections.Generic; using System.IO; using System.Xml; -using Xex = System.Xml.Expression.Xexpression; +using Xex = System.Xml.Xexpression; public class Test { public static void Main(params string[] args) { - Xex.debug_level = 10; + Xex.DebugDepth = 10; Xex.Domain domain = new Xex.Domain ("test", null); Xex xex = new Xex (domain, "xex.xml"); if (args.Length >= 2 && args[0] == "-d") - Xex.debug_level = int.Parse (args[1]); + Xex.DebugDepth = int.Parse (args[1]); Console.WriteLine (xex); Console.WriteLine (xex.Eval (domain)); }