Compare commits
No commits in common. "59fa39070f0c93be71060afb2584608e90cef84f" and "10a12f2ab20199df580da5bd7d8d22bae0a58cf0" have entirely different histories.
59fa39070f
...
10a12f2ab2
26
deps/ox/src/ox/fs/filesystem/filelocation.cpp
vendored
26
deps/ox/src/ox/fs/filesystem/filelocation.cpp
vendored
@ -88,32 +88,6 @@ FileAddress &FileAddress::operator=(FileAddress &&other) noexcept {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileAddress::operator==(FileAddress const&other) const noexcept {
|
|
||||||
if (m_type != other.m_type) {
|
|
||||||
auto const aIsPath =
|
|
||||||
m_type == FileAddressType::Path || m_type == FileAddressType::ConstPath;
|
|
||||||
auto const bIsPath =
|
|
||||||
other.m_type == FileAddressType::Path || other.m_type == FileAddressType::ConstPath;
|
|
||||||
if (!(aIsPath && bIsPath)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (m_type) {
|
|
||||||
case FileAddressType::ConstPath:
|
|
||||||
case FileAddressType::Path: {
|
|
||||||
auto const a = getPath();
|
|
||||||
auto const b = other.getPath();
|
|
||||||
return (other.m_type == FileAddressType::ConstPath || other.m_type == FileAddressType::Path)
|
|
||||||
&& (a.value == b.value);
|
|
||||||
}
|
|
||||||
case FileAddressType::Inode:
|
|
||||||
return m_data.inode == other.m_data.inode;
|
|
||||||
case FileAddressType::None:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FileAddress::operator==(CRStringView path) const noexcept {
|
bool FileAddress::operator==(CRStringView path) const noexcept {
|
||||||
auto [p, err] = getPath();
|
auto [p, err] = getPath();
|
||||||
if (err) {
|
if (err) {
|
||||||
|
11
deps/ox/src/ox/fs/filesystem/filelocation.hpp
vendored
11
deps/ox/src/ox/fs/filesystem/filelocation.hpp
vendored
@ -22,9 +22,6 @@ enum class FileAddressType: int8_t {
|
|||||||
Inode,
|
Inode,
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
constexpr Error model(T *h, CommonPtrWith<class FileAddress> auto *fa) noexcept;
|
|
||||||
|
|
||||||
class FileAddress {
|
class FileAddress {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -70,8 +67,6 @@ class FileAddress {
|
|||||||
|
|
||||||
FileAddress &operator=(FileAddress &&other) noexcept;
|
FileAddress &operator=(FileAddress &&other) noexcept;
|
||||||
|
|
||||||
bool operator==(const FileAddress &other) const noexcept;
|
|
||||||
|
|
||||||
bool operator==(CRStringView path) const noexcept;
|
bool operator==(CRStringView path) const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
@ -94,12 +89,12 @@ class FileAddress {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Result<ox::CStringView> getPath() const noexcept {
|
constexpr Result<ox::StringView> getPath() const noexcept {
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case FileAddressType::Path:
|
case FileAddressType::Path:
|
||||||
return ox::CStringView(m_data.path);
|
return ox::StringView(m_data.path);
|
||||||
case FileAddressType::ConstPath:
|
case FileAddressType::ConstPath:
|
||||||
return ox::CStringView(m_data.constPath);
|
return ox::StringView(m_data.constPath);
|
||||||
default:
|
default:
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
}
|
}
|
||||||
|
2
deps/ox/src/ox/model/modelvalue.hpp
vendored
2
deps/ox/src/ox/model/modelvalue.hpp
vendored
@ -760,7 +760,7 @@ constexpr std::size_t alignOf(const ModelValue &t) noexcept {
|
|||||||
size = PlatSpec::alignOf(t.get<int64_t>());
|
size = PlatSpec::alignOf(t.get<int64_t>());
|
||||||
break;
|
break;
|
||||||
case ModelValue::Type::String:
|
case ModelValue::Type::String:
|
||||||
size = alignOf<PlatSpec>(t.get<ox::String>());
|
size = PlatSpec::alignOf(t.get<ox::String>());
|
||||||
break;
|
break;
|
||||||
case ModelValue::Type::Object:
|
case ModelValue::Type::Object:
|
||||||
size = alignOf<PlatSpec>(t.get<ox::ModelObject>());
|
size = alignOf<PlatSpec>(t.get<ox::ModelObject>());
|
||||||
|
1
deps/ox/src/ox/preloader/platspecs.hpp
vendored
1
deps/ox/src/ox/preloader/platspecs.hpp
vendored
@ -9,7 +9,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ox/std/serialize.hpp>
|
#include <ox/std/serialize.hpp>
|
||||||
#include <ox/std/string.hpp>
|
|
||||||
#include <ox/std/typetraits.hpp>
|
#include <ox/std/typetraits.hpp>
|
||||||
|
|
||||||
#include "alignmentcatcher.hpp"
|
#include "alignmentcatcher.hpp"
|
||||||
|
48
deps/ox/src/ox/preloader/preloader.hpp
vendored
48
deps/ox/src/ox/preloader/preloader.hpp
vendored
@ -14,12 +14,10 @@
|
|||||||
#include <ox/std/error.hpp>
|
#include <ox/std/error.hpp>
|
||||||
#include <ox/std/memops.hpp>
|
#include <ox/std/memops.hpp>
|
||||||
#include <ox/std/memory.hpp>
|
#include <ox/std/memory.hpp>
|
||||||
#include <ox/std/string.hpp>
|
|
||||||
#include <ox/std/types.hpp>
|
#include <ox/std/types.hpp>
|
||||||
#include <ox/std/typetraits.hpp>
|
#include <ox/std/typetraits.hpp>
|
||||||
#include <ox/std/units.hpp>
|
#include <ox/std/units.hpp>
|
||||||
#include <ox/model/modelhandleradaptor.hpp>
|
#include <ox/model/modelhandleradaptor.hpp>
|
||||||
#include <ox/model/modelvalue.hpp>
|
|
||||||
|
|
||||||
#include "platspecs.hpp"
|
#include "platspecs.hpp"
|
||||||
|
|
||||||
@ -107,9 +105,9 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>, OpType::Reflect> {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr ox::Error field(CRStringView, const T **val, std::size_t cnt) noexcept;
|
constexpr ox::Error field(CRStringView, const T **val, std::size_t cnt) noexcept;
|
||||||
|
|
||||||
constexpr ox::Result<std::size_t> startAlloc(size_t sz, size_t align) noexcept;
|
constexpr ox::Result<std::size_t> startAlloc(std::size_t sz) noexcept;
|
||||||
|
|
||||||
constexpr ox::Result<std::size_t> startAlloc(size_t sz, size_t align, std::size_t restore) noexcept;
|
constexpr ox::Result<std::size_t> startAlloc(std::size_t sz, std::size_t restore) noexcept;
|
||||||
|
|
||||||
constexpr ox::Error endAlloc() noexcept;
|
constexpr ox::Error endAlloc() noexcept;
|
||||||
|
|
||||||
@ -171,16 +169,14 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const T *val)
|
|||||||
}
|
}
|
||||||
oxReturnError(pad(val));
|
oxReturnError(pad(val));
|
||||||
if constexpr(ox::is_integral_v<T>) {
|
if constexpr(ox::is_integral_v<T>) {
|
||||||
|
//oxDebugf("Preloader::field(name, val): {}", name);
|
||||||
return ox::serialize(&m_writer, PlatSpec::correctEndianness(*val));
|
return ox::serialize(&m_writer, PlatSpec::correctEndianness(*val));
|
||||||
} else if constexpr(ox::is_pointer_v<T>) {
|
} else if constexpr(ox::is_pointer_v<T>) {
|
||||||
const PtrType a = startAlloc(sizeOf<PlatSpec>(val), alignOf<PlatSpec>(*val), m_writer.tellp()) + PlatSpec::RomStart;
|
const PtrType a = startAlloc(sizeOf<PlatSpec>(*val), m_writer.tellp()) + PlatSpec::RomStart;
|
||||||
oxReturnError(field(name, *val));
|
oxReturnError(field(name, *val));
|
||||||
oxReturnError(endAlloc());
|
oxReturnError(endAlloc());
|
||||||
return ox::serialize(&m_writer, PlatSpec::correctEndianness(a));
|
return ox::serialize(&m_writer, PlatSpec::correctEndianness(a));
|
||||||
} else if constexpr(ox::isVector_v<T>) {
|
} else if constexpr(ox::isVector_v<T> || ox::is_same_v<T, ox::ModelValueVector>) {
|
||||||
return fieldVector(name, val);
|
|
||||||
} else if constexpr(ox::is_same_v<T, ox::ModelValueVector>) {
|
|
||||||
val->types();
|
|
||||||
return fieldVector(name, val);
|
return fieldVector(name, val);
|
||||||
} else {
|
} else {
|
||||||
m_unionIdx.emplace_back(-1);
|
m_unionIdx.emplace_back(-1);
|
||||||
@ -226,7 +222,6 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const ox::Arra
|
|||||||
if (!unionCheckAndIt()) {
|
if (!unionCheckAndIt()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
oxReturnError(pad(&(*val)[0]));
|
|
||||||
// serialize the Array elements
|
// serialize the Array elements
|
||||||
if constexpr(sz) {
|
if constexpr(sz) {
|
||||||
m_unionIdx.emplace_back(-1);
|
m_unionIdx.emplace_back(-1);
|
||||||
@ -244,36 +239,27 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const T **val, std:
|
|||||||
if (!unionCheckAndIt()) {
|
if (!unionCheckAndIt()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (cnt) {
|
// serialize the array
|
||||||
oxReturnError(pad(*val));
|
m_unionIdx.emplace_back(-1);
|
||||||
// serialize the array
|
for (std::size_t i = 0; i < cnt; ++i) {
|
||||||
m_unionIdx.emplace_back(-1);
|
oxReturnError(this->interface()->field(nullptr, &val[i]));
|
||||||
for (std::size_t i = 0; i < cnt; ++i) {
|
|
||||||
oxReturnError(this->interface()->field(nullptr, &val[i]));
|
|
||||||
}
|
|
||||||
m_unionIdx.pop_back();
|
|
||||||
}
|
}
|
||||||
|
m_unionIdx.pop_back();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PlatSpec>
|
template<typename PlatSpec>
|
||||||
constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(size_t sz, size_t align) noexcept {
|
constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(std::size_t sz) noexcept {
|
||||||
|
oxRequire(a, ox::allocate(&m_writer, sz));
|
||||||
m_allocStack.emplace_back(static_cast<typename PlatSpec::PtrType>(m_writer.tellp()));
|
m_allocStack.emplace_back(static_cast<typename PlatSpec::PtrType>(m_writer.tellp()));
|
||||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
|
||||||
const auto padding = m_writer.tellp() % align;
|
|
||||||
oxRequireM(a, ox::allocate(&m_writer, sz + padding));
|
|
||||||
a += padding;
|
|
||||||
oxReturnError(m_writer.seekp(a));
|
oxReturnError(m_writer.seekp(a));
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PlatSpec>
|
template<typename PlatSpec>
|
||||||
constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(std::size_t sz, size_t align, std::size_t restore) noexcept {
|
constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(std::size_t sz, std::size_t restore) noexcept {
|
||||||
|
oxRequire(a, ox::allocate(&m_writer, sz));
|
||||||
m_allocStack.emplace_back(restore, ox::ios_base::beg);
|
m_allocStack.emplace_back(restore, ox::ios_base::beg);
|
||||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
|
||||||
const auto padding = m_writer.tellp() % align;
|
|
||||||
oxRequireM(a, ox::allocate(&m_writer, sz + padding));
|
|
||||||
a += padding;
|
|
||||||
oxReturnError(m_writer.seekp(a));
|
oxReturnError(m_writer.seekp(a));
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@ -345,11 +331,7 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
|||||||
// serialize the Vector elements
|
// serialize the Vector elements
|
||||||
if (val->size()) {
|
if (val->size()) {
|
||||||
const auto sz = sizeOf<PlatSpec>(&(*val)[0]) * val->size();
|
const auto sz = sizeOf<PlatSpec>(&(*val)[0]) * val->size();
|
||||||
const auto align = alignOf<PlatSpec>((*val)[0]);
|
oxRequire(p, ox::allocate(&m_writer, sz));
|
||||||
oxReturnError(m_writer.seekp(0, ox::ios_base::end));
|
|
||||||
const auto padding = m_writer.tellp() % align;
|
|
||||||
oxRequireM(p, ox::allocate(&m_writer, sz + padding));
|
|
||||||
p += padding;
|
|
||||||
oxReturnError(m_writer.seekp(p));
|
oxReturnError(m_writer.seekp(p));
|
||||||
m_unionIdx.emplace_back(-1);
|
m_unionIdx.emplace_back(-1);
|
||||||
for (std::size_t i = 0; i < val->size(); ++i) {
|
for (std::size_t i = 0; i < val->size(); ++i) {
|
||||||
|
2
deps/ox/src/ox/std/strops.hpp
vendored
2
deps/ox/src/ox/std/strops.hpp
vendored
@ -20,7 +20,7 @@ namespace ox {
|
|||||||
|
|
||||||
template<OxString_c Str>
|
template<OxString_c Str>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr Str substr(Str const&str, std::size_t pos) noexcept {
|
constexpr ox::StringView substr(Str const&str, std::size_t pos) noexcept {
|
||||||
if (str.len() >= pos) {
|
if (str.len() >= pos) {
|
||||||
return Str(str.data() + pos, str.len() - pos);
|
return Str(str.data() + pos, str.len() - pos);
|
||||||
}
|
}
|
||||||
|
12
deps/ox/src/ox/std/vector.hpp
vendored
12
deps/ox/src/ox/std/vector.hpp
vendored
@ -239,9 +239,6 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr Result<const T*> back() const noexcept;
|
constexpr Result<const T*> back() const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr std::size_t capacity() const noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::size_t size() const noexcept;
|
constexpr std::size_t size() const noexcept;
|
||||||
|
|
||||||
@ -427,7 +424,7 @@ constexpr const T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t
|
|||||||
|
|
||||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||||
constexpr Result<T*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) noexcept {
|
constexpr Result<T*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) noexcept {
|
||||||
if (i < size()) [[likely]] {
|
if (i < size()) {
|
||||||
return &operator[](i);
|
return &operator[](i);
|
||||||
}
|
}
|
||||||
return OxError(1, "Vector: Invalid index");
|
return OxError(1, "Vector: Invalid index");
|
||||||
@ -435,7 +432,7 @@ constexpr Result<T*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) noexcep
|
|||||||
|
|
||||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||||
constexpr Result<T const*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) const noexcept {
|
constexpr Result<T const*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) const noexcept {
|
||||||
if (i < size()) [[likely]] {
|
if (i < size()) {
|
||||||
return &operator[](i);
|
return &operator[](i);
|
||||||
}
|
}
|
||||||
return OxError(1, "Vector: Invalid index");
|
return OxError(1, "Vector: Invalid index");
|
||||||
@ -473,11 +470,6 @@ constexpr Result<const T*> Vector<T, SmallVectorSize, Allocator>::back() const n
|
|||||||
return &m_items[m_size - 1];
|
return &m_items[m_size - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
|
||||||
constexpr std::size_t Vector<T, SmallVectorSize, Allocator>::capacity() const noexcept {
|
|
||||||
return m_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||||
constexpr std::size_t Vector<T, SmallVectorSize, Allocator>::size() const noexcept {
|
constexpr std::size_t Vector<T, SmallVectorSize, Allocator>::size() const noexcept {
|
||||||
return m_size;
|
return m_size;
|
||||||
|
@ -91,9 +91,9 @@ ox::Error preloadObj(
|
|||||||
oxRequireM(buff, romFs.read(path));
|
oxRequireM(buff, romFs.read(path));
|
||||||
oxRequireM(obj, keel::readAsset(ts, buff));
|
oxRequireM(obj, keel::readAsset(ts, buff));
|
||||||
if (obj.type()->preloadable) {
|
if (obj.type()->preloadable) {
|
||||||
oxOutf("preloading {} as a {}\n", path, obj.type()->typeName);
|
oxOutf("preloading {}\n", path);
|
||||||
// preload
|
// preload
|
||||||
oxRequire(a, pl.startAlloc(ox::sizeOf<GbaPlatSpec>(&obj), ox::alignOf<GbaPlatSpec>(obj)));
|
oxRequire(a, pl.startAlloc(ox::sizeOf<GbaPlatSpec>(&obj)));
|
||||||
auto const err = ox::preload<GbaPlatSpec, decltype(obj)>(&pl, &obj);
|
auto const err = ox::preload<GbaPlatSpec, decltype(obj)>(&pl, &obj);
|
||||||
oxReturnError(pl.endAlloc());
|
oxReturnError(pl.endAlloc());
|
||||||
oxReturnError(err);
|
oxReturnError(err);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user