Changeset View
Changeset View
Standalone View
Standalone View
src/script/katescript.cpp
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Line(s) | |||||
193 | QJSValue KateScript::evaluate(const QString& program, const FieldMap& env) | 193 | QJSValue KateScript::evaluate(const QString& program, const FieldMap& env) | ||
194 | { | 194 | { | ||
195 | if ( !load() ) { | 195 | if ( !load() ) { | ||
196 | qWarning() << "load of script failed:" << program; | 196 | qWarning() << "load of script failed:" << program; | ||
197 | return QJSValue(); | 197 | return QJSValue(); | ||
198 | } | 198 | } | ||
199 | 199 | | |||
200 | // Wrap the arguments in a function to avoid polluting the global object | 200 | // Wrap the arguments in a function to avoid polluting the global object | ||
201 | QString programWithContext = QStringLiteral("(function(") + | 201 | QString programWithContext = QLatin1String("(function(") + | ||
202 | QStringList(env.keys()).join(QLatin1Char(',')) + | 202 | QStringList(env.keys()).join(QLatin1Char(',')) + | ||
203 | QStringLiteral(") { return ") + | 203 | QLatin1String(") { return ") + | ||
204 | program + | 204 | program + | ||
205 | QStringLiteral("})"); | 205 | QLatin1String("})"); | ||
206 | QJSValue programFunction = m_engine->evaluate(programWithContext); | 206 | QJSValue programFunction = m_engine->evaluate(programWithContext); | ||
207 | Q_ASSERT(programFunction.isCallable()); | 207 | Q_ASSERT(programFunction.isCallable()); | ||
208 | 208 | | |||
209 | QJSValueList args; | 209 | QJSValueList args; | ||
210 | for ( auto it = env.begin(); it != env.end(); it++ ) { | 210 | for ( auto it = env.begin(); it != env.end(); it++ ) { | ||
211 | args << it.value(); | 211 | args << it.value(); | ||
212 | } | 212 | } | ||
213 | 213 | | |||
Show All 40 Lines |