Commit 0090436a authored by eric@webkit.org's avatar eric@webkit.org

2010-01-26 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>

        Reviewed by Simon Hausmann.

        First steps of the QtScript API.

        Two new classes were created; QScriptEngine and QScriptValue.
        The first should encapsulate a javascript context and the second a script
        value.

        This API is still in development, so it isn't compiled by default.
        To trigger compilation, pass --qmakearg="CONFIG+=build-qtscript" to
        build-webkit.

        https://bugs.webkit.org/show_bug.cgi?id=32565

        * WebKit.pro:
2010-01-26  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>

        Reviewed by Simon Hausmann.

        First steps of the QtScript API.

        Two new classes were created; QScriptEngine and QScriptValue.
        The first should encapsulate a javascript context and the second a script
        value.

        This API is still in development, so it isn't compiled by default.
        To trigger compilation, pass --qmakearg="CONFIG+=build-qtscript" to
        build-webkit.

        https://bugs.webkit.org/show_bug.cgi?id=32565

        * qt/api/QtScript.pro: Added.
        * qt/api/qscriptconverter_p.h: Added.
        (QScriptConverter::toString):
        * qt/api/qscriptengine.cpp: Added.
        (QScriptEngine::QScriptEngine):
        (QScriptEngine::~QScriptEngine):
        (QScriptEngine::evaluate):
        (QScriptEngine::collectGarbage):
        * qt/api/qscriptengine.h: Added.
        * qt/api/qscriptengine_p.cpp: Added.
        (QScriptEnginePrivate::QScriptEnginePrivate):
        (QScriptEnginePrivate::~QScriptEnginePrivate):
        (QScriptEnginePrivate::evaluate):
        * qt/api/qscriptengine_p.h: Added.
        (QScriptEnginePrivate::get):
        (QScriptEnginePrivate::collectGarbage):
        (QScriptEnginePrivate::makeJSValue):
        (QScriptEnginePrivate::context):
        * qt/api/qscriptvalue.cpp: Added.
        (QScriptValue::QScriptValue):
        (QScriptValue::~QScriptValue):
        (QScriptValue::isValid):
        (QScriptValue::isBool):
        (QScriptValue::isBoolean):
        (QScriptValue::isNumber):
        (QScriptValue::isNull):
        (QScriptValue::isString):
        (QScriptValue::isUndefined):
        (QScriptValue::isError):
        (QScriptValue::isObject):
        (QScriptValue::isFunction):
        (QScriptValue::toString):
        (QScriptValue::toNumber):
        (QScriptValue::toBool):
        (QScriptValue::toBoolean):
        (QScriptValue::toInteger):
        (QScriptValue::toInt32):
        (QScriptValue::toUInt32):
        (QScriptValue::toUInt16):
        (QScriptValue::call):
        (QScriptValue::engine):
        (QScriptValue::operator=):
        (QScriptValue::equals):
        (QScriptValue::strictlyEquals):
        * qt/api/qscriptvalue.h: Added.
        (QScriptValue::):
        * qt/api/qscriptvalue_p.h: Added.
        (QScriptValuePrivate::):
        (QScriptValuePrivate::get):
        (QScriptValuePrivate::QScriptValuePrivate):
        (QScriptValuePrivate::isValid):
        (QScriptValuePrivate::isBool):
        (QScriptValuePrivate::isNumber):
        (QScriptValuePrivate::isNull):
        (QScriptValuePrivate::isString):
        (QScriptValuePrivate::isUndefined):
        (QScriptValuePrivate::isError):
        (QScriptValuePrivate::isObject):
        (QScriptValuePrivate::isFunction):
        (QScriptValuePrivate::toString):
        (QScriptValuePrivate::toNumber):
        (QScriptValuePrivate::toBool):
        (QScriptValuePrivate::toInteger):
        (QScriptValuePrivate::toInt32):
        (QScriptValuePrivate::toUInt32):
        (QScriptValuePrivate::toUInt16):
        (QScriptValuePrivate::equals):
        (QScriptValuePrivate::strictlyEquals):
        (QScriptValuePrivate::assignEngine):
        (QScriptValuePrivate::call):
        (QScriptValuePrivate::engine):
        (QScriptValuePrivate::context):
        (QScriptValuePrivate::value):
        (QScriptValuePrivate::object):
        (QScriptValuePrivate::inherits):
        (QScriptValuePrivate::isJSBased):
        (QScriptValuePrivate::isNumberBased):
        (QScriptValuePrivate::isStringBased):
        * qt/api/qtscriptglobal.h: Added.
        * qt/tests/qscriptengine/qscriptengine.pro: Added.
        * qt/tests/qscriptengine/tst_qscriptengine.cpp: Added.
        (tst_QScriptEngine::tst_QScriptEngine):
        (tst_QScriptEngine::~tst_QScriptEngine):
        (tst_QScriptEngine::init):
        (tst_QScriptEngine::cleanup):
        (tst_QScriptEngine::collectGarbage):
        (tst_QScriptEngine::evaluate):
        * qt/tests/qscriptvalue/qscriptvalue.pro: Added.
        * qt/tests/qscriptvalue/tst_qscriptvalue.cpp: Added.
        (tst_QScriptValue::tst_QScriptValue):
        (tst_QScriptValue::~tst_QScriptValue):
        (tst_QScriptValue::init):
        (tst_QScriptValue::cleanup):
        (tst_QScriptValue::ctor):
        (tst_QScriptValue::toString_data):
        (tst_QScriptValue::toString):
        (tst_QScriptValue::copyConstructor_data):
        (tst_QScriptValue::copyConstructor):
        (tst_QScriptValue::assignOperator_data):
        (tst_QScriptValue::assignOperator):
        (tst_QScriptValue::dataSharing):
        (tst_QScriptValue::constructors_data):
        (tst_QScriptValue::constructors):
        (tst_QScriptValue::call):
        * qt/tests/tests.pri: Added.
        * qt/tests/tests.pro: Added.
