2 Commit-ok 40d01586cc ... b22ace3807

Szerző SHA1 Üzenet Dátum
  Kajetan Johannes Hammerle b22ace3807 GCC fixes 1 hónapja
  Kajetan Johannes Hammerle e84617ae1a Export interface modules 1 hónapja

+ 1 - 0
CMakeLists.txt

@@ -28,6 +28,7 @@ set(SRC_MODULES
     "modules/Random.cppm"
     "modules/ReadLine.cppm"
     "modules/Terminal.cppm"
+    "modules/TerminalConstants.cppm"
     "modules/Test.cppm"
     "modules/Thread.cppm"
     "modules/ToString.cppm"

+ 1 - 1
modules/AlignedData.cppm

@@ -2,7 +2,7 @@ module;
 
 export module Core.AlignedData;
 
-import Core.Types;
+export import Core.Types;
 
 export namespace Core {
     template<size_t SIZE, size_t ALIGNMENT>

+ 2 - 2
modules/Array.cppm

@@ -1,9 +1,9 @@
 module;
 
-#include <cstddef>
-
 export module Core.Array;
 
+export import Core.Types;
+
 namespace Core {
     export template<typename T, size_t N>
     struct Array final {

+ 3 - 0
modules/ArrayList.cppm

@@ -1,6 +1,7 @@
 module;
 
 #include <cassert>
+#include <new>
 
 export module Core.ArrayList;
 
@@ -8,6 +9,8 @@ import Core.AlignedData;
 import Core.Meta;
 import Core.Types;
 
+export using ::operator new;
+
 export namespace Core {
     template<typename T, size_t N>
     class ArrayList final {

+ 1 - 2
modules/Box.cppm

@@ -2,8 +2,7 @@ module;
 
 export module Core.Box;
 
-import Core.Vector;
-import Core.Types;
+export import Core.Vector;
 
 export namespace Core {
     class Box final {

+ 2 - 2
modules/Buffer.cppm

@@ -1,9 +1,9 @@
 module;
 
-#include <cstddef>
-
 export module Core.Buffer;
 
+import Core.Types;
+
 export namespace Core {
     class Buffer final {
         size_t length;

+ 0 - 1
modules/Clock.cppm

@@ -3,7 +3,6 @@ module;
 export module Core.Clock;
 
 import Core.Array;
-import Core.Types;
 
 export namespace Core {
     struct Clock final {

+ 1 - 1
modules/Color.cppm

@@ -2,7 +2,7 @@ module;
 
 export module Core.Color;
 
-import Core.Types;
+export import Core.Types;
 
 export namespace Core {
     using ColorChannel = u8;

+ 4 - 1
modules/Components.cppm

@@ -2,11 +2,14 @@ module;
 
 export module Core.Components;
 
+export import Core.Utility;
+
 import Core.HashMap;
 import Core.List;
-import Core.Types;
 import Core.Meta;
 
+export using ::operator new;
+
 export namespace Core {
     using Entity = size_t;
 

+ 1 - 1
modules/File.cppm

@@ -2,7 +2,7 @@ module;
 
 export module Core.File;
 
-import Core.List;
+export import Core.List;
 
 export namespace Core {
     bool readFile(List<char>& content, const char* path);

+ 2 - 2
modules/Frustum.cppm

@@ -2,10 +2,10 @@ module;
 
 export module Core.Frustum;
 
+export import Core.Matrix;
+
 import Core.Array;
-import Core.Matrix;
 import Core.Plane;
-import Core.Vector;
 
 export namespace Core {
     class Frustum final {

+ 5 - 2
modules/HashMap.cppm

@@ -2,14 +2,17 @@ module;
 
 export module Core.HashMap;
 
+export import Core.Types;
+export import Core.Utility;
+
 import Core.List;
 import Core.ToString;
-import Core.Types;
-import Core.Utility;
 import Core.AlignedData;
 import Core.Math;
 import Core.Meta;
 
+export using ::operator new;
+
 export template<typename T>
 concept Hashable = requires(const T& t) { t.hashCode(); };
 export template<typename T>

+ 2 - 0
modules/HashedString.cppm

@@ -5,6 +5,8 @@ module;
 
 export module Core.HashedString;
 
+export import Core.Types;
+
 export namespace Core {
     struct StringHash {
         size_t length = 0;

+ 4 - 3
modules/List.cppm

@@ -1,18 +1,19 @@
 module;
 
 #include <cassert>
-#include <cstdio>
 #include <new>
 
 export module Core.List;
 
+export import Core.Utility;
+
 import Core.AlignedData;
 import Core.Math;
 import Core.Meta;
-import Core.Types;
-import Core.Utility;
 import Core.ToString;
 
+export using ::operator new;
+
 export namespace Core {
     template<typename T>
     class List final {

+ 1 - 1
modules/Logger.cppm

@@ -5,7 +5,7 @@ module;
 
 export module Core.Logger;
 
-import Core.Terminal;
+import Core.TerminalConstants;
 import Core.Meta;
 import Core.ToString;
 

+ 1 - 3
modules/Matrix.cppm

@@ -2,9 +2,7 @@ module;
 
 export module Core.Matrix;
 
-import Core.Quaternion;
-import Core.Vector;
-import Core.Types;
+export import Core.Quaternion;
 
 export namespace Core {
     class Matrix final {

+ 51 - 51
modules/Meta.cppm

@@ -2,54 +2,54 @@ module;
 
 export module Core.Meta;
 
-export namespace Core {
-    namespace Internal {
-        template<typename T>
-        struct BaseRemovePointer final {
-            using Type = T;
-        };
-
-        template<typename T>
-        struct BaseRemovePointer<T*> final {
-            using Type = T;
-        };
-
-        template<typename T>
-        struct BaseRemoveReference final {
-            using Type = T;
-        };
-
-        template<typename T>
-        struct BaseRemoveReference<T&> final {
-            using Type = T;
-        };
-
-        template<typename T>
-        struct BaseRemoveReference<T&&> final {
-            using Type = T;
-        };
-
-        template<typename A, typename B>
-        struct BaseIsSame final {
-            static constexpr bool value = false;
-        };
-
-        template<typename T>
-        struct BaseIsSame<T, T> final {
-            static constexpr bool value = true;
-        };
-
-        template<bool C, typename A, typename B>
-        struct BaseIf final {
-            using Type = A;
-        };
-
-        template<typename A, typename B>
-        struct BaseIf<false, A, B> final {
-            using Type = B;
-        };
-    }
+namespace Core {
+    template<typename T>
+    struct BaseRemovePointer final {
+        using Type = T;
+    };
+
+    template<typename T>
+    struct BaseRemovePointer<T*> final {
+        using Type = T;
+    };
+
+    template<typename T>
+    struct BaseRemoveReference final {
+        using Type = T;
+    };
+
+    template<typename T>
+    struct BaseRemoveReference<T&> final {
+        using Type = T;
+    };
+
+    template<typename T>
+    struct BaseRemoveReference<T&&> final {
+        using Type = T;
+    };
+
+    template<typename A, typename B>
+    struct BaseIsSame final {
+        static constexpr bool value = false;
+    };
+
+    template<typename T>
+    struct BaseIsSame<T, T> final {
+        static constexpr bool value = true;
+    };
 
+    template<bool C, typename A, typename B>
+    struct BaseIf final {
+        using Type = A;
+    };
+
+    template<typename A, typename B>
+    struct BaseIf<false, A, B> final {
+        using Type = B;
+    };
+}
+
+export namespace Core {
     template<typename T>
     concept Iterable = requires(T& t) {
         t.begin();
@@ -57,16 +57,16 @@ export namespace Core {
     };
 
     template<typename T>
-    using RemovePointer = Internal::BaseRemovePointer<T>::Type;
+    using RemovePointer = BaseRemovePointer<T>::Type;
 
     template<typename T>
-    using RemoveReference = Internal::BaseRemoveReference<T>::Type;
+    using RemoveReference = BaseRemoveReference<T>::Type;
 
     template<typename T, typename U>
-    constexpr bool IsSame = Internal::BaseIsSame<T, U>::value;
+    constexpr bool IsSame = BaseIsSame<T, U>::value;
 
     template<bool C, typename A, typename B>
-    using If = Internal::BaseIf<C, A, B>::Type;
+    using If = BaseIf<C, A, B>::Type;
 
     template<typename T>
     constexpr RemoveReference<T>&& move(T&& t) {

+ 1 - 2
modules/Plane.cppm

@@ -2,8 +2,7 @@ module;
 
 export module Core.Plane;
 
-import Core.Vector;
-import Core.Types;
+export import Core.Vector;
 
 export namespace Core {
     class Plane final {

+ 1 - 2
modules/Quaternion.cppm

@@ -2,8 +2,7 @@ module;
 
 export module Core.Quaternion;
 
-import Core.Vector;
-import Core.Types;
+export import Core.Vector;
 
 export namespace Core {
     class Quaternion final {

+ 4 - 1
modules/Queue.cppm

@@ -1,13 +1,16 @@
 module;
 
 #include <cassert>
+#include <new>
 
 export module Core.Queue;
 
 import Core.AlignedData;
 import Core.ToString;
-import Core.Types;
 import Core.Meta;
+import Core.Utility;
+
+export using ::operator new;
 
 export namespace Core {
     template<typename T, size_t N>

+ 0 - 1
modules/Random.cppm

@@ -3,7 +3,6 @@ module;
 export module Core.Random;
 
 import Core.Array;
-import Core.Types;
 
 export namespace Core {
     class Random final {

+ 2 - 2
modules/ReadLine.cppm

@@ -1,9 +1,9 @@
 module;
 
-#include <cstddef>
-
 export module Core.ReadLine;
 
+export import Core.Types;
+
 export namespace Core {
     bool startReadLine();
     bool readLine(char* buffer, size_t n);

+ 2 - 71
modules/Terminal.cppm

@@ -1,79 +1,10 @@
 module;
-export module Core.Terminal;
 
-import Core.Types;
-import Core.Vector;
+export module Core.Terminal;
 
-#define ESC "\33["
+export import Core.Vector;
 
 export namespace Core {
-    namespace Terminal {
-        inline constexpr const char RESET[] = ESC "0m";
-        inline constexpr const char BOLD[] = ESC "1m";
-        // foreground colors
-        inline constexpr const char FG_BLACK[] = ESC "30m";
-        inline constexpr const char FG_RED[] = ESC "31m";
-        inline constexpr const char FG_GREEN[] = ESC "32m";
-        inline constexpr const char FG_YELLOW[] = ESC "33m";
-        inline constexpr const char FG_BLUE[] = ESC "34m";
-        inline constexpr const char FG_MAGENTA[] = ESC "35m";
-        inline constexpr const char FG_CYAN[] = ESC "36m";
-        inline constexpr const char FG_WHITE[] = ESC "37m";
-        inline constexpr const char FG_BRIGHT_BLACK[] = ESC "90m";
-        inline constexpr const char FG_BRIGHT_RED[] = ESC "91m";
-        inline constexpr const char FG_BRIGHT_GREEN[] = ESC "92m";
-        inline constexpr const char FG_BRIGHT_YELLOW[] = ESC "93m";
-        inline constexpr const char FG_BRIGHT_BLUE[] = ESC "94m";
-        inline constexpr const char FG_BRIGHT_MAGENTA[] = ESC "95m";
-        inline constexpr const char FG_BRIGHT_CYAN[] = ESC "96m";
-        inline constexpr const char FG_BRIGHT_WHITE[] = ESC "97m";
-        // background colors
-        inline constexpr const char BG_BLACK[] = ESC "40m";
-        inline constexpr const char BG_RED[] = ESC "41m";
-        inline constexpr const char BG_GREEN[] = ESC "42m";
-        inline constexpr const char BG_YELLOW[] = ESC "43m";
-        inline constexpr const char BG_BLUE[] = ESC "44m";
-        inline constexpr const char BG_MAGENTA[] = ESC "45m";
-        inline constexpr const char BG_CYAN[] = ESC "46m";
-        inline constexpr const char BG_WHITE[] = ESC "47m";
-        inline constexpr const char BG_BRIGHT_BLACK[] = ESC "100m";
-        inline constexpr const char BG_BRIGHT_RED[] = ESC "101m";
-        inline constexpr const char BG_BRIGHT_GREEN[] = ESC "102m";
-        inline constexpr const char BG_BRIGHT_YELLOW[] = ESC "103m";
-        inline constexpr const char BG_BRIGHT_BLUE[] = ESC "104m";
-        inline constexpr const char BG_BRIGHT_MAGENTA[] = ESC "105m";
-        inline constexpr const char BG_BRIGHT_CYAN[] = ESC "106m";
-        inline constexpr const char BG_BRIGHT_WHITE[] = ESC "107m";
-        // keycodes
-        inline constexpr const unsigned long KEY_UNKNOWN = 0x1'0000'0000lu;
-        // default keycodes
-        inline constexpr const unsigned long KEY_ARROW_LEFT = 0x1'0000'0001lu;
-        inline constexpr const unsigned long KEY_ARROW_RIGHT = 0x1'0000'0002lu;
-        inline constexpr const unsigned long KEY_ARROW_UP = 0x1'0000'0003lu;
-        inline constexpr const unsigned long KEY_ARROW_DOWN = 0x1'0000'0004lu;
-        inline constexpr const unsigned long KEY_DELETE = 0x1'0000'0005lu;
-        inline constexpr const unsigned long KEY_F1 = 0x1'0000'0006lu;
-        inline constexpr const unsigned long KEY_F2 = 0x1'0000'0007lu;
-        inline constexpr const unsigned long KEY_F3 = 0x1'0000'0008lu;
-        inline constexpr const unsigned long KEY_F4 = 0x1'0000'0009lu;
-        inline constexpr const unsigned long KEY_F5 = 0x1'0000'000Alu;
-        inline constexpr const unsigned long KEY_F6 = 0x1'0000'000Blu;
-        inline constexpr const unsigned long KEY_F7 = 0x1'0000'000Clu;
-        inline constexpr const unsigned long KEY_F8 = 0x1'0000'000Dlu;
-        inline constexpr const unsigned long KEY_F9 = 0x1'0000'000Elu;
-        inline constexpr const unsigned long KEY_F10 = 0x1'0000'000Flu;
-        inline constexpr const unsigned long KEY_F11 = 0x1'0000'0010lu;
-        inline constexpr const unsigned long KEY_F12 = 0x1'0000'0011lu;
-        inline constexpr const unsigned long KEY_PAGE_UP = 0x1'0000'0012lu;
-        inline constexpr const unsigned long KEY_PAGE_DOWN = 0x1'0000'0013lu;
-        inline constexpr const unsigned long KEY_HOME = 0x1'0000'0014lu;
-        inline constexpr const unsigned long KEY_END = 0x1'0000'0015lu;
-        // key modifiers
-        inline constexpr const unsigned long KEY_CTRL = 0x2'0000'0000lu;
-        inline constexpr const unsigned long KEY_SHIFT = 0x4'0000'0000lu;
-        inline constexpr const unsigned long KEY_ALT = 0x8'0000'0000lu;
-    }
-
     void enterAlternativeTerminal();
     void leaveAlternativeTerminal();
     IntVector2 getTerminalSize();

+ 76 - 0
modules/TerminalConstants.cppm

@@ -0,0 +1,76 @@
+module;
+
+export module Core.TerminalConstants;
+
+export import Core.Vector;
+
+#define ESC "\33["
+
+export namespace Core {
+    namespace Terminal {
+        inline constexpr const char RESET[] = ESC "0m";
+        inline constexpr const char BOLD[] = ESC "1m";
+        // foreground colors
+        inline constexpr const char FG_BLACK[] = ESC "30m";
+        inline constexpr const char FG_RED[] = ESC "31m";
+        inline constexpr const char FG_GREEN[] = ESC "32m";
+        inline constexpr const char FG_YELLOW[] = ESC "33m";
+        inline constexpr const char FG_BLUE[] = ESC "34m";
+        inline constexpr const char FG_MAGENTA[] = ESC "35m";
+        inline constexpr const char FG_CYAN[] = ESC "36m";
+        inline constexpr const char FG_WHITE[] = ESC "37m";
+        inline constexpr const char FG_BRIGHT_BLACK[] = ESC "90m";
+        inline constexpr const char FG_BRIGHT_RED[] = ESC "91m";
+        inline constexpr const char FG_BRIGHT_GREEN[] = ESC "92m";
+        inline constexpr const char FG_BRIGHT_YELLOW[] = ESC "93m";
+        inline constexpr const char FG_BRIGHT_BLUE[] = ESC "94m";
+        inline constexpr const char FG_BRIGHT_MAGENTA[] = ESC "95m";
+        inline constexpr const char FG_BRIGHT_CYAN[] = ESC "96m";
+        inline constexpr const char FG_BRIGHT_WHITE[] = ESC "97m";
+        // background colors
+        inline constexpr const char BG_BLACK[] = ESC "40m";
+        inline constexpr const char BG_RED[] = ESC "41m";
+        inline constexpr const char BG_GREEN[] = ESC "42m";
+        inline constexpr const char BG_YELLOW[] = ESC "43m";
+        inline constexpr const char BG_BLUE[] = ESC "44m";
+        inline constexpr const char BG_MAGENTA[] = ESC "45m";
+        inline constexpr const char BG_CYAN[] = ESC "46m";
+        inline constexpr const char BG_WHITE[] = ESC "47m";
+        inline constexpr const char BG_BRIGHT_BLACK[] = ESC "100m";
+        inline constexpr const char BG_BRIGHT_RED[] = ESC "101m";
+        inline constexpr const char BG_BRIGHT_GREEN[] = ESC "102m";
+        inline constexpr const char BG_BRIGHT_YELLOW[] = ESC "103m";
+        inline constexpr const char BG_BRIGHT_BLUE[] = ESC "104m";
+        inline constexpr const char BG_BRIGHT_MAGENTA[] = ESC "105m";
+        inline constexpr const char BG_BRIGHT_CYAN[] = ESC "106m";
+        inline constexpr const char BG_BRIGHT_WHITE[] = ESC "107m";
+        // keycodes
+        inline constexpr const unsigned long KEY_UNKNOWN = 0x1'0000'0000lu;
+        // default keycodes
+        inline constexpr const unsigned long KEY_ARROW_LEFT = 0x1'0000'0001lu;
+        inline constexpr const unsigned long KEY_ARROW_RIGHT = 0x1'0000'0002lu;
+        inline constexpr const unsigned long KEY_ARROW_UP = 0x1'0000'0003lu;
+        inline constexpr const unsigned long KEY_ARROW_DOWN = 0x1'0000'0004lu;
+        inline constexpr const unsigned long KEY_DELETE = 0x1'0000'0005lu;
+        inline constexpr const unsigned long KEY_F1 = 0x1'0000'0006lu;
+        inline constexpr const unsigned long KEY_F2 = 0x1'0000'0007lu;
+        inline constexpr const unsigned long KEY_F3 = 0x1'0000'0008lu;
+        inline constexpr const unsigned long KEY_F4 = 0x1'0000'0009lu;
+        inline constexpr const unsigned long KEY_F5 = 0x1'0000'000Alu;
+        inline constexpr const unsigned long KEY_F6 = 0x1'0000'000Blu;
+        inline constexpr const unsigned long KEY_F7 = 0x1'0000'000Clu;
+        inline constexpr const unsigned long KEY_F8 = 0x1'0000'000Dlu;
+        inline constexpr const unsigned long KEY_F9 = 0x1'0000'000Elu;
+        inline constexpr const unsigned long KEY_F10 = 0x1'0000'000Flu;
+        inline constexpr const unsigned long KEY_F11 = 0x1'0000'0010lu;
+        inline constexpr const unsigned long KEY_F12 = 0x1'0000'0011lu;
+        inline constexpr const unsigned long KEY_PAGE_UP = 0x1'0000'0012lu;
+        inline constexpr const unsigned long KEY_PAGE_DOWN = 0x1'0000'0013lu;
+        inline constexpr const unsigned long KEY_HOME = 0x1'0000'0014lu;
+        inline constexpr const unsigned long KEY_END = 0x1'0000'0015lu;
+        // key modifiers
+        inline constexpr const unsigned long KEY_CTRL = 0x2'0000'0000lu;
+        inline constexpr const unsigned long KEY_SHIFT = 0x4'0000'0000lu;
+        inline constexpr const unsigned long KEY_ALT = 0x8'0000'0000lu;
+    }
+}

+ 1 - 2
modules/Test.cppm

@@ -6,8 +6,7 @@ module;
 export module Core.Test;
 
 import Core.Logger;
-import Core.Terminal;
-import Core.Meta;
+import Core.TerminalConstants;
 import Core.ToString;
 
 #define SOURCE const std::source_location& l = std::source_location::current()

+ 1 - 3
modules/ToString.cppm

@@ -1,12 +1,10 @@
 module;
 
-#include <cstdio>
-#include <cstring>
-
 export module Core.ToString;
 
 import Core.Math;
 import Core.Meta;
+import Core.Types;
 
 export namespace Core {
     size_t toString(signed char v, char* s, size_t n);

+ 1 - 1
modules/Unicode.cppm

@@ -2,7 +2,7 @@ module;
 
 export module Core.Unicode;
 
-import Core.Types;
+export import Core.Types;
 
 export namespace Core {
     struct UTF8 {

+ 6 - 0
modules/Utility.cppm

@@ -9,11 +9,17 @@ import Core.Meta;
 
 #define SOURCE const std::source_location& l = std::source_location::current()
 
+export namespace std {
+    using std::source_location;
+}
+
 #ifdef CHECK_MEMORY
 export void* operator new(size_t count, const std::source_location& l);
 export void* operator new[](size_t count, const std::source_location& l);
 #endif
 
+export using ::operator new;
+
 export namespace Core {
     template<typename T, typename C = int>
     C popCount(const T& t) {

+ 2 - 0
modules/Vector.cppm

@@ -4,6 +4,8 @@ module;
 
 export module Core.Vector;
 
+export import Core.Types;
+
 import Core.Math;
 import Core.Meta;
 import Core.ToString;

+ 1 - 3
modules/View.cppm

@@ -2,9 +2,7 @@ module;
 
 export module Core.View;
 
-import Core.Matrix;
-import Core.Vector;
-import Core.Quaternion;
+export import Core.Matrix;
 
 export namespace Core {
     class View {

+ 1 - 0
src/ReadLine.cpp

@@ -13,6 +13,7 @@ import Core.Logger;
 import Core.Queue;
 import Core.Thread;
 import Core.Terminal;
+import Core.TerminalConstants;
 import Core.Types;
 import Core.Unicode;
 

+ 1 - 0
src/Terminal.cpp

@@ -8,6 +8,7 @@ module;
 
 module Core.Terminal;
 
+import Core.TerminalConstants;
 import Core.Array;
 import Core.Logger;
 import Core.Unicode;

+ 1 - 1
test/modules/ColorTests.cpp

@@ -8,7 +8,7 @@ template class Core::Color<2>;
 template class Core::Color<3>;
 template class Core::Color<4>;
 
-const float eps = 0.0001f;
+static const float eps = 0.0001f;
 
 static void testColor1() {
     Core::Color1 c(36);

+ 0 - 1
test/modules/FileTests.cpp

@@ -10,7 +10,6 @@ module Tests;
 import Core.File;
 import Core.Logger;
 import Core.Test;
-import Core.List;
 
 static int failIndex = 0;
 static const char* fails[] = {

+ 0 - 2
test/modules/RandomTests.cpp

@@ -1,8 +1,6 @@
 module Tests;
-
 import Core.Random;
 import Core.Test;
-import Core.Types;
 import Core.Array;
 
 using Core::Random;

+ 1 - 0
test/modules/TerminalTests.cpp

@@ -7,6 +7,7 @@ module Tests;
 import Core.Clock;
 import Core.Logger;
 import Core.Terminal;
+import Core.TerminalConstants;
 import Core.Test;
 import Core.Vector;
 import Core.Types;

+ 1 - 1
test/modules/VectorTests.cpp

@@ -8,7 +8,7 @@ import Core.Test;
 import Core.Vector;
 import Core.ToString;
 
-const float eps = 0.0001f;
+static const float eps = 0.0001f;
 
 using V3 = Core::Vector3;
 using I3 = Core::IntVector3;