diff options
author | axis <qt-info@nokia.com> | 2009-04-24 11:34:15 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-04-24 11:34:15 (GMT) |
commit | 8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (patch) | |
tree | a17e1a767a89542ab59907462206d7dcf2e504b2 /examples/script/customclass | |
download | Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.zip Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.gz Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.bz2 |
Long live Qt for S60!
Diffstat (limited to 'examples/script/customclass')
-rw-r--r-- | examples/script/customclass/bytearrayclass.cpp | 304 | ||||
-rw-r--r-- | examples/script/customclass/bytearrayclass.h | 90 | ||||
-rw-r--r-- | examples/script/customclass/bytearrayclass.pri | 6 | ||||
-rw-r--r-- | examples/script/customclass/bytearrayprototype.cpp | 136 | ||||
-rw-r--r-- | examples/script/customclass/bytearrayprototype.h | 80 | ||||
-rw-r--r-- | examples/script/customclass/customclass.pro | 15 | ||||
-rw-r--r-- | examples/script/customclass/main.cpp | 70 |
7 files changed, 701 insertions, 0 deletions
diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp new file mode 100644 index 0000000..7865381 --- /dev/null +++ b/examples/script/customclass/bytearrayclass.cpp @@ -0,0 +1,304 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtScript/QScriptClassPropertyIterator> +#include <QtScript/QScriptEngine> +#include "bytearrayclass.h" +#include "bytearrayprototype.h" + +#include <stdlib.h> + +Q_DECLARE_METATYPE(QByteArray*) +Q_DECLARE_METATYPE(ByteArrayClass*) + +class ByteArrayClassPropertyIterator : public QScriptClassPropertyIterator +{ +public: + ByteArrayClassPropertyIterator(const QScriptValue &object); + ~ByteArrayClassPropertyIterator(); + + bool hasNext() const; + void next(); + + bool hasPrevious() const; + void previous(); + + void toFront(); + void toBack(); + + QScriptString name() const; + uint id() const; + +private: + int m_index; + int m_last; +}; + +static qint32 toArrayIndex(const QString &str) +{ + QByteArray bytes = str.toUtf8(); + char *eptr; + quint32 pos = strtoul(bytes.constData(), &eptr, 10); + if ((eptr == bytes.constData() + bytes.size()) + && (QByteArray::number(pos) == bytes)) { + return pos; + } + return -1; +} + +//! [0] +ByteArrayClass::ByteArrayClass(QScriptEngine *engine) + : QObject(engine), QScriptClass(engine) +{ + qScriptRegisterMetaType<QByteArray>(engine, toScriptValue, fromScriptValue); + + length = engine->toStringHandle(QLatin1String("length")); + + proto = engine->newQObject(new ByteArrayPrototype(this), + QScriptEngine::QtOwnership, + QScriptEngine::SkipMethodsInEnumeration + | QScriptEngine::ExcludeSuperClassMethods + | QScriptEngine::ExcludeSuperClassProperties); + QScriptValue global = engine->globalObject(); + proto.setPrototype(global.property("Object").property("prototype")); + + ctor = engine->newFunction(construct); + ctor.setData(qScriptValueFromValue(engine, this)); +} +//! [0] + +ByteArrayClass::~ByteArrayClass() +{ +} + +//! [3] +QScriptClass::QueryFlags ByteArrayClass::queryProperty(const QScriptValue &object, + const QScriptString &name, + QueryFlags flags, uint *id) +{ + QByteArray *ba = qscriptvalue_cast<QByteArray*>(object.data()); + if (!ba) + return 0; + if (name == length) { + return flags; + } else { + qint32 pos = toArrayIndex(name); + if (pos == -1) + return 0; + *id = pos; + if ((flags & HandlesReadAccess) && (pos >= ba->size())) + flags &= ~HandlesReadAccess; + return flags; + } +} +//! [3] + +//! [4] +QScriptValue ByteArrayClass::property(const QScriptValue &object, + const QScriptString &name, uint id) +{ + QByteArray *ba = qscriptvalue_cast<QByteArray*>(object.data()); + if (!ba) + return QScriptValue(); + if (name == length) { + return ba->length(); + } else { + qint32 pos = id; + if ((pos < 0) || (pos >= ba->size())) + return QScriptValue(); + return uint(ba->at(pos)) & 255; + } + return QScriptValue(); +} +//! [4] + +//! [5] +void ByteArrayClass::setProperty(QScriptValue &object, + const QScriptString &name, + uint id, const QScriptValue &value) +{ + QByteArray *ba = qscriptvalue_cast<QByteArray*>(object.data()); + if (!ba) + return; + if (name == length) { + ba->resize(value.toInt32()); + } else { + qint32 pos = id; + if (pos < 0) + return; + if (ba->size() <= pos) + ba->resize(pos + 1); + (*ba)[pos] = char(value.toInt32()); + } +} +//! [5] + +//! [6] +QScriptValue::PropertyFlags ByteArrayClass::propertyFlags( + const QScriptValue &/*object*/, const QScriptString &name, uint /*id*/) +{ + if (name == length) { + return QScriptValue::Undeletable + | QScriptValue::SkipInEnumeration; + } + return QScriptValue::Undeletable; +} +//! [6] + +//! [7] +QScriptClassPropertyIterator *ByteArrayClass::newIterator(const QScriptValue &object) +{ + return new ByteArrayClassPropertyIterator(object); +} +//! [7] + +QString ByteArrayClass::name() const +{ + return QLatin1String("ByteArray"); +} + +QScriptValue ByteArrayClass::prototype() const +{ + return proto; +} + +QScriptValue ByteArrayClass::constructor() +{ + return ctor; +} + +QScriptValue ByteArrayClass::newInstance(int size) +{ + return newInstance(QByteArray(size, /*ch=*/0)); +} + +//! [1] +QScriptValue ByteArrayClass::newInstance(const QByteArray &ba) +{ + QScriptValue data = engine()->newVariant(qVariantFromValue(ba)); + return engine()->newObject(this, data); +} +//! [1] + +//! [2] +QScriptValue ByteArrayClass::construct(QScriptContext *ctx, QScriptEngine *) +{ + ByteArrayClass *cls = qscriptvalue_cast<ByteArrayClass*>(ctx->callee().data()); + if (!cls) + return QScriptValue(); + int size = ctx->argument(0).toInt32(); + return cls->newInstance(size); +} +//! [2] + +QScriptValue ByteArrayClass::toScriptValue(QScriptEngine *eng, const QByteArray &ba) +{ + QScriptValue ctor = eng->globalObject().property("ByteArray"); + ByteArrayClass *cls = qscriptvalue_cast<ByteArrayClass*>(ctor.data()); + if (!cls) + return eng->newVariant(qVariantFromValue(ba)); + return cls->newInstance(ba); +} + +void ByteArrayClass::fromScriptValue(const QScriptValue &obj, QByteArray &ba) +{ + ba = qscriptvalue_cast<QByteArray>(obj.data()); +} + + + +ByteArrayClassPropertyIterator::ByteArrayClassPropertyIterator(const QScriptValue &object) + : QScriptClassPropertyIterator(object) +{ + toFront(); +} + +ByteArrayClassPropertyIterator::~ByteArrayClassPropertyIterator() +{ +} + +//! [8] +bool ByteArrayClassPropertyIterator::hasNext() const +{ + QByteArray *ba = qscriptvalue_cast<QByteArray*>(object().data()); + return m_index < ba->size(); +} + +void ByteArrayClassPropertyIterator::next() +{ + m_last = m_index; + ++m_index; +} + +bool ByteArrayClassPropertyIterator::hasPrevious() const +{ + return (m_index > 0); +} + +void ByteArrayClassPropertyIterator::previous() +{ + --m_index; + m_last = m_index; +} + +void ByteArrayClassPropertyIterator::toFront() +{ + m_index = 0; + m_last = -1; +} + +void ByteArrayClassPropertyIterator::toBack() +{ + QByteArray *ba = qscriptvalue_cast<QByteArray*>(object().data()); + m_index = ba->size(); + m_last = -1; +} + +QScriptString ByteArrayClassPropertyIterator::name() const +{ + return QScriptString(); +} + +uint ByteArrayClassPropertyIterator::id() const +{ + return m_last; +} +//! [8] diff --git a/examples/script/customclass/bytearrayclass.h b/examples/script/customclass/bytearrayclass.h new file mode 100644 index 0000000..e9a5f07 --- /dev/null +++ b/examples/script/customclass/bytearrayclass.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BYTEARRAYCLASS_H +#define BYTEARRAYCLASS_H + +#include <QtCore/QObject> +#include <QtScript/QScriptClass> +#include <QtScript/QScriptString> + +class ByteArrayClass : public QObject, public QScriptClass +{ +public: + ByteArrayClass(QScriptEngine *engine); + ~ByteArrayClass(); + + QScriptValue constructor(); + + QScriptValue newInstance(int size = 0); + QScriptValue newInstance(const QByteArray &ba); + + QueryFlags queryProperty(const QScriptValue &object, + const QScriptString &name, + QueryFlags flags, uint *id); + + QScriptValue property(const QScriptValue &object, + const QScriptString &name, uint id); + + void setProperty(QScriptValue &object, const QScriptString &name, + uint id, const QScriptValue &value); + + QScriptValue::PropertyFlags propertyFlags( + const QScriptValue &object, const QScriptString &name, uint id); + + QScriptClassPropertyIterator *newIterator(const QScriptValue &object); + + QString name() const; + + QScriptValue prototype() const; + +private: + static QScriptValue construct(QScriptContext *ctx, QScriptEngine *eng); + + static QScriptValue toScriptValue(QScriptEngine *eng, const QByteArray &ba); + static void fromScriptValue(const QScriptValue &obj, QByteArray &ba); + + QScriptString length; + QScriptValue proto; + QScriptValue ctor; +}; + +#endif diff --git a/examples/script/customclass/bytearrayclass.pri b/examples/script/customclass/bytearrayclass.pri new file mode 100644 index 0000000..05fdeb4 --- /dev/null +++ b/examples/script/customclass/bytearrayclass.pri @@ -0,0 +1,6 @@ +SOURCES += $$PWD/bytearrayclass.cpp \ + $$PWD/bytearrayprototype.cpp +HEADERS += $$PWD/bytearrayclass.h \ + $$PWD/bytearrayprototype.h + +INCLUDEPATH += $$PWD diff --git a/examples/script/customclass/bytearrayprototype.cpp b/examples/script/customclass/bytearrayprototype.cpp new file mode 100644 index 0000000..eeb73f9 --- /dev/null +++ b/examples/script/customclass/bytearrayprototype.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "bytearrayprototype.h" +#include <QtScript/QScriptEngine> + +Q_DECLARE_METATYPE(QByteArray*) + +ByteArrayPrototype::ByteArrayPrototype(QObject *parent) + : QObject(parent) +{ +} + +ByteArrayPrototype::~ByteArrayPrototype() +{ +} + +//! [0] +QByteArray *ByteArrayPrototype::thisByteArray() const +{ + return qscriptvalue_cast<QByteArray*>(thisObject().data()); +} +//! [0] + +void ByteArrayPrototype::chop(int n) +{ + thisByteArray()->chop(n); +} + +bool ByteArrayPrototype::equals(const QByteArray &other) +{ + return *thisByteArray() == other; +} + +QByteArray ByteArrayPrototype::left(int len) const +{ + return thisByteArray()->left(len); +} + +//! [1] +QByteArray ByteArrayPrototype::mid(int pos, int len) const +{ + return thisByteArray()->mid(pos, len); +} + +QScriptValue ByteArrayPrototype::remove(int pos, int len) +{ + thisByteArray()->remove(pos, len); + return thisObject(); +} +//! [1] + +QByteArray ByteArrayPrototype::right(int len) const +{ + return thisByteArray()->right(len); +} + +QByteArray ByteArrayPrototype::simplified() const +{ + return thisByteArray()->simplified(); +} + +QByteArray ByteArrayPrototype::toBase64() const +{ + return thisByteArray()->toBase64(); +} + +QByteArray ByteArrayPrototype::toLower() const +{ + return thisByteArray()->toLower(); +} + +QByteArray ByteArrayPrototype::toUpper() const +{ + return thisByteArray()->toUpper(); +} + +QByteArray ByteArrayPrototype::trimmed() const +{ + return thisByteArray()->trimmed(); +} + +void ByteArrayPrototype::truncate(int pos) +{ + thisByteArray()->truncate(pos); +} + +QString ByteArrayPrototype::toLatin1String() const +{ + return QString::fromLatin1(*thisByteArray()); +} + +//! [2] +QScriptValue ByteArrayPrototype::valueOf() const +{ + return thisObject().data(); +} +//! [2] diff --git a/examples/script/customclass/bytearrayprototype.h b/examples/script/customclass/bytearrayprototype.h new file mode 100644 index 0000000..fe9e15b --- /dev/null +++ b/examples/script/customclass/bytearrayprototype.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BYTEARRAYPROTOTYPE_H +#define BYTEARRAYPROTOTYPE_H + +#include <QtCore/QByteArray> +#include <QtCore/QObject> +#include <QtScript/QScriptable> +#include <QtScript/QScriptValue> + +//! [0] +class ByteArrayPrototype : public QObject, public QScriptable +{ +Q_OBJECT +public: + ByteArrayPrototype(QObject *parent = 0); + ~ByteArrayPrototype(); + +public slots: + void chop(int n); + bool equals(const QByteArray &other); + QByteArray left(int len) const; + QByteArray mid(int pos, int len = -1) const; + QScriptValue remove(int pos, int len); + QByteArray right(int len) const; + QByteArray simplified() const; + QByteArray toBase64() const; + QByteArray toLower() const; + QByteArray toUpper() const; + QByteArray trimmed() const; + void truncate(int pos); + QString toLatin1String() const; + QScriptValue valueOf() const; + +private: + QByteArray *thisByteArray() const; +}; +//! [0] + + +#endif diff --git a/examples/script/customclass/customclass.pro b/examples/script/customclass/customclass.pro new file mode 100644 index 0000000..bb263d2 --- /dev/null +++ b/examples/script/customclass/customclass.pro @@ -0,0 +1,15 @@ +QT = core script +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + +include(bytearrayclass.pri) + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/script/customclass +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.pri +sources.path = $$[QT_INSTALL_EXAMPLES]/script/customclass +INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/script/customclass/main.cpp b/examples/script/customclass/main.cpp new file mode 100644 index 0000000..1c3ceb1 --- /dev/null +++ b/examples/script/customclass/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtScript> +#include "bytearrayclass.h" + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + QScriptEngine eng; + + ByteArrayClass *baClass = new ByteArrayClass(&eng); + eng.globalObject().setProperty("ByteArray", baClass->constructor()); + + qDebug() << "ba = new ByteArray(4):" << eng.evaluate("ba = new ByteArray(4)").toString(); + qDebug() << "ba.length:" << eng.evaluate("ba.length").toNumber(); + qDebug() << "ba[1] = 123; ba[1]:" << eng.evaluate("ba[1] = 123; ba[1]").toNumber(); + qDebug() << "ba[7] = 224; ba.length:" << eng.evaluate("ba[7] = 224; ba.length").toNumber(); + qDebug() << "for-in loop:" << eng.evaluate("result = '';\n" + "for (var p in ba) {\n" + " if (result.length > 0)\n" + " result += ', ';\n" + " result += '(' + p + ',' + ba[p] + ')';\n" + "} result").toString(); + qDebug() << "ba.toBase64():" << eng.evaluate("b64 = ba.toBase64()").toString(); + qDebug() << "ba.toBase64().toLatin1String():" << eng.evaluate("b64.toLatin1String()").toString(); + qDebug() << "ba.valueOf():" << eng.evaluate("ba.valueOf()").toString(); + qDebug() << "ba.chop(2); ba.length:" << eng.evaluate("ba.chop(2); ba.length").toNumber(); + + return 0; +} |