Example #1
0
        //----------------------------------------------------------------------------
        // Overloaded .Has methods that convert their argument into either a string
        // (property) or uint32 (index) and fowards the call to the correct .Has
        //----------------------------------------------------------------------------

        public bool Delete(BoxedValue index)
        {
            uint i = 0;

            if (TypeConverter.TryToIndex(index, out i))
            {
                return(this.Delete(i));
            }
            return(this.Delete(TypeConverter.ToString(index)));
        }
Example #2
0
        public bool Delete(double index)
        {
            uint parsed = 0;

            if (TypeConverter.TryToIndex(index, out parsed))
            {
                return(this.Delete(parsed));
            }
            return(this.Delete(TypeConverter.ToString(index)));
        }
Example #3
0
        //----------------------------------------------------------------------------
        // Overloaded .Get methods that convert their argument into either a string
        // or uint32 and forwards the call to the correct .Get method
        //----------------------------------------------------------------------------

        public BoxedValue Get(BoxedValue index)
        {
            uint i = 0;

            if (TypeConverter.TryToIndex(index, out i))
            {
                return(this.Get(i));
            }
            return(this.Get(TypeConverter.ToString(index)));
        }
Example #4
0
        public BoxedValue Get(double index)
        {
            uint parsed = 0;

            if (TypeConverter.TryToIndex(index, out parsed))
            {
                return(this.Get(parsed));
            }
            return(this.Get(TypeConverter.ToString(index)));
        }
Example #5
0
        public bool Has(CommonObject index)
        {
            string s      = TypeConverter.ToString(index);
            uint   parsed = 0;

            if (TypeConverter.TryToIndex(s, out parsed))
            {
                return(this.Has(parsed));
            }
            return(this.Has(s));
        }
Example #6
0
        public BoxedValue Get(CommonObject index)
        {
            string s      = TypeConverter.ToString(index);
            uint   parsed = 0;

            if (TypeConverter.TryToIndex(s, out parsed))
            {
                return(this.Get(parsed));
            }
            return(this.Get(s));
        }
Example #7
0
        public bool Delete(object index)
        {
            string name   = TypeConverter.ToString(index);
            uint   parsed = 0;

            if (TypeConverter.TryToIndex(name, out parsed))
            {
                return(this.Delete(parsed));
            }
            return(this.Delete(name));
        }
Example #8
0
        public void Put(double index, BoxedValue value)
        {
            uint parsed = 0;

            if (TypeConverter.TryToIndex(index, out parsed))
            {
                this.Put(parsed, value);
            }
            else
            {
                this.Put(TypeConverter.ToString(index), value);
            }
        }
Example #9
0
        public void Put(double index, object value, uint tag)
        {
            uint parsed = 0;

            if (TypeConverter.TryToIndex(index, out parsed))
            {
                this.Put(parsed, value, tag);
            }
            else
            {
                this.Put(TypeConverter.ToString(index), value, tag);
            }
        }
Example #10
0
        //----------------------------------------------------------------------------
        // Put methods for setting indexes to doubles
        //----------------------------------------------------------------------------

        public void Put(BoxedValue index, object value, uint tag)
        {
            uint i = 0;

            if (TypeConverter.TryToIndex(index, out i))
            {
                this.Put(i, value, tag);
            }
            else
            {
                this.Put(TypeConverter.ToString(index), value, tag);
            }
        }
Example #11
0
        //----------------------------------------------------------------------------
        // Put methods for setting indexes to doubles
        //----------------------------------------------------------------------------

        public void Put(BoxedValue index, double value)
        {
            uint i = 0;

            if (TypeConverter.TryToIndex(index, out i))
            {
                this.Put(i, value);
            }
            else
            {
                this.Put(TypeConverter.ToString(index), value);
            }
        }
Example #12
0
        public void Put(object index, object value, uint tag)
        {
            var s      = TypeConverter.ToString(index);
            var parsed = 0u;

            if (TypeConverter.TryToIndex(s, out parsed))
            {
                this.Put(parsed, value, tag);
            }
            else
            {
                this.Put(s, value, tag);
            }
        }
Example #13
0
        public void Put(object index0, double value)
        {
            string index  = TypeConverter.ToString(index0);
            uint   parsed = 0;

            if (TypeConverter.TryToIndex(index, out parsed))
            {
                this.Put(parsed, value);
            }
            else
            {
                this.Put(index, value);
            }
        }
Example #14
0
        public void Put(object index, BoxedValue value)
        {
            string s      = TypeConverter.ToString(index);
            uint   parsed = 0;

            if (TypeConverter.TryToIndex(s, out parsed))
            {
                this.Put(parsed, value);
            }
            else
            {
                this.Put(s, value);
            }
        }
Example #15
0
        public void Put(CommonObject index, object value, uint tag)
        {
            string s      = TypeConverter.ToString(index);
            uint   parsed = 0;

            if (TypeConverter.TryToIndex(s, out parsed))
            {
                this.Put(parsed, value, tag);
            }
            else
            {
                this.Put(s, value, tag);
            }
        }
Example #16
0
        /// <summary>
        /// Implements the binary `in` operator.
        /// </summary>
        public static bool @in(Environment env, BoxedValue l, BoxedValue r)
        {
            if (!r.IsObject)
            {
                return(env.RaiseTypeError <bool>("Right operand is not a object"));
            }
            uint index = 0;

            if (TypeConverter.TryToIndex(l, out index))
            {
                return(r.Object.Has(index));
            }
            string name = TypeConverter.ToString(l);

            return(r.Object.Has(name));
        }
Example #17
0
        public override void Put(string name, double value)
        {
            if (name == "length")
            {
                this.PutLength(TypeConverter.ToNumber(value));
                this.SetAttrs("length", DescriptorAttrs.DontEnum); //TODO: Shouldn't `PutLength` keep the `DontEnum` flag?
                return;
            }

            uint index;

            if (TypeConverter.TryToIndex(name, out index))  //TODO: I changed this to use TryToIndex, but that forgoes checking that `index.ToString() == name`, which may be necessary.
            {
                this.Put(index, value);
                return;
            }

            base.Put(name, value);
        }