diff --git a/deps/ox/src/ox/claw/read.hpp b/deps/ox/src/ox/claw/read.hpp index 7dd6f29d..1ae56658 100644 --- a/deps/ox/src/ox/claw/read.hpp +++ b/deps/ox/src/ox/claw/read.hpp @@ -45,6 +45,7 @@ Error readClaw(const char *buff, std::size_t buffLen, T *val) { return OxError(Error_ClawTypeMismatch, "Claw Read: Type mismatch"); } if (header.typeVersion != getModelTypeVersion()) { + oxDebugf("version: {}, {}", header.typeVersion, getModelTypeVersion()); return OxError(Error_ClawTypeVersionMismatch, "Claw Read: Type Version mismatch"); } switch (header.fmt) { diff --git a/deps/ox/src/ox/claw/test/tests.cpp b/deps/ox/src/ox/claw/test/tests.cpp index 3a3306ec..41c65e2f 100644 --- a/deps/ox/src/ox/claw/test/tests.cpp +++ b/deps/ox/src/ox/claw/test/tests.cpp @@ -22,7 +22,7 @@ union TestUnion { static constexpr auto TypeName = "TestUnion"; - static constexpr auto Fields = 3; + static constexpr auto TypeVersion = 1; bool Bool; uint32_t Int = 5; char String[32]; @@ -30,7 +30,7 @@ union TestUnion { struct TestStructNest { static constexpr auto TypeName = "TestStructNest"; - static constexpr auto Fields = 3; + static constexpr auto TypeVersion = 1; bool Bool = false; uint32_t Int = 0; ox::BString<32> String = ""; @@ -38,7 +38,7 @@ struct TestStructNest { struct TestStruct { static constexpr auto TypeName = "TestStruct"; - static constexpr auto Fields = 16; + static constexpr auto TypeVersion = 1; bool Bool = false; int32_t Int = 0; int32_t Int1 = 0; diff --git a/deps/ox/src/ox/claw/write.hpp b/deps/ox/src/ox/claw/write.hpp index e43ff5c5..e0c8681d 100644 --- a/deps/ox/src/ox/claw/write.hpp +++ b/deps/ox/src/ox/claw/write.hpp @@ -26,7 +26,7 @@ struct TypeInfoCatcher { const char *name = nullptr; template - constexpr void setTypeInfo(const char *name = T::TypeName, int = T::Fields) noexcept { + constexpr void setTypeInfo(const char *name = T::TypeName, int = T::TypeVersion) noexcept { this->name = name; } diff --git a/deps/ox/src/ox/model/metadata.hpp b/deps/ox/src/ox/model/metadata.hpp index 67ae8f6d..a0cd7f6f 100644 --- a/deps/ox/src/ox/model/metadata.hpp +++ b/deps/ox/src/ox/model/metadata.hpp @@ -19,7 +19,6 @@ #include "desctypes.hpp" #include "fieldcounter.hpp" #include "optype.hpp" -#include "typenamecatcher.hpp" #include "types.hpp" namespace ox::detail { @@ -37,6 +36,10 @@ struct preloadable> { static constexpr bool value = T::Preloadable; }; +template +struct IntWrapper { +}; + // cannot be done until C++20 //struct PseudoString { // constexpr PseudoString(const char* = "") noexcept {} @@ -56,4 +59,4 @@ struct preloadable> { // static constexpr const char *value = T::TypeName; //}; -} \ No newline at end of file +} diff --git a/deps/ox/src/ox/model/typenamecatcher.hpp b/deps/ox/src/ox/model/typenamecatcher.hpp index 0635906f..73b3f9c1 100644 --- a/deps/ox/src/ox/model/typenamecatcher.hpp +++ b/deps/ox/src/ox/model/typenamecatcher.hpp @@ -40,6 +40,45 @@ struct TypeNameCatcher { return OxError(0); } + template + constexpr Error fieldCString(const char*, T) noexcept { + return OxError(0); + } + + static constexpr auto opType() noexcept { + return OpType::WriteDefinition; + } + +}; + +struct TypeInfoCatcher { + + const char *name = ""; + int version = 0; + + constexpr TypeInfoCatcher() noexcept = default; + + template + constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion) noexcept { + this->name = n; + this->version = v; + } + + template + constexpr Error field(const char*, T*, std::size_t) noexcept { + return OxError(0); + } + + template + constexpr Error field(const char*, T) noexcept { + return OxError(0); + } + + template + constexpr Error fieldCString(const char*, T) noexcept { + return OxError(0); + } + static constexpr auto opType() noexcept { return OpType::WriteDefinition; } @@ -50,7 +89,7 @@ template constexpr int getModelTypeVersion() noexcept { auto a = std::allocator(); auto t = a.allocate(1); - TypeNameCatcher nc; + TypeInfoCatcher nc; oxIgnoreError(model(&nc, t)); a.deallocate(t, 1); return nc.version; @@ -58,7 +97,7 @@ constexpr int getModelTypeVersion() noexcept { template constexpr int getModelTypeVersion(T *val) noexcept { - TypeNameCatcher nc; + TypeInfoCatcher nc; oxIgnoreError(model(&nc, val)); return nc.version; } @@ -66,7 +105,7 @@ constexpr int getModelTypeVersion(T *val) noexcept { template consteval int requireModelTypeVersion() noexcept { constexpr auto version = getModelTypeVersion(); - static_assert(version != 0, "TypeName is required"); + static_assert(version != 0, "TypeVersion is required"); return version; }