Compare commits

..

No commits in common. 'master' and 'v0.1' have entirely different histories.
master ... v0.1

@ -2,14 +2,13 @@
* @file code.cpp * @file code.cpp
* @brief Functionality for compiling and disassembling source code. * @brief Functionality for compiling and disassembling source code.
* *
* Copyright (C) 2022 Clyne Sullivan * Copyright (C) 2021 Clyne Sullivan
* *
* Distributed under the GNU GPL v3 or later. You should have received a copy of * Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program. * the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
#include "main.hpp"
#include "stmdsp.hpp" #include "stmdsp.hpp"
#include "stmdsp_code.hpp" #include "stmdsp_code.hpp"
@ -21,32 +20,20 @@
#include <string> #include <string>
extern std::shared_ptr<stmdsp::device> m_device; extern std::shared_ptr<stmdsp::device> m_device;
void log(const std::string& str);
// Stores the temporary file name currently used for compiling the algorithm. std::ifstream compileOpenBinaryFile();
static std::string tempFileName; void compileEditorCode(const std::string& code);
void disassembleCode();
/** static std::string tempFileName;
* Generates a new temporary file name.
* @return A string containing the path and file name.
*/
static std::string newTempFileName(); static std::string newTempFileName();
static bool codeExecuteCommand(
/** const std::string& command,
* Executes the given command using system(), collecting the text output in the const std::string& file);
* given file. static void stringReplaceAll(
* @param command The command to be executed. std::string& str,
* @param file The file to write command output to. const std::string& what,
* @return True if the command was successful (i.e. returned zero).
*/
static bool codeExecuteCommand(const std::string& command, const std::string& file);
/**
* Does an in-place replacement of all occurances of "what" with "with".
* @param str The text string to operate on.
* @param what The text to search for.
* @param with The text that will replace occurances of "what".
*/
static void stringReplaceAll(std::string& str, const std::string& what,
const std::string& with); const std::string& with);
std::ifstream compileOpenBinaryFile() std::ifstream compileOpenBinaryFile()

@ -1,39 +0,0 @@
/**
* @file code.hpp
* @brief Functionality for compiling and disassembling source code.
*
* Copyright (C) 2022 Clyne Sullivan
*
* Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef STMDSPGUI_CODE_HPP
#define STMDSPGUI_CODE_HPP
#include <fstream>
#include <istream>
#include <string>
/**
* Attempts to open the most recently created binary file.
* @return An opened stream of the file if it exists, an empty stream otherwise.
*/
std::ifstream compileOpenBinaryFile();
/**
* Attempts to compile the given C++ algorithm code into a binary.
* Errors are reported to the log view.
* @param code The C++ code for the algorithm (usually from the text editor).
*/
void compileEditorCode(const std::string& code);
/**
* Disassembles the most recently compiled binary, outputting the results to
* the log view.
*/
void disassembleCode();
#endif // STMDSPGUI_CODE_HPP

@ -9,7 +9,6 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
#include "code.hpp"
#include "imgui.h" #include "imgui.h"
#include "backends/imgui_impl_sdl.h" #include "backends/imgui_impl_sdl.h"
#include "backends/imgui_impl_opengl2.h" #include "backends/imgui_impl_opengl2.h"
@ -17,6 +16,9 @@
#include <string> #include <string>
extern void compileEditorCode(const std::string& code);
extern void disassembleCode();
TextEditor editor; // file.cpp TextEditor editor; // file.cpp
static std::string editorCompiled; static std::string editorCompiled;

@ -1,14 +1,3 @@
/**
* @file gui_help.cpp
* @brief Defines the "Help" menu and provides its functionality.
*
* Copyright (C) 2022 Clyne Sullivan
*
* Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
#include "imgui.h" #include "imgui.h"
#include "ImGuiFileDialog.h" #include "ImGuiFileDialog.h"

@ -1,19 +0,0 @@
/**
* @file gui_help.hpp
* @brief Defines the "Help" menu and provides its functionality.
*
* Copyright (C) 2022 Clyne Sullivan
*
* Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef STMDSPGUI_GUI_HELP
#define STMDSPGUI_GUI_HELP
void helpRenderMenu();
void helpRenderDialog();
#endif // STMDSPGUI_GUI_HELP

@ -2,7 +2,7 @@
* @file main.cpp * @file main.cpp
* @brief Program entry point and main loop. * @brief Program entry point and main loop.
* *
* Copyright (C) 2022 Clyne Sullivan * Copyright (C) 2021 Clyne Sullivan
* *
* Distributed under the GNU GPL v3 or later. You should have received a copy of * Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program. * the GNU General Public License along with this program.
@ -13,9 +13,7 @@
#include "backends/imgui_impl_sdl.h" #include "backends/imgui_impl_sdl.h"
#include "backends/imgui_impl_opengl2.h" #include "backends/imgui_impl_opengl2.h"
#include "gui_help.hpp"
#include "logview.h" #include "logview.h"
#include "main.hpp"
#include "stmdsp.hpp" #include "stmdsp.hpp"
#include <chrono> #include <chrono>
@ -39,6 +37,10 @@ bool guiInitialize();
bool guiHandleEvents(); bool guiHandleEvents();
void guiShutdown(); void guiShutdown();
void guiRender(); void guiRender();
void helpRenderMenu();
void helpRenderDialog();
void log(const std::string& str);
static LogView logView; static LogView logView;
static ImFont *fontSans = nullptr; static ImFont *fontSans = nullptr;

@ -1,20 +0,0 @@
/**
* @file main.hpp
* @brief Common functions.
*
* Copyright (C) 2022 Clyne Sullivan
*
* Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef STMDSPGUI_MAIN_HPP
#define STMDSPGUI_MAIN_HPP
#include <string>
void log(const std::string& str);
#endif // STMDSPGUI_MAIN_HPP

@ -14,7 +14,6 @@
#include <serial/serial.h> #include <serial/serial.h>
#include <algorithm> #include <algorithm>
#include <array>
extern void log(const std::string& str); extern void log(const std::string& str);

Loading…
Cancel
Save