00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 00004 ** All rights reserved. 00005 ** Contact: Nokia Corporation (qt-info@nokia.com) 00006 ** 00007 ** This file is part of the QtScript module of the Qt Toolkit. 00008 ** 00009 ** $QT_BEGIN_LICENSE:LGPL-ONLY$ 00010 ** GNU Lesser General Public License Usage 00011 ** This file may be used under the terms of the GNU Lesser 00012 ** General Public License version 2.1 as published by the Free Software 00013 ** Foundation and appearing in the file LICENSE.LGPL included in the 00014 ** packaging of this file. Please review the following information to 00015 ** ensure the GNU Lesser General Public License version 2.1 requirements 00016 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 00017 ** 00018 ** If you have questions regarding the use of this file, please contact 00019 ** Nokia at qt-info@nokia.com. 00020 ** $QT_END_LICENSE$ 00021 ** 00022 ****************************************************************************/ 00023 00024 #ifndef QSCRIPTCONTEXT_H 00025 #define QSCRIPTCONTEXT_H 00026 00027 #include <QtCore/qobjectdefs.h> 00028 00029 #include <QtScript/qscriptvalue.h> 00030 00031 QT_BEGIN_HEADER 00032 00033 QT_BEGIN_NAMESPACE 00034 00035 QT_MODULE(Script) 00036 00037 class QScriptContextPrivate; 00038 00039 class Q_SCRIPT_EXPORT QScriptContext 00040 { 00041 public: 00042 enum ExecutionState { 00043 NormalState, 00044 ExceptionState 00045 }; 00046 00047 enum Error { 00048 UnknownError, 00049 ReferenceError, 00050 SyntaxError, 00051 TypeError, 00052 RangeError, 00053 URIError 00054 }; 00055 00056 ~QScriptContext(); 00057 00058 QScriptContext *parentContext() const; 00059 QScriptEngine *engine() const; 00060 00061 ExecutionState state() const; 00062 QScriptValue callee() const; 00063 00064 int argumentCount() const; 00065 QScriptValue argument(int index) const; 00066 QScriptValue argumentsObject() const; 00067 00068 QScriptValueList scopeChain() const; 00069 void pushScope(const QScriptValue &object); 00070 QScriptValue popScope(); 00071 00072 QScriptValue returnValue() const; 00073 void setReturnValue(const QScriptValue &result); 00074 00075 QScriptValue activationObject() const; 00076 void setActivationObject(const QScriptValue &activation); 00077 00078 QScriptValue thisObject() const; 00079 void setThisObject(const QScriptValue &thisObject); 00080 00081 bool isCalledAsConstructor() const; 00082 00083 QScriptValue throwValue(const QScriptValue &value); 00084 QScriptValue throwError(Error error, const QString &text); 00085 QScriptValue throwError(const QString &text); 00086 00087 QStringList backtrace() const; 00088 00089 QString toString() const; 00090 00091 private: 00092 QScriptContext(); 00093 00094 QScriptContextPrivate *d_ptr; 00095 00096 Q_DECLARE_PRIVATE(QScriptContext) 00097 Q_DISABLE_COPY(QScriptContext) 00098 }; 00099 00100 QT_END_NAMESPACE 00101 00102 QT_END_HEADER 00103 00104 #endif