예제 #1
0
파일: Const.cs 프로젝트: retahc/old-code
 internal void Init(NetRuby rb)
 {
     rb.cFalseClass = rb.DefineClass("FalseClass", rb.cObject);
     rb.cFalseClass.DefineMethod("&", new RMethod(ruby_and), 1);
     rb.cFalseClass.DefineMethod("|", new RMethod(ruby_or), 1);
     rb.cFalseClass.DefineMethod("^", new RMethod(ruby_xor), 1);
     rb.ClassOf(rb.cFalseClass).UndefMethod("new");
     rb.DefineGlobalConst("FALSE", false);
 }
예제 #2
0
파일: Const.cs 프로젝트: retahc/old-code
        internal void Init(NetRuby rb)
        {
            BindingFlags bf = BindingFlags.InvokeMethod
                              | BindingFlags.Static | BindingFlags.Public
                              | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy
                              | BindingFlags.Instance;

            rb.cNilClass = rb.DefineClass("NilClass", rb.cObject);
            Type obj = typeof(RNil);

            rb.cNilClass.DefineMethod("to_i", obj.GetMethod("ToInteger", bf));
            rb.cNilClass.DefineMethod("to_a", obj.GetMethod("ToArray", bf));
            rb.cNilClass.DefineMethod("to_s", new RMethod(nil_to_s), 0);
            rb.cNilClass.DefineMethod("&", new RMethod(ruby_and), 1);
            rb.cNilClass.DefineMethod("|", new RMethod(ruby_or), 1);
            rb.cNilClass.DefineMethod("^", new RMethod(ruby_xor), 1);
            rb.cNilClass.DefineMethod("nil?", new RMethod(ruby_true), 0);

            rb.ClassOf(rb.cNilClass).UndefMethod("new");
            rb.DefineGlobalConst("NIL", null);
        }
예제 #3
0
        static internal void Init(NetRuby rb)
        {
            rb.eRegexpError = rb.DefineClass("RegexpError", rb.eStandardError);

            rb.DefineVirtualVariable("$~",
                                     new GlobalEntry.Getter(matchGetter),
                                     new GlobalEntry.Setter(matchSetter));
            rb.DefineVirtualVariable("$&",
                                     new GlobalEntry.Getter(lastMatchGetter), null);
            rb.DefineVirtualVariable("$`",
                                     new GlobalEntry.Getter(preMatchGetter), null);
            rb.DefineVirtualVariable("$'",
                                     new GlobalEntry.Getter(postMatchGetter), null);
            rb.DefineVirtualVariable("$+",
                                     new GlobalEntry.Getter(lastParenGetter), null);
            rb.DefineVirtualVariable("$=",
                                     new GlobalEntry.Getter(iCaseGetter),
                                     new GlobalEntry.Setter(iCaseSetter));
            rb.DefineVirtualVariable("$KCODE",
                                     new GlobalEntry.Getter(kCodeGetter),
                                     new GlobalEntry.Setter(kCodeSetter));
            rb.DefineVirtualVariable("$-K",
                                     new GlobalEntry.Getter(kCodeGetter),
                                     new GlobalEntry.Setter(kCodeSetter));

            RRegexpClass reg = new RRegexpClass(rb);

            reg.DefineClass("Regexp", rb.cObject);
            rb.cRegexp = reg;

            reg.DefineSingletonMethod("new", new RMethod(s_new), -1);
            reg.DefineSingletonMethod("compile", new RMethod(s_new), -1);
            reg.DefineSingletonMethod("quote", new RMethod(s_quote), -1);
            reg.DefineSingletonMethod("escape", new RMethod(s_quote), -1);
            reg.DefineSingletonMethod("last_match", new RMethod(s_lastmatch), 0);

            reg.DefineMethod("initialize", new RMethod(initialize), -1);
            reg.DefineMethod("=~", new RMethod(match), 1);
            reg.DefineMethod("===", new RMethod(match), 1);
            reg.DefineMethod("~", new RMethod(match2), 0);
            reg.DefineMethod("match", new RMethod(match_m), 1);
            reg.DefineMethod("source", new RMethod(source), 0);
            reg.DefineMethod("casefold?", new RMethod(casefold_p), 0);
            reg.DefineMethod("kcode", new RMethod(kcode_m), 0);

            reg.DefineConst("IGNORECASE", RegexOptions.IgnoreCase);
            reg.DefineConst("EXTENDED", RegexOptions.IgnorePatternWhitespace);
            reg.DefineConst("MULTILINE", RegexOptions.Multiline);

            RClass md = rb.DefineClass("MatchData", rb.cObject);

            rb.DefineGlobalConst("MatchingData", md);
            rb.cMatch = md;
            rb.ClassOf(md).UndefMethod("new");
            md.DefineMethod("size", new RMethod(match_size), 0);
            md.DefineMethod("length", new RMethod(match_size), 0);
            md.DefineMethod("offset", new RMethod(match_offset), 1);
            md.DefineMethod("begin", new RMethod(match_begin), 1);
            md.DefineMethod("end", new RMethod(match_end), 1);
            md.DefineMethod("to_a", new RMethod(match_to_a), 0);
            md.DefineMethod("[]", new RMethod(match_aref), -1);
            md.DefineMethod("pre_match", new RMethod(match_pre), 0);
            md.DefineMethod("post_match", new RMethod(match_post), 0);
            md.DefineMethod("to_s", new RMethod(match_to_s), 0);
            md.DefineMethod("string", new RMethod(match_string), 0);
        }