Qt 4.8
qscriptextensionplugin.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtScript module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.LGPL included in the
13 ** packaging of this file. Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** If you have questions regarding the use of this file, please contact
18 ** us via http://www.qt-project.org/.
19 **
20 ** $QT_END_LICENSE$
21 **
22 ****************************************************************************/
23 
24 #include "qscriptextensionplugin.h"
25 
26 #include "qscriptvalue.h"
27 #include "qscriptengine.h"
28 
30 
84  : QObject(parent)
85 {
86 }
87 
95 {
96 }
97 
116  const QString &key, QScriptEngine *engine) const
117 {
118  QStringList components = key.split(QLatin1Char('.'));
119  QScriptValue o = engine->globalObject();
120  for (int i = 0; i < components.count(); ++i) {
121  QScriptValue oo = o.property(components.at(i));
122  if (!oo.isValid()) {
123  oo = engine->newObject();
124  o.setProperty(components.at(i), oo);
125  }
126  o = oo;
127  }
128  return o;
129 }
130 
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue&#39;s property with the given name, using the given mode to resolv...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
~QScriptExtensionPlugin()
Destroys the script extension plugin.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QScriptValue setupPackage(const QString &key, QScriptEngine *engine) const
This function is provided for convenience when reimplementing initialize().
The QScriptEngine class provides an environment for evaluating Qt Script code.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QScriptValue newObject()
Creates a QtScript object of class Object.
QScriptExtensionPlugin(QObject *parent=0)
Constructs a script extension plugin with the given parent.
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
int key
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
bool isValid() const
Returns true if this QScriptValue is valid; otherwise returns false.