Merge branch 'master' of github.com:OpenSpace/OpenSpace into feature/data-management

Conflicts:
	data/scene/default.scene
	modules/sync/syncmodule.h
	openspace.cfg
	src/engine/openspaceengine.cpp
	src/scene/scene.cpp
	src/scene/scene_doc.inl
	src/scene/scenegraphnode.cpp
	src/scene/scenegraphnode_doc.inl
	src/scene/sceneloader.cpp
	src/scripting/scriptengine.cpp
This commit is contained in:
Emil Axelsson
2017-08-14 11:17:25 +02:00
928 changed files with 10516 additions and 10536 deletions

View File

@@ -41,7 +41,7 @@
#include "scriptengine_lua.inl"
namespace {
const std::string _loggerCat = "ScriptEngine";
const char* _loggerCat = "ScriptEngine";
const char* LuaGlobalNamespace = "_G";
const char* PrintFunctionName = "print";
@@ -54,8 +54,7 @@ namespace {
const char* JsFilename = "${OPENSPACE_DATA}/web/luascripting/script.js";
} // namespace
namespace openspace {
namespace scripting {
namespace openspace::scripting {
std::string ScriptEngine::OpenSpaceLibraryName = "openspace";
@@ -76,8 +75,6 @@ void ScriptEngine::initialize() {
addBaseLibrary();
LDEBUG("Initializing Lua state");
initializeLuaState(_state);
//LDEBUG("Remapping Print functions");
//remapPrintFunction();
}
void ScriptEngine::deinitialize() {}
@@ -418,112 +415,128 @@ void ScriptEngine::addLibraryFunctions(lua_State* state, LuaLibrary& library, bo
}
void ScriptEngine::addBaseLibrary() {
LuaLibrary lib = {
"",
LuaLibrary lib = {
"",
{
{
{
"printTrace",
&luascriptfunctions::printTrace,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Trace'"
},
{
"printDebug",
&luascriptfunctions::printDebug,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Debug'"
},
{
"printInfo",
&luascriptfunctions::printInfo,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Info'"
},
{
"printWarning",
&luascriptfunctions::printWarning,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Warning'"
},
{
"printError",
&luascriptfunctions::printError,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Error'"
},
{
"printFatal",
&luascriptfunctions::printFatal,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Fatal'"
},
{
"absPath",
&luascriptfunctions::absolutePath,
{},
"string",
"Returns the absolute path to the passed path, resolving path tokens as "
"well as resolving relative paths"
},
{
"fileExists",
&luascriptfunctions::fileExists,
{},
"string",
"Checks whether the provided file exists."
},
{
"setPathToken",
&luascriptfunctions::setPathToken,
{},
"string, string",
"Registers a new path token provided by the first argument to the path "
"provided in the second argument"
},
{
"walkDirectory",
&luascriptfunctions::walkDirectory,
{},
"string [bool, bool]",
"Walks a directory and returns all contents (files and directories) of "
"the directory as absolute paths. The first argument is the path of the "
"directory that should be walked, the second argument determines if the "
"walk is recursive and will continue in contained directories. The third "
"argument determines whether the table that is returned is sorted."
},
{
"walkDirectoryFiles",
&luascriptfunctions::walkDirectoryFiles,
{},
"string [bool, bool]",
"Walks a directory and returns the files of the directory as absolute "
"paths. The first argument is the path of the directory that should be "
"walked, the second argument determines if the walk is recursive and "
"will continue in contained directories. The third argument determines "
"whether the table that is returned is sorted."
},
{
"walkDirectoryFolder",
&luascriptfunctions::walkDirectoryFolder,
{},
"string [bool, bool]",
"Walks a directory and returns the subfolders of the directory as "
"absolute paths. The first argument is the path of the directory that "
"should be walked, the second argument determines if the walk is "
"recursive and will continue in contained directories. The third "
"argument determines whether the table that is returned is sorted."
"printTrace",
&luascriptfunctions::printTrace,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Trace'"
},
{
"printDebug",
&luascriptfunctions::printDebug,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Debug'"
},
{
"printInfo",
&luascriptfunctions::printInfo,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Info'"
},
{
"printWarning",
&luascriptfunctions::printWarning,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Warning'"
},
{
"printError",
&luascriptfunctions::printError,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Error'"
},
{
"printFatal",
&luascriptfunctions::printFatal,
{},
"*",
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Fatal'"
},
{
"absPath",
&luascriptfunctions::absolutePath,
{},
"string",
"Returns the absolute path to the passed path, resolving path tokens as "
"well as resolving relative paths"
},
{
"fileExists",
&luascriptfunctions::fileExists,
{},
"string",
"Checks whether the provided file exists."
},
{
"directoryExists",
&luascriptfunctions::directoryExists,
{},
"string",
"Chckes whether the provided directory exists."
},
{
"setPathToken",
&luascriptfunctions::setPathToken,
{},
"string, string",
"Registers a new path token provided by the first argument to the path "
"provided in the second argument"
},
{
"walkDirectory",
&luascriptfunctions::walkDirectory,
{},
"string [bool, bool]",
"Walks a directory and returns all contents (files and directories) of "
"the directory as absolute paths. The first argument is the path of the "
"directory that should be walked, the second argument determines if the "
"walk is recursive and will continue in contained directories. The third "
"argument determines whether the table that is returned is sorted."
},
{
"walkDirectoryFiles",
&luascriptfunctions::walkDirectoryFiles,
{},
"string [bool, bool]",
"Walks a directory and returns the files of the directory as absolute "
"paths. The first argument is the path of the directory that should be "
"walked, the second argument determines if the walk is recursive and "
"will continue in contained directories. The third argument determines "
"whether the table that is returned is sorted."
},
{
"walkDirectoryFolder",
&luascriptfunctions::walkDirectoryFolder,
{},
"string [bool, bool]",
"Walks a directory and returns the subfolders of the directory as "
"absolute paths. The first argument is the path of the directory that "
"should be walked, the second argument determines if the walk is "
"recursive and will continue in contained directories. The third "
"argument determines whether the table that is returned is sorted."
},
{
"directoryForPath",
&luascriptfunctions::directoryForPath,
{},
"string",
"This function extracts the directory part of the passed path. For example, "
"if the parameter is 'C:/OpenSpace/foobar/foo.txt', this function returns "
"'C:/OpenSpace/foobar'."
}
}
};
@@ -622,8 +635,8 @@ std::string ScriptEngine::generateJson() const {
for (const LuaLibrary::Function& f : l.functions) {
json << "{";
json << "\"name\": \"" << f.name << "\", ";
json << "\"arguments\": \"" << f.argumentText << "\", ";
json << "\"help\": \"" << f.helpText << "\"";
json << "\"arguments\": \"" << escapedJson(f.argumentText) << "\", ";
json << "\"help\": \"" << escapedJson(f.helpText) << "\"";
json << "}";
if (&f != &l.functions.back() || !l.documentations.empty()) {
json << ",";
@@ -633,8 +646,8 @@ std::string ScriptEngine::generateJson() const {
for (const LuaLibrary::Documentation& doc : l.documentations) {
json << "{";
json << "\"name\": \"" << doc.name << "\", ";
json << "\"arguments\": \"" << doc.parameter<< "\", ";
json << "\"help\": \"" << doc.description<< "\"";
json << "\"arguments\": \"" << escapedJson(doc.parameter) << "\", ";
json << "\"help\": \"" << escapedJson(doc.description) << "\"";
json << "}";
if (&doc != &l.documentations.back()) {
json << ",";
@@ -772,5 +785,4 @@ void ScriptEngine::queueScript(const std::string &script, ScriptEngine::RemoteSc
_mutex.unlock();
}
} // namespace scripting
} // namespace openspace
} // namespace openspace::scripting