Qt 4.8
qscriptable.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 "qscriptable.h"
25 #include "qscriptable_p.h"
26 #include "qscriptengine.h"
27 
29 
88  : d_ptr(new QScriptablePrivate())
89 {
90  d_ptr->q_ptr = this;
91 }
92 
97 {
98 }
99 
106 {
107  Q_D(const QScriptable);
108  return d->engine;
109 }
110 
117 {
118  if (QScriptEngine *e = engine())
119  return e->currentContext();
120 
121  return 0;
122 }
123 
131 {
132  if (QScriptContext *c = context())
133  return c->thisObject();
134 
135  return QScriptValue();
136 }
137 
146 {
147  if (QScriptContext *c = context())
148  return c->argumentCount();
149 
150  return -1;
151 }
152 
160 {
161  if (QScriptContext *c = context())
162  return c->argument(index);
163 
164  return QScriptValue();
165 }
166 
double d
Definition: qnumeric_p.h:62
The QScriptContext class represents a Qt Script function invocation.
QScriptable * q_ptr
Definition: qscriptable_p.h:56
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QScriptEngine * engine() const
Returns a pointer to the QScriptEngine associated with the current Qt function call, or 0 if the Qt function was not invoked from script code.
QScriptValue thisObject() const
Returns the `this' object associated with the current Qt function call, or an invalid QScriptValue if...
#define Q_D(Class)
Definition: qglobal.h:2482
QScopedPointer< QScriptablePrivate > d_ptr
Definition: qscriptable.h:58
The QScriptable class provides access to the Qt Script environment from Qt C++ member functions...
Definition: qscriptable.h:45
The QScriptEngine class provides an environment for evaluating Qt Script code.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QScriptValue argument(int index) const
Returns the function argument at the given index, or an invalid QScriptValue if the Qt function was n...
int argumentCount() const
Returns the number of arguments passed to the function in this invocation, or -1 if the Qt function w...
QScriptContext * context() const
Returns a pointer to the QScriptContext associated with the current Qt function call, or 0 if the Qt function was not invoked from script code.
quint16 index
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57