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) { RClass sym = rb.DefineClass("Symbol", rb.cObject); rb.cSymbol = sym; rb.oSymbol = new Symbol(rb); sym.DefineMethod("to_i", new RMethod(to_i), 0); sym.DefineMethod("to_int", new RMethod(to_i), 0); sym.DefineMethod("inspect", new RMethod(inspect), 0); sym.DefineMethod("to_s", new RMethod(to_s), 0); sym.DefineMethod("id2name", new RMethod(to_s), 0); }
static internal new void Init(NetRuby rb) { RClass big = rb.DefineClass("Bignum", rb.cInteger); rb.cBignum = big; big.DefineMethod("~", new RMethod(ruby_neg), 0); RMethod rm = new RMethod(ruby_eq); big.DefineMethod("==", rm, 1); big.DefineMethod("===", rm, 1); big.DefineMethod("eql?", rm, 1); }
static internal new void Init(NetRuby rb) { RClass fix = rb.DefineClass("Fixnum", rb.cInteger); rb.cFixnum = fix; RFixnum o = new RFixnum(rb); rb.oFixnum = o; rb.oFixZero = new RFixnum(rb, 0); fix.DefineMethod("to_f", new RMethod(o.ruby_to_f), 0); fix.DefineMethod("to_c", new RMethod(o.ruby_to_c), 0); fix.DefineMethod("==", new RMethod(fix_equal), 1); }
internal static new void Init(NetRuby rb) { RClass it = rb.DefineClass("Integer", rb.cNumeric); rb.cInteger = it; rb.ClassOf(it).UndefMethod("new"); it.DefineMethod("upto", new RMethod(int_upto), 1); it.DefineMethod("downto", new RMethod(int_downto), 1); it.DefineMethod("step", new RMethod(int_step), 2); it.DefineMethod("to_int", new RMethod(num_to_i), 0); it.DefineMethod("floor", new RMethod(num_to_i), 0); it.DefineMethod("ceil", new RMethod(num_to_i), 0); it.DefineMethod("round", new RMethod(num_to_i), 0); }
static internal new void Init(NetRuby rb) { BindingFlags bf = BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Instance; RClass flo = rb.DefineClass("Float", rb.cNumeric); rb.cFloat = flo; rb.oFloat = new RFloat(rb, 0.0); Type obj = typeof(RFloat); rb.ClassOf(flo).UndefMethod("new"); flo.DefineMethod("floor", obj.GetMethod("get_Floor", bf)); flo.DefineMethod("ceil", obj.GetMethod("get_Ceil", bf)); flo.DefineMethod("round", obj.GetMethod("get_Round", bf)); flo.DefineMethod("nan?", obj.GetMethod("get_IsNaN", bf)); flo.DefineMethod("infinite?", obj.GetMethod("get_IsInfinite", bf)); flo.DefineMethod("finite?", obj.GetMethod("get_IsFinite", bf)); }
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)); }
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); }
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)); }
static internal void Init(NetRuby ruby) { RClass num = ruby.DefineClass("Numeric", ruby.cObject); ruby.cNumeric = num; num.DefineMethod("coerce", new RMethod(num_coerce), 1); num.DefineMethod("to_i", new RMethod(num_to_i), 0); num.DefineMethod("truncate", new RMethod(num_to_i), 0); num.DefineMethod("+@", new RMethod(num_uplus), 0); num.DefineMethod("-@", new RMethod(num_uminus), 0); num.DefineMethod("===", new RMethod(num_equal), 1); num.DefineMethod("+", new RMethod(num_plus), 1); num.DefineMethod("-", new RMethod(num_minus), 1); num.DefineMethod("*", new RMethod(num_mul), 1); num.DefineMethod("/", new RMethod(num_div), 1); num.DefineMethod("%", new RMethod(num_mod), 1); num.DefineMethod("modulo", new RMethod(num_mod), 1); num.DefineMethod("divmod", new RMethod(num_divmod), 1); num.DefineMethod("remainder", new RMethod(num_remainder), 1); num.DefineMethod("<=>", new RMethod(num_cmp), 1); num.DefineMethod(">", new RMethod(num_gt), 1); num.DefineMethod(">=", new RMethod(num_ge), 1); num.DefineMethod("<", new RMethod(num_lt), 1); num.DefineMethod("<=", new RMethod(num_le), 1); }