2010-01-26  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>

        Reviewed by Simon Hausmann.

        First steps of the QtScript API.

        Two new classes were created; QScriptEngine and QScriptValue.
        The first should encapsulate a javascript context and the second a script
        value.

        This API is still in development, so it isn't compiled by default.
        To trigger compilation, pass --qmakearg="CONFIG+=build-qtscript" to
        build-webkit.

        https://bugs.webkit.org/show_bug.cgi?id=32565

        * docs/qtwebkit.qdocconf:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53850 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 472aca8e
2010-01-26 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed by Simon Hausmann.
First steps of the QtScript API.
Two new classes were created; QScriptEngine and QScriptValue.
The first should encapsulate a javascript context and the second a script
value.
This API is still in development, so it isn't compiled by default.
To trigger compilation, pass --qmakearg="CONFIG+=build-qtscript" to
build-webkit.
https://bugs.webkit.org/show_bug.cgi?id=32565
* WebKit.pro:
2010-01-25 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Laszlo Gombos.
......
2010-01-26 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed by Simon Hausmann.
First steps of the QtScript API.
Two new classes were created; QScriptEngine and QScriptValue.
The first should encapsulate a javascript context and the second a script
value.
This API is still in development, so it isn't compiled by default.
To trigger compilation, pass --qmakearg="CONFIG+=build-qtscript" to
build-webkit.
https://bugs.webkit.org/show_bug.cgi?id=32565
* qt/api/QtScript.pro: Added.
* qt/api/qscriptconverter_p.h: Added.
(QScriptConverter::toString):
* qt/api/qscriptengine.cpp: Added.
(QScriptEngine::QScriptEngine):
(QScriptEngine::~QScriptEngine):
(QScriptEngine::evaluate):
(QScriptEngine::collectGarbage):
* qt/api/qscriptengine.h: Added.
* qt/api/qscriptengine_p.cpp: Added.
(QScriptEnginePrivate::QScriptEnginePrivate):
(QScriptEnginePrivate::~QScriptEnginePrivate):
(QScriptEnginePrivate::evaluate):
* qt/api/qscriptengine_p.h: Added.
(QScriptEnginePrivate::get):
(QScriptEnginePrivate::collectGarbage):
(QScriptEnginePrivate::makeJSValue):
(QScriptEnginePrivate::context):
* qt/api/qscriptvalue.cpp: Added.
(QScriptValue::QScriptValue):
(QScriptValue::~QScriptValue):
(QScriptValue::isValid):
(QScriptValue::isBool):
(QScriptValue::isBoolean):
(QScriptValue::isNumber):
(QScriptValue::isNull):
(QScriptValue::isString):
(QScriptValue::isUndefined):
(QScriptValue::isError):
(QScriptValue::isObject):
(QScriptValue::isFunction):
(QScriptValue::toString):
(QScriptValue::toNumber):
(QScriptValue::toBool):
(QScriptValue::toBoolean):
(QScriptValue::toInteger):
(QScriptValue::toInt32):
(QScriptValue::toUInt32):
(QScriptValue::toUInt16):
(QScriptValue::call):
(QScriptValue::engine):
(QScriptValue::operator=):
(QScriptValue::equals):
(QScriptValue::strictlyEquals):
* qt/api/qscriptvalue.h: Added.
(QScriptValue::):
* qt/api/qscriptvalue_p.h: Added.
(QScriptValuePrivate::):
(QScriptValuePrivate::get):
(QScriptValuePrivate::QScriptValuePrivate):
(QScriptValuePrivate::isValid):
(QScriptValuePrivate::isBool):
(QScriptValuePrivate::isNumber):
(QScriptValuePrivate::isNull):
(QScriptValuePrivate::isString):
(QScriptValuePrivate::isUndefined):
(QScriptValuePrivate::isError):
(QScriptValuePrivate::isObject):
(QScriptValuePrivate::isFunction):
(QScriptValuePrivate::toString):
(QScriptValuePrivate::toNumber):
(QScriptValuePrivate::toBool):
(QScriptValuePrivate::toInteger):
(QScriptValuePrivate::toInt32):
(QScriptValuePrivate::toUInt32):
(QScriptValuePrivate::toUInt16):
(QScriptValuePrivate::equals):
(QScriptValuePrivate::strictlyEquals):
(QScriptValuePrivate::assignEngine):
(QScriptValuePrivate::call):
(QScriptValuePrivate::engine):
(QScriptValuePrivate::context):
(QScriptValuePrivate::value):
(QScriptValuePrivate::object):
(QScriptValuePrivate::inherits):
(QScriptValuePrivate::isJSBased):
(QScriptValuePrivate::isNumberBased):
(QScriptValuePrivate::isStringBased):
* qt/api/qtscriptglobal.h: Added.
* qt/tests/qscriptengine/qscriptengine.pro: Added.
* qt/tests/qscriptengine/tst_qscriptengine.cpp: Added.
(tst_QScriptEngine::tst_QScriptEngine):
(tst_QScriptEngine::~tst_QScriptEngine):
(tst_QScriptEngine::init):
(tst_QScriptEngine::cleanup):
(tst_QScriptEngine::collectGarbage):
(tst_QScriptEngine::evaluate):
* qt/tests/qscriptvalue/qscriptvalue.pro: Added.
* qt/tests/qscriptvalue/tst_qscriptvalue.cpp: Added.
(tst_QScriptValue::tst_QScriptValue):
(tst_QScriptValue::~tst_QScriptValue):
(tst_QScriptValue::init):
(tst_QScriptValue::cleanup):
(tst_QScriptValue::ctor):
(tst_QScriptValue::toString_data):
(tst_QScriptValue::toString):
(tst_QScriptValue::copyConstructor_data):
(tst_QScriptValue::copyConstructor):
(tst_QScriptValue::assignOperator_data):
(tst_QScriptValue::assignOperator):
(tst_QScriptValue::dataSharing):
(tst_QScriptValue::constructors_data):
(tst_QScriptValue::constructors):
(tst_QScriptValue::call):
* qt/tests/tests.pri: Added.
* qt/tests/tests.pro: Added.
2010-01-25 Dmitry Titov <dimich@chromium.org>
Reviewed by David Levin.
......
TARGET = QtScript
TEMPLATE = lib
QT = core
INCLUDEPATH += $$PWD
CONFIG += building-libs
JAVASCRIPTCORE_JIT = yes
isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = ../../generated
CONFIG(debug, debug|release) {
OBJECTS_DIR = obj/debug
} else { # Release
OBJECTS_DIR = obj/release
}
include($$PWD/../../../WebKit.pri)
include($$PWD/../../JavaScriptCore.pri)
INCLUDEPATH += $$PWD/../../API
SOURCES += $$PWD/qscriptengine.cpp \
$$PWD/qscriptengine_p.cpp \
$$PWD/qscriptvalue.cpp \
HEADERS += $$PWD/qtscriptglobal.h \
$$PWD/qscriptengine.h \
$$PWD/qscriptengine_p.h \
$$PWD/qscriptvalue.h \
$$PWD/qscriptvalue_p.h \
$$PWD/qscriptconverter_p.h \
!static: DEFINES += QT_MAKEDLL
DESTDIR = $$OUTPUT_DIR/lib
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef qscriptconverter_p_h
#define qscriptconverter_p_h
#include <JavaScriptCore/JavaScript.h>
#include <QtCore/qstring.h>
/*
\internal
\class QScriptConverter
QScriptValue and QScriptEngine helper class. This class's responsibility is to convert values
between JS values and Qt/C++ values.
This is a nice way to inline these functions in both QScriptValue and QScriptEngine.
*/
class QScriptConverter {
public:
static QString toString(const JSStringRef str)
{
return QString(reinterpret_cast<const QChar*>(JSStringGetCharactersPtr(str)), JSStringGetLength(str));
}
static JSStringRef toString(const QString& str)
{
return JSStringCreateWithUTF8CString(str.toUtf8().constData());
}
static JSStringRef toString(const char* str)
{
return JSStringCreateWithUTF8CString(str);
}
};
#endif // qscriptconverter_p_h
/*
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "qscriptengine.h"
#include "qscriptengine_p.h"
#include "qscriptvalue_p.h"
/*!
Constructs a QScriptEngine object.
The globalObject() is initialized to have properties as described in ECMA-262, Section 15.1.
*/
QScriptEngine::QScriptEngine()
: d_ptr(new QScriptEnginePrivate(this))
{
}
/*!
Destroys this QScriptEngine.
*/
QScriptEngine::~QScriptEngine()
{
}
/*!
Evaluates \a program, using \a lineNumber as the base line number,
and returns the result of the evaluation.
The script code will be evaluated in the current context.
The evaluation of \a program can cause an exception in the
engine; in this case the return value will be the exception
that was thrown (typically an \c{Error} object). You can call
hasUncaughtException() to determine if an exception occurred in
the last call to evaluate().
\a lineNumber is used to specify a starting line number for \a
program; line number information reported by the engine that pertain
to this evaluation (e.g. uncaughtExceptionLineNumber()) will be
based on this argument. For example, if \a program consists of two
lines of code, and the statement on the second line causes a script
exception, uncaughtExceptionLineNumber() would return the given \a
lineNumber plus one. When no starting line number is specified, line
numbers will be 1-based.
\a fileName is used for error reporting. For example in error objects
the file name is accessible through the "fileName" property if it's
provided with this function.
*/
QScriptValue QScriptEngine::evaluate(const QString& program, const QString& fileName, int lineNumber)
{
return QScriptValuePrivate::get(d_ptr->evaluate(program, fileName, lineNumber));
}
/*!
Runs the garbage collector.
The garbage collector will attempt to reclaim memory by locating and disposing of objects that are
no longer reachable in the script environment.
Normally you don't need to call this function; the garbage collector will automatically be invoked
when the QScriptEngine decides that it's wise to do so (i.e. when a certain number of new objects
have been created). However, you can call this function to explicitly request that garbage
collection should be performed as soon as possible.
*/
void QScriptEngine::collectGarbage()
{
d_ptr->collectGarbage();
}
/*
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef qscriptengine_h
#define qscriptengine_h
#include <QtCore/qobject.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
class QScriptValue;
class QScriptEnginePrivate;
// Internal typedef
typedef QExplicitlySharedDataPointer<QScriptEnginePrivate> QScriptEnginePtr;
class QScriptEngine : public QObject {
public:
QScriptEngine();
~QScriptEngine();
QScriptValue evaluate(const QString& program, const QString& fileName = QString(), int lineNumber = 1);
void collectGarbage();
private:
friend class QScriptEnginePrivate;
QScriptEnginePtr d_ptr;
};
#endif
/*
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "qscriptengine_p.h"
#include "qscriptvalue_p.h"
/*!
Constructs a default QScriptEnginePrivate object, a new global context will be created.
\internal
*/
QScriptEnginePrivate::QScriptEnginePrivate(const QScriptEngine* engine)
: q_ptr(const_cast<QScriptEngine*>(engine))
, m_context(JSGlobalContextCreate(0))
{
}
QScriptEnginePrivate::~QScriptEnginePrivate()
{
JSGlobalContextRelease(m_context);
}
/*!
Evaluates program and returns the result of the evaluation.
\internal
*/
QScriptValuePrivate* QScriptEnginePrivate::evaluate(const QString& program, const QString& fileName, int lineNumber)
{
JSStringRef script = QScriptConverter::toString(program);
JSStringRef file = QScriptConverter::toString(fileName);
JSValueRef exception;
JSValueRef result = JSEvaluateScript(m_context, script, /* Global Object */ 0, file, lineNumber, &exception);
if (!result)
return new QScriptValuePrivate(this, exception); // returns an exception
return new QScriptValuePrivate(this, result);
}
/*
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef qscriptengine_p_h
#define qscriptengine_p_h
#include "qscriptconverter_p.h"
#include "qscriptengine.h"
#include "qscriptvalue.h"
#include <JavaScriptCore/JavaScript.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
class QScriptEngine;
class QScriptEnginePrivate : public QSharedData {
public:
static QScriptEnginePtr get(const QScriptEngine* q) { Q_ASSERT(q); return q->d_ptr; }
static QScriptEngine* get(const QScriptEnginePrivate* d) { Q_ASSERT(d); return d->q_ptr; }
QScriptEnginePrivate(const QScriptEngine*);
~QScriptEnginePrivate();
QScriptValuePrivate* evaluate(const QString& program, const QString& fileName, int lineNumber);
inline void collectGarbage();
inline JSValueRef makeJSValue(double number) const;
inline JSValueRef makeJSValue(int number) const;
inline JSValueRef makeJSValue(uint number) const;
inline JSValueRef makeJSValue(const QString& string) const;
inline JSValueRef makeJSValue(bool number) const;
inline JSValueRef makeJSValue(QScriptValue::SpecialValue value) const;
inline JSGlobalContextRef context() const;
private:
QScriptEngine* q_ptr;
JSGlobalContextRef m_context;
};
void QScriptEnginePrivate::collectGarbage()
{
JSGarbageCollect(m_context);
}
JSValueRef QScriptEnginePrivate::makeJSValue(double number) const
{
return JSValueMakeNumber(m_context, number);
}
JSValueRef QScriptEnginePrivate::makeJSValue(int number) const
{
return JSValueMakeNumber(m_context, number);
}
JSValueRef QScriptEnginePrivate::makeJSValue(uint number) const
{
return JSValueMakeNumber(m_context, number);
}
JSValueRef QScriptEnginePrivate::makeJSValue(const QString& string) const
{
return JSValueMakeString(m_context, QScriptConverter::toString(string));
}
JSValueRef QScriptEnginePrivate::makeJSValue(bool value) const
{
return JSValueMakeBoolean(m_context, value);
}
JSValueRef QScriptEnginePrivate::makeJSValue(QScriptValue::SpecialValue value) const
{
if (value == QScriptValue::NullValue)
return JSValueMakeNull(m_context);
return JSValueMakeUndefined(m_context);
}
JSGlobalContextRef QScriptEnginePrivate::context() const
{
return m_context;
}
#endif
/*
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "qscriptvalue.h"
#include "qscriptengine.h"
#include "qscriptengine_p.h"
#include "qscriptvalue_p.h"
#include <QtCore/qdebug.h>
/*!
Constructs an invalid value.
*/
QScriptValue::QScriptValue()
: d_ptr(new QScriptValuePrivate())
{
}
/*!
Constructs a new QScriptValue with a boolean \a value.
*/
QScriptValue::QScriptValue(bool value)
: d_ptr(new QScriptValuePrivate(value))
{
}
/*!
Constructs a new QScriptValue with a number \a value.
*/
QScriptValue::QScriptValue(int value)
: d_ptr(new QScriptValuePrivate(value))
{
}
/*!
Constructs a new QScriptValue with a number \a value.
*/
QScriptValue::QScriptValue(uint value)
: d_ptr(new QScriptValuePrivate(value))
{
}
/*!
Constructs a new QScriptValue with a number \a value.
*/
QScriptValue::QScriptValue(qsreal value)
: d_ptr(new QScriptValuePrivate(value))
{
}
/*!
Constructs a new QScriptValue with a string \a value.
*/
QScriptValue::QScriptValue(const QString& value)
: d_ptr(new QScriptValuePrivate(value))
{
}
/*!
Constructs a new QScriptValue with a special \a value.
*/
QScriptValue::QScriptValue(SpecialValue value)
: d_ptr(new QScriptValuePrivate(value))
{
}
/*!
Constructs a new QScriptValue with a string \a value.
*/
QScriptValue::QScriptValue(const char* value)
: d_ptr(new QScriptValuePrivate(QString::fromUtf8(value)))
{
}
/*!
Block automatic convertion to bool
\internal
*/
QScriptValue::QScriptValue(void* d)
{
Q_ASSERT(false);
}
/*!
Constructs a new QScriptValue from private
\internal
*/
QScriptValue::QScriptValue(QScriptValuePrivate* d)
: d_ptr(d)
{
}
/*!
\obsolete