[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 {};
|
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);
|
MetalClawWriter mcWriter(writer);
|
||||||
ModelHandlerInterface handler{&mcWriter};
|
ModelHandlerInterface handler{&mcWriter};
|
||||||
oxReturnError(model(&handler, &val));
|
oxReturnError(model(&handler, &val));
|
||||||
@ -414,7 +414,7 @@ Result<Buffer> writeMC(Writer_c auto &writer, auto &val) noexcept {
|
|||||||
return {};
|
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);
|
Buffer buff(buffReserveSz);
|
||||||
BufferWriter bw(&buff, 0);
|
BufferWriter bw(&buff, 0);
|
||||||
oxReturnError(writeMC(bw, *val));
|
oxReturnError(writeMC(bw, *val));
|
||||||
@ -422,7 +422,7 @@ Result<Buffer> writeMC(auto *val, std::size_t buffReserveSz = 2 * units::KB) noe
|
|||||||
return buff;
|
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);
|
CharBuffWriter bw(buff, buffLen);
|
||||||
oxReturnError(writeMC(bw, *val));
|
oxReturnError(writeMC(bw, *val));
|
||||||
if (sizeOut) {
|
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) {
|
if constexpr(T::opType() == OpType::Reflect) {
|
||||||
uint32_t st = 0;
|
uint32_t st = 0;
|
||||||
oxReturnError(io->field("subscriptType", &st));
|
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 {
|
} else {
|
||||||
auto pt = type ? static_cast<uint32_t>(type->subscriptType) : 0;
|
auto pt = type ? static_cast<uint32_t>(type->subscriptType) : 0;
|
||||||
oxReturnError(io->field("subscriptType", &pt));
|
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) {
|
if constexpr(T::opType() == OpType::Reflect) {
|
||||||
uint8_t pt = 0;
|
uint8_t pt = 0;
|
||||||
oxReturnError(io->field("primitiveType", &pt));
|
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 {
|
} else {
|
||||||
auto pt = type ? static_cast<uint8_t>(type->primitiveType) : 0;
|
auto pt = type ? static_cast<uint8_t>(type->primitiveType) : 0;
|
||||||
oxReturnError(io->field("primitiveType", &pt));
|
oxReturnError(io->field("primitiveType", &pt));
|
||||||
|
Loading…
Reference in New Issue
Block a user