static internal void Init(NetRuby rb) { BindingFlags bf = BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Instance; RClass ary = rb.DefineClass("Array", rb.cObject); RMetaObject.IncludeModule(ary, rb.mEnumerable); rb.cArray = ary; Type obj = typeof(RArray); ary.DefineSingletonMethod("new", new RMethod(s_new), -1); ary.DefineSingletonMethod("[]", obj.GetMethod("Create", bf)); ary.DefineMethod("initialize", obj.GetMethod("Initialize", bf)); ary.DefineMethod("to_ary", obj.GetMethod("ToArray", bf)); ary.DefineMethod("==", obj.GetMethod("ArrayEqual", bf)); ary.DefineMethod("eql?", obj.GetMethod("ArrayEql", bf)); ary.DefineMethod("[]", obj.GetMethod("ARef", bf)); ary.DefineMethod("[]=", obj.GetMethod("ASet", bf)); ary.DefineMethod("at", obj.GetMethod("At", bf)); ary.DefineMethod("first", obj.GetMethod("get_First", bf)); ary.DefineMethod("last", obj.GetMethod("get_Last", bf)); ary.DefineMethod("concat", obj.GetMethod("Concat", bf)); ary.DefineMethod("<<", obj.GetMethod("Push", bf)); ary.DefineMethod("push", obj.GetMethod("Push", bf)); ary.DefineMethod("pop", obj.GetMethod("Pop", bf)); ary.DefineMethod("shift", obj.GetMethod("Shift", bf)); ary.DefineMethod("unshift", obj.GetMethod("Unshift", bf)); ary.DefineMethod("each", obj.GetMethod("Each", bf)); ary.DefineMethod("each_index", obj.GetMethod("EachIndex", bf)); ary.DefineMethod("reverse_each", obj.GetMethod("ReverseEach", bf)); ary.DefineMethod("length", obj.GetMethod("get_Count", bf)); ary.DefineAlias("size", "length"); ary.DefineMethod("empty?", obj.GetMethod("get_IsEmpty", bf)); ary.DefineMethod("index", obj.GetMethod("Index", bf)); ary.DefineMethod("rindex", obj.GetMethod("RIndex", bf)); ary.DefineMethod("clone", obj.GetMethod("Clone", bf)); ary.DefineMethod("join", obj.GetMethod("JoinMethod", bf)); ary.DefineMethod("reverse", obj.GetMethod("Reverse", bf)); ary.DefineMethod("reverse!", obj.GetMethod("ReverseAt", bf)); ary.DefineMethod("sort", obj.GetMethod("Sort", bf)); ary.DefineMethod("sort!", obj.GetMethod("SortAt", bf)); ary.DefineMethod("collect", obj.GetMethod("Collect", bf)); ary.DefineMethod("collect!", obj.GetMethod("CollectAt", bf)); ary.DefineMethod("delete", obj.GetMethod("Delete", bf)); ary.DefineMethod("delete_at", obj.GetMethod("DeleteAt", bf)); ary.DefineMethod("clear", obj.GetMethod("Clear2", bf)); ary.DefineMethod("fill", obj.GetMethod("Fill", bf)); ary.DefineMethod("include", obj.GetMethod("Contains", bf)); }
internal static void Init(NetRuby rb) { RClass ex = rb.DefineClass("Exception", rb.cObject); rb.eException = ex; ex.DefineSingletonMethod("exception", new RMethod(exc_new), -1); ex.DefineMethod("exception", new RMethod(exc_exception), -1); ex.DefineMethod("initialize", new RMethod(exc_initialize), -1); ex.DefineMethod("message", new RMethod(exc_to_s), 0); ex.DefineMethod("backtrace", new RMethod(exc_backtrace), 0); ex.DefineMethod("set_backtrace", new RMethod(exc_set_backtrace), 0); rb.eSystemExit = rb.DefineClass("SystemExit", ex); rb.eFatal = rb.DefineClass("Fatal", ex); rb.eInterrupt = rb.DefineClass("Interrupt", ex); rb.eSignal = rb.DefineClass("SignalException", ex); rb.eStandardError = rb.DefineClass("StandardError", ex); rb.eTypeError = rb.DefineClass("TypeError", rb.eStandardError); rb.eArgError = rb.DefineClass("ArgumentError", rb.eStandardError); rb.eIndexError = rb.DefineClass("IndexError", rb.eStandardError); rb.eRangeError = rb.DefineClass("RangeError", rb.eStandardError); rb.eScriptError = rb.DefineClass("ScriptError", ex); rb.eSyntaxError = rb.DefineClass("SyntaxError", rb.eScriptError); rb.eNameError = rb.DefineClass("NameError", rb.eScriptError); rb.eLoadError = rb.DefineClass("LoadError", rb.eScriptError); rb.eNotImpError = rb.DefineClass("NotImplementedError", rb.eScriptError); rb.eRuntimeError = rb.DefineClass("RuntimeError", rb.eStandardError); rb.eSecurityError = rb.DefineClass("SecurityError", rb.eStandardError); rb.eNoMemError = rb.DefineClass("NoMemoryError", ex); }
static internal void Init(NetRuby rb) { BindingFlags bf = BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Instance; RClass str = rb.DefineClass("String", rb.cObject); rb.cString = str; rb.oString = new RString(rb, String.Empty); #if MIXIN RClass.IncludeModule(str, rb.mComparable); RClass.IncludeModule(str, rb.mEnumerable); #endif Type obj = typeof(RString); str.DefineSingletonMethod("new", obj.GetMethod("New", bf)); str.DefineMethod("initialize", obj.GetMethod("Initialize", bf)); str.DefineMethod("clone", obj.GetMethod("Clone", bf)); str.DefineMethod("dup", obj.GetMethod("Dup", new Type[0])); str.DefineMethod("<=>", obj.GetMethod("CompareMethod", bf)); str.DefineMethod("eql?", obj.GetMethod("Equals", bf & (~BindingFlags.Static))); str.DefineMethod("equal?", new RMethod(rb.oString.str_equal), 1); str.DefineMethod("+", obj.GetMethod("Plus", bf)); str.DefineMethod("length", obj.GetMethod("get_Length", bf)); str.DefineMethod("size", obj.GetMethod("get_Length", bf)); str.DefineMethod("empty?", obj.GetMethod("get_IsEmpty", bf)); str.DefineMethod("to_i", obj.GetMethod("ToInteger", new Type[0])); str.DefineMethod("to_f", obj.GetMethod("ToFloat", bf)); MethodInfo mi = obj.GetMethod("ToRString", bf); str.DefineMethod("to_s", mi); str.DefineMethod("to_str", mi); str.DefineMethod("inspect", obj.GetMethod("Inspect", bf)); str.DefineMethod("dump", obj.GetMethod("Dump", bf)); str.DefineMethod("upcase", obj.GetMethod("UpCase", bf)); str.DefineMethod("downcase", obj.GetMethod("DownCase", bf)); str.DefineMethod("capitalize", obj.GetMethod("Capitalize", bf)); str.DefineMethod("swapcase", obj.GetMethod("SwapCase", bf)); str.DefineMethod("upcase!", obj.GetMethod("UpCaseBang", bf)); str.DefineMethod("downcase!", obj.GetMethod("DownCaseBang", bf)); str.DefineMethod("capitalize!", obj.GetMethod("CapitalizeBang", bf)); str.DefineMethod("swapcase!", obj.GetMethod("SwapCaseBang", bf)); str.DefineMethod("sub", obj.GetMethod("Sub", bf)); str.DefineMethod("gsub", obj.GetMethod("Gsub", bf)); str.DefineMethod("sub!", obj.GetMethod("SubAt", bf)); str.DefineMethod("gsub!", obj.GetMethod("GsubAt", bf)); }