History

Move extract/encode enitty functions in ScriptEngine

Ryan Huffman committed 10 years ago

Commit 42b0d821 parent df092541 file · +19 −19Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+19−19
@@ -107,6 +107,25 @@ void inputControllerFromScriptValue(const QScriptValue &object, controller::Inpu · 106 unmodified lines
107107 out = qobject_cast<controller::InputController*>(object.toQObject());
108108 }
109109
110+// The purpose of the following two function is to embed entity ids into entity script filenames
111+// so that they show up in stacktraces
112+//
113+// Extract the url portion of a url that has been encoded with encodeEntityIdIntoEntityUrl(...)
114+QString extractUrlFromEntityUrl(const QString& url) {
115+ auto parts = url.split(' ', QString::SkipEmptyParts);
116+ if (parts.length() > 0) {
117+ return parts[0];
118+ } else {
119+ return "";
120+ }
121+}
122+
123+// Encode an entity id into an entity url
124+// Example: http://www.example.com/some/path.js [EntityID:{9fdd355f-d226-4887-9484-44432d29520e}]
125+QString encodeEntityIdIntoEntityUrl(const QString& url, const QString& entityID) {
126+ return url + " [EntityID:" + entityID + "]";
127+}
128+
110129 static bool hasCorrectSyntax(const QScriptProgram& program) {
111130 const auto syntaxCheck = QScriptEngine::checkSyntax(program.sourceCode());
112131 if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) {
@@ -1303,25 +1322,6 @@ void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const · 1190 unmodified lines
13031322 }, forceRedownload);
13041323 }
13051324
1306−// The purpose of the following two function is to embed entity ids into entity script filenames
1307−// so that they show up in stacktraces
1308−//
1309−// Extract the url portion of a url that has been encoded with encodeEntityIdIntoEntityUrl(...)
1310−QString extractUrlFromEntityUrl(const QString& url) {
1311− auto parts = url.split(' ', QString::SkipEmptyParts);
1312− if (parts.length() > 0) {
1313− return parts[0];
1314− } else {
1315− return "";
1316− }
1317−}
1318−
1319−// Encode an entity id into an entity url
1320−// Example: http://www.example.com/some/path.js [EntityID:{9fdd355f-d226-4887-9484-44432d29520e}]
1321−QString encodeEntityIdIntoEntityUrl(const QString& url, const QString& entityID) {
1322− return url + " [EntityID:" + entityID + "]";
1323−}
1324−
13251325 // since all of these operations can be asynch we will always do the actual work in the response handler
13261326 // for the download
13271327 void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, const QString& scriptOrURL, const QString& contents, bool isURL, bool success) {