src/script/api/qscriptcontext.h
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtScript module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QSCRIPTCONTEXT_H
       
    43 #define QSCRIPTCONTEXT_H
       
    44 
       
    45 #include <QtCore/qobjectdefs.h>
       
    46 
       
    47 #include <QtScript/qscriptvalue.h>
       
    48 
       
    49 QT_BEGIN_HEADER
       
    50 
       
    51 QT_BEGIN_NAMESPACE
       
    52 
       
    53 QT_MODULE(Script)
       
    54 
       
    55 class QScriptContextPrivate;
       
    56 
       
    57 class Q_SCRIPT_EXPORT QScriptContext
       
    58 {
       
    59 public:
       
    60     enum ExecutionState {
       
    61         NormalState,
       
    62         ExceptionState
       
    63     };
       
    64 
       
    65     enum Error {
       
    66         UnknownError,
       
    67         ReferenceError,
       
    68         SyntaxError,
       
    69         TypeError,
       
    70         RangeError,
       
    71         URIError
       
    72     };
       
    73 
       
    74     ~QScriptContext();
       
    75 
       
    76     QScriptContext *parentContext() const;
       
    77     QScriptEngine *engine() const;
       
    78 
       
    79     ExecutionState state() const;
       
    80     QScriptValue callee() const;
       
    81 
       
    82     int argumentCount() const;
       
    83     QScriptValue argument(int index) const;
       
    84     QScriptValue argumentsObject() const;
       
    85 
       
    86     QScriptValueList scopeChain() const;
       
    87     void pushScope(const QScriptValue &object);
       
    88     QScriptValue popScope();
       
    89 
       
    90     QScriptValue returnValue() const;
       
    91     void setReturnValue(const QScriptValue &result);
       
    92 
       
    93     QScriptValue activationObject() const;
       
    94     void setActivationObject(const QScriptValue &activation);
       
    95 
       
    96     QScriptValue thisObject() const;
       
    97     void setThisObject(const QScriptValue &thisObject);
       
    98 
       
    99     bool isCalledAsConstructor() const;
       
   100 
       
   101     QScriptValue throwValue(const QScriptValue &value);
       
   102     QScriptValue throwError(Error error, const QString &text);
       
   103     QScriptValue throwError(const QString &text);
       
   104 
       
   105     QStringList backtrace() const;
       
   106 
       
   107     QString toString() const;
       
   108 
       
   109 private:
       
   110     QScriptContext();
       
   111 
       
   112     QScriptContextPrivate *d_ptr;
       
   113 
       
   114     Q_DECLARE_PRIVATE(QScriptContext)
       
   115     Q_DISABLE_COPY(QScriptContext)
       
   116 };
       
   117 
       
   118 QT_END_NAMESPACE
       
   119 
       
   120 QT_END_HEADER
       
   121 
       
   122 #endif