From 34a8d4eafda508e245ea9e6771ca11d054f18914 Mon Sep 17 00:00:00 2001 From: Ilusha <63184036+IlyaShurupov@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:35:16 -0800 Subject: [PATCH] Adding support for windows and fixing some errors --- Allocators/public/NewPlacement.hpp | 2 ++ Allocators/tests/TestsAll.cpp | 4 +-- CommandLine/private/CmdLineInterpreter.cpp | 4 +-- CommandLine/private/CommandLine.cpp | 4 +-- CommandLine/public/CommandLine.hpp | 3 +- CommandLine/tests/TestCommandLine.cpp | 2 -- CommandLine/tests/TestInterpreter.cpp | 2 -- CommandLine/tests/Tests.cpp | 2 -- Connection/private/LocalConnection.cpp | 4 +-- Connection/tests/TestLocal.cpp | 4 +-- Containers/tests/Buffer2DTest.cpp | 8 ++--- Containers/tests/BufferTest.cpp | 8 ++--- Containers/tests/ListTest.cpp | 14 ++++----- Containers/tests/MapTest.cpp | 14 ++++----- Containers/tests/TreeTest.cpp | 8 ++--- Externals/CMakeLists.txt | 15 ++++++++++ Graphics/CMakeLists.txt | 7 ++--- Graphics/private/bindings/Window.cpp | 2 +- Graphics/public/Keycodes.hpp | 4 +-- LibraryViewer/CMakeLists.txt | 10 +++---- LibraryViewer/applications/Entry.cpp | 2 -- LibraryViewer/private/Player.cpp | 1 - LibraryViewer/private/Streamer.cpp | 2 ++ Math/CMakeLists.txt | 4 +-- Math/private/MathCommon.cpp | 7 ++--- Math/private/Topology.cpp | 2 +- Math/tests/TestCommon.cpp | 2 +- Objects/applications/GUI.h | 2 +- Objects/applications/GUIEntry.cpp | 3 +- Objects/private/compiler/constants.cpp | 3 +- Objects/private/compiler/expression.cpp | 15 +++++----- Objects/private/compiler/function.cpp | 10 +++---- Objects/private/compiler/instruction.cpp | 7 ++--- Objects/private/compiler/statement.cpp | 5 ++-- Objects/private/core/module.cpp | 4 +-- Objects/private/core/object.cpp | 4 +-- Objects/private/core/objectsave.cpp | 3 +- Objects/private/core/scriptsection.cpp | 1 - Objects/private/core/typegroups.cpp | 4 +-- Objects/private/core/typemethods.cpp | 4 +-- Objects/private/interpreter/callstack.cpp | 4 +-- Objects/private/interpreter/interpreter.cpp | 4 +-- Objects/private/interpreter/operandsstack.cpp | 2 -- Objects/private/interpreter/scopestack.cpp | 2 -- Objects/private/primitives/boolobject.cpp | 3 +- Objects/private/primitives/classobject.cpp | 3 -- Objects/private/primitives/colorobject.cpp | 3 +- Objects/private/primitives/dictobject.cpp | 3 -- Objects/private/primitives/enumobject.cpp | 5 +--- Objects/private/primitives/floatobject.cpp | 5 +--- .../private/primitives/interpreterobject.cpp | 4 +-- Objects/private/primitives/intobject.cpp | 6 +--- Objects/private/primitives/linkobject.cpp | 5 +--- Objects/private/primitives/listobject.cpp | 6 +--- Objects/private/primitives/methodobject.cpp | 5 +--- Objects/private/primitives/nullobject.cpp | 5 +--- Objects/private/primitives/stringobject.cpp | 5 +--- Objects/private/primitives/typeobject.cpp | 5 +--- Objects/public/compiler/constants.h | 7 +++-- Objects/public/compiler/expression.h | 2 +- Objects/public/compiler/instruction.h | 7 +++-- Objects/public/parser/parser.h | 4 +-- Objects/tests/Tests.cpp | 3 +- Objects/tests/core/TestCore.cpp | 4 +-- Objects/tests/interpreter/TestInterpreter.cpp | 4 +-- Objects/tests/primitives/TestPrimitives.cpp | 4 +-- Parser/applications/Cfg.cpp | 4 +-- Parser/private/CLR.cpp | 3 +- Parser/private/CfGrammar.cpp | 3 +- Parser/private/CfGrammarParser.cpp | 2 -- Parser/private/Parser.cpp | 2 -- Parser/tests/CLRTests.cpp | 3 +- Parser/tests/GrammarTests.cpp | 3 +- Parser/tests/Tests.cpp | 3 +- RayTracer/applications/Rayt.cpp | 30 ++++++++----------- RayTracer/private/RayTracer.cpp | 9 +++--- Strings/private/Logging.cpp | 4 +-- Strings/tests/TestsStrings.cpp | 4 +-- Strings/tests/TestsStringsLogic.cpp | 4 +-- Tokenizer/public/AutomataGraph.h | 7 ++++- Tokenizer/tests/TestTokenizer.cpp | 5 ++-- Utils/private/Debugging.cpp | 9 ++++++ Utils/private/Testing.cpp | 2 +- Utils/public/Multithreading.hpp | 10 +++---- 84 files changed, 168 insertions(+), 255 deletions(-) diff --git a/Allocators/public/NewPlacement.hpp b/Allocators/public/NewPlacement.hpp index c76af8f..7641add 100644 --- a/Allocators/public/NewPlacement.hpp +++ b/Allocators/public/NewPlacement.hpp @@ -2,5 +2,7 @@ #include "Common.hpp" +#ifndef ENV_OS_WINDOWS inline void* operator new(std::size_t aSize, void* aWhere) noexcept { return aWhere; } inline void* operator new[](std::size_t aSize, void* aWhere) noexcept { return aWhere; } +#endif diff --git a/Allocators/tests/TestsAll.cpp b/Allocators/tests/TestsAll.cpp index e098fa7..a8f2f0e 100644 --- a/Allocators/tests/TestsAll.cpp +++ b/Allocators/tests/TestsAll.cpp @@ -200,7 +200,7 @@ private: } }; -const ualni size = 1000; +const ualni size = 500; template void testAlloc() { @@ -214,7 +214,7 @@ void testAlloc() { TEST_DEF_STATIC(GlobalHeap) { testAlloc(); } -TEST_DEF_STATIC(Heap) { testAlloc(); } +TEST_DEF_STATIC(Heap) { testAlloc(); } TEST_DEF_STATIC(Chunk) { testAlloc>(); diff --git a/CommandLine/private/CmdLineInterpreter.cpp b/CommandLine/private/CmdLineInterpreter.cpp index 3d31ad6..8b9761b 100644 --- a/CommandLine/private/CmdLineInterpreter.cpp +++ b/CommandLine/private/CmdLineInterpreter.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "CmdLineInterpreter.hpp" #define MAX_LINE_LENGTH 1024 @@ -116,4 +114,4 @@ CmdLineInterpreter::~CmdLineInterpreter() { for (auto cmd : mCommands) { delete cmd->val.args; } -} \ No newline at end of file +} diff --git a/CommandLine/private/CommandLine.cpp b/CommandLine/private/CommandLine.cpp index dd112b1..afeeeb9 100644 --- a/CommandLine/private/CommandLine.cpp +++ b/CommandLine/private/CommandLine.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "CommandLine.hpp" using namespace tp; @@ -463,4 +461,4 @@ void CommandLine::help() const { for (auto arg : mArgsOrder) { logArg(*arg.data()); } -} \ No newline at end of file +} diff --git a/CommandLine/public/CommandLine.hpp b/CommandLine/public/CommandLine.hpp index 1d2ff81..e9103e3 100644 --- a/CommandLine/public/CommandLine.hpp +++ b/CommandLine/public/CommandLine.hpp @@ -4,6 +4,7 @@ #include "Map.hpp" #include "Tokenizer.hpp" + namespace tp { extern ModuleManifest gModuleCommandLine; @@ -127,4 +128,4 @@ namespace tp { static void initDefault(Arg& arg); void parseArg(Arg& arg, const char* src); }; -} \ No newline at end of file +} diff --git a/CommandLine/tests/TestCommandLine.cpp b/CommandLine/tests/TestCommandLine.cpp index f74ff8c..18b3b91 100644 --- a/CommandLine/tests/TestCommandLine.cpp +++ b/CommandLine/tests/TestCommandLine.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "Tests.hpp" using namespace tp; diff --git a/CommandLine/tests/TestInterpreter.cpp b/CommandLine/tests/TestInterpreter.cpp index c853cf2..a927d6b 100644 --- a/CommandLine/tests/TestInterpreter.cpp +++ b/CommandLine/tests/TestInterpreter.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "CmdLineInterpreter.hpp" #include "Tests.hpp" diff --git a/CommandLine/tests/Tests.cpp b/CommandLine/tests/Tests.cpp index 45e0203..9cef1ea 100644 --- a/CommandLine/tests/Tests.cpp +++ b/CommandLine/tests/Tests.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "Tests.hpp" int main() { diff --git a/Connection/private/LocalConnection.cpp b/Connection/private/LocalConnection.cpp index 606d7bc..7689181 100644 --- a/Connection/private/LocalConnection.cpp +++ b/Connection/private/LocalConnection.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "LocalConnection.hpp" #include "bindings/Disk.hpp" @@ -84,4 +82,4 @@ LocalConnection::SizeBytes LocalConnection::size() { DEBUG_ASSERT(mStatus.isOpened()); if (!mStatus.isOpened() || !mHandle) return 0; return mHandle->size(); -} \ No newline at end of file +} diff --git a/Connection/tests/TestLocal.cpp b/Connection/tests/TestLocal.cpp index 1fdb4b1..c693a8e 100644 --- a/Connection/tests/TestLocal.cpp +++ b/Connection/tests/TestLocal.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "LocalConnection.hpp" #include "Testing.hpp" @@ -30,4 +28,4 @@ TEST_DEF_STATIC(Simple) { } } -TEST_DEF(LocalConnection) { testSimple(); } \ No newline at end of file +TEST_DEF(LocalConnection) { testSimple(); } diff --git a/Containers/tests/Buffer2DTest.cpp b/Containers/tests/Buffer2DTest.cpp index 7b3de92..54fa270 100644 --- a/Containers/tests/Buffer2DTest.cpp +++ b/Containers/tests/Buffer2DTest.cpp @@ -1,15 +1,15 @@ -#include "NewPlacement.hpp" - #include "Buffer2D.hpp" #include "Testing.hpp" #include "Tests.hpp" +#include "HeapAllocator.hpp" + using namespace tp; const ualni size = 1000; TEST_DEF_STATIC(Simple1) { - Buffer2D buff; + Buffer2D buff; buff.reserve({ 4, 4 }); buff.set({ 2, 2 }, 5); TEST(buff.get({ 2, 2 }) == 5); @@ -22,4 +22,4 @@ TEST_DEF_STATIC(Simple2) { TEST_DEF(Buffer2d) { testSimple1(); testSimple2(); -} \ No newline at end of file +} diff --git a/Containers/tests/BufferTest.cpp b/Containers/tests/BufferTest.cpp index eb3494a..e449b1e 100644 --- a/Containers/tests/BufferTest.cpp +++ b/Containers/tests/BufferTest.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "Buffer.hpp" #include "Testing.hpp" #include "Tests.hpp" @@ -9,7 +7,7 @@ using namespace tp; const ualni size = 1000; TEST_DEF_STATIC(Simple1) { - Buffer buff; + Buffer buff; TEST(buff.size() == 0); for (auto i : Range(size * 10)) { buff.append(TestClass(i)); @@ -21,7 +19,7 @@ TEST_DEF_STATIC(Simple1) { } TEST_DEF_STATIC(Simple2) { - Buffer buff(size); + Buffer buff(size); TEST(buff.size() == size); for (auto i : Range(size * 10)) buff.append(TestClass(i)); @@ -34,4 +32,4 @@ TEST_DEF_STATIC(Simple2) { TEST_DEF(Buffer) { testSimple1(); testSimple2(); -} \ No newline at end of file +} diff --git a/Containers/tests/ListTest.cpp b/Containers/tests/ListTest.cpp index 64801b1..2542ea5 100644 --- a/Containers/tests/ListTest.cpp +++ b/Containers/tests/ListTest.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "Archiver.hpp" #include "Testing.hpp" #include "Tests.hpp" @@ -7,7 +5,7 @@ using namespace tp; TEST_DEF_STATIC(SimpleReference) { - tp::List list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) }; + tp::List list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) }; list.pushBack(TestClass(5)); list.pushFront(TestClass(0)); @@ -24,7 +22,7 @@ TEST_DEF_STATIC(SimpleReference) { } TEST_DEF_STATIC(SimplePointer) { - tp::List list = { new TestClass(1), new TestClass(2), new TestClass(3), new TestClass(4) }; + tp::List list = { new TestClass(1), new TestClass(2), new TestClass(3), new TestClass(4) }; list.pushBack(new TestClass(5)); list.pushFront(new TestClass(0)); @@ -45,8 +43,8 @@ TEST_DEF_STATIC(SimplePointer) { } TEST_DEF_STATIC(Copy) { - tp::List list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) }; - tp::List list2 = list; + tp::List list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) }; + tp::List list2 = list; TEST_EQUAL(list, list2); @@ -55,7 +53,7 @@ TEST_DEF_STATIC(Copy) { } TEST_DEF_STATIC(Serialization) { - tp::List list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) }; + tp::List list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) }; ArchiverExample<1024, false> write; ArchiverExample<1024, true> read; @@ -82,4 +80,4 @@ TEST_DEF(List) { testSimplePointer(); testSimpleReference(); testSerialization(); -} \ No newline at end of file +} diff --git a/Containers/tests/MapTest.cpp b/Containers/tests/MapTest.cpp index b18d8fd..d7dfed8 100644 --- a/Containers/tests/MapTest.cpp +++ b/Containers/tests/MapTest.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "Archiver.hpp" #include "Map.hpp" #include "Testing.hpp" @@ -8,7 +6,7 @@ using namespace tp; TEST_DEF_STATIC(SimpleReference) { - tp::Map map; + tp::Map map; for (auto i : Range(1000, 100000)) { map.put(i, TestClass(i)); @@ -42,7 +40,7 @@ TEST_DEF_STATIC(SimpleReference) { } TEST_DEF_STATIC(SimplePointer) { - tp::Map map; + tp::Map map; for (auto i : Range(1000)) { map.put(i, new TestClass(i)); @@ -80,13 +78,13 @@ TEST_DEF_STATIC(SimplePointer) { } TEST_DEF_STATIC(Copy) { - tp::Map map; + tp::Map map; for (auto i : Range(10)) { map.put(i, TestClass(i)); } - tp::Map map2 = map; + tp::Map map2 = map; TEST_EQUAL(map, map2); @@ -95,7 +93,7 @@ TEST_DEF_STATIC(Copy) { } TEST_DEF_STATIC(SaveLoad) { - tp::Map map; + tp::Map map; for (auto i : Range(10)) { map.put(i, TestClass(i)); @@ -128,4 +126,4 @@ TEST_DEF(Map) { testSimplePointer(); testSimpleReference(); testSaveLoad(); -} \ No newline at end of file +} diff --git a/Containers/tests/TreeTest.cpp b/Containers/tests/TreeTest.cpp index d305eff..1f3097a 100644 --- a/Containers/tests/TreeTest.cpp +++ b/Containers/tests/TreeTest.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "Testing.hpp" #include "Tests.hpp" #include "Tree.hpp" @@ -7,7 +5,7 @@ using namespace tp; TEST_DEF_STATIC(Simple) { - AvlTree, TestClass, HeapAlloc> tree; + AvlTree, TestClass, tp::HeapAlloc> tree; TEST(tree.size() == 0); TEST(tree.head() == nullptr); @@ -24,7 +22,7 @@ TEST_DEF_STATIC(Simple) { } TEST_DEF_STATIC(Persistance) { - AvlTree, TestClass, HeapAlloc> tree; + AvlTree, TestClass, tp::HeapAlloc> tree; const auto size = 1000; @@ -126,4 +124,4 @@ TEST_DEF_STATIC(Persistance) { TEST_DEF(Avl) { testSimple(); testPersistance(); -} \ No newline at end of file +} diff --git a/Externals/CMakeLists.txt b/Externals/CMakeLists.txt index 83c4e95..3542789 100644 --- a/Externals/CMakeLists.txt +++ b/Externals/CMakeLists.txt @@ -1,3 +1,18 @@ +# find_package(ALSA REQUIRED) + +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(CMAKE_PREFIX_PATH "../../ModulesWindowsLibraries/glew-2.1.0") + find_package(GLEW REQUIRED) + set(GLEW_LIB ${GLEW_STATIC_LIBRARY_RELEASE} opengl32.lib PARENT_SCOPE) + + set(PORTAUDIO_INCLUDE_DIR "../../ModulesWindowsLibraries/portaudio/include" PARENT_SCOPE) + set(PORTAUDIO_LIB "../../ModulesWindowsLibraries/portaudio_build/Debug/portaudio" PARENT_SCOPE) +else() + find_package(GLEW REQUIRED) + set(GLEW_LIB ${GLEW_LIBRARIES} GL PARENT_SCOPE) + + set(PORTAUDIO_LIB portaudio PARENT_SCOPE) +endif() #add_subdirectory(glew/build/cmake/) #target_compile_definitions(glew_s PUBLIC GLEW_NO_GLU) diff --git a/Graphics/CMakeLists.txt b/Graphics/CMakeLists.txt index 469e0ee..eabf910 100644 --- a/Graphics/CMakeLists.txt +++ b/Graphics/CMakeLists.txt @@ -1,11 +1,8 @@ project(Graphics) -find_package(GLEW REQUIRED) - ### ---------------------- Externals --------------------- ### -set(BINDINGS_INCLUDE ../Externals/glfw/include ../Externals/glew/include) -set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIBRARIES} GL) - +set(BINDINGS_INCLUDE ../Externals/glfw/include ${GLEW_INCLUDE_DIR}) +set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIB}) ### ---------------------- Static Library --------------------- ### file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp") diff --git a/Graphics/private/bindings/Window.cpp b/Graphics/private/bindings/Window.cpp index 559342d..2f23ca7 100644 --- a/Graphics/private/bindings/Window.cpp +++ b/Graphics/private/bindings/Window.cpp @@ -194,4 +194,4 @@ halnf Window::Events::getScrollY() const { bool Window::Events::isEvent() const { return mContext->inputManager.isEvents(); -} \ No newline at end of file +} diff --git a/Graphics/public/Keycodes.hpp b/Graphics/public/Keycodes.hpp index f42b90d..6e9a39e 100644 --- a/Graphics/public/Keycodes.hpp +++ b/Graphics/public/Keycodes.hpp @@ -65,7 +65,7 @@ namespace tp { TAB = 258, BACKSPACE = 259, INSERT = 260, - DELETE = 261, + DELETE_KEY = 261, RIGHT = 262, LEFT = 263, DOWN = 264, @@ -156,7 +156,7 @@ namespace tp { }; struct KeyEvent { - Keycode code; + Keycode code; enum class EventState { RELEASED = 0, PRESSED = 1, diff --git a/LibraryViewer/CMakeLists.txt b/LibraryViewer/CMakeLists.txt index e86a449..b5c64c4 100644 --- a/LibraryViewer/CMakeLists.txt +++ b/LibraryViewer/CMakeLists.txt @@ -1,11 +1,8 @@ project(LibraryViewer) -find_package(ALSA REQUIRED) -find_package(GLEW REQUIRED) - ### ---------------------- Externals --------------------- ### -set(BINDINGS_INCLUDE ../Externals/glfw/include ../Externals/glew/include) -set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIBRARIES} GL portaudio) +set(BINDINGS_INCLUDE ../Externals/glfw/include ${GLEW_INCLUDE_DIR} ${PORTAUDIO_INCLUDE_DIR}) +set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIB} ${ALSA_LIBRARY} ${PORTAUDIO_LIB}) ### ---------------------- Static Library --------------------- ### file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp") @@ -22,4 +19,5 @@ file(COPY "applications/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAM ### -------------------------- Applications -------------------------- ### add_executable(libView ./applications/Entry.cpp) -target_link_libraries(libView ${PROJECT_NAME} ${ALSA_LIBRARY}) +target_link_libraries(libView ${PROJECT_NAME}) + diff --git a/LibraryViewer/applications/Entry.cpp b/LibraryViewer/applications/Entry.cpp index 19733dc..f769322 100644 --- a/LibraryViewer/applications/Entry.cpp +++ b/LibraryViewer/applications/Entry.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "Player.hpp" #include "GUI.hpp" diff --git a/LibraryViewer/private/Player.cpp b/LibraryViewer/private/Player.cpp index 18c1c4a..4f693f6 100644 --- a/LibraryViewer/private/Player.cpp +++ b/LibraryViewer/private/Player.cpp @@ -1,4 +1,3 @@ -#include "NewPlacement.hpp" #include "Player.hpp" #include "Buffer.hpp" #include "Multithreading.hpp" diff --git a/LibraryViewer/private/Streamer.cpp b/LibraryViewer/private/Streamer.cpp index feac4c7..f1ddcbe 100644 --- a/LibraryViewer/private/Streamer.cpp +++ b/LibraryViewer/private/Streamer.cpp @@ -1,8 +1,10 @@ #include "Streamer.hpp" +#ifndef ENV_OS_WINDOWS typedef u_int8_t uint8_t; typedef u_int16_t uint16_t; typedef u_int32_t uint32_t; +#endif #define DR_FLAC_IMPLEMENTATION #include "dr_flac.h" diff --git a/Math/CMakeLists.txt b/Math/CMakeLists.txt index e86d6b4..1b981f2 100644 --- a/Math/CMakeLists.txt +++ b/Math/CMakeLists.txt @@ -5,11 +5,11 @@ file(GLOB SOURCES "./private/*.cpp") file(GLOB HEADERS "./public/*.hpp") add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) target_include_directories(${PROJECT_NAME} PUBLIC ./public/) -target_link_libraries(${PROJECT_NAME} PUBLIC Utils) +target_link_libraries(${PROJECT_NAME} PUBLIC Allocators) ### -------------------------- Tests -------------------------- ### enable_testing() file(GLOB TEST_SOURCES "./tests/*.cpp") add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} Utils) -add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) \ No newline at end of file +add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) diff --git a/Math/private/MathCommon.cpp b/Math/private/MathCommon.cpp index 623e279..405c761 100644 --- a/Math/private/MathCommon.cpp +++ b/Math/private/MathCommon.cpp @@ -2,10 +2,9 @@ /// whoaoao wtf #include "MathCommon.hpp" +#include "Allocators.hpp" -#include "ContainersCommon.hpp" - -static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleContainers, nullptr }; +static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleAllocators, nullptr }; tp::ModuleManifest tp::gModuleMath = ModuleManifest("Math", nullptr, nullptr, sModuleDependencies); @@ -42,4 +41,4 @@ tp::alnf std_rad(const tp::alnf val) { return val * (PI / 180.f); } tp::alnf std_deg(const tp::alnf val) { return val * (180.f / PI); } tp::alnf std_atan2(const tp::alnf X, const tp::alnf Y) { return atan2((tp::halnf) X, (tp::halnf) Y); } tp::alnf std_atan(const tp::alnf val) { return atan((tp::halnf) val); } -tp::alnf std_log2(const tp::alnf val) { return log2((tp::halnf) val); } \ No newline at end of file +tp::alnf std_log2(const tp::alnf val) { return log2((tp::halnf) val); } diff --git a/Math/private/Topology.cpp b/Math/private/Topology.cpp index 592f9c7..336a5a6 100644 --- a/Math/private/Topology.cpp +++ b/Math/private/Topology.cpp @@ -1,7 +1,7 @@ #include "Topology.hpp" -void* operator new(std::size_t, void* in) { return in; } +#include "NewPlacement.hpp" using namespace tp; diff --git a/Math/tests/TestCommon.cpp b/Math/tests/TestCommon.cpp index ba0946d..e712f74 100644 --- a/Math/tests/TestCommon.cpp +++ b/Math/tests/TestCommon.cpp @@ -6,7 +6,7 @@ using namespace tp; TEST_DEF(ComplexNumber) { TEST((ComplexCart{ 3, 4 }.mod() == 5)); - TEST((ComplexCart{ 1, 1 }.arg() == 0.7853981633974483)); + TEST((abs(ComplexCart{ 1, 1 }.arg() - 0.7853981633974483) < 0.001)); TEST((ComplexCart{ 3, 4 }.norm2() == 25)); { diff --git a/Objects/applications/GUI.h b/Objects/applications/GUI.h index 6297db6..a206a70 100644 --- a/Objects/applications/GUI.h +++ b/Objects/applications/GUI.h @@ -6,7 +6,7 @@ #include "compiler/function.h" -#include "strings.h" +#include "Strings.hpp" namespace obj { diff --git a/Objects/applications/GUIEntry.cpp b/Objects/applications/GUIEntry.cpp index b96d0b5..aecd300 100644 --- a/Objects/applications/GUIEntry.cpp +++ b/Objects/applications/GUIEntry.cpp @@ -1,5 +1,4 @@ -#include "NewPlacement.hpp" #include "Window.hpp" #include "GUI.h" @@ -45,4 +44,4 @@ int main() { } return 0; -} \ No newline at end of file +} diff --git a/Objects/private/compiler/constants.cpp b/Objects/private/compiler/constants.cpp index 6de7e67..5c7100a 100644 --- a/Objects/private/compiler/constants.cpp +++ b/Objects/private/compiler/constants.cpp @@ -1,5 +1,4 @@ #include "compiler/constants.h" -#include "NewPlacement.hpp" #include "primitives/methodobject.h" #include "primitives/primitives.h" @@ -142,4 +141,4 @@ void ConstObjectsPool::save(tp::Buffer& out) { mBoolTrue.mConstIdx = data_idx; } mDelete = false; -} \ No newline at end of file +} diff --git a/Objects/private/compiler/expression.cpp b/Objects/private/compiler/expression.cpp index a11c81d..2701a5b 100644 --- a/Objects/private/compiler/expression.cpp +++ b/Objects/private/compiler/expression.cpp @@ -1,5 +1,4 @@ #include "compiler/expression.h" -#include "NewPlacement.hpp" using namespace obj; using namespace BCgen; @@ -64,30 +63,30 @@ ExpressionFunc::ExpressionFunc(tp::String id) : Expression(Type::FUNC), mFuncId(id) {} ExpressionConst::ExpressionConst(tp::String val) : - Expression(Type::CONST), + Expression(Type::CONST_EXPR), mConstType(STR), str(val) {} ExpressionConst::ExpressionConst(const char* val) : - Expression(Type::CONST), + Expression(Type::CONST_EXPR), mConstType(STR), str(val) {} ExpressionConst::ExpressionConst(tp::int4 val) : - Expression(Type::CONST), + Expression(Type::CONST_EXPR), mConstType(INT), integer(val) {} ExpressionConst::ExpressionConst(tp::flt4 val) : - Expression(Type::CONST), + Expression(Type::CONST_EXPR), mConstType(FLT), floating(val) {} ExpressionConst::ExpressionConst(tp::alni val) : - Expression(Type::CONST), + Expression(Type::CONST_EXPR), mConstType(INT), integer(val) {} ExpressionConst::ExpressionConst(tp::alnf val) : - Expression(Type::CONST), + Expression(Type::CONST_EXPR), mConstType(FLT), floating(val) {} ExpressionConst::ExpressionConst(bool val) : - Expression(Type::CONST), + Expression(Type::CONST_EXPR), mConstType(BOOL), boolean(val) {} diff --git a/Objects/private/compiler/function.cpp b/Objects/private/compiler/function.cpp index 6cb85ae..9e5a6a6 100644 --- a/Objects/private/compiler/function.cpp +++ b/Objects/private/compiler/function.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "compiler/function.h" #include "primitives/methodobject.h" @@ -305,7 +303,7 @@ void FunctionDefinition::EvalExpr(Expression* expr) { inst(Instruction(OpCode::LOAD_LOCAL, mConstants.get(local->mLocalId))); break; } - case Expression::Type::CONST: + case Expression::Type::CONST_EXPR: { auto constobj = (ExpressionConst*) expr; switch (constobj->mConstType) { @@ -384,7 +382,7 @@ tp::alni instSize(const Instruction& inst) { out += inst.mParamBytes; return out; } - case Instruction::ArgType::CONST: + case Instruction::ArgType::CONST_ARG: { out += 2; if (inst.mConstData2) { @@ -516,7 +514,7 @@ void FunctionDefinition::generateByteCode(ByteCode& out) { writeParam(out, idx, (tp::int1*) &inst.mParam, inst.mParamBytes); break; } - case Instruction::ArgType::CONST: + case Instruction::ArgType::CONST_ARG: { writeConst(out, idx, (tp::uint2) inst.mConstData->mConstIdx); if (inst.mConstData2) { @@ -594,4 +592,4 @@ bool obj::BCgen::Compile(obj::MethodObject* method) { delete res.scope; return true; -} \ No newline at end of file +} diff --git a/Objects/private/compiler/instruction.cpp b/Objects/private/compiler/instruction.cpp index f82760a..ae9bc59 100644 --- a/Objects/private/compiler/instruction.cpp +++ b/Objects/private/compiler/instruction.cpp @@ -1,6 +1,5 @@ #include "compiler/instruction.h" -#include "NewPlacement.hpp" using namespace obj; using namespace tp; @@ -21,14 +20,14 @@ Instruction::Instruction(ConstObject* constData) : Instruction::Instruction(OpCode op, ConstObject* constData) : mOp(op), mConstData(constData), - mArgType(ArgType::CONST), + mArgType(ArgType::CONST_ARG), mInstType(InstType::EXEC) {} Instruction::Instruction(OpCode op, ConstObject* constData, ConstObject* constData2) : mOp(op), mConstData(constData), mConstData2(constData2), - mArgType(ArgType::CONST), + mArgType(ArgType::CONST_ARG), mInstType(InstType::EXEC) {} Instruction::Instruction(OpCode op, tp::alni param, tp::alni nBytes) : @@ -41,4 +40,4 @@ Instruction::Instruction(OpCode op, tp::alni param, tp::alni nBytes) : Instruction::Instruction(Instruction* inst, InstType jump_type) : mInstTarget(inst) { mInstType = jump_type; -} \ No newline at end of file +} diff --git a/Objects/private/compiler/statement.cpp b/Objects/private/compiler/statement.cpp index 67fcb60..572e7a6 100644 --- a/Objects/private/compiler/statement.cpp +++ b/Objects/private/compiler/statement.cpp @@ -1,5 +1,4 @@ #include "compiler/statement.h" -#include "NewPlacement.hpp" using namespace obj; using namespace BCgen; @@ -76,7 +75,7 @@ StatementClassDef::StatementClassDef(tp::String class_id, StatementScope* scope) StatementFuncDef* obj::BCgen::StmDefFunc(tp::String id, tp::InitialierList args, tp::InitialierList stms) { return new StatementFuncDef(id, args, stms); } StatementLocalDef* obj::BCgen::StmDefLocal(tp::String id, Expression* value) { - if (value->mType == Expression::Type::CONST) { + if (value->mType == Expression::Type::CONST_EXPR) { return new StatementLocalDef(id, (ExpressionConst*) value); } @@ -99,4 +98,4 @@ StatementWhile* obj::BCgen::StmWhile(Expression* condition, StatementScope* scop StatementIgnore* obj::BCgen::StmIgnore(Expression* expr) { return new StatementIgnore(expr); } -StatementClassDef* obj::BCgen::StmClassDef(tp::String id, StatementScope* scope) { return new StatementClassDef(id, scope); } \ No newline at end of file +StatementClassDef* obj::BCgen::StmClassDef(tp::String id, StatementScope* scope) { return new StatementClassDef(id, scope); } diff --git a/Objects/private/core/module.cpp b/Objects/private/core/module.cpp index 538f87f..70d6dc1 100644 --- a/Objects/private/core/module.cpp +++ b/Objects/private/core/module.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "Tokenizer.hpp" #include "compiler/function.h" @@ -88,4 +86,4 @@ static tp::ModuleManifest* sModuleDependencies[] = { NULL }; -tp::ModuleManifest obj::gModuleObjects = tp::ModuleManifest("Objects", init, deinit, sModuleDependencies); \ No newline at end of file +tp::ModuleManifest obj::gModuleObjects = tp::ModuleManifest("Objects", init, deinit, sModuleDependencies); diff --git a/Objects/private/core/object.cpp b/Objects/private/core/object.cpp index a78e69b..ba3816f 100644 --- a/Objects/private/core/object.cpp +++ b/Objects/private/core/object.cpp @@ -1,7 +1,5 @@ -#include "NewPlacement.hpp" - #include "core/object.h" #include "primitives/classobject.h" @@ -224,4 +222,4 @@ namespace obj { } return NULL; } -}; \ No newline at end of file +}; diff --git a/Objects/private/core/objectsave.cpp b/Objects/private/core/objectsave.cpp index 7d2cf8f..5563fb0 100644 --- a/Objects/private/core/objectsave.cpp +++ b/Objects/private/core/objectsave.cpp @@ -1,6 +1,5 @@ -#include "NewPlacement.hpp" #include "core/object.h" #include "primitives/nullobject.h" @@ -432,4 +431,4 @@ namespace obj { sl_callbacks[sl_callbacks_load_idx] = in; sl_callbacks_load_idx++; } -}; \ No newline at end of file +}; diff --git a/Objects/private/core/scriptsection.cpp b/Objects/private/core/scriptsection.cpp index f5f10c3..e9f6447 100644 --- a/Objects/private/core/scriptsection.cpp +++ b/Objects/private/core/scriptsection.cpp @@ -1,6 +1,5 @@ #include "HeapAllocatorGlobal.hpp" -#include "NewPlacement.hpp" #include "core/scriptsection.h" diff --git a/Objects/private/core/typegroups.cpp b/Objects/private/core/typegroups.cpp index 0ce1589..2c89f24 100644 --- a/Objects/private/core/typegroups.cpp +++ b/Objects/private/core/typegroups.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "core/typegroups.h" #include "core/object.h" @@ -80,4 +78,4 @@ obj::TypeGroups::~TypeGroups() { } childs.~Map(); } -} \ No newline at end of file +} diff --git a/Objects/private/core/typemethods.cpp b/Objects/private/core/typemethods.cpp index b7f45ed..57d728b 100644 --- a/Objects/private/core/typemethods.cpp +++ b/Objects/private/core/typemethods.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "core/typemethods.h" #include "primitives/floatobject.h" @@ -131,4 +129,4 @@ void TypeMethod::init() { while (args[mNargs].descr) { mNargs++; } -} \ No newline at end of file +} diff --git a/Objects/private/interpreter/callstack.cpp b/Objects/private/interpreter/callstack.cpp index 4a68cb0..bb9817d 100644 --- a/Objects/private/interpreter/callstack.cpp +++ b/Objects/private/interpreter/callstack.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "interpreter/callstack.h" #include "interpreter/bytecode.h" @@ -33,4 +31,4 @@ void CallStack::leave() { ByteCode* CallStack::getBytecode() { return &mStack.last().mMethod->mScript->mBytecode; } -tp::halni CallStack::len() const { return mStack.size(); } \ No newline at end of file +tp::halni CallStack::len() const { return mStack.size(); } diff --git a/Objects/private/interpreter/interpreter.cpp b/Objects/private/interpreter/interpreter.cpp index 83a1f9e..92fe87d 100644 --- a/Objects/private/interpreter/interpreter.cpp +++ b/Objects/private/interpreter/interpreter.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "interpreter/interpreter.h" #include "primitives/primitives.h" @@ -606,4 +604,4 @@ void Interpreter::execAll(obj::MethodObject* method, obj::ClassObject* self, obj while (!finished()) { stepBytecodeIn(); } -} \ No newline at end of file +} diff --git a/Objects/private/interpreter/operandsstack.cpp b/Objects/private/interpreter/operandsstack.cpp index e4de0a2..eccd5a3 100644 --- a/Objects/private/interpreter/operandsstack.cpp +++ b/Objects/private/interpreter/operandsstack.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "interpreter/operandsstack.h" using namespace obj; diff --git a/Objects/private/interpreter/scopestack.cpp b/Objects/private/interpreter/scopestack.cpp index cdffaee..33a40d7 100644 --- a/Objects/private/interpreter/scopestack.cpp +++ b/Objects/private/interpreter/scopestack.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "interpreter/scopestack.h" using namespace obj; diff --git a/Objects/private/primitives/boolobject.cpp b/Objects/private/primitives/boolobject.cpp index 72c8380..4521502 100644 --- a/Objects/private/primitives/boolobject.cpp +++ b/Objects/private/primitives/boolobject.cpp @@ -1,7 +1,6 @@ #include "primitives/boolobject.h" -#include "NewPlacement.hpp" using namespace obj; using namespace tp; @@ -53,4 +52,4 @@ struct obj::ObjectType obj::BoolObject::TypeData = { .save_size = (object_save_size) save_size, .save = (object_save) save, .load = (object_load) load, -}; \ No newline at end of file +}; diff --git a/Objects/private/primitives/classobject.cpp b/Objects/private/primitives/classobject.cpp index d755046..87f8d77 100644 --- a/Objects/private/primitives/classobject.cpp +++ b/Objects/private/primitives/classobject.cpp @@ -1,6 +1,3 @@ -#pragma once - -#include "NewPlacement.hpp" #include "primitives/classobject.h" #include "primitives/dictobject.h" diff --git a/Objects/private/primitives/colorobject.cpp b/Objects/private/primitives/colorobject.cpp index e315542..a9bab7f 100644 --- a/Objects/private/primitives/colorobject.cpp +++ b/Objects/private/primitives/colorobject.cpp @@ -1,6 +1,5 @@ #include "primitives/colorobject.h" -#include "NewPlacement.hpp" using namespace obj; using namespace tp; @@ -63,4 +62,4 @@ struct obj::ObjectType obj::ColorObject::TypeData = { .save_size = (object_save_size) save_size, .save = (object_save) save, .load = (object_load) load, -}; \ No newline at end of file +}; diff --git a/Objects/private/primitives/dictobject.cpp b/Objects/private/primitives/dictobject.cpp index f91b012..6af7a9a 100644 --- a/Objects/private/primitives/dictobject.cpp +++ b/Objects/private/primitives/dictobject.cpp @@ -1,6 +1,3 @@ -#pragma once - -#include "NewPlacement.hpp" #include "primitives/dictobject.h" #include "primitives/stringobject.h" diff --git a/Objects/private/primitives/enumobject.cpp b/Objects/private/primitives/enumobject.cpp index cc22388..4e0d3bc 100644 --- a/Objects/private/primitives/enumobject.cpp +++ b/Objects/private/primitives/enumobject.cpp @@ -1,8 +1,5 @@ -#pragma once - #include "primitives/enumobject.h" -#include "NewPlacement.hpp" #include @@ -174,4 +171,4 @@ struct obj::ObjectType obj::EnumObject::TypeData = { .load = (object_load) load, .comparison = (object_compare) EnumObject::compare, .allocated_size = (object_allocated_size) allocated_size, -}; \ No newline at end of file +}; diff --git a/Objects/private/primitives/floatobject.cpp b/Objects/private/primitives/floatobject.cpp index 8428ab4..e49a0b0 100644 --- a/Objects/private/primitives/floatobject.cpp +++ b/Objects/private/primitives/floatobject.cpp @@ -1,7 +1,4 @@ -#pragma once - #include "primitives/floatobject.h" -#include "NewPlacement.hpp" using namespace obj; using namespace tp; @@ -69,4 +66,4 @@ struct obj::ObjectType obj::FloatObject::TypeData = { .save_size = (object_save_size) save_size, .save = (object_save) save, .load = (object_load) load, -}; \ No newline at end of file +}; diff --git a/Objects/private/primitives/interpreterobject.cpp b/Objects/private/primitives/interpreterobject.cpp index 4d2518b..85e1771 100644 --- a/Objects/private/primitives/interpreterobject.cpp +++ b/Objects/private/primitives/interpreterobject.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "primitives/interpreterobject.h" #include "primitives/linkobject.h" #include "primitives/methodobject.h" @@ -75,4 +73,4 @@ struct obj::ObjectType InterpreterObject::TypeData = { .size = sizeof(InterpreterObject), .name = "interpreter", .load = (object_load) InterpreterObject::load, -}; \ No newline at end of file +}; diff --git a/Objects/private/primitives/intobject.cpp b/Objects/private/primitives/intobject.cpp index 5956b2b..a01192b 100644 --- a/Objects/private/primitives/intobject.cpp +++ b/Objects/private/primitives/intobject.cpp @@ -1,8 +1,4 @@ -#pragma once - -#include "NewPlacement.hpp" - #include "primitives/intobject.h" using namespace obj; @@ -71,4 +67,4 @@ struct obj::ObjectType obj::IntObject::TypeData = { .save_size = (object_save_size) save_size, .save = (object_save) save, .load = (object_load) load, -}; \ No newline at end of file +}; diff --git a/Objects/private/primitives/linkobject.cpp b/Objects/private/primitives/linkobject.cpp index 7c51e11..e96c29d 100644 --- a/Objects/private/primitives/linkobject.cpp +++ b/Objects/private/primitives/linkobject.cpp @@ -1,8 +1,5 @@ -#pragma once - #include "primitives/linkobject.h" -#include "NewPlacement.hpp" using namespace obj; using namespace tp; @@ -106,4 +103,4 @@ struct obj::ObjectType LinkObject::TypeData = { .base = NULL, .type_methods = { .methods = { &tm_set, &tm_get, - } } }; \ No newline at end of file + } } }; diff --git a/Objects/private/primitives/listobject.cpp b/Objects/private/primitives/listobject.cpp index 8e5869c..8624302 100644 --- a/Objects/private/primitives/listobject.cpp +++ b/Objects/private/primitives/listobject.cpp @@ -1,8 +1,4 @@ -#pragma once - -#include "NewPlacement.hpp" - #include "primitives/intobject.h" #include "primitives/listobject.h" @@ -130,4 +126,4 @@ struct obj::ObjectType obj::ListObject::TypeData = { .base = NULL, .load = (object_load) load, .childs_retrival = (object_debug_all_childs_retrival) childs_retrival, .allocated_size = (object_allocated_size) allocated_size, - .allocated_size_recursive = (object_allocated_size_recursive) allocated_size_recursive }; \ No newline at end of file + .allocated_size_recursive = (object_allocated_size_recursive) allocated_size_recursive }; diff --git a/Objects/private/primitives/methodobject.cpp b/Objects/private/primitives/methodobject.cpp index e0af945..b845995 100644 --- a/Objects/private/primitives/methodobject.cpp +++ b/Objects/private/primitives/methodobject.cpp @@ -1,6 +1,3 @@ -#pragma once - -#include "NewPlacement.hpp" #include "compiler/function.h" #include "core/scriptsection.h" @@ -62,4 +59,4 @@ MethodObject* MethodObject::create(tp::String script) { out->mScript->mReadable->val = script; out->compile(); return out; -} \ No newline at end of file +} diff --git a/Objects/private/primitives/nullobject.cpp b/Objects/private/primitives/nullobject.cpp index d1f09c6..019ff71 100644 --- a/Objects/private/primitives/nullobject.cpp +++ b/Objects/private/primitives/nullobject.cpp @@ -1,7 +1,4 @@ -#pragma once - -#include "NewPlacement.hpp" #include "primitives/nullobject.h" @@ -47,4 +44,4 @@ struct ObjectType NullObject::TypeData = { .size = sizeof(NullObject), .name = "null", .convesions = &NullObjectTypeConversions, -}; \ No newline at end of file +}; diff --git a/Objects/private/primitives/stringobject.cpp b/Objects/private/primitives/stringobject.cpp index 941506a..72e55f0 100644 --- a/Objects/private/primitives/stringobject.cpp +++ b/Objects/private/primitives/stringobject.cpp @@ -1,7 +1,4 @@ -#pragma once - -#include "NewPlacement.hpp" #include "primitives/stringobject.h" @@ -75,4 +72,4 @@ struct obj::ObjectType StringObject::TypeData = { .load = (object_load) load, .comparison = (object_compare) compare_strings, .allocated_size = (object_allocated_size) allocated_size, -}; \ No newline at end of file +}; diff --git a/Objects/private/primitives/typeobject.cpp b/Objects/private/primitives/typeobject.cpp index 9e84fe5..c91a5c7 100644 --- a/Objects/private/primitives/typeobject.cpp +++ b/Objects/private/primitives/typeobject.cpp @@ -1,8 +1,5 @@ -#pragma once - #include "primitives/typeobject.h" -#include "NewPlacement.hpp" #include "primitives/nullobject.h" using namespace obj; @@ -69,4 +66,4 @@ struct obj::ObjectType TypeObject::TypeData = { .load = (object_load) load, .comparison = (object_compare) comparator, .allocated_size = (object_allocated_size) allocated_size, -}; \ No newline at end of file +}; diff --git a/Objects/public/compiler/constants.h b/Objects/public/compiler/constants.h index 5a95697..5c8d32b 100644 --- a/Objects/public/compiler/constants.h +++ b/Objects/public/compiler/constants.h @@ -7,7 +7,8 @@ namespace obj { namespace BCgen { - struct ConstObject { + class ConstObject { + public: obj::Object* mObj = NULL; tp::alni mConstIdx = 0; @@ -16,7 +17,8 @@ namespace obj { }; - struct ConstObjectsPool { + class ConstObjectsPool { + public: tp::Map mMethods; tp::Map mStrings; tp::Map mIntegers; @@ -36,6 +38,7 @@ namespace obj { ConstObject* registerObject(obj::Object* obj); void save(tp::Buffer& out); + ConstObjectsPool() = default; ~ConstObjectsPool(); }; }; diff --git a/Objects/public/compiler/expression.h b/Objects/public/compiler/expression.h index 3e71c73..424a9be 100644 --- a/Objects/public/compiler/expression.h +++ b/Objects/public/compiler/expression.h @@ -18,7 +18,7 @@ namespace obj { NONE, NEW, LOCAL, - CONST, + CONST_EXPR, CHILD, CALL, ARIPHM, diff --git a/Objects/public/compiler/instruction.h b/Objects/public/compiler/instruction.h index 26f142d..8d2b370 100644 --- a/Objects/public/compiler/instruction.h +++ b/Objects/public/compiler/instruction.h @@ -10,16 +10,17 @@ namespace obj { namespace BCgen { - struct ConstObject; + class ConstObject; - struct Instruction { + class Instruction { + public: OpCode mOp = OpCode::NONE; enum class ArgType : tp::ualni { NO_ARG, PARAM, - CONST, + CONST_ARG, } mArgType = ArgType::NO_ARG; enum class InstType : tp::ualni { diff --git a/Objects/public/parser/parser.h b/Objects/public/parser/parser.h index dba98fb..ea55a49 100644 --- a/Objects/public/parser/parser.h +++ b/Objects/public/parser/parser.h @@ -1,5 +1,5 @@ #pragma once -#include "NewPlacement.hpp" + #include "compiler/statement.h" #include "compiler/expression.h" @@ -192,4 +192,4 @@ namespace obj { BCgen::StatementScope* parseScope(bool aPushToScopeStack); }; -}; \ No newline at end of file +}; diff --git a/Objects/tests/Tests.cpp b/Objects/tests/Tests.cpp index e5e07bb..2b8906c 100644 --- a/Objects/tests/Tests.cpp +++ b/Objects/tests/Tests.cpp @@ -1,5 +1,4 @@ -#include "NewPlacement.hpp" #include "Testing.hpp" #include "primitives/primitives.h" @@ -32,4 +31,4 @@ int main() { } return 0; -} \ No newline at end of file +} diff --git a/Objects/tests/core/TestCore.cpp b/Objects/tests/core/TestCore.cpp index 7816e62..d7a815b 100644 --- a/Objects/tests/core/TestCore.cpp +++ b/Objects/tests/core/TestCore.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "Testing.hpp" #include "core/object.h" @@ -30,4 +28,4 @@ TEST_DEF_STATIC(BasicAPI) { NDO->destroy(savedInt); } -TEST_DEF(Core) { testBasicAPI(); } \ No newline at end of file +TEST_DEF(Core) { testBasicAPI(); } diff --git a/Objects/tests/interpreter/TestInterpreter.cpp b/Objects/tests/interpreter/TestInterpreter.cpp index c23929e..afbfdc2 100644 --- a/Objects/tests/interpreter/TestInterpreter.cpp +++ b/Objects/tests/interpreter/TestInterpreter.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "Testing.hpp" #include "compiler/function.h" @@ -84,4 +82,4 @@ TEST_DEF_STATIC(Simple) { TEST_DEF(Interpreter) { testSimple(); // testComplex(); -} \ No newline at end of file +} diff --git a/Objects/tests/primitives/TestPrimitives.cpp b/Objects/tests/primitives/TestPrimitives.cpp index 1eacf6e..1cc9c65 100644 --- a/Objects/tests/primitives/TestPrimitives.cpp +++ b/Objects/tests/primitives/TestPrimitives.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "Testing.hpp" #include "core/object.h" @@ -30,4 +28,4 @@ TEST_DEF_STATIC(Dict) { NDO->destroy(dictLoaded); } -TEST_DEF(Primitives) { testDict(); } \ No newline at end of file +TEST_DEF(Primitives) { testDict(); } diff --git a/Parser/applications/Cfg.cpp b/Parser/applications/Cfg.cpp index 2aca37b..5a2950c 100644 --- a/Parser/applications/Cfg.cpp +++ b/Parser/applications/Cfg.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "CommandLine.hpp" #include "Parser.hpp" @@ -81,4 +79,4 @@ int main(int argc, const char* argv[]) { testModule.deinitialize(); return 0; -} \ No newline at end of file +} diff --git a/Parser/private/CLR.cpp b/Parser/private/CLR.cpp index 7625b8b..d0aefa7 100644 --- a/Parser/private/CLR.cpp +++ b/Parser/private/CLR.cpp @@ -1,5 +1,4 @@ #include "CLR.hpp" -#include "NewPlacement.hpp" using namespace tp; @@ -17,4 +16,4 @@ void CLR::setTerminal(const String& name, TerminalStream::TerminalID id) {} void CLR::build() {} -void CLR::parse(TerminalStream* source, List& out, ASTNode** root) { *root = nullptr; } \ No newline at end of file +void CLR::parse(TerminalStream* source, List& out, ASTNode** root) { *root = nullptr; } diff --git a/Parser/private/CfGrammar.cpp b/Parser/private/CfGrammar.cpp index bfc3d64..b0b02b9 100644 --- a/Parser/private/CfGrammar.cpp +++ b/Parser/private/CfGrammar.cpp @@ -1,6 +1,5 @@ #include "CfGrammar.hpp" -#include "NewPlacement.hpp" #include "Timing.hpp" @@ -159,4 +158,4 @@ bool CfGrammar::compile() { } return true; -} \ No newline at end of file +} diff --git a/Parser/private/CfGrammarParser.cpp b/Parser/private/CfGrammarParser.cpp index 04d5c00..162a080 100644 --- a/Parser/private/CfGrammarParser.cpp +++ b/Parser/private/CfGrammarParser.cpp @@ -1,6 +1,4 @@ -#include "NewPlacement.hpp" - #include "CfGrammar.hpp" #include "Tokenizer.hpp" diff --git a/Parser/private/Parser.cpp b/Parser/private/Parser.cpp index e292312..2720e52 100644 --- a/Parser/private/Parser.cpp +++ b/Parser/private/Parser.cpp @@ -1,6 +1,4 @@ #include "Parser.hpp" -#include "NewPlacement.hpp" - #include "Tokenizer.hpp" using namespace tp; diff --git a/Parser/tests/CLRTests.cpp b/Parser/tests/CLRTests.cpp index 60708a8..79aabd2 100644 --- a/Parser/tests/CLRTests.cpp +++ b/Parser/tests/CLRTests.cpp @@ -1,5 +1,4 @@ -#include "NewPlacement.hpp" #include "Parser.hpp" #include "Testing.hpp" @@ -7,4 +6,4 @@ using namespace tp; TEST_DEF(CLR) { // TEST(false); -} \ No newline at end of file +} diff --git a/Parser/tests/GrammarTests.cpp b/Parser/tests/GrammarTests.cpp index f45e670..5668cbf 100644 --- a/Parser/tests/GrammarTests.cpp +++ b/Parser/tests/GrammarTests.cpp @@ -1,5 +1,4 @@ -#include "NewPlacement.hpp" #include "Parser.hpp" #include "Testing.hpp" @@ -46,4 +45,4 @@ List : [ LIST ]; printf("Example sentences formed from grammar: \n"); for (auto sentence : sentences) tp::CfGrammar::printSentence(sentence.data()); -} \ No newline at end of file +} diff --git a/Parser/tests/Tests.cpp b/Parser/tests/Tests.cpp index 90a03e9..9c7d8dd 100644 --- a/Parser/tests/Tests.cpp +++ b/Parser/tests/Tests.cpp @@ -1,5 +1,4 @@ -#include "NewPlacement.hpp" #include "Parser.hpp" #include "Testing.hpp" @@ -21,4 +20,4 @@ int main(int argc, const char* argv[]) { testModule.deinitialize(); return 0; -} \ No newline at end of file +} diff --git a/RayTracer/applications/Rayt.cpp b/RayTracer/applications/Rayt.cpp index 2516035..8ecda23 100644 --- a/RayTracer/applications/Rayt.cpp +++ b/RayTracer/applications/Rayt.cpp @@ -9,6 +9,10 @@ #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" +#include +#include +#include + using namespace tp; void writeImage(const RayTracer::RenderBuffer& output, const char* name) { @@ -37,22 +41,19 @@ void writeImage(const RayTracer::RenderBuffer& output, const char* name) { } } -static void* printStatus(void* arg) { - auto percentage = (const halnf*) arg; +void printStatus(const halnf* percentage) { auto old = *percentage; while (*percentage < 0.99f) { - sleep(500); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); if (old != *percentage && (*percentage - old) > 0.01) { - printf("Progress - %f\n", (*percentage) * 100); + std::cout << "Progress - " << (*percentage) * 100 << std::endl; old = *percentage; } } - pthread_exit(NULL); } void renderCommand(const String& scenePath) { Scene scene; - RayTracer::RenderSettings settings; loadScene(scene, scenePath, settings); @@ -60,16 +61,9 @@ void renderCommand(const String& scenePath) { RayTracer::OutputBuffers output; RayTracer rayt; - pthread_t my_thread; - int ret; + std::thread statusThread(printStatus, &rayt.mProgress.percentage); - printf("\nStarting Render:\n\n"); - - ret = pthread_create(&my_thread, NULL, &printStatus, &rayt.mProgress.percentage); - if (ret != 0) { - printf("Error: pthread_create() failed\n"); - exit(EXIT_FAILURE); - } + std::cout << "\nStarting Render:\n\n"; auto start = get_time(); @@ -77,9 +71,9 @@ void renderCommand(const String& scenePath) { auto end = get_time(); - pthread_join(my_thread, NULL); + statusThread.join(); - printf("\nRender finished with average render time per sample - %i (ms)\n", end - start); + std::cout << "\nRender finished with average render time per sample - " << (end - start) << " (ms)\n"; writeImage(output.normals, "normals.png"); writeImage(output.color, "color.png"); @@ -97,4 +91,4 @@ int main(int argc, const char** argv) { } return 0; -} +} \ No newline at end of file diff --git a/RayTracer/private/RayTracer.cpp b/RayTracer/private/RayTracer.cpp index f1a4a40..a054eb1 100644 --- a/RayTracer/private/RayTracer.cpp +++ b/RayTracer/private/RayTracer.cpp @@ -1,6 +1,5 @@ #include "MathCommon.hpp" -#include "NewPlacement.hpp" #include "CommandLine.hpp" #include "Module.hpp" @@ -48,10 +47,10 @@ ModuleManifest* sDependencies[] = { &gModuleMath, &gModuleCommandLine, &gModuleC ModuleManifest tp::gModuleRayTracer = ModuleManifest("RayTracer", nullptr, nullptr, sDependencies); -void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf far) { +void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf farVal) { out.hit = false; - far *= far; + farVal *= farVal; for (auto obj : mScene->mObjects) { for (auto trig : obj->mCache.TrigCaches) { @@ -60,13 +59,13 @@ void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf far) { auto dist = (trig->getHitPos() - ray.pos).length2(); - if (far > dist && dist > EPSILON) { + if (farVal > dist && dist > EPSILON) { out.trig = &trig.data(); out.hitPos = trig->getHitPos(); out.obj = &obj.data(); out.hit = true; - far = dist; + farVal = dist; } } } diff --git a/Strings/private/Logging.cpp b/Strings/private/Logging.cpp index e77be62..55ef8db 100644 --- a/Strings/private/Logging.cpp +++ b/Strings/private/Logging.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "Logging.hpp" #include @@ -51,4 +49,4 @@ namespace tp { delete gLogger; gLogger = nullptr; } -} \ No newline at end of file +} diff --git a/Strings/tests/TestsStrings.cpp b/Strings/tests/TestsStrings.cpp index 5e20bf8..8323ad9 100644 --- a/Strings/tests/TestsStrings.cpp +++ b/Strings/tests/TestsStrings.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "Strings.hpp" #include "Tests.hpp" @@ -46,4 +44,4 @@ TEST_DEF_STATIC(Simple) { TEST_DEF(Strings) { testSimple(); testAddition(); -} \ No newline at end of file +} diff --git a/Strings/tests/TestsStringsLogic.cpp b/Strings/tests/TestsStringsLogic.cpp index 1d30d92..4f35152 100644 --- a/Strings/tests/TestsStringsLogic.cpp +++ b/Strings/tests/TestsStringsLogic.cpp @@ -1,5 +1,3 @@ -#include "NewPlacement.hpp" - #include "StringLogic.hpp" #include "Tests.hpp" @@ -242,4 +240,4 @@ TEST_DEF(StringLogic) { testremoveLogic(); testConversions(); -} \ No newline at end of file +} diff --git a/Tokenizer/public/AutomataGraph.h b/Tokenizer/public/AutomataGraph.h index 5a03edb..5a91f3a 100644 --- a/Tokenizer/public/AutomataGraph.h +++ b/Tokenizer/public/AutomataGraph.h @@ -7,6 +7,11 @@ #include "Utils.hpp" #include "Map.hpp" +#ifdef ENV_OS_WINDOWS +#undef min +#undef max +#endif + namespace tp { extern ModuleManifest gModuleTokenizer; @@ -100,7 +105,7 @@ namespace tp { Range getAlphabetRange() const { tAlphabetType start = 0, end = 0; - Range all_range = { std::numeric_limits::min(), std::numeric_limits::max() }; + Range all_range(std::numeric_limits::min(), std::numeric_limits::max()); bool first = true; for (auto vertex : mVertices) { diff --git a/Tokenizer/tests/TestTokenizer.cpp b/Tokenizer/tests/TestTokenizer.cpp index be898a1..2d651cc 100644 --- a/Tokenizer/tests/TestTokenizer.cpp +++ b/Tokenizer/tests/TestTokenizer.cpp @@ -1,10 +1,11 @@ -#include "NewPlacement.hpp" +// #include "NewPlacement.hpp" #include "Testing.hpp" #include "Tokenizer.hpp" #include +#include -#define LOG(val) // std::cout << #val << " " +#define LOG(val) std::cout << #val << " " using namespace tp; diff --git a/Utils/private/Debugging.cpp b/Utils/private/Debugging.cpp index 066246d..cc1d63e 100644 --- a/Utils/private/Debugging.cpp +++ b/Utils/private/Debugging.cpp @@ -13,6 +13,7 @@ void initializeCallStackCapture() { gCSCapture = new (malloc(sizeof(CallStackCap void deinitializeCallStackCapture() { gCSCapture->~CallStackCapture(); free(gCSCapture); + gCSCapture = nullptr; } ualni CallStackCapture::CallStack::getDepth() const { @@ -70,6 +71,8 @@ CallStackCapture::CallStackCapture() { } const CallStackCapture::CallStack* CallStackCapture::getSnapshot() { + MODULE_SANITY_CHECK(gModuleUtils) + if (mBuffLoad > mBuffLen) { static CallStack cs; cs.frames[0] = 0; @@ -229,4 +232,10 @@ void CallStackCapture::platformWriteDebugSymbols(FramePointer frame, DebugSymbol std::strcpy(out->file, "unresolved"); std::strcpy(out->function, "unresolved"); } +void CallStackCapture::printSnapshot(const CallStack* snapshot) { + printf("CallStack: \n"); + printf("Call stack debugging is not supported on this platform"); + printf("\n"); +} +void CallStackCapture::logAll() { printf("Call stack debugging is not supported on this platform"); } #endif \ No newline at end of file diff --git a/Utils/private/Testing.cpp b/Utils/private/Testing.cpp index 10283b6..2f156e3 100644 --- a/Utils/private/Testing.cpp +++ b/Utils/private/Testing.cpp @@ -37,7 +37,7 @@ void Testing::reportState() { printf("\n"); mRootTest.report(); -} + } bool Testing::hasFailed() { mRootTest.updateState(); diff --git a/Utils/public/Multithreading.hpp b/Utils/public/Multithreading.hpp index 7f0b6c5..066868b 100644 --- a/Utils/public/Multithreading.hpp +++ b/Utils/public/Multithreading.hpp @@ -1,16 +1,16 @@ #pragma once -#include +#include namespace tp { class Mutex { - pthread_mutex_t mMutex{}; + std::mutex mMutex; public: Mutex() = default; - void lock() { pthread_mutex_lock(&mMutex); } + void lock() { mMutex.lock(); } - void unlock() { pthread_mutex_unlock(&mMutex); } + void unlock() { mMutex.unlock(); } }; -} \ No newline at end of file +}