2010-07-14  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        Introduce QScriptOriginalGlobalObject.

        QtScript exposes more functionality than JSC C API. Sometimes it is
        necessary to take a shortcut in implementation. Really often we have
        to use a standard JS function. These function could be changed or
        even deleted by a script, so a backup of a reference to an object is needed.

        In them same time this is rather a workaround then real fix, so the code
        should be separated and changed easily in future. It is why we need
        the new internal class.

        The patch fixes a few crashes.

        [Qt] QScriptEngine should work correctly even after global object changes
        https://bugs.webkit.org/show_bug.cgi?id=41839

        * api/QtScript.pro:
        * api/qscriptengine_p.cpp:
        (QScriptEnginePrivate::QScriptEnginePrivate):
        (QScriptEnginePrivate::~QScriptEnginePrivate):
        * api/qscriptengine_p.h:
        (QScriptEnginePrivate::isArray):
        (QScriptEnginePrivate::isError):
        (QScriptEnginePrivate::objectHasOwnProperty):
        (QScriptEnginePrivate::objectGetOwnPropertyNames):
        * api/qscriptoriginalglobalobject_p.h: Added.
        (QScriptOriginalGlobalObject::QScriptOriginalGlobalObject):
        (QScriptOriginalGlobalObject::initializeMember):
        (QScriptOriginalGlobalObject::~QScriptOriginalGlobalObject):
        (QScriptOriginalGlobalObject::objectHasOwnProperty):
        (QScriptOriginalGlobalObject::objectGetOwnPropertyNames):
        (QScriptOriginalGlobalObject::isArray):
        (QScriptOriginalGlobalObject::isError):
        (QScriptOriginalGlobalObject::isType):
        * api/qscriptvalue_p.h:
        (QScriptValuePrivate::isError):
        (QScriptValuePrivate::hasOwnProperty):
        * api/qscriptvalueiterator_p.h:
        (QScriptValueIteratorPrivate::QScriptValueIteratorPrivate):
        * tests/qscriptvalue/tst_qscriptvalue.cpp:
        (tst_QScriptValue::globalObjectChanges):
        * tests/qscriptvalue/tst_qscriptvalue.h:

2010-07-13  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>

        Reviewed by Simon Hausmann.

        Introduce QScriptValueIterator.

        The QScriptValueIterator class permits to iterate over a QScriptValue's properties.

        [Qt] QtScript should provide an API for enumerating a JS object's properties
        https://bugs.webkit.org/show_bug.cgi?id=41680

        * api/QtScript.pro:
        * api/qscriptvalueiterator.cpp: Added.
        (QScriptValueIterator::QScriptValueIterator):
        (QScriptValueIterator::~QScriptValueIterator):
        (QScriptValueIterator::hasNext):
        (QScriptValueIterator::next):
        (QScriptValueIterator::hasPrevious):
        (QScriptValueIterator::previous):
        (QScriptValueIterator::toFront):
        (QScriptValueIterator::toBack):
        (QScriptValueIterator::name):
        (QScriptValueIterator::scriptName):
        (QScriptValueIterator::value):
        (QScriptValueIterator::setValue):
        (QScriptValueIterator::remove):
        (QScriptValueIterator::flags):
        (QScriptValueIterator::operator=):
        * api/qscriptvalueiterator.h: Added.
        * api/qscriptvalueiterator_p.h: Added.
        (QScriptValueIteratorPrivate::QScriptValueIteratorPrivate):
        (QScriptValueIteratorPrivate::~QScriptValueIteratorPrivate):
        (QScriptValueIteratorPrivate::hasNext):
        (QScriptValueIteratorPrivate::next):
        (QScriptValueIteratorPrivate::hasPrevious):
        (QScriptValueIteratorPrivate::previous):
        (QScriptValueIteratorPrivate::name):
        (QScriptValueIteratorPrivate::scriptName):
        (QScriptValueIteratorPrivate::value):
        (QScriptValueIteratorPrivate::setValue):
        (QScriptValueIteratorPrivate::remove):
        (QScriptValueIteratorPrivate::toFront):
        (QScriptValueIteratorPrivate::toBack):
        (QScriptValueIteratorPrivate::flags):
        (QScriptValueIteratorPrivate::isValid):
        (QScriptValueIteratorPrivate::engine):
        * tests/qscriptvalueiterator/qscriptvalueiterator.pro: Added.
        * tests/qscriptvalueiterator/tst_qscriptvalueiterator.cpp: Added.
        (tst_QScriptValueIterator::tst_QScriptValueIterator):
        (tst_QScriptValueIterator::~tst_QScriptValueIterator):
        (tst_QScriptValueIterator::iterateForward_data):
        (tst_QScriptValueIterator::iterateForward):
        (tst_QScriptValueIterator::iterateBackward_data):
        (tst_QScriptValueIterator::iterateBackward):
        (tst_QScriptValueIterator::iterateArray_data):
        (tst_QScriptValueIterator::iterateArray):
        (tst_QScriptValueIterator::iterateBackAndForth):
        (tst_QScriptValueIterator::setValue):
        (tst_QScriptValueIterator::remove):
        (tst_QScriptValueIterator::removeMixed):
        (tst_QScriptValueIterator::removeUndeletable):
        (tst_QScriptValueIterator::iterateString):
        (tst_QScriptValueIterator::assignObjectToIterator):
        * tests/tests.pro:

