/*! Returns true if this QScriptProgram is equal to \a other; otherwise returns false. */ bool QScriptProgram::operator==(const QScriptProgram &other) const { Q_D(const QScriptProgram); if (d == other.d_func()) return true; return (sourceCode() == other.sourceCode()) && (fileName() == other.fileName()) && (firstLineNumber() == other.firstLineNumber()); }
// Copied from ScriptEngine.cpp. We should make this a class method for reuse. // Note: I've deliberately stopped short of using ScriptEngine instead of QScriptEngine, as that is out of project scope at this point. static bool hasCorrectSyntax(const QScriptProgram& program) { const auto syntaxCheck = QScriptEngine::checkSyntax(program.sourceCode()); if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) { const auto error = syntaxCheck.errorMessage(); const auto line = QString::number(syntaxCheck.errorLineNumber()); const auto column = QString::number(syntaxCheck.errorColumnNumber()); const auto message = QString("[SyntaxError] %1 in %2:%3(%4)").arg(error, program.fileName(), line, column); qCritical() << qPrintable(message); return false; } return true; }