[ox] Add StringView, Writer system, Preloader system

This commit is contained in:
2022-11-30 01:45:11 -06:00
parent 98f35140fe
commit cbb496c59f
64 changed files with 2343 additions and 417 deletions

View File

@ -24,10 +24,12 @@ namespace detail {
struct TypeInfoCatcher {
const char *name = nullptr;
int version = 0;
template<typename T = void>
constexpr void setTypeInfo(const char *name = T::TypeName, int = T::TypeVersion) noexcept {
constexpr void setTypeInfo(const char *name = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, int = 0) noexcept {
this->name = name;
this->version = v;
}
constexpr Error field(...) noexcept {
@ -57,6 +59,13 @@ constexpr const char *getTypeName(T *t) noexcept {
return tnc.name;
}
template<typename T>
constexpr int getTypeVersion(T *t) noexcept {
TypeInfoCatcher tnc;
oxIgnoreError(model(&tnc, t));
return tnc.version;
}
template<typename T>
Result<String> writeClawHeader(T *t, ClawFormat fmt) noexcept {
String out;
@ -72,7 +81,7 @@ Result<String> writeClawHeader(T *t, ClawFormat fmt) noexcept {
}
out += detail::getTypeName(t);
out += ";";
const auto tn = detail::type_version<T>::value;
const auto tn = detail::getTypeVersion(t);
if (tn > -1) {
out += tn;
}