diff options
Diffstat (limited to 'src/qml/jsruntime/qv4property_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4property_p.h | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h index ff9ea59514..4b0896b264 100644 --- a/src/qml/jsruntime/qv4property_p.h +++ b/src/qml/jsruntime/qv4property_p.h @@ -52,13 +52,8 @@ namespace QV4 { struct FunctionObject; struct Property { - union { - SafeValue value; - struct { - FunctionObject *get; - FunctionObject *set; - }; - }; + SafeValue value; + SafeValue set; // Section 8.10 inline void fullyPopulated(PropertyAttributes *attrs) { @@ -67,10 +62,10 @@ struct Property { } if (attrs->type() == PropertyAttributes::Accessor) { attrs->clearWritable(); - if (get == (FunctionObject *)0x1) - get = 0; - if (set == (FunctionObject *)0x1) - set = 0; + if (value.managed() == (Managed *)0x1) + value = Primitive::fromManaged(0); + if (set.managed() == (Managed *)0x1) + set = Primitive::fromManaged(0); } attrs->resolve(); } @@ -82,8 +77,8 @@ struct Property { } static inline Property fromAccessor(FunctionObject *getter, FunctionObject *setter) { Property pd; - pd.get = getter; - pd.set = setter; + pd.value = Primitive::fromManaged(reinterpret_cast<Managed *>(getter)); + pd.set = Primitive::fromManaged(reinterpret_cast<Managed *>(setter)); return pd; } @@ -96,10 +91,10 @@ struct Property { inline bool isSubset(const PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs) const; inline void merge(PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs); - inline FunctionObject *getter() const { return get; } - inline FunctionObject *setter() const { return set; } - inline void setGetter(FunctionObject *g) { get = g; } - inline void setSetter(FunctionObject *s) { set = s; } + inline FunctionObject *getter() const { return reinterpret_cast<FunctionObject *>(value.managed()); } + inline FunctionObject *setter() const { return reinterpret_cast<FunctionObject *>(set.managed()); } + inline void setGetter(FunctionObject *g) { value = Primitive::fromManaged(reinterpret_cast<Managed *>(g)); } + inline void setSetter(FunctionObject *s) { set = Primitive::fromManaged(reinterpret_cast<Managed *>(s)); } }; inline bool Property::isSubset(const PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs) const @@ -115,9 +110,9 @@ inline bool Property::isSubset(const PropertyAttributes &attrs, const Property & if (attrs.type() == PropertyAttributes::Data && !value.sameValue(other.value)) return false; if (attrs.type() == PropertyAttributes::Accessor) { - if (get != other.get) + if (value.managed() != other.value.managed()) return false; - if (set != other.set) + if (set.managed() != other.set.managed()) return false; } return true; @@ -133,10 +128,10 @@ inline void Property::merge(PropertyAttributes &attrs, const Property &other, Pr attrs.setWritable(otherAttrs.isWritable()); if (otherAttrs.type() == PropertyAttributes::Accessor) { attrs.setType(PropertyAttributes::Accessor); - if (other.get) - get = (other.get == (FunctionObject *)0x1) ? 0 : other.get; - if (other.set) - set = (other.set == (FunctionObject *)0x1) ? 0 : other.set; + if (other.value.managed()) + value = (other.value.managed() == (Managed *)0x1) ? Primitive::fromManaged(0).asReturnedValue() : other.value.asReturnedValue(); + if (other.set.managed()) + set = (other.set.managed() == (Managed *)0x1) ? Primitive::fromManaged(0).asReturnedValue() : other.set.asReturnedValue(); } else if (otherAttrs.type() == PropertyAttributes::Data){ attrs.setType(PropertyAttributes::Data); value = other.value; |