示例#1
0
        public static bool IsConstantDefined(RubyModule /*!*/ self, [DefaultProtocol] string /*!*/ constantName)
        {
            RubyUtils.CheckConstantName(constantName);

            object constant;

            return(self.TryResolveConstantNoAutoload(constantName, out constant));
        }
示例#2
0
        public static bool IsConstantDefined(RubyModule /*!*/ self, [DefaultProtocol, NotNull] string /*!*/ constantName)
        {
            RubyUtils.CheckConstantName(constantName);
            object constant;

            // MRI checks declared constans only and don't trigger autoload:
            return(self.TryGetConstant(null, constantName, out constant));
        }
示例#3
0
        public static void SetAutoloadedConstant(RubyModule /*!*/ self,
                                                 [DefaultProtocol] string /*!*/ constantName, [DefaultProtocol, NotNull] MutableString /*!*/ path)
        {
            RubyUtils.CheckConstantName(constantName);
            if (path.IsEmpty)
            {
                throw RubyExceptions.CreateArgumentError("empty file name");
            }

            self.SetAutoloadedConstant(constantName, path);
        }
示例#4
0
        public static object RemoveConstant(RubyModule /*!*/ self, [DefaultProtocol, NotNull] string /*!*/ constantName)
        {
            object value;

            if (!self.TryRemoveConstant(constantName, out value))
            {
                RubyUtils.CheckConstantName(constantName);
                throw RubyExceptions.CreateNameError("constant {0}::{1} not defined", self.Name, constantName);
            }
            return(value);
        }
示例#5
0
        public static object RemoveConstant(RubyModule /*!*/ self, [DefaultProtocol] string /*!*/ constantName)
        {
            object value;

            if (!self.TryGetConstantNoAutoload(constantName, out value))
            {
                RubyUtils.CheckConstantName(constantName);
                throw RubyExceptions.CreateNameError(String.Format("constant {0}::{1} not defined", self.Name, constantName));
            }
            self.RemoveConstant(constantName);
            return(value);
        }
示例#6
0
        public static object NewStruct(BlockParam block, RubyClass /*!*/ self, [DefaultProtocol] MutableString className,
                                       [DefaultProtocol, NotNullItems] params string /*!*/[] /*!*/ attributeNames)
        {
            if (className == null)
            {
                return(Create(block, self, null, attributeNames));
            }

            string strName = className.ConvertToString();

            RubyUtils.CheckConstantName(strName);
            return(Create(block, self, strName, attributeNames));
        }
示例#7
0
        public static object NewStruct(BlockParam block, RubyClass /*!*/ self, [DefaultProtocol, Optional] MutableString className,
                                       [NotNull] params object[] /*!*/ attributeNames)
        {
            string[] symbols = Protocols.CastToSymbols(self.Context, attributeNames);

            if (className == null)
            {
                return(Create(block, self, null, symbols));
            }

            string strName = className.ConvertToString();

            RubyUtils.CheckConstantName(strName);
            return(Create(block, self, strName, symbols));
        }
示例#8
0
 public static object SetConstantValue(RubyModule /*!*/ self, [DefaultProtocol] string /*!*/ constantName, object value)
 {
     RubyUtils.CheckConstantName(constantName);
     RubyUtils.SetConstant(self, constantName, value);
     return(value);
 }