diff --git a/deps/ox/src/ox/model/descwrite.cpp b/deps/ox/src/ox/model/descwrite.cpp index 6889b81a..93de2a32 100644 --- a/deps/ox/src/ox/model/descwrite.cpp +++ b/deps/ox/src/ox/model/descwrite.cpp @@ -47,96 +47,94 @@ static_assert([] { return detail::indirectionLevels(i) == 1; }(), "indirectionLevels broken: indirectionLevels(int[])"); -const DescriptorType *TypeDescWriter::type(int8_t*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(int8_t*) noexcept { constexpr auto String = "B:int8_t"; constexpr auto PT = PrimitiveType::SignedInteger; constexpr auto Bytes = 1; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::type(int16_t*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(int16_t*) noexcept { constexpr auto String = "B:int16_t"; constexpr auto PT = PrimitiveType::SignedInteger; constexpr auto Bytes = 2; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::type(int32_t*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(int32_t*) noexcept { constexpr auto String = "B:int32_t"; constexpr auto PT = PrimitiveType::SignedInteger; constexpr auto Bytes = 4; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::type(int64_t*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(int64_t*) noexcept { constexpr auto String = "B:int64_t"; constexpr auto PT = PrimitiveType::SignedInteger; constexpr auto Bytes = 8; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::type(uint8_t*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(uint8_t*) noexcept { constexpr auto String = "B:uint8_t"; constexpr auto PT = PrimitiveType::UnsignedInteger; constexpr auto Bytes = 1; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::type(uint16_t*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(uint16_t*) noexcept { constexpr auto String = "B:uint16_t"; constexpr auto PT = PrimitiveType::UnsignedInteger; constexpr auto Bytes = 2; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::type(uint32_t*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(uint32_t*) noexcept { constexpr auto String = "B:uint32_t"; constexpr auto PT = PrimitiveType::UnsignedInteger; constexpr auto Bytes = 4; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::type(uint64_t*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(uint64_t*) noexcept { constexpr auto String = "B:uint64_t"; constexpr auto PT = PrimitiveType::UnsignedInteger; constexpr auto Bytes = 8; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::type(char*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(char*) noexcept { constexpr auto String = "B:string"; constexpr auto PT = PrimitiveType::String; - return getType(String, PT, 0, alreadyExisted); + return getType(String, PT, 0); } -const DescriptorType *TypeDescWriter::type(SerStr, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(SerStr) noexcept { constexpr auto String = "B:string"; constexpr auto PT = PrimitiveType::String; - return getType(String, PT, 0, alreadyExisted); + return getType(String, PT, 0); } -const DescriptorType *TypeDescWriter::type(String*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(String*) noexcept { constexpr auto String = "B:string"; constexpr auto PT = PrimitiveType::String; - return getType(String, PT, 0, alreadyExisted); + return getType(String, PT, 0); } -const DescriptorType *TypeDescWriter::type(bool*, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::type(bool*) noexcept { constexpr auto String = "B:bool"; constexpr auto PT = PrimitiveType::Bool; constexpr auto Bytes = 0; - return getType(String, PT, Bytes, alreadyExisted); + return getType(String, PT, Bytes); } -const DescriptorType *TypeDescWriter::getType(const String &tn, PrimitiveType pt, int b, bool *alreadyExisted) noexcept { +const DescriptorType *TypeDescWriter::getType(const String &tn, PrimitiveType pt, int b) noexcept { auto t = m_typeStore->get(tn); if (!t.error) { - *alreadyExisted = true; auto type = t.value; oxAssert(type != nullptr, "TypeDescWriter::getType returning null DescriptorType"); return type; } else { - *alreadyExisted = false; auto dt = ox::make_unique(tn); dt->primitiveType = pt; dt->length = b; diff --git a/deps/ox/src/ox/model/descwrite.hpp b/deps/ox/src/ox/model/descwrite.hpp index 58545052..8bf23c03 100644 --- a/deps/ox/src/ox/model/descwrite.hpp +++ b/deps/ox/src/ox/model/descwrite.hpp @@ -71,40 +71,40 @@ class TypeDescWriter { } private: - const DescriptorType *type(int8_t *val, bool *alreadyExisted) noexcept; - const DescriptorType *type(int16_t *val, bool *alreadyExisted) noexcept; - const DescriptorType *type(int32_t *val, bool *alreadyExisted) noexcept; - const DescriptorType *type(int64_t *val, bool *alreadyExisted) noexcept; + const DescriptorType *type(int8_t *val) noexcept; + const DescriptorType *type(int16_t *val) noexcept; + const DescriptorType *type(int32_t *val) noexcept; + const DescriptorType *type(int64_t *val) noexcept; - const DescriptorType *type(uint8_t *val, bool *alreadyExisted) noexcept; - const DescriptorType *type(uint16_t *val, bool *alreadyExisted) noexcept; - const DescriptorType *type(uint32_t *val, bool *alreadyExisted) noexcept; - const DescriptorType *type(uint64_t *val, bool *alreadyExisted) noexcept; + const DescriptorType *type(uint8_t *val) noexcept; + const DescriptorType *type(uint16_t *val) noexcept; + const DescriptorType *type(uint32_t *val) noexcept; + const DescriptorType *type(uint64_t *val) noexcept; - const DescriptorType *type(bool *val, bool *alreadyExisted) noexcept; + const DescriptorType *type(bool *val) noexcept; - const DescriptorType *type(char *val, bool *alreadyExisted) noexcept; + const DescriptorType *type(char *val) noexcept; - const DescriptorType *type(SerStr val, bool *alreadyExisted) noexcept; + const DescriptorType *type(SerStr val) noexcept; - const DescriptorType *type(String *val, bool *alreadyExisted) noexcept; + const DescriptorType *type(String *val) noexcept; template - constexpr const DescriptorType *type(BString *val, bool *alreadyExisted) noexcept; + constexpr const DescriptorType *type(BString *val) noexcept; template - constexpr const DescriptorType *type(T *val, bool *alreadyExisted) noexcept; + constexpr const DescriptorType *type(T *val) noexcept; template - constexpr const DescriptorType *type(Vector *val, bool *alreadyExisted) noexcept; + constexpr const DescriptorType *type(Vector *val) noexcept; template - constexpr const DescriptorType *type(HashMap *val, bool *alreadyExisted) noexcept; + constexpr const DescriptorType *type(HashMap *val) noexcept; template - constexpr const DescriptorType *type(UnionView val, bool *alreadyExisted) noexcept; + constexpr const DescriptorType *type(UnionView val) noexcept; - const DescriptorType *getType(const String &tn, PrimitiveType t, int b, bool *alreadyExisted) noexcept; + const DescriptorType *getType(const String &tn, PrimitiveType t, int b) noexcept; }; constexpr TypeDescWriter::TypeDescWriter(TypeStore *typeStore) noexcept: m_typeStore(typeStore) { @@ -115,11 +115,10 @@ template constexpr Error TypeDescWriter::field(const char *name, T *val, std::size_t) noexcept { if (m_type) { constexpr typename remove_pointer::type *p = nullptr; - bool alreadyExisted = false; - const auto t = type(p, &alreadyExisted); + const auto t = type(p); oxAssert(t != nullptr, "field(const char *name, T *val, std::size_t): Type not found or generated"); if (t == nullptr) { - type(p, &alreadyExisted); + type(p); } m_type->fieldList.emplace_back(t, name, detail::indirectionLevels(val), t->typeName); return OxError(0); @@ -130,8 +129,7 @@ constexpr Error TypeDescWriter::field(const char *name, T *val, std::size_t) noe template constexpr Error TypeDescWriter::field(const char *name, T val) noexcept { if (m_type) { - bool alreadyExisted = false; - const auto t = type(val, &alreadyExisted); + const auto t = type(val); oxAssert(t != nullptr, "field(const char *name, T val): Type not found or generated"); m_type->fieldList.emplace_back(t, name, 0, t->typeName); return OxError(0); @@ -142,8 +140,7 @@ constexpr Error TypeDescWriter::field(const char *name, T val) noexcept { template constexpr Error TypeDescWriter::field(const char *name, T *val) noexcept { if (m_type) { - bool alreadyExisted = false; - const auto t = type(val, &alreadyExisted); + const auto t = type(val); oxAssert(t != nullptr, "field(const char *name, T *val): Type not found or generated"); m_type->fieldList.emplace_back(t, name, 0, t->typeName); return OxError(0); @@ -152,37 +149,35 @@ constexpr Error TypeDescWriter::field(const char *name, T *val) noexcept { } template -constexpr const DescriptorType *TypeDescWriter::type(BString *val, bool *alreadyExisted) noexcept { - return type(SerStr(val), alreadyExisted); +constexpr const DescriptorType *TypeDescWriter::type(BString *val) noexcept { + return type(SerStr(val)); } template -constexpr const DescriptorType *TypeDescWriter::type(T *val, bool *alreadyExisted) noexcept { +constexpr const DescriptorType *TypeDescWriter::type(T *val) noexcept { auto [t, err] = m_typeStore->template get(); if (!err) { - *alreadyExisted = true; return t; } else { TypeDescWriter dw(m_typeStore); oxLogError(model(&dw, val)); - *alreadyExisted = false; return dw.m_type; } } template -constexpr const DescriptorType *TypeDescWriter::type(Vector *val, bool *alreadyExisted) noexcept { - return type(val->data(), alreadyExisted); +constexpr const DescriptorType *TypeDescWriter::type(Vector *val) noexcept { + return type(val->data()); } template -constexpr const DescriptorType *TypeDescWriter::type(HashMap*, bool *alreadyExisted) noexcept { - return type(static_cast(nullptr), alreadyExisted); +constexpr const DescriptorType *TypeDescWriter::type(HashMap*) noexcept { + return type(static_cast(nullptr)); } template -constexpr const DescriptorType *TypeDescWriter::type(UnionView val, bool *alreadyExisted) noexcept { - return type(val.get(), alreadyExisted); +constexpr const DescriptorType *TypeDescWriter::type(UnionView val) noexcept { + return type(val.get()); } template