Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QScriptContext Class Reference

List of all members.


Detailed Description

The QScriptContext class represents a Qt Script function invocation.

Since:
4.3

A QScriptContext provides access to the `this' object and arguments passed to a script function. You typically want to access this information when you're writing a native (C++) function (see QScriptEngine::newFunction()) that will be called from script code. For example, when the script code

  foo(20.5, "hello", new Object())

is evaluated, a QScriptContext will be created, and the context will carry the arguments as QScriptValues; in this particular case, the arguments will be one QScriptValue containing the number 20.5, a second QScriptValue containing the string {"hello"}, and a third QScriptValue containing a Qt Script object.

Use argumentCount() to get the number of arguments passed to the function, and argument() to get an argument at a certain index.

Use thisObject() to get the `this' object associated with the function call, and setThisObject() to set the `this' object.

Use isCalledAsConstructor() to determine if the function was called as a constructor (e.g. {"new foo()"} (as constructor) or just {"foo()"}).

Use throwValue() or throwError() to throw an exception.

Use callee() to obtain the QScriptValue that represents the function being called.

Use parentContext() to get a pointer to the context that precedes this context in the activation stack.

Use engine() to obtain a pointer to the QScriptEngine that this context resides in.

Use backtrace() to get a human-readable backtrace associated with this context. This can be useful for debugging purposes when implementing native functions.

See also:
QScriptEngine::newFunction(), QScriptable

Definition at line 54 of file qscriptcontext.h.


Public Types

enum  Error {
  UnknownError, ReferenceError, SyntaxError, TypeError,
  RangeError, URIError
}
enum  ExecutionState { NormalState, ExceptionState }

Public Member Functions

QScriptValue activationObject () const
QScriptValue argument (int index) const
int argumentCount () const
QScriptValue argumentsObject () const
QStringList backtrace () const
QScriptValue callee () const
QScriptEngineengine () const
bool isCalledAsConstructor () const
QScriptContextparentContext () const
QScriptValue returnValue () const
void setActivationObject (const QScriptValue &activation)
void setReturnValue (const QScriptValue &result)
void setThisObject (const QScriptValue &thisObject)
ExecutionState state () const
QScriptValue thisObject () const
QScriptValue throwError (const QString &text)
QScriptValue throwError (Error error, const QString &text)
QScriptValue throwValue (const QScriptValue &value)
 ~QScriptContext ()

Private Member Functions

 QScriptContext ()

Private Attributes

QScriptContextPrivate * d_ptr

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index