]> git.saurik.com Git - apple/javascriptcore.git/blame - qt/api/qscriptengine.h
JavaScriptCore-903.5.tar.gz
[apple/javascriptcore.git] / qt / api / qscriptengine.h
CommitLineData
f9bf01c6
A
1/*
2 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef qscriptengine_h
21#define qscriptengine_h
22
4e4e5a6f
A
23#include "qscriptprogram.h"
24#include "qscriptstring.h"
25#include "qscriptsyntaxcheckresult.h"
14957cd0 26#include "qscriptvalue.h"
f9bf01c6
A
27#include <QtCore/qobject.h>
28#include <QtCore/qshareddata.h>
29#include <QtCore/qstring.h>
30
14957cd0 31class QDateTime;
f9bf01c6
A
32class QScriptEnginePrivate;
33
14957cd0
A
34// FIXME: Remove this once QScriptContext is properly defined.
35typedef void QScriptContext;
36
f9bf01c6
A
37// Internal typedef
38typedef QExplicitlySharedDataPointer<QScriptEnginePrivate> QScriptEnginePtr;
39
40class QScriptEngine : public QObject {
41public:
42 QScriptEngine();
43 ~QScriptEngine();
44
4e4e5a6f 45 static QScriptSyntaxCheckResult checkSyntax(const QString& program);
f9bf01c6 46 QScriptValue evaluate(const QString& program, const QString& fileName = QString(), int lineNumber = 1);
4e4e5a6f
A
47 QScriptValue evaluate(const QScriptProgram& program);
48
14957cd0
A
49 bool hasUncaughtException() const;
50 QScriptValue uncaughtException() const;
51 void clearExceptions();
52 int uncaughtExceptionLineNumber() const;
53 QStringList uncaughtExceptionBacktrace() const;
54
f9bf01c6 55 void collectGarbage();
4e4e5a6f
A
56 void reportAdditionalMemoryCost(int cost);
57
58 QScriptString toStringHandle(const QString& str);
14957cd0 59 QScriptValue toObject(const QScriptValue& value);
f9bf01c6 60
4e4e5a6f
A
61 QScriptValue nullValue();
62 QScriptValue undefinedValue();
14957cd0
A
63
64 typedef QScriptValue (*FunctionSignature)(QScriptContext *, QScriptEngine *);
65 typedef QScriptValue (*FunctionWithArgSignature)(QScriptContext *, QScriptEngine *, void *);
66
67 QScriptValue newFunction(FunctionSignature fun, int length = 0);
68 QScriptValue newFunction(FunctionSignature fun, const QScriptValue& prototype, int length = 0);
69 QScriptValue newFunction(FunctionWithArgSignature fun, void* arg);
70
71 QScriptValue newObject();
72 QScriptValue newArray(uint length = 0);
73 QScriptValue newDate(qsreal value);
74 QScriptValue newDate(const QDateTime& value);
4e4e5a6f 75 QScriptValue globalObject() const;
f9bf01c6
A
76private:
77 friend class QScriptEnginePrivate;
78
79 QScriptEnginePtr d_ptr;
80};
81
82#endif