Index: trunk/src/script/bridge/qscriptdeclarativeobject.cpp
===================================================================
--- trunk/src/script/bridge/qscriptdeclarativeobject.cpp	(revision 651)
+++ trunk/src/script/bridge/qscriptdeclarativeobject.cpp	(revision 846)
@@ -1,5 +1,5 @@
 /****************************************************************************
 **
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
@@ -67,5 +67,4 @@
                                                    JSC::PropertySlot &slot)
 {
-    QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
     QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep();
 
@@ -75,7 +74,7 @@
         m_class->queryProperty(m_object, identifier, QScriptClass::HandlesReadAccess);
     if (flags & QScriptClass::HandlesReadAccess) {
-        QScriptValue value = m_class->property(m_object, identifier);
+        QScriptDeclarativeClass::Value val = m_class->property(m_object, identifier);
         p->context = 0;
-        slot.setValue(engine->scriptValueToJSCValue(value));
+        slot.setValue((const JSC::JSValue &)val);
         return true;
     }
@@ -90,4 +89,5 @@
 {
     QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
+    QScript::SaveFrameHelper saveFrame(engine, exec);
     QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep();
 
@@ -107,41 +107,12 @@
 
 bool DeclarativeObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState *exec,
-                                               const JSC::Identifier &propertyName,
-                                               bool checkDontDelete)
+                                               const JSC::Identifier &propertyName)
 {
-    return QScriptObjectDelegate::deleteProperty(object, exec, propertyName, checkDontDelete);
-}
-
-bool DeclarativeObjectDelegate::getPropertyAttributes(const QScriptObject* object, 
-                                                      JSC::ExecState *exec,
-                                                      const JSC::Identifier &propertyName,
-                                                      unsigned &attribs) const
-{
-    QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep();
-
-    QScriptClass::QueryFlags flags = 
-        m_class->queryProperty(m_object, identifier, QScriptClass::HandlesReadAccess);
-    if (flags & QScriptClass::HandlesReadAccess) {
-        QScriptValue::PropertyFlags flags = m_class->propertyFlags(m_object, identifier);
-        attribs = 0;
-        if (flags & QScriptValue::ReadOnly)
-            attribs |= JSC::ReadOnly;
-        if (flags & QScriptValue::SkipInEnumeration)
-            attribs |= JSC::DontEnum;
-        if (flags & QScriptValue::Undeletable)
-            attribs |= JSC::DontDelete;
-        if (flags & QScriptValue::PropertyGetter)
-            attribs |= JSC::Getter;
-        if (flags & QScriptValue::PropertySetter)
-            attribs |= JSC::Setter;
-        attribs |= flags & QScriptValue::UserRange;
-        return true;
-    }
-    return QScriptObjectDelegate::getPropertyAttributes(object, exec, propertyName, attribs);
+    return QScriptObjectDelegate::deleteProperty(object, exec, propertyName);
 }
 
 void DeclarativeObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecState *exec,
                                                     JSC::PropertyNameArray &propertyNames,
-                                                    bool includeNonEnumerable)
+                                                    JSC::EnumerationMode mode)
 {
     QStringList properties = m_class->propertyNames(m_object);
@@ -151,10 +122,38 @@
     }
 
-    QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, includeNonEnumerable);
+    QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, mode);
 }
 
 JSC::CallType DeclarativeObjectDelegate::getCallData(QScriptObject *object, JSC::CallData &callData)
 {
-    return QScriptObjectDelegate::getCallData(object, callData);
+    if (!QScriptDeclarativeClassPrivate::get(m_class)->supportsCall) 
+        return JSC::CallTypeNone;
+    callData.native.function = call;
+    return JSC::CallTypeHost;
+}
+
+JSC::JSValue DeclarativeObjectDelegate::call(JSC::ExecState *exec, JSC::JSObject *callee,
+                                             JSC::JSValue thisValue, const JSC::ArgList &args)
+{
+    if (!callee->inherits(&QScriptObject::info))
+        return JSC::throwError(exec, JSC::TypeError, "callee is not a DeclarativeObject object");
+    QScriptObject *obj = static_cast<QScriptObject*>(callee);
+    QScriptObjectDelegate *delegate = obj->delegate();
+    if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
+        return JSC::throwError(exec, JSC::TypeError, "callee is not a DeclarativeObject object");
+
+    QScriptDeclarativeClass *scriptClass = static_cast<DeclarativeObjectDelegate*>(delegate)->m_class;
+    QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
+
+    QScript::SaveFrameHelper saveFrame(eng_p, exec);
+    eng_p->pushContext(exec, thisValue, args, callee);
+    QScriptContext *ctxt = eng_p->contextForFrame(eng_p->currentFrame);
+
+    QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj);
+    QScriptDeclarativeClass::Value result = 
+        scriptClass->call(static_cast<DeclarativeObjectDelegate*>(delegate)->m_object, ctxt);
+
+    eng_p->popContext();
+    return (JSC::JSValue &)(result);
 }
 
@@ -170,4 +169,21 @@
 }
 
+bool DeclarativeObjectDelegate::compareToObject(QScriptObject *o, JSC::ExecState *exec, JSC::JSObject *o2)
+{
+    if (!o2->inherits(&QScriptObject::info))
+        return false;
+    
+    QScriptObject *scriptObject = static_cast<QScriptObject*>(o2);
+    QScriptObjectDelegate *delegate = scriptObject->delegate();
+    if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
+        return false;
+
+    DeclarativeObjectDelegate *other = static_cast<DeclarativeObjectDelegate*>(delegate);
+    if (m_class != other->m_class)
+        return false;
+    else
+        return m_class->compare(m_object, other->m_object);
+}
+
 } // namespace QScript
 
