mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:24:03 +02:00
Move extract/encode enitty functions in ScriptEngine
This commit is contained in:
parent
df09254437
commit
42b0d8230c
1 changed files with 19 additions and 19 deletions
|
@ -107,6 +107,25 @@ void inputControllerFromScriptValue(const QScriptValue &object, controller::Inpu
|
|||
out = qobject_cast<controller::InputController*>(object.toQObject());
|
||||
}
|
||||
|
||||
// The purpose of the following two function is to embed entity ids into entity script filenames
|
||||
// so that they show up in stacktraces
|
||||
//
|
||||
// Extract the url portion of a url that has been encoded with encodeEntityIdIntoEntityUrl(...)
|
||||
QString extractUrlFromEntityUrl(const QString& url) {
|
||||
auto parts = url.split(' ', QString::SkipEmptyParts);
|
||||
if (parts.length() > 0) {
|
||||
return parts[0];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Encode an entity id into an entity url
|
||||
// Example: http://www.example.com/some/path.js [EntityID:{9fdd355f-d226-4887-9484-44432d29520e}]
|
||||
QString encodeEntityIdIntoEntityUrl(const QString& url, const QString& entityID) {
|
||||
return url + " [EntityID:" + entityID + "]";
|
||||
}
|
||||
|
||||
static bool hasCorrectSyntax(const QScriptProgram& program) {
|
||||
const auto syntaxCheck = QScriptEngine::checkSyntax(program.sourceCode());
|
||||
if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) {
|
||||
|
@ -1303,25 +1322,6 @@ void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const
|
|||
}, forceRedownload);
|
||||
}
|
||||
|
||||
// The purpose of the following two function is to embed entity ids into entity script filenames
|
||||
// so that they show up in stacktraces
|
||||
//
|
||||
// Extract the url portion of a url that has been encoded with encodeEntityIdIntoEntityUrl(...)
|
||||
QString extractUrlFromEntityUrl(const QString& url) {
|
||||
auto parts = url.split(' ', QString::SkipEmptyParts);
|
||||
if (parts.length() > 0) {
|
||||
return parts[0];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Encode an entity id into an entity url
|
||||
// Example: http://www.example.com/some/path.js [EntityID:{9fdd355f-d226-4887-9484-44432d29520e}]
|
||||
QString encodeEntityIdIntoEntityUrl(const QString& url, const QString& entityID) {
|
||||
return url + " [EntityID:" + entityID + "]";
|
||||
}
|
||||
|
||||
// since all of these operations can be asynch we will always do the actual work in the response handler
|
||||
// for the download
|
||||
void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, const QString& scriptOrURL, const QString& contents, bool isURL, bool success) {
|
||||
|
|
Loading…
Reference in a new issue