当前位置: 首页>>代码示例>>C#>>正文


C# NetRuby.DefineGlobalConst方法代码示例

本文整理汇总了C#中NETRuby.NetRuby.DefineGlobalConst方法的典型用法代码示例。如果您正苦于以下问题:C# NetRuby.DefineGlobalConst方法的具体用法?C# NetRuby.DefineGlobalConst怎么用?C# NetRuby.DefineGlobalConst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NETRuby.NetRuby的用法示例。


在下文中一共展示了NetRuby.DefineGlobalConst方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        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);
        }
开发者ID:emtees,项目名称:old-code,代码行数:19,代码来源:Const.cs

示例2: Init

        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);
        }
开发者ID:emtees,项目名称:old-code,代码行数:64,代码来源:Regexp.cs


注:本文中的NETRuby.NetRuby.DefineGlobalConst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。