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


C# NetRuby.DefineGlobalFunction方法代码示例

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


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

示例1: Init

        internal static void Init(NetRuby rb)
        {
            RIOClass io = new RIOClass(rb);
            io.DefineClass("IO", rb.cObject);
            rb.cIO = io;
        
            rb.DefineGlobalFunction("printf", new RMethod(io.ruby_printf), -1);
            rb.DefineGlobalFunction("print", new RMethod(io.ruby_print), -1);
        
            rb.DefineGlobalFunction("p", new RMethod(io.ruby_p), -1);

        }
开发者ID:emtees,项目名称:old-code,代码行数:12,代码来源:IO.cs

示例2: Init

        internal void Init(NetRuby rb)
        {
            BindingFlags bf = BindingFlags.InvokeMethod
                | BindingFlags.Static | BindingFlags.Public
                | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy
                | BindingFlags.Instance;

            RMethod rmDummy = new RMethod(ruby_dummy);
            rb.cObject.DefinePrivateMethod("initialize", rmDummy, 0);
            rb.cClass.DefinePrivateMethod("inherited", rmDummy, 1);

            DefineMethod("nil?", new RMethod(ruby_isnil), 0);
            DefineMethod("==", new RMethod(ruby_equals), 1);
            DefineAlias("equal?", "==");
            DefineAlias("===", "==");
            DefineMethod("=~", new RMethod(ruby_false), 1);
            DefineMethod("eql?", new RMethod(ruby_eql), 1);

            Type obj = GetType();

            RMethod rm = new RMethod(ruby_id);
            DefineMethod("hash", rm, 0);
            DefineMethod("id", rm, 0);
            DefineMethod("__id__", rm, 0);
            rm = new RMethod(ruby_class);
            DefineMethod("type", rm, 0);
            DefineMethod("class", rm, 0);
        
            DefineMethod("clone", new RMethod(ruby_clone), 0);
            DefineMethod("dup", new RMethod(ruby_dup), 0);
                   DefineMethod("taint", new RMethod(ruby_taint), 0);
            DefineMethod("tainted?", new RMethod(ruby_istainted), 0);
        
            DefineMethod("Untaint", new RMethod(ruby_untaint), 0);
            DefineMethod("freeze", new RMethod(ruby_freeze), 0);
            DefineMethod("frozen?", new RMethod(ruby_isfrozen), 0);
        
            DefineMethod("to_a", new RMethod(ruby_to_a), 0);
            DefineMethod("to_s", new RMethod(ruby_to_s), 0);
            DefineMethod("inspect", new RMethod(ruby_inspect), 0);
            rm = new RMethod(ruby_methods);
            DefineMethod("methods", rm, 0);
            DefineMethod("public_methods", rm, 0);
            DefineMethod("singleton_methods", new RMethod(ruby_singleton_methods), 0);
            DefineMethod("protected_methods", new RMethod(ruby_protected_methods), 0);
            DefineMethod("private_methods", new RMethod(ruby_private_methods), 0);
            DefineMethod("instance_variables", new RMethod(ruby_instance_variables), 0);
            DefinePrivateMethod("remove_instance_variable",
                                new RMethod(ruby_remove_instance_variable), 1);
            DefineMethod("instance_of?", new RMethod(IsInstanceOf), 1);
            rm = new RMethod(IsKindOf);
            DefineMethod("kind_of?", rm, 1);
            DefineMethod("is_a?", rm, 1);

            rb.DefineGlobalFunction("singleton_method_added", rmDummy, 1);
            rb.DefineGlobalFunction("sprintf", new RMethod(sprintf), -1);
            rb.DefineGlobalFunction("format",  new RMethod(sprintf), -1);

            rb.DefineGlobalFunction("Integer", new RMethod(ruby_integer), 1);
            rb.DefineGlobalFunction("Float", new RMethod(ruby_float), 1);
            rb.DefineGlobalFunction("String", new RMethod(ruby_string), 1);
            rb.DefineGlobalFunction("Array", new RMethod(ruby_array), 1);
        
            rb.DefineGlobalFunction("sleep", new RMethod(ruby_sleep), -1);
        
            rb.oNil = new RNil(rb);
            rb.oNil.Init(rb);

            Symbol.Init(rb);

            obj = typeof(RMetaObject);
                rb.cModule.DefineMethod("===", obj.GetMethod("Eqq"));
            rb.cModule.DefineMethod("<=>", obj.GetMethod("CompareTo"));
            rb.cModule.DefineMethod("<", obj.GetMethod("lt"));
            rb.cModule.DefineMethod("<=", obj.GetMethod("le"));
            rb.cModule.DefineMethod(">", obj.GetMethod("gt"));
            rb.cModule.DefineMethod(">=", obj.GetMethod("ge"));
        
            rb.cModule.DefineMethod("included_modules", obj.GetMethod("IncludedModules"));
            rb.cModule.DefineMethod("name", obj.GetMethod("get_ModuleName"));

            rb.cModule.DefineMethod("attr", new RMethod(attr), -1);
            rb.cModule.DefineMethod("attr_reader", new RMethod(attr_reader), -1);
            rb.cModule.DefineMethod("attr_writer", new RMethod(attr_writer), -1);
            rb.cModule.DefineMethod("attr_accessor", new RMethod(attr_accessor), -1);

            rb.cModule.DefineSingletonMethod("new", new RMethod(s_new), 0);
            rb.cModule.DefineMethod("initialize", new RMethod(initialize), -1);
        
            rb.cModule.DefineMethod("instance_methods", obj.GetMethod("ClassInstanceMethods", bf));
            rb.cModule.DefineMethod("public_instance_methods", obj.GetMethod("ClassInstanceMethods", bf));
            rb.cModule.DefineMethod("protected_instance_methods", obj.GetMethod("ClassProtectedInstanceMethods", bf));
            rb.cModule.DefineMethod("private_instance_methods", obj.GetMethod("ClassPrivateInstanceMethods", bf));

            rb.cModule.DefineMethod("constants", new RMethod(rb.cModule.constants), 0);
            rb.cModule.DefineMethod("const_get", new RMethod(rb.cModule.const_get), 1);
            rb.cModule.DefineMethod("const_set", new RMethod(rb.cModule.const_set), 2);
            rb.cModule.DefineMethod("const_defined?", new RMethod(rb.cModule.is_const_defined), 1);
            rb.cModule.DefineMethod("remove_const", new RMethod(rb.cModule.remove_const), 1);
            rb.cModule.DefineMethod("method_added", rmDummy, 1);
//.........这里部分代码省略.........
开发者ID:emtees,项目名称:old-code,代码行数:101,代码来源:Kernel.cs

示例3: Init

 internal static void Init(NetRuby rb)
 {
     RProcClass prc = new RProcClass(rb);
     prc.DefineClass("Proc", rb.cObject);
     rb.cProc = prc;
     prc.DefineSingletonMethod("new", new RMethod(proc_new), -1);
     prc.DefineMethod("call", new RMethod(proc_call), -2);
     prc.DefineMethod("arity", new RMethod(proc_arity), 0);
     prc.DefineMethod("[]", new RMethod(proc_call), -2);
     rb.DefineGlobalFunction("proc", new RMethod(proc_lambda), 0);
     rb.DefineGlobalFunction("lambda", new RMethod(proc_lambda), 0);
 }
开发者ID:emtees,项目名称:old-code,代码行数:12,代码来源:Proc.cs

示例4: Init

 internal static Loader Init(NetRuby rb)
 {
     Loader ld = new Loader(rb);
     rb.DefineReadonlyVariable("$-I", null, new GlobalEntry.Getter(ld.lpGetter));
     rb.DefineReadonlyVariable("$:", null, new GlobalEntry.Getter(ld.lpGetter));
     rb.DefineReadonlyVariable("$LOAD_PATH", null, new GlobalEntry.Getter(ld.lpGetter));
     rb.DefineReadonlyVariable("$\"", null, new GlobalEntry.Getter(ld.ftGetter));
     rb.DefineGlobalFunction("load", new RBasic.RMethod(ld.f_load), -1);
     rb.DefineGlobalFunction("require", new RBasic.RMethod(ld.require), 1);
     return ld;
 }
开发者ID:emtees,项目名称:old-code,代码行数:11,代码来源:Loader.cs


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