[ox/mc] Make writeOC work with const inputs
This commit is contained in:
parent
ce4dcdcd18
commit
6f5f2c7219
6
deps/ox/src/ox/mc/write.hpp
vendored
6
deps/ox/src/ox/mc/write.hpp
vendored
@ -406,7 +406,7 @@ ox::Error MetalClawWriter<Writer>::finalize() noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
Result<Buffer> writeMC(Writer_c auto &writer, auto &val) noexcept {
|
||||
Result<Buffer> writeMC(Writer_c auto &writer, const auto &val) noexcept {
|
||||
MetalClawWriter mcWriter(writer);
|
||||
ModelHandlerInterface handler{&mcWriter};
|
||||
oxReturnError(model(&handler, &val));
|
||||
@ -414,7 +414,7 @@ Result<Buffer> writeMC(Writer_c auto &writer, auto &val) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
Result<Buffer> writeMC(auto *val, std::size_t buffReserveSz = 2 * units::KB) noexcept {
|
||||
Result<Buffer> writeMC(const auto *val, std::size_t buffReserveSz = 2 * units::KB) noexcept {
|
||||
Buffer buff(buffReserveSz);
|
||||
BufferWriter bw(&buff, 0);
|
||||
oxReturnError(writeMC(bw, *val));
|
||||
@ -422,7 +422,7 @@ Result<Buffer> writeMC(auto *val, std::size_t buffReserveSz = 2 * units::KB) noe
|
||||
return buff;
|
||||
}
|
||||
|
||||
Error writeMC(char *buff, std::size_t buffLen, auto *val, std::size_t *sizeOut = nullptr) noexcept {
|
||||
Error writeMC(char *buff, std::size_t buffLen, const auto *val, std::size_t *sizeOut = nullptr) noexcept {
|
||||
CharBuffWriter bw(buff, buffLen);
|
||||
oxReturnError(writeMC(bw, *val));
|
||||
if (sizeOut) {
|
||||
|
6
deps/ox/src/ox/model/desctypes.hpp
vendored
6
deps/ox/src/ox/model/desctypes.hpp
vendored
@ -79,6 +79,9 @@ constexpr Error model(T *io, CommonPtrWith<Subscript> auto *type) noexcept {
|
||||
if constexpr(T::opType() == OpType::Reflect) {
|
||||
uint32_t st = 0;
|
||||
oxReturnError(io->field("subscriptType", &st));
|
||||
} else if constexpr(T::opType() == OpType::Write) {
|
||||
auto pt = type ? static_cast<uint8_t>(type->subscriptType) : 0;
|
||||
oxReturnError(io->field("subscriptType", &pt));
|
||||
} else {
|
||||
auto pt = type ? static_cast<uint32_t>(type->subscriptType) : 0;
|
||||
oxReturnError(io->field("subscriptType", &pt));
|
||||
@ -186,6 +189,9 @@ constexpr Error model(T *io, CommonPtrWith<DescriptorType> auto *type) noexcept
|
||||
if constexpr(T::opType() == OpType::Reflect) {
|
||||
uint8_t pt = 0;
|
||||
oxReturnError(io->field("primitiveType", &pt));
|
||||
} else if constexpr(T::opType() == OpType::Write) {
|
||||
auto pt = type ? static_cast<uint8_t>(type->primitiveType) : 0;
|
||||
oxReturnError(io->field("primitiveType", &pt));
|
||||
} else {
|
||||
auto pt = type ? static_cast<uint8_t>(type->primitiveType) : 0;
|
||||
oxReturnError(io->field("primitiveType", &pt));
|
||||
|
Loading…
Reference in New Issue
Block a user