Exemplo n.º 1
0
        public void Attribute(string name, bool read, bool write, bool ex)
        {
            NOEX    noex = NOEX.PUBLIC;
            RThread th   = ruby.GetCurrentContext();

            if (ex)
            {
                if (th.ScopeTest(Scope.ScopeMode.Private))
                {
                    noex = NOEX.PRIVATE;
                    ruby.warning((th.ScopeMode == Scope.ScopeMode.ModFunc) ?
                                 "attribute accessor as module_function" :
                                 "private attribute?");
                }
                else if (th.ScopeTest(Scope.ScopeMode.Protected))
                {
                    noex = NOEX.PROTECTED;
                }
            }
            uint id     = ruby.ToID(name);
            uint attriv = ruby.intern("@" + name);

            if (read)
            {
                ////addMethod(id, new RNIVar(th, attriv), noex);
                ruby.Funcall(this, "method_added", Symbol.ID2SYM(id));
            }
            if (write)
            {
                id = ruby.intern(name + "=");
                ////addMethod(id, new RNAttrSet(th, attriv), noex);
                ruby.Funcall(this, "method_added", Symbol.ID2SYM(id));
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        private void ExportMethod(uint name, NOEX noex)
        {
/*
 *          if (this == ruby.cObject)
 *          {
 *              ruby.Secure(4);
 *          }
 *          RMetaObject origin;
 *          RNode body = SearchMethod(name, out origin);
 *          if (body == null && this is RModule)
 *          {
 *              body = ruby.cObject.SearchMethod(name, out origin);
 *          }
 *          if (body == null)
 *          {
 *              printUndef(name);
 *          }
 *          if (body.noex != noex)
 *          {
 *              if (this == origin)
 *              {
 *                  body.noex = noex;
 *              }
 *              else
 *              {
 *                  ruby.ClearCache(name);
 *                  addMethod(name, new RNZSuper(ruby.GetCurrentContext(), ruby), noex);
 *              }
 *          }
 */
        }
Exemplo n.º 4
0
 private void SetMethodVisibility(object[] args, NOEX ex)
 {
     ////ruby.SecureVisibility(this);
     for (int i = 0; i < args.Length; i++)
     {
         ExportMethod(ruby.ToID(args[i]), ex);
     }
 }
Exemplo n.º 5
0
        protected void addMethod(string name, MethodInfo mi, NOEX noex)
        {
            if (!mi.IsStatic)
            {
                m_tbl[name] = new RBuiltinMethod(ruby, mi);
            }

            /*
             * Console.WriteLine("adding " + mi.DeclaringType.Name + "." + mi.Name + " static=" + mi.IsStatic.ToString()
             + " ret=" + mi.ReturnType.Name);
             +
             + foreach(ParameterInfo pi in mi.GetParameters()) {
             +  Console.WriteLine("param " + pi.ParameterType.Name + " " + pi.Name);
             + }
             */
        }
Exemplo n.º 6
0
 public void Write(NOEX n)
 {
     Write(n.ToString());
 }
Exemplo n.º 7
0
/*
 *      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);
        }
Exemplo n.º 8
0
 protected void addMethod(string name, MethodInfo mi, NOEX noex)
 {
     if(!mi.IsStatic) {
         m_tbl[name] = new RBuiltinMethod(ruby, mi);
     }
     /*
     Console.WriteLine("adding " + mi.DeclaringType.Name + "." + mi.Name + " static=" + mi.IsStatic.ToString()
             + " ret=" + mi.ReturnType.Name);
     
     foreach(ParameterInfo pi in mi.GetParameters()) {
         Console.WriteLine("param " + pi.ParameterType.Name + " " + pi.Name); 
     }
     */
 }
Exemplo n.º 9
0
/*
        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);
        }
Exemplo n.º 10
0
 private void SetMethodVisibility(object[] args, NOEX ex)
 {
     ////ruby.SecureVisibility(this);
     for (int i = 0; i < args.Length; i++)
     {
         ExportMethod(ruby.ToID(args[i]), ex);
     }
 }
Exemplo n.º 11
0
        private void ExportMethod(uint name, NOEX noex)
        {
/*        
            if (this == ruby.cObject)
            {
                ruby.Secure(4);
            }
            RMetaObject origin;
            RNode body = SearchMethod(name, out origin);
            if (body == null && this is RModule)
            {
                body = ruby.cObject.SearchMethod(name, out origin);
            }
            if (body == null)
            {
                printUndef(name);
            }
            if (body.noex != noex)
            {
                if (this == origin)
                {
                    body.noex = noex;
                }
                else
                {
                    ruby.ClearCache(name);
                    addMethod(name, new RNZSuper(ruby.GetCurrentContext(), ruby), noex);
                }
            }
*/                        
        }
Exemplo n.º 12
0
 internal RNDefn(RThread ps, uint i, RNode a, RNode d, NOEX p)
     : base(ps, i, a, d)
 {
     ex = p;
 }