From: Lars Knoll Date: Mon, 29 Oct 2012 14:50:07 +0000 (+0100) Subject: Set property attributes more correctly X-Git-Tag: upstream/5.2.1~669^2~659^2~883 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=477ea45b0b7d7b9dcc60d4cba4a4036359a969b6;p=platform%2Fupstream%2Fqtdeclarative.git Set property attributes more correctly Also now check for enumerable in for/in statements. Change-Id: I03a9968fc3d7f8f5e4eaf26591040acd9cc8ced1 Reviewed-by: Simon Hausmann --- diff --git a/qmljs_objects.cpp b/qmljs_objects.cpp index ecf97c4..5d71aa4 100644 --- a/qmljs_objects.cpp +++ b/qmljs_objects.cpp @@ -153,9 +153,6 @@ void Object::__put__(Context *ctx, String *name, const Value &value, bool throwE // ### to simplify and speed up we should expand the relevant parts here (clauses 6,7,9,10,12,13) PropertyDescriptor desc = PropertyDescriptor::fromValue(value); - desc.configurable = PropertyDescriptor::Undefined; - desc.enumberable = PropertyDescriptor::Undefined; - desc.writable = PropertyDescriptor::Undefined; __defineOwnProperty__(ctx, name, &desc, throwException); return; } @@ -185,6 +182,9 @@ void Object::__put__(Context *ctx, String *name, const Value &value, bool throwE PropertyDescriptor *p = members->insert(name); *p = PropertyDescriptor::fromValue(value); + p->configurable = PropertyDescriptor::Set; + p->enumberable = PropertyDescriptor::Set; + p->writable = PropertyDescriptor::Set; } reject: @@ -312,7 +312,7 @@ String *ForEachIteratorObject::nextPropertyName() } p = current->members->_properties[tableIndex]; // ### check that it's not a repeated attribute - if (p /*&& !(p->attributes & DontEnumAttribute)*/) + if (p && p->descriptor.isEnumerable()) return p->name; } } @@ -431,6 +431,7 @@ PropertyDescriptor *ActivationObject::__getPropertyDescriptor__(Context *ctx, St if (__qmljs_string_equal(var, name)) { *to_fill = PropertyDescriptor::fromValue(context->locals[i]); to_fill->writable = PropertyDescriptor::Set; + to_fill->enumberable = PropertyDescriptor::Set; return to_fill; } } @@ -439,6 +440,7 @@ PropertyDescriptor *ActivationObject::__getPropertyDescriptor__(Context *ctx, St if (__qmljs_string_equal(formal, name)) { *to_fill = PropertyDescriptor::fromValue(context->arguments[i]); to_fill->writable = PropertyDescriptor::Set; + to_fill->enumberable = PropertyDescriptor::Set; return to_fill; } } @@ -449,6 +451,8 @@ PropertyDescriptor *ActivationObject::__getPropertyDescriptor__(Context *ctx, St } *to_fill = PropertyDescriptor::fromValue(arguments); + to_fill->writable = PropertyDescriptor::Unset; + to_fill->enumberable = PropertyDescriptor::Unset; return to_fill; } } @@ -469,6 +473,8 @@ PropertyDescriptor *ArgumentsObject::__getPropertyDescriptor__(Context *ctx, Str const quint32 i = Value::fromString(name).toUInt32(ctx); if (i < context->argumentCount) { *to_fill = PropertyDescriptor::fromValue(context->arguments[i]); + to_fill->writable = PropertyDescriptor::Unset; + to_fill->enumberable = PropertyDescriptor::Unset; return to_fill; } } diff --git a/qmljs_objects.h b/qmljs_objects.h index 0760591..f7c3507 100644 --- a/qmljs_objects.h +++ b/qmljs_objects.h @@ -138,9 +138,9 @@ struct PropertyDescriptor { PropertyDescriptor pd; pd.value = v; pd.type = Data; - pd.writable = Set; - pd.enumberable = Set; - pd.configurable = Set; + pd.writable = Undefined; + pd.enumberable = Undefined; + pd.configurable = Undefined; return pd; } static inline PropertyDescriptor fromAccessor(Object *getter, Object *setter) { @@ -149,8 +149,8 @@ struct PropertyDescriptor { pd.set = setter; pd.type = Accessor; pd.writable = Undefined; - pd.enumberable = Set; - pd.configurable = Set; + pd.enumberable = Undefined; + pd.configurable = Undefined; return pd; }