From: Simon Hausmann Date: Fri, 8 Mar 2013 09:47:18 +0000 (+0100) Subject: Implemented Template::Set X-Git-Tag: upstream/5.2.1~669^2~659^2~123 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1fd5ca8ffc778755736bcad611e51ea415accce;p=platform%2Fupstream%2Fqtdeclarative.git Implemented Template::Set Change-Id: I237fdf6acdfad9805306e4fc5f437457efa8eb7f Reviewed-by: Lars Knoll --- diff --git a/src/v4/qv4v8.cpp b/src/v4/qv4v8.cpp index 15d0aed..1b96ffc 100644 --- a/src/v4/qv4v8.cpp +++ b/src/v4/qv4v8.cpp @@ -1106,12 +1106,16 @@ void *External::Value() const void Template::Set(Handle name, Handle value, PropertyAttribute attributes) { - Q_UNIMPLEMENTED(); + Property p; + p.name = Persistent::New(name); + p.value = Persistent::New(value); + p.attributes = attributes; + m_properties << p; } void Template::Set(const char *name, Handle value) { - Q_UNIMPLEMENTED(); + Set(String::New(name), value); } @@ -1486,6 +1490,14 @@ Local ObjectTemplate::NewInstance() pd->enumerable = acc.attribute & DontEnum ? VM::PropertyDescriptor::Disabled : VM::PropertyDescriptor::Enabled; } + foreach (const Property &p, m_properties) { + VM::PropertyDescriptor *pd = o->insertMember(p.name->asVMString()); + *pd = VM::PropertyDescriptor::fromValue(p.value->vmValue()); + pd->writable = p.attributes & ReadOnly ? VM::PropertyDescriptor::Disabled : VM::PropertyDescriptor::Enabled; + pd->configurable = p.attributes & DontDelete ? VM::PropertyDescriptor::Disabled : VM::PropertyDescriptor::Enabled; + pd->enumerable = p.attributes & DontEnum ? VM::PropertyDescriptor::Disabled : VM::PropertyDescriptor::Enabled; + } + return Local::New(Value::fromVmValue(VM::Value::fromObject(o))); } diff --git a/src/v4/qv4v8.h b/src/v4/qv4v8.h index 3a2966d..2b3fa7e 100644 --- a/src/v4/qv4v8.h +++ b/src/v4/qv4v8.h @@ -1650,6 +1650,13 @@ class V8EXPORT Template : public Data { void Set(Handle name, Handle value, PropertyAttribute attributes = None); void Set(const char* name, Handle value); + + struct Property { + Persistent name; + Persistent value; + PropertyAttribute attributes; + }; + QVector m_properties; }; DEFINE_REFCOUNTED_HANDLE_OPERATIONS(Template)