mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-20 17:51:19 -05:00
Cleanup for coding style
Add strict mode to check_style_guide script
This commit is contained in:
@@ -79,7 +79,7 @@ void ScriptEngine::initializeLuaState(lua_State* state) {
|
||||
LDEBUG("Create openspace base library");
|
||||
lua_newtable(state);
|
||||
lua_setglobal(state, OpenSpaceLibraryName.c_str());
|
||||
|
||||
|
||||
LDEBUG("Add OpenSpace modules");
|
||||
for (LuaLibrary& lib : _registeredLibraries) {
|
||||
registerLuaLibrary(state, lib);
|
||||
@@ -170,10 +170,10 @@ bool ScriptEngine::runScript(const std::string& script) {
|
||||
LERRORC(e.component, e.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ScriptEngine::runScriptFile(const std::string& filename) {
|
||||
if (filename.empty()) {
|
||||
LWARNING("Filename was empty");
|
||||
@@ -183,7 +183,7 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
|
||||
LERROR("Script with name '" << filename << "' did not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
ghoul::lua::runScriptFile(_state, filename);
|
||||
}
|
||||
@@ -195,7 +195,7 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
|
||||
LERRORC(e.component, e.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<scripting::LuaLibrary::Function>::const_iterator funcit;
|
||||
//library was found
|
||||
if (libit != _registeredLibraries.cend()){
|
||||
@@ -222,19 +222,19 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}*/
|
||||
|
||||
|
||||
/*void ScriptEngine::cacheScript(const std::string &library, const std::string &function, const std::string &script){
|
||||
_cachedScriptsMutex.lock();
|
||||
_cachedScripts[library][function] = script;
|
||||
_cachedScriptsMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> ScriptEngine::cachedScripts(){
|
||||
_cachedScriptsMutex.lock();
|
||||
|
||||
|
||||
std::vector<std::string> retVal;
|
||||
std::map<std::string, std::map<std::string, std::string>>::const_iterator outerIt;
|
||||
std::map<std::string, std::string>::const_iterator innerIt;
|
||||
@@ -247,15 +247,15 @@ std::vector<std::string> ScriptEngine::cachedScripts(){
|
||||
retVal.push_back(innerIt->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_cachedScriptsMutex.unlock();
|
||||
|
||||
return retVal;
|
||||
}*/
|
||||
|
||||
|
||||
/*
|
||||
bool ScriptEngine::parseLibraryAndFunctionNames(std::string &library, std::string &function, const std::string &script){
|
||||
|
||||
|
||||
//"deconstruct the script to find library and function name
|
||||
//assuming a script looks like: "openspace.library.function()"
|
||||
//or openspace.funcion()
|
||||
@@ -264,7 +264,7 @@ bool ScriptEngine::parseLibraryAndFunctionNames(std::string &library, std::strin
|
||||
function.clear();
|
||||
//find first "."
|
||||
std::size_t pos = script.find(".");
|
||||
|
||||
|
||||
if (pos != std::string::npos){
|
||||
//strip "openspace."
|
||||
sub = script.substr(pos + 1, script.size());
|
||||
@@ -402,7 +402,7 @@ void ScriptEngine::addLibraryFunctions(lua_State* state, LuaLibrary& library, bo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ScriptEngine::addBaseLibrary() {
|
||||
LuaLibrary lib = {
|
||||
"",
|
||||
@@ -517,7 +517,7 @@ LuaLibrary lib = {
|
||||
};
|
||||
addLibrary(lib);
|
||||
}
|
||||
|
||||
|
||||
void ScriptEngine::remapPrintFunction() {
|
||||
//ghoul::lua::logStack(_state);
|
||||
// lua_getglobal(_state, _luaGlobalNamespace.c_str());
|
||||
@@ -754,7 +754,7 @@ void ScriptEngine::queueScript(const std::string &script, ScriptEngine::RemoteSc
|
||||
if (script.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_mutex.lock();
|
||||
_queuedScripts.insert(_queuedScripts.begin(), std::make_pair(script, remoteScripting));
|
||||
_mutex.unlock();
|
||||
|
||||
@@ -102,7 +102,7 @@ ScriptScheduler::ScheduledScript::ScheduledScript(const ghoul::Dictionary& dicti
|
||||
{
|
||||
std::string timeStr = dictionary.value<std::string>(KeyTime);
|
||||
time = Time::convertTime(timeStr);
|
||||
|
||||
|
||||
// If a universal script is specified, retrieve it and add a ; as a separator so that
|
||||
// it can be added to the other scripts
|
||||
std::string universal;
|
||||
@@ -110,12 +110,12 @@ ScriptScheduler::ScheduledScript::ScheduledScript(const ghoul::Dictionary& dicti
|
||||
if (!universal.empty()) {
|
||||
universal += ";";
|
||||
}
|
||||
|
||||
|
||||
if (dictionary.hasKeyAndValue<std::string>(KeyForwardScript)) {
|
||||
forwardScript =
|
||||
universal + dictionary.value<std::string>(KeyForwardScript);
|
||||
}
|
||||
|
||||
|
||||
if (dictionary.hasKeyAndValue<std::string>(KeyBackwardScript)) {
|
||||
backwardScript =
|
||||
universal + dictionary.value<std::string>(KeyBackwardScript);
|
||||
@@ -129,7 +129,7 @@ void ScriptScheduler::loadScripts(const ghoul::Dictionary& dictionary) {
|
||||
dictionary,
|
||||
"ScriptScheduler"
|
||||
);
|
||||
|
||||
|
||||
// Create all the scheduled script first
|
||||
std::vector<ScheduledScript> scheduledScripts;
|
||||
for (size_t i = 1; i <= dictionary.size(); ++i) {
|
||||
@@ -148,7 +148,7 @@ void ScriptScheduler::loadScripts(const ghoul::Dictionary& dictionary) {
|
||||
return lhs.time < rhs.time;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Move the scheduled scripts into their SOA alignment
|
||||
// For the forward scripts, this is the forwards direction
|
||||
// For the backward scripts, we insert them in the opposite order so that we can still
|
||||
@@ -168,7 +168,7 @@ void ScriptScheduler::loadScripts(const ghoul::Dictionary& dictionary) {
|
||||
double lastTime = _currentTime;
|
||||
rewind();
|
||||
progressTo(lastTime);
|
||||
|
||||
|
||||
ghoul_assert(
|
||||
(_timings.size() == _forwardScripts.size()) &&
|
||||
(_timings.size() == _backwardScripts.size()),
|
||||
@@ -206,14 +206,14 @@ ScriptScheduler::progressTo(double newTime)
|
||||
_timings.end(),
|
||||
newTime
|
||||
);
|
||||
|
||||
|
||||
// How many values did we pass over?
|
||||
ptrdiff_t n = std::distance(_timings.begin() + prevIndex, it);
|
||||
_currentIndex = static_cast<int>(prevIndex + n);
|
||||
|
||||
|
||||
// Update the new time
|
||||
_currentTime = newTime;
|
||||
|
||||
|
||||
return {
|
||||
_forwardScripts.begin() + prevIndex,
|
||||
_forwardScripts.begin() + _currentIndex
|
||||
@@ -228,11 +228,11 @@ ScriptScheduler::progressTo(double newTime)
|
||||
_timings.begin() + prevIndex, // We can stop at the previous time
|
||||
newTime
|
||||
);
|
||||
|
||||
|
||||
// How many values did we pass over?
|
||||
ptrdiff_t n = std::distance(it, _timings.begin() + prevIndex);
|
||||
_currentIndex = static_cast<int>(prevIndex - n);
|
||||
|
||||
|
||||
// Update the new time
|
||||
_currentTime = newTime;
|
||||
|
||||
@@ -254,13 +254,13 @@ std::vector<ScriptScheduler::ScheduledScript> ScriptScheduler::allScripts() cons
|
||||
script.time = _timings[i];
|
||||
script.forwardScript = _forwardScripts[i];
|
||||
script.backwardScript = _backwardScripts[i];
|
||||
|
||||
|
||||
result.push_back(std::move(script));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
LuaLibrary ScriptScheduler::luaLibrary() {
|
||||
LuaLibrary ScriptScheduler::luaLibrary() {
|
||||
return {
|
||||
"scriptScheduler",
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ int loadFile(lua_State* L) {
|
||||
OsEng.scriptScheduler().loadScripts(
|
||||
ghoul::lua::loadDictionaryFromFile(missionFileName, L)
|
||||
);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ int cores(lua_State* L) {
|
||||
lua_pushnumber(L, CpuCap.cores());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int cacheLineSize(lua_State* L) {
|
||||
lua_pushnumber(L, CpuCap.cacheLineSize());
|
||||
return 1;
|
||||
@@ -68,32 +68,31 @@ int L2Associativity(lua_State* L) {
|
||||
lua_pushnumber(L, CpuCap.L2Associativity());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int cacheSize(lua_State* L) {
|
||||
lua_pushnumber(L, CpuCap.cacheSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int extensions(lua_State* L) {
|
||||
lua_pushstring(L, CpuCap.extensions().c_str());
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace luascripting::general
|
||||
|
||||
namespace luascripting::opengl {
|
||||
|
||||
|
||||
int hasOpenGLVersion(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
SCRIPT_CHECK_ARGUMENTS("hasVersion", L, 1, nArguments);
|
||||
|
||||
|
||||
std::vector<std::string> v = ghoul::tokenizeString(luaL_checkstring(L, -1));
|
||||
if (v.size() != 2 && v.size() != 3) {
|
||||
LERRORC("hasVersion", ghoul::lua::errorLocation(L) << "Malformed version string");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
for (const std::string& i : v) {
|
||||
for (char c : i) {
|
||||
if (!std::isdigit(c)) {
|
||||
@@ -102,7 +101,6 @@ int hasOpenGLVersion(lua_State* L) {
|
||||
ghoul::lua::errorLocation(L) << "Malformed version string"
|
||||
);
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,81 +109,80 @@ int hasOpenGLVersion(lua_State* L) {
|
||||
int minor = std::stoi(v[1]);
|
||||
int release = v.size() == 3 ? std::stoi(v[2]) : 0;
|
||||
Version version = { major, minor, release };
|
||||
|
||||
|
||||
bool supported = OpenGLCap.openGLVersion() >= version;
|
||||
|
||||
|
||||
lua_pushboolean(L, supported);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int openGLVersion(lua_State* L) {
|
||||
lua_pushstring(L, std::to_string(OpenGLCap.openGLVersion()).c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int glslCompiler(lua_State* L) {
|
||||
lua_pushstring(L, OpenGLCap.glslCompiler().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int gpuVendor(lua_State* L) {
|
||||
lua_pushstring(L, OpenGLCap.gpuVendorString().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int extensions(lua_State* L) {
|
||||
const std::vector<std::string>& extensions = OpenGLCap.extensions();
|
||||
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
|
||||
for (size_t i = 1; i <= extensions.size(); ++i) {
|
||||
lua_pushstring(L, extensions[i].c_str());
|
||||
lua_rawseti(L, -2, i);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int isExtensionSupported(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
SCRIPT_CHECK_ARGUMENTS("hasVersion", L, 1, nArguments);
|
||||
|
||||
std::string extension = luaL_checkstring(L, -1);
|
||||
|
||||
|
||||
lua_pushboolean(L, OpenGLCap.isExtensionSupported(extension));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int maxTextureUnits(lua_State* L) {
|
||||
lua_pushnumber(L, OpenGLCap.maxTextureUnits());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int max2DTextureSize(lua_State* L) {
|
||||
lua_pushnumber(L, OpenGLCap.max2DTextureSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int max3DTextureSize(lua_State* L) {
|
||||
lua_pushnumber(L, OpenGLCap.max3DTextureSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int maxAtomicCounterBufferBindings(lua_State* L) {
|
||||
lua_pushnumber(L, OpenGLCap.maxAtomicCounterBufferBindings());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int maxShaderStorageBufferBindings(lua_State* L) {
|
||||
lua_pushnumber(L, OpenGLCap.maxShaderStorageBufferBindings());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int maxUniformBufferBindings(lua_State* L) {
|
||||
lua_pushnumber(L, OpenGLCap.maxUniformBufferBindings());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace luascripting::opengl
|
||||
|
||||
@@ -251,7 +248,7 @@ LuaLibrary generalSystemCapabilities() {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
LuaLibrary openglSystemCapabilities() {
|
||||
return {
|
||||
"openglCapabilities",
|
||||
|
||||
Reference in New Issue
Block a user