| Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The QScriptContext class represents a Qt Script function invocation. More...
#include <QScriptContext>
This class was introduced in Qt 4.3.
The QScriptContext class represents a Qt Script function invocation.
A QScriptContext contains 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::createFunction()) 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 calledAsConstructor() 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.
See also QScriptEngine.
| Constant | Value | Description |
|---|---|---|
| QScriptContext::ReferenceError | 1 | A reference error. |
| QScriptContext::SyntaxError | 2 | A syntax error. |
| QScriptContext::TypeError | 3 | A type error. |
| QScriptContext::RangeError | 4 | A range error. |
| QScriptContext::URIError | 5 | A URI error. |
| QScriptContext::UnknownError | 0 | An unknown error. |
Destroys this QScriptContext.
Returns the function argument at the given index.
If index >= argumentCount(), a QScriptValue of the primitive type Undefined is returned.
See also argumentCount().
Returns the number of arguments passed to the function in this invocation.
See also argument().
Returns true if the function was called as a constructor (e.g. "new foo()"); otherwise returns false.
When a function is called as constructor, the thisObject() contains the newly constructed object to be initialized.
Returns the callee. The callee is the function object that this QScriptContext represents an invocation of.
Returns the QScriptEngine that this QScriptContext belongs to.
Returns the parent context of this QScriptContext.
Sets the `this' object associated with this QScriptContext to be thisObject.
See also thisObject().
Returns the state of this QScriptContext.
Returns the `this' object associated with this QScriptContext.
See also setThisObject().
Throws an error with the given text. Returns the created error object.
The text will be stored in the message property of the error object.
See also throwValue(), recoverFromException(), and state().
This is an overloaded member function, provided for convenience.
Throws an error with the given text. Returns the created error object.
See also throwValue(), recoverFromException(), and state().
Throws an exception with the given value. Returns the value thrown (the same as the argument).
See also throwError(), recoverFromException(), and state().
| Copyright © 2007 Trolltech | Trademarks | Qt 4.3.0-snapshot-20070202 |