Showing the changes to libraries/script-engine/src/qtscript/ScriptEngineQtScript.cpp (1 of 3 files). Show all
Unified · Split
| @@ -52,15 +52,10 @@ · 51 unmodified lines | ||
| 52 | 52 | #include "ScriptProgramQtWrapper.h" |
| 53 | 53 | #include "ScriptValueQtWrapper.h" |
| 54 | 54 | |
| 55 | −static const int MAX_MODULE_ID_LENGTH { 4096 }; | |
| 56 | 55 | static const int MAX_DEBUG_VALUE_LENGTH { 80 }; |
| 57 | 56 | |
| 58 | 57 | static const QScriptEngine::QObjectWrapOptions DEFAULT_QOBJECT_WRAP_OPTIONS = |
| 59 | 58 | QScriptEngine::ExcludeDeleteLater | QScriptEngine::ExcludeChildObjects; |
| 60 | −static const QScriptValue::PropertyFlags READONLY_PROP_FLAGS { QScriptValue::ReadOnly | QScriptValue::Undeletable }; | |
| 61 | −static const QScriptValue::PropertyFlags READONLY_HIDDEN_PROP_FLAGS { READONLY_PROP_FLAGS | QScriptValue::SkipInEnumeration }; | |
| 62 | − | |
| 63 | −static const bool HIFI_AUTOREFRESH_FILE_SCRIPTS { true }; | |
| 64 | 59 | |
| 65 | 60 | Q_DECLARE_METATYPE(ScriptValue); |
| 66 | 61 | |
| @@ -315,74 +310,6 @@ void ScriptEngineQtScript::_debugDump(const QString& header, const QScriptValue& · 248 unmodified lines | ||
| 315 | 310 | } |
| 316 | 311 | #endif |
| 317 | 312 | |
| 318 | −static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { | |
| 319 | − // assemble the message by concatenating our arguments | |
| 320 | − QString message = ""; | |
| 321 | − for (int i = 0; i < context->argumentCount(); i++) { | |
| 322 | − if (i > 0) { | |
| 323 | − message += " "; | |
| 324 | − } | |
| 325 | − message += context->argument(i).toString(); | |
| 326 | − } | |
| 327 | − | |
| 328 | − // was this generated by a script engine? If we don't recognize it then send the message and exit | |
| 329 | − ScriptEngineQtScript* scriptEngine = qobject_cast<ScriptEngineQtScript*>(engine); | |
| 330 | − if (!scriptEngine) { | |
| 331 | − qCDebug(scriptengine_script, "%s", qUtf8Printable(message)); | |
| 332 | − return QScriptValue(); | |
| 333 | − } | |
| 334 | − | |
| 335 | − QString filename; | |
| 336 | − auto scriptManager = scriptEngine->manager(); | |
| 337 | − if (scriptManager) { | |
| 338 | − filename = scriptManager->getFilename(); | |
| 339 | − } | |
| 340 | − | |
| 341 | − // This message was sent by one of our script engines, let's try to see if we can find the source. | |
| 342 | − // Note that the first entry in the backtrace should be "print" and is somewhat useless to us | |
| 343 | − AbstractLoggerInterface* loggerInterface = AbstractLoggerInterface::get(); | |
| 344 | − if (loggerInterface && loggerInterface->showSourceDebugging()) { | |
| 345 | − QScriptContext* userContext = context; | |
| 346 | − while (userContext && QScriptContextInfo(userContext).functionType() == QScriptContextInfo::NativeFunction) { | |
| 347 | − userContext = userContext->parentContext(); | |
| 348 | − } | |
| 349 | − QString location; | |
| 350 | − if (userContext) { | |
| 351 | − QScriptContextInfo contextInfo(userContext); | |
| 352 | − QString fileName = contextInfo.fileName(); | |
| 353 | − int lineNumber = contextInfo.lineNumber(); | |
| 354 | − QString functionName = contextInfo.functionName(); | |
| 355 | − | |
| 356 | − location = functionName; | |
| 357 | − if (!fileName.isEmpty()) { | |
| 358 | − if (location.isEmpty()) { | |
| 359 | − location = fileName; | |
| 360 | − } else { | |
| 361 | − location = QString("%1 at %2").arg(location).arg(fileName); | |
| 362 | − } | |
| 363 | − } | |
| 364 | − if (lineNumber != -1) { | |
| 365 | − location = QString("%1:%2").arg(location).arg(lineNumber); | |
| 366 | − } | |
| 367 | − } | |
| 368 | − if (location.isEmpty()) { | |
| 369 | − location = filename; | |
| 370 | − } | |
| 371 | − | |
| 372 | − // give the script engine a chance to notify the system about this message | |
| 373 | − scriptEngine->print(message); | |
| 374 | − | |
| 375 | − // send the message to debug log | |
| 376 | − qCDebug(scriptengine_script, "[%s] %s", qUtf8Printable(location), qUtf8Printable(message)); | |
| 377 | − } else { | |
| 378 | − scriptEngine->print(message); | |
| 379 | − // prefix the script engine name to help disambiguate messages in the main debug log | |
| 380 | − qCDebug(scriptengine_script, "[%s] %s", qUtf8Printable(filename), qUtf8Printable(message)); | |
| 381 | − } | |
| 382 | − | |
| 383 | − return QScriptValue(); | |
| 384 | −} | |
| 385 | − | |
| 386 | 313 | static QScriptValue ScriptValueToQScriptValue(QScriptEngine* engine, const ScriptValue& src) { |
| 387 | 314 | return ScriptValueQtWrapper::fullUnwrap(static_cast<ScriptEngineQtScript*>(engine), src); |
| 388 | 315 | } |