2010-07-09  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>

        Reviewed by Simon Hausmann.

        Implementation of the QScriptValue::propertyFlags function.

        The function returns the flags of a property with the given name,
        using a given mode to resolve the property. This is a simple
        implementation that is sufficient to test the QScriptValueIterator.

        [Qt] QScriptValue API should have a property flag accessor.
        https://bugs.webkit.org/show_bug.cgi?id=41769

        * api/qscriptvalue.cpp:
        (QScriptValue::propertyFlags):
        * api/qscriptvalue.h:
        * api/qscriptvalue_p.h:
        (QScriptValuePrivate::propertyFlags):
        * tests/qscriptvalue/tst_qscriptvalue.cpp:
        (tst_QScriptValue::propertyFlag_data):
        (tst_QScriptValue::propertyFlag):
        * tests/qscriptvalue/tst_qscriptvalue.h:

2010-07-07  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>

        Reviewed by Kenneth Rohde Christiansen.

        Implementation of QScriptValue::isArray()
        https://bugs.webkit.org/show_bug.cgi?id=41713

        Since we don't have access to the [[Class]] internal property of
        builtins (including Array), the solution was to keep the original 'Array'
        (constructor) and 'Array.prototype' objects and use them to identify
        if a given object is an Array.

        Also uncomment some tests and add some tests of newArray() that
        depended on isArray(). 

        * api/qscriptengine_p.cpp:
        (QScriptEnginePrivate::QScriptEnginePrivate):
        (QScriptEnginePrivate::~QScriptEnginePrivate):
        * api/qscriptengine_p.h:
        (QScriptEnginePrivate::isArray):
        * api/qscriptvalue.cpp:
        (QScriptValue::isArray):
        * api/qscriptvalue.h:
        * api/qscriptvalue_p.h:
        (QScriptValuePrivate::isArray):
        * tests/qscriptengine/tst_qscriptengine.cpp:
        (tst_QScriptEngine::newArray):

2010-07-06  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        Implementation of QScriptValue properties accessors.

        The patch contains implementation of the QScriptValue::property() and
        the QScriptValue::setProperty(). It is not full functionality, as these
        method are too complex for one patch, but it is enough to cover about
        95% of use cases.

        Missing functionality:
         - Few of the PropertyFlags are ignored.
         - Only a public part of the ResolveFlags can be used (ResolveLocal,
         ResolvePrototype).

        A lot of new test cases were added.

        [Qt] QScriptValue should have API for accessing object properties
        https://bugs.webkit.org/show_bug.cgi?id=40903

        * api/qscriptconverter_p.h:
        (QScriptConverter::toPropertyFlags):
        * api/qscriptstring_p.h:
        (QScriptStringPrivate::operator JSStringRef):
        * api/qscriptvalue.cpp:
        (QScriptValue::property):
        (QScriptValue::setProperty):
        * api/qscriptvalue.h:
        (QScriptValue::):
        * api/qscriptvalue_p.h:
        (QScriptValuePrivate::assignEngine):
        (QScriptValuePrivate::property):
        (QScriptValuePrivate::hasOwnProperty):
        (QScriptValuePrivate::setProperty):
        (QScriptValuePrivate::deleteProperty):
        * tests/qscriptvalue/tst_qscriptvalue.cpp:
        (tst_QScriptValue::getPropertySimple_data):
        (tst_QScriptValue::getPropertySimple):
        (tst_QScriptValue::setPropertySimple):
        (tst_QScriptValue::getPropertyResolveFlag):
        (tst_QScriptValue::getSetProperty):
        (tst_QScriptValue::setProperty_data):
        (tst_QScriptValue::setProperty):
        * tests/qscriptvalue/tst_qscriptvalue.h:

2010-07-02  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>

        Reviewed by Simon Hausmann.

        Compilation fix.

        QScriptEnginePrivate::newArray can't be const because it can
        throw an exception.

        [Qt] QScriptEnginePrivate compilation fix
        https://bugs.webkit.org/show_bug.cgi?id=41520

        * api/qscriptengine_p.cpp:
        (QScriptEnginePrivate::newArray):
        * api/qscriptengine_p.h:

2010-06-28  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>

        Reviewed by Simon Hausmann.

        Implement exception reporting in the QtScript API.

        The exception should be accessible through the API by the uncaughtException
        function. Functions; hasUncaughtException, clearExceptions, uncaughtExceptionLineNumber,
        uncaughtExceptionBacktrace were added to facilitate error checking and debugging.

        [Qt] QtScript API should be exceptions aware.
        https://bugs.webkit.org/show_bug.cgi?id=41199

        * api/qscriptengine.cpp:
        (QScriptEngine::hasUncaughtException):
        (QScriptEngine::uncaughtException):
        (QScriptEngine::clearExceptions):
        (QScriptEngine::uncaughtExceptionLineNumber):
        (QScriptEngine::uncaughtExceptionBacktrace):
        * api/qscriptengine.h:
        * api/qscriptengine_p.cpp:
        (QScriptEnginePrivate::QScriptEnginePrivate):
        (QScriptEnginePrivate::~QScriptEnginePrivate):
        (QScriptEnginePrivate::uncaughtException):
        * api/qscriptengine_p.h:
        (QScriptEnginePrivate::):
        (QScriptEnginePrivate::evaluate):
        (QScriptEnginePrivate::hasUncaughtException):
        (QScriptEnginePrivate::clearExceptions):
        (QScriptEnginePrivate::setException):
        (QScriptEnginePrivate::uncaughtExceptionLineNumber):
        (QScriptEnginePrivate::uncaughtExceptionBacktrace):
        * api/qscriptvalue_p.h:
        (QScriptValuePrivate::toString):
        (QScriptValuePrivate::toNumber):
        (QScriptValuePrivate::toObject):
        (QScriptValuePrivate::equals):
        (QScriptValuePrivate::instanceOf):
        (QScriptValuePrivate::call):
        (QScriptValuePrivate::inherits):
        * tests/qscriptengine/tst_qscriptengine.cpp:
        (tst_QScriptEngine::uncaughtException):

