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); }
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); obj = rb.cClass.GetType(); rb.cClass.DefineMethod("new", new RMethod(ruby_new), -1); rb.cClass.DefineMethod("superclass", new RMethod(ruby_superclass), 0); rb.cClass.DefineSingletonMethod("new", new RMethod(ruby_s_new), -1); rb.cClass.UndefMethod("extend_object"); rb.cClass.UndefMethod("append_feartures"); rb.cClass.DefineSingletonMethod("inherited", new RMethod(RClass.Inherited), 1); rb.cData = rb.DefineClass("Data", rb.cObject); rb.ClassOf(rb.cData).UndefMethod("new"); rb.topSelf = new RMainObject(rb); rb.oTrue = new RTrue(rb); rb.oTrue.Init(rb); rb.oFalse = new RFalse(rb); rb.oFalse.Init(rb); }
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); }
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; }