public void DefineMethod(string name, RMethod rm, int argc) { AddMethodCheck(); NOEX accs = ((name == "initialize") ? NOEX.PRIVATE : NOEX.PUBLIC) | NOEX.CFUNC; addMethod(name, rm, argc, accs); }
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); }
public void DefineProtectedMethod(string name, RMethod rm, int argc) { addMethod(name, rm, argc, NOEX.PROTECTED | NOEX.CFUNC); }
public void DefinePrivateMethod(string name, RMethod rm, int argc) { addMethod(name, rm, argc, NOEX.PRIVATE | NOEX.CFUNC); }
public void DefineModuleFunction(string name, RMethod rm, int argc) { DefinePrivateMethod(name, rm, argc); DefineSingletonMethod(name, rm, argc); }
internal RDelegateMethod(NetRuby r, string n, RMethod m) { method = m; ruby = r; name = n; }
/* * protected void addMethod(string name, RMethod rm, int argc, NOEX noex) * { * RNode func = new RNRFunc(ruby, rm, argc); * RNode body = new RNMethod(func, noex); #if INIT_DEBUG * System.Console.WriteLine("AddMethod for " + ToString() + ", " + name + "(" + ruby.intern(name).ToString() + ")"); #endif * lock (m_tbl.SyncRoot) * { * m_tbl[ruby.intern(name)] = body; * } * } */ protected void addMethod(string name, RMethod rm, int argc, NOEX noex) { //Console.WriteLine("addMethod " + rm.Method.DeclaringType.Name + "." + rm.Method.Name); m_tbl[name] = new RDelegateMethod(ruby, name, rm); }
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); }
/* protected void addMethod(string name, RMethod rm, int argc, NOEX noex) { RNode func = new RNRFunc(ruby, rm, argc); RNode body = new RNMethod(func, noex); #if INIT_DEBUG System.Console.WriteLine("AddMethod for " + ToString() + ", " + name + "(" + ruby.intern(name).ToString() + ")"); #endif lock (m_tbl.SyncRoot) { m_tbl[ruby.intern(name)] = body; } } */ protected void addMethod(string name, RMethod rm, int argc, NOEX noex) { //Console.WriteLine("addMethod " + rm.Method.DeclaringType.Name + "." + rm.Method.Name); m_tbl[name] = new RDelegateMethod(ruby, name, rm); }
public void DefineSingletonMethod(string name, RMethod rm, int argc) { SingletonClass(this, ruby).DefineMethod(name, rm, argc); }