diff --git a/CMakeLists.txt b/CMakeLists.txt index 2be4412d612884e9ba45b5e3c7b3b7e313e7ac67..95680006dd07e41fdcebe82a2b23dcff951980a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,12 +108,8 @@ target_compile_options(Vivy PRIVATE -Woverloaded-virtual -Wnon-virtual-dtor -Wignored-qualifiers - - -fopenmp ) -target_link_libraries(Vivy PRIVATE -fopenmp) - # Prepare for Qt6 target_compile_definitions(Vivy PRIVATE QT_DISABLE_DEPRECATED_BEFORE=0x050F00 @@ -134,18 +130,15 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") -Wno-c++98-c++11-c++14-c++17-compat-pedantic -Wno-c++20-compat + -Wno-reserved-identifier -Wno-extra-semi-stmt -Wno-redundant-parens -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors ) - target_link_libraries(Vivy PRIVATE - -fopenmp - ) elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") target_compile_options(Vivy PRIVATE - -fopenmp -Wno-subobject-linkage # Kubat: Some proglems here, it seems they # occure because of the usage of "using" for # type aliasing... As I won't get ride of the diff --git a/src/Lib/Script/ScriptOption.cc b/src/Lib/Script/ScriptOption.cc deleted file mode 100644 index 3c855cf7d581f4887bf1a0300b2d96aacddfb29a..0000000000000000000000000000000000000000 --- a/src/Lib/Script/ScriptOption.cc +++ /dev/null @@ -1,63 +0,0 @@ -#include "PreCompiledHeaders.hh" -#include "Lib/Script/ScriptOption.hh" - -// OptionDeclaration -using namespace Vivy::Script; - -ScriptOption::ScriptOption(const std::string &str) noexcept - : string(str) - , type(Type::String) -{ -} - -ScriptOption::ScriptOption(const std::string_view str) noexcept - : string(str) - , type(Type::String) -{ -} - -ScriptOption::ScriptOption(double n) noexcept - : number(n) - , type(Type::Number) -{ -} - -ScriptOption::ScriptOption(bool b) noexcept - : boolean(b) - , type(Type::Boolean) -{ -} - -std::string * -ScriptOption::getString() noexcept -{ - return type == Type::String ? &string : nullptr; -} - -double * -ScriptOption::getNumber() noexcept -{ - return type == Type::Number ? &number : nullptr; -} - -bool * -ScriptOption::getBoolean() noexcept -{ - return type == Type::Boolean ? &boolean : nullptr; -} - -std::string_view -ScriptOption::getSignature() const noexcept -{ - static constexpr std::string_view signatureNumber = "Number"; - static constexpr std::string_view signatureString = "String"; - static constexpr std::string_view signatureBoolean = "Boolean"; - switch (type) { - case Type::String: return signatureString; - case Type::Number: return signatureNumber; - case Type::Boolean: return signatureBoolean; - } - - // Let the program crash - qFatal("UNREACHABLE"); -} diff --git a/src/Lib/Script/ScriptOption.hh b/src/Lib/Script/ScriptOption.hh deleted file mode 100644 index fc3c060732df5883e18e6262e93920d141015682..0000000000000000000000000000000000000000 --- a/src/Lib/Script/ScriptOption.hh +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "PreCompiledHeaders.hh" - -namespace Vivy::Script -{ -// The options -class ScriptOption { - enum class Type { String, Number, Boolean }; - -private: - std::string string; - double number; - bool boolean; - - Type type; - -public: - ScriptOption(const std::string &) noexcept; - ScriptOption(const std::string_view) noexcept; - ScriptOption(bool) noexcept; - ScriptOption(double) noexcept; - - std::string *getString() noexcept; - double *getNumber() noexcept; - bool *getBoolean() noexcept; - - std::string_view getSignature() const noexcept; -}; -} diff --git a/src/Lib/Script/ScriptStore.cc b/src/Lib/Script/ScriptStore.cc index 86a4fdc11661ebc647da8f8cf66ae561468932b5..b3e20da77c39576ac5f7720f40248cfc657db92d 100644 --- a/src/Lib/Script/ScriptStore.cc +++ b/src/Lib/Script/ScriptStore.cc @@ -4,7 +4,6 @@ using namespace Vivy; using namespace std::string_literals; -using Code = Script::LuaContext::Code; ScriptStore::ScriptStore() noexcept { resetLoadedScripts(); } @@ -36,36 +35,19 @@ ScriptStore::getLoadedScripts() const noexcept void ScriptStore::resetLoadedScripts() noexcept { - luaContext.reset(new Script::LuaContext()); + logInfo() << "TODO"; } bool ScriptStore::executeScript(Uuid id) noexcept { - const auto &script = documents.at(id); - return luaContext->loadDocument(script) == Code::Success; + logInfo() << "TODO"; + return false; } bool ScriptStore::executeScript(Uuid id, std::shared_ptr<Vivy::VivyDocument> doc) noexcept { - if (doc == nullptr) - return false; - if (luaContext->loadDocument(doc) != Script::LuaContext::Success) { - luaContext->setFailedWith("A VivyDocument is already loaded, can't attach a new one"); - return false; - } - return executeScript(id); -} - -const std::vector<std::string_view> -ScriptStore::getLoadedModules() const noexcept -{ - return luaContext ? luaContext->getAllModuleName() : std::vector<std::string_view>{}; -} - -const Script::ModuleDeclaration * -ScriptStore::getModule(const std::string_view str) const noexcept -{ - return luaContext->getModule(str); + logInfo() << "TODO"; + return false; } diff --git a/src/Lib/Script/ScriptStore.hh b/src/Lib/Script/ScriptStore.hh index 5311b8ab5db495719ca0851fd1259de759e0bf7e..8e10eabbf3eaa3b04043913d5daed57637d1ec8a 100644 --- a/src/Lib/Script/ScriptStore.hh +++ b/src/Lib/Script/ScriptStore.hh @@ -28,8 +28,6 @@ public: bool executeScript(Uuid) noexcept; bool executeScript(Uuid, std::shared_ptr<Vivy::VivyDocument>) noexcept; - QString getLastLuaError() noexcept; - // Get modules from scripts const std::vector<std::string_view> getLoadedModules() const noexcept; const Script::ModuleDeclaration *getModule(const std::string_view) const noexcept; diff --git a/src/VivyApplication.cc b/src/VivyApplication.cc index f37e95cd229fe8138adfaf10b5ea259dcdd8ff93..2944b0890f1764d25c651b0b48944a4b96c37b3e 100644 --- a/src/VivyApplication.cc +++ b/src/VivyApplication.cc @@ -20,7 +20,7 @@ VivyApplication::VivyApplication(int &argc, char **argv) if (argc >= 2) { for (int i = 1; i < argc; ++i) { - const QString passedFileName(QString::fromUtf8(argv[1])); + const QString passedFileName(QString::fromUtf8(argv[i])); const QFileInfo passedArgumentFile(passedFileName); Utils::DocumentType passedFileType; if (Utils::detectDocumentType(passedArgumentFile, &passedFileType)) { @@ -91,46 +91,25 @@ VivyApplication::exec() noexcept // Cursor blinking setCursorFlashTime(0); - switch (selectedType) { - case ApplicationType::CLI: { - if ((selectedVivyDoc == nullptr) || (selectedScriptDoc == nullptr)) - return 1; - - if (!scriptStore->executeScript(selectedScriptDoc->getUuid(), selectedVivyDoc)) - return 2; - - for (const auto &str : scriptStore->getLoadedModules()) { - std::cout << "Module " << str << " was loaded!\n"; - [[maybe_unused]] const auto *mod = scriptStore->getModule(str); - } - return 0; - } - - case ApplicationType::GUI: { - // Show the main window, also set up the log console - mainWindowPtr = std::make_unique<MainWindow>(); - QDockWidget *logConsoleDock = new QDockWidget("Console", mainWindowPtr.get()); - LogConsole *logConsole = new LogConsole(mainWindowPtr.get()); - std::shared_ptr<ConsoleLogSinkDispatcher> consoleLogSinkDispatcher = - logSink->newDispatcher<ConsoleLogSinkDispatcher>(); - - DockWidgetTitleBar::addToDock(logConsoleDock); - consoleLogSinkDispatcher->attachLogConsole(logConsole); - logConsoleDock->setAllowedAreas(Qt::BottomDockWidgetArea); - logConsoleDock->setFeatures(QDockWidget::DockWidgetMovable); - logConsoleDock->setWidget(logConsole); - mainWindowPtr->addDockWidget(Qt::BottomDockWidgetArea, logConsoleDock); - mainWindowPtr->show(); - - logInfo() << "Entering the main event loop"; - - // Main loop - return QApplication::exec(); - } - } - - logFatal() << "Unreachable: undefined ApplicationType"; - return 1; + // Show the main window, also set up the log console + mainWindowPtr = std::make_unique<MainWindow>(); + QDockWidget *logConsoleDock = new QDockWidget("Console", mainWindowPtr.get()); + LogConsole *logConsole = new LogConsole(mainWindowPtr.get()); + std::shared_ptr<ConsoleLogSinkDispatcher> consoleLogSinkDispatcher = + logSink->newDispatcher<ConsoleLogSinkDispatcher>(); + + DockWidgetTitleBar::addToDock(logConsoleDock); + consoleLogSinkDispatcher->attachLogConsole(logConsole); + logConsoleDock->setAllowedAreas(Qt::BottomDockWidgetArea); + logConsoleDock->setFeatures(QDockWidget::DockWidgetMovable); + logConsoleDock->setWidget(logConsole); + mainWindowPtr->addDockWidget(Qt::BottomDockWidgetArea, logConsoleDock); + mainWindowPtr->show(); + + logInfo() << "Entering the main event loop"; + + // Main loop + return QApplication::exec(); } QFont diff --git a/src/VivyApplication.hh b/src/VivyApplication.hh index d5307b7d7af257ad803cbd07098206a0fd27bcdf..75b1f1d1bbe907bd97fb187c4c023d34ebd8ad63 100644 --- a/src/VivyApplication.hh +++ b/src/VivyApplication.hh @@ -91,7 +91,6 @@ private: std::unique_ptr<Vivy::Theme> qtCreatorThemePtr{ nullptr }; std::unique_ptr<MainWindow> mainWindowPtr{ nullptr }; bool useFakeVim{ false }; - ApplicationType selectedType{ ApplicationType::GUI }; // ApplicationType::CLI Only! std::shared_ptr<ScriptDocument> selectedScriptDoc{ nullptr };