[ox/model] Add preloadable attribute to type descriptor
This commit is contained in:
parent
dfb17c851b
commit
f91874182e
2
deps/ox/src/ox/model/desctypes.hpp
vendored
2
deps/ox/src/ox/model/desctypes.hpp
vendored
@ -106,6 +106,7 @@ struct DescriptorType {
|
||||
// - number of bytes for integer and float types
|
||||
// - number of fields for structs and lists
|
||||
int64_t length = 0;
|
||||
bool preloadable = false;
|
||||
|
||||
DescriptorType() = default;
|
||||
|
||||
@ -125,6 +126,7 @@ Error model(T *io, DescriptorType *type) {
|
||||
err |= io->field("primitiveType", &type->primitiveType);
|
||||
err |= io->field("fieldList", &type->fieldList);
|
||||
err |= io->field("length", &type->length);
|
||||
err |= io->field("preloadable", &type->preloadable);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
20
deps/ox/src/ox/model/descwrite.cpp
vendored
20
deps/ox/src/ox/model/descwrite.cpp
vendored
@ -12,6 +12,26 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct preloadable_type {
|
||||
static constexpr auto Preloadable = true;
|
||||
};
|
||||
|
||||
struct non_preloadable_type {
|
||||
static constexpr auto Preloadable = false;
|
||||
};
|
||||
|
||||
struct non_preloadable_type2 {
|
||||
};
|
||||
|
||||
static_assert(preloadable<preloadable_type>::value);
|
||||
static_assert(!preloadable<non_preloadable_type>::value);
|
||||
static_assert(!preloadable<non_preloadable_type2>::value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static_assert([] {
|
||||
int i = 0;
|
||||
return indirectionLevels(i) == 0;
|
||||
|
19
deps/ox/src/ox/model/descwrite.hpp
vendored
19
deps/ox/src/ox/model/descwrite.hpp
vendored
@ -21,6 +21,22 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<bool>
|
||||
struct BoolWrapper {
|
||||
};
|
||||
|
||||
template<typename T, typename = BoolWrapper<true>>
|
||||
struct preloadable: false_type {};
|
||||
|
||||
template<typename T>
|
||||
struct preloadable<T, BoolWrapper<T::Preloadable>> {
|
||||
static constexpr bool value = T::Preloadable;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static constexpr int indirectionLevels(T) {
|
||||
return 0;
|
||||
@ -187,11 +203,12 @@ void TypeDescWriter::setTypeInfo(const char *name, int) {
|
||||
}
|
||||
m_type = t;
|
||||
m_type->typeName = name;
|
||||
if (ox::is_union_v<T>) {
|
||||
if (is_union_v<T>) {
|
||||
m_type->primitiveType = PrimitiveType::Union;
|
||||
} else {
|
||||
m_type->primitiveType = PrimitiveType::Struct;
|
||||
}
|
||||
m_type->preloadable = detail::preloadable<T>::value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user