Changeset View
Changeset View
Standalone View
Standalone View
src/script/katescript.h
Context not available. | |||||
21 | #ifndef KATE_SCRIPT_H | 21 | #ifndef KATE_SCRIPT_H | ||
---|---|---|---|---|---|
22 | #define KATE_SCRIPT_H | 22 | #define KATE_SCRIPT_H | ||
23 | 23 | | |||
24 | #include <QScriptValue> | 24 | #include <QtCore/QString> | ||
25 | #include <QString> | 25 | #include <QtCore/QMap> | ||
26 | #include <QMap> | 26 | #include <QtQml/QJSValue> | ||
27 | 27 | | |||
28 | class QScriptEngine; | 28 | class QJSEngine; | ||
29 | 29 | | |||
30 | namespace KTextEditor { class ViewPrivate; } | 30 | namespace KTextEditor { class ViewPrivate; } | ||
31 | 31 | | |||
Context not available. | |||||
42 | /** Don't know what kind of script this is */ | 42 | /** Don't know what kind of script this is */ | ||
43 | UnknownScript | 43 | UnknownScript | ||
44 | }; | 44 | }; | ||
45 | class ScriptHelper; | ||||
45 | } | 46 | } | ||
46 | 47 | | |||
47 | //BEGIN KateScriptHeader | 48 | //BEGIN KateScriptHeader | ||
Context not available. | |||||
122 | InputSCRIPT | 123 | InputSCRIPT | ||
123 | }; | 124 | }; | ||
124 | 125 | | |||
125 | typedef QMap<QString, QScriptValue> FieldMap; | 126 | typedef QMap<QString, QJSValue> FieldMap; | ||
126 | 127 | | |||
127 | /** | 128 | /** | ||
128 | * Create a new script representation, passing either a file or the script | 129 | * Create a new script representation, passing either a file or the script | ||
Context not available. | |||||
154 | bool setView(KTextEditor::ViewPrivate *view); | 155 | bool setView(KTextEditor::ViewPrivate *view); | ||
155 | 156 | | |||
156 | /** | 157 | /** | ||
157 | * Get a QScriptValue for a global item in the script given its name, or an | 158 | * Get a QJSValue for a global item in the script given its name, or an | ||
158 | * invalid QScriptValue if no such global item exists. | 159 | * invalid QJSValue if no such global item exists. | ||
159 | */ | 160 | */ | ||
160 | QScriptValue global(const QString &name); | 161 | QJSValue global(const QString &name); | ||
161 | 162 | | |||
162 | /** | 163 | /** | ||
163 | * Return a function in the script of the given name, or an invalid QScriptValue | 164 | * Return a function in the script of the given name, or an invalid QJSValue | ||
164 | * if no such function exists. | 165 | * if no such function exists. | ||
165 | */ | 166 | */ | ||
166 | QScriptValue function(const QString &name); | 167 | QJSValue function(const QString &name); | ||
167 | 168 | | |||
168 | /** Return a context-specific error message */ | 169 | /** Return a context-specific error message */ | ||
169 | const QString &errorMessage() | 170 | const QString &errorMessage() | ||
Context not available. | |||||
172 | } | 173 | } | ||
173 | 174 | | |||
174 | /** Returns the backtrace when a script has errored out */ | 175 | /** Returns the backtrace when a script has errored out */ | ||
175 | QString backtrace(const QScriptValue &error, const QString &header = QString()); | 176 | QString backtrace(const QJSValue &error, const QString &header = QString()); | ||
176 | 177 | | |||
177 | /** Execute a piece of code **/ | 178 | /** Execute a piece of code **/ | ||
178 | QScriptValue evaluate(const QString& program, const FieldMap& env = FieldMap()); | 179 | QJSValue evaluate(const QString& program, const FieldMap& env = FieldMap()); | ||
179 | 180 | | |||
180 | /** Displays the backtrace when a script has errored out */ | 181 | /** Displays the backtrace when a script has errored out */ | ||
181 | void displayBacktrace(const QScriptValue &error, const QString &header = QString()); | 182 | void displayBacktrace(const QJSValue &error, const QString &header = QString()); | ||
182 | 183 | | |||
183 | /** Clears any uncaught exceptions in the script engine. */ | 184 | /** Clears any uncaught exceptions in the script engine. */ | ||
184 | void clearExceptions(); | 185 | void clearExceptions(); | ||
Context not available. | |||||
190 | 191 | | |||
191 | protected: | 192 | protected: | ||
192 | /** Checks for exception and gives feedback on the console. */ | 193 | /** Checks for exception and gives feedback on the console. */ | ||
193 | bool hasException(const QScriptValue &object, const QString &file); | 194 | bool hasException(const QJSValue &object, const QString &file); | ||
194 | 195 | | |||
195 | private: | 196 | private: | ||
196 | /** Whether or not there has been a call to load */ | 197 | /** Whether or not there has been a call to load */ | ||
Context not available. | |||||
207 | 208 | | |||
208 | protected: | 209 | protected: | ||
209 | /** The Qt interpreter for this script */ | 210 | /** The Qt interpreter for this script */ | ||
210 | QScriptEngine *m_engine; | 211 | QJSEngine *m_engine; | ||
211 | 212 | | |||
212 | private: | 213 | private: | ||
213 | /** general header data */ | 214 | /** general header data */ | ||
Context not available. | |||||
216 | /** document/view wrapper objects */ | 217 | /** document/view wrapper objects */ | ||
217 | KateScriptDocument *m_document; | 218 | KateScriptDocument *m_document; | ||
218 | KateScriptView *m_view; | 219 | KateScriptView *m_view; | ||
220 | | ||||
221 | Kate::ScriptHelper *m_scriptHelper; | ||||
219 | 222 | | |||
220 | private: | 223 | private: | ||
221 | /** if input is script or url**/ | 224 | /** if input is script or url**/ | ||
Context not available. |