Inheritance: IPropertyDescriptor
 public void CreateMutableBinding(string n, bool d)
 {
     var desc = new SPropertyDescriptor() {
         Value = _environment.Undefined,
         Writable = true,
         Enumerable = true,
         Configurable = d
     };
     _bindingObject.DefineOwnProperty(n, desc, false);
 }
Example #2
0
        public void CreateMutableBinding(string n, bool d)
        {
            var desc = new SPropertyDescriptor()
            {
                Value        = _environment.Undefined,
                Writable     = true,
                Enumerable   = true,
                Configurable = d
            };

            _bindingObject.DefineOwnProperty(n, desc, false);
        }
Example #3
0
        public IPropertyDescriptor ToPropertyDescriptor(IObject obj)
        {
            // 8.10.5 ToPropertyDescriptor ( Obj )

            Debug.Assert(obj != null);

            var desc = new SPropertyDescriptor();

            if (obj.HasProperty("enumerable"))
            {
                desc.Enumerable = obj.Get("enumerable").ConvertToBoolean().BaseValue;
            }

            if (obj.HasProperty("configurable"))
            {
                desc.Enumerable = obj.Get("configurable").ConvertToBoolean().BaseValue;
            }

            if (obj.HasProperty("value"))
            {
                desc.Value = obj.Get("value");
            }

            if (obj.HasProperty("writable"))
            {
                desc.Writable = obj.Get("writable").ConvertToBoolean().BaseValue;
            }

            if (obj.HasProperty("get"))
            {
                var getter = obj.Get("get");
                if (getter.TypeCode != LanguageTypeCode.Undefined && !(getter is ICallable))
                {
                    throw CreateTypeError("");
                }
                desc.Get = getter;
            }

            if (obj.HasProperty("set"))
            {
                var setter = obj.Get("set");
                if (setter.TypeCode != LanguageTypeCode.Undefined && !(setter is ICallable))
                {
                    throw CreateTypeError("");
                }
                desc.Get = setter;
            }

            if (desc.Get != null || desc.Set != null)
            {
                if (desc.Value != null || desc.Writable != null)
                {
                    throw CreateTypeError("");
                }
            }

            return desc;
        }