[ox] GBA fixes

This commit is contained in:
Gary Talent 2023-02-03 21:56:30 -06:00
parent 535480ef26
commit b1b2780eb9
4 changed files with 17 additions and 2 deletions

View File

@ -8,7 +8,7 @@
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <cassert>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <memory> #include <memory>

View File

@ -93,7 +93,14 @@ Result<String> writeClawHeader(T *t, ClawFormat fmt) noexcept {
Result<Buffer> writeClaw(auto *t, ClawFormat fmt = ClawFormat::Metal) { Result<Buffer> writeClaw(auto *t, ClawFormat fmt = ClawFormat::Metal) {
oxRequire(header, detail::writeClawHeader(t, fmt)); oxRequire(header, detail::writeClawHeader(t, fmt));
#ifdef OX_USE_STDLIB
oxRequire(data, fmt == ClawFormat::Metal ? writeMC(t) : writeOC(t)); oxRequire(data, fmt == ClawFormat::Metal ? writeMC(t) : writeOC(t));
#else
if (fmt != ClawFormat::Metal) {
return OxError(1, "OC is not supported in this build");
}
oxRequire(data, writeMC(t));
#endif
Buffer out(header.len() + data.size()); Buffer out(header.len() + data.size());
memcpy(out.data(), header.data(), header.len()); memcpy(out.data(), header.data(), header.len());
memcpy(out.data() + header.len(), data.data(), data.size()); memcpy(out.data() + header.len(), data.data(), data.size());

View File

@ -342,7 +342,7 @@ constexpr Error MetalClawWriter::field(const char*, T *val, std::size_t len) noe
MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt); MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt);
ModelHandlerInterface handler{&writer}; ModelHandlerInterface handler{&writer};
handler.setTypeInfo<T>("List", 0, {}, len); handler.setTypeInfo<T>("List", 0, {}, static_cast<int>(len));
// write the array // write the array
for (std::size_t i = 0; i < len; i++) { for (std::size_t i = 0; i < len; i++) {

View File

@ -19,6 +19,7 @@
#include "optype.hpp" #include "optype.hpp"
#include "types.hpp" #include "types.hpp"
#include "typenamecatcher.hpp"
namespace ox { namespace ox {
@ -26,6 +27,13 @@ using FieldName = String;
using TypeParamPack = Vector<String>; using TypeParamPack = Vector<String>;
template<typename T>
constexpr auto buildTypeId() noexcept {
constexpr auto name = requireModelTypeName<T>();
constexpr auto version = requireModelTypeVersion<T>();
return ox::sfmt("{};{}", name, version);
}
static constexpr auto buildTypeId(CRStringView name, int version, static constexpr auto buildTypeId(CRStringView name, int version,
const TypeParamPack &typeParams = {}) noexcept { const TypeParamPack &typeParams = {}) noexcept {
String tp; String tp;