Compare commits
2 Commits
release-d2
...
3006e77ef3
Author | SHA1 | Date | |
---|---|---|---|
3006e77ef3 | |||
59c112a69c |
38
deps/ox/src/ox/std/new.hpp
vendored
38
deps/ox/src/ox/std/new.hpp
vendored
@@ -30,11 +30,49 @@ constexpr void *operator new(std::size_t, void *addr) noexcept {
|
||||
constexpr void *operator new[](std::size_t, void *addr) noexcept {
|
||||
return addr;
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]]
|
||||
constexpr T* launder(T* __p) noexcept {
|
||||
return __builtin_launder(__p);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args, bool noex>
|
||||
void launder(T(*)(Args...) noexcept(noex)) = delete;
|
||||
template<typename T, typename... Args, bool noex>
|
||||
void launder(T(*)(Args......) noexcept(noex)) = delete;
|
||||
void launder(void*) = delete;
|
||||
void launder(void const*) = delete;
|
||||
void launder(volatile void*) = delete;
|
||||
void launder(volatile void const*) = delete;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace ox {
|
||||
|
||||
/**
|
||||
* Aliases type T in size and alignment to allow allocating space for a T
|
||||
* without running the constructor.
|
||||
*/
|
||||
template<typename T, std::size_t sz = sizeof(T)>
|
||||
struct alignas(alignof(T)) AllocAlias {
|
||||
char buff[sz];
|
||||
constexpr AllocAlias() noexcept = default;
|
||||
[[nodiscard]]
|
||||
auto data() noexcept {
|
||||
return reinterpret_cast<T*>(this);
|
||||
}
|
||||
[[nodiscard]]
|
||||
auto data() const noexcept {
|
||||
return reinterpret_cast<T const*>(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename T, typename U = T, typename ...Args>
|
||||
[[nodiscard]]
|
||||
constexpr U *make(Args &&...args) noexcept {
|
||||
|
19
deps/ox/src/ox/std/types.hpp
vendored
19
deps/ox/src/ox/std/types.hpp
vendored
@@ -63,25 +63,6 @@ namespace ox {
|
||||
|
||||
using CString = char const*;
|
||||
|
||||
/**
|
||||
* Aliases type T in size and alignment to allow allocating space for a T
|
||||
* without running the constructor.
|
||||
*/
|
||||
template<typename T, std::size_t sz = sizeof(T)>
|
||||
struct alignas(alignof(T)) AllocAlias {
|
||||
char buff[sz];
|
||||
constexpr AllocAlias() noexcept = default;
|
||||
[[nodiscard]]
|
||||
auto data() noexcept {
|
||||
return reinterpret_cast<T*>(this);
|
||||
}
|
||||
[[nodiscard]]
|
||||
auto data() const noexcept {
|
||||
return reinterpret_cast<const T*>(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<std::size_t sz>
|
||||
struct SignedType {
|
||||
};
|
||||
|
54
deps/ox/src/ox/std/vector.hpp
vendored
54
deps/ox/src/ox/std/vector.hpp
vendored
@@ -34,10 +34,10 @@ struct VectorAllocator {
|
||||
ox::Array<AllocAlias<T>, Size> m_data = {};
|
||||
protected:
|
||||
constexpr VectorAllocator() noexcept = default;
|
||||
constexpr VectorAllocator(const VectorAllocator&) noexcept = default;
|
||||
constexpr VectorAllocator(VectorAllocator const&) noexcept = default;
|
||||
constexpr VectorAllocator(VectorAllocator&&) noexcept = default;
|
||||
|
||||
constexpr void allocate(T **items, std::size_t cap) noexcept {
|
||||
constexpr void allocate(T **items, std::size_t const cap) noexcept {
|
||||
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
|
||||
if (std::is_constant_evaluated() || cap > Size) {
|
||||
*items = Allocator{}.allocate(cap);
|
||||
@@ -49,42 +49,26 @@ struct VectorAllocator {
|
||||
constexpr void moveConstructItemsFrom(
|
||||
T **items,
|
||||
VectorAllocator *src,
|
||||
const std::size_t count,
|
||||
const std::size_t cap) noexcept {
|
||||
std::size_t const count,
|
||||
std::size_t const cap) noexcept {
|
||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||
// try removing it later
|
||||
if (!std::is_constant_evaluated()) {
|
||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||
for (auto i = 0u; i < count; ++i) {
|
||||
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
|
||||
std::construct_at<T>(dstItem, std::move(*srcItem));
|
||||
auto const srcItem = std::launder(reinterpret_cast<T*>(&src->m_data[i]));
|
||||
new (&m_data[i]) T(std::move(*srcItem));
|
||||
}
|
||||
if (count) {
|
||||
*items = std::launder(reinterpret_cast<T*>(m_data.data()));
|
||||
} else {
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void moveItemsFrom(
|
||||
T **items,
|
||||
VectorAllocator *src,
|
||||
const std::size_t count,
|
||||
const std::size_t cap) noexcept {
|
||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||
// try removing it later
|
||||
if (!std::is_constant_evaluated()) {
|
||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||
for (std::size_t i = 0; i < count; ++i) {
|
||||
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
|
||||
*dstItem = std::move(*srcItem);
|
||||
}
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void deallocate(T *items, std::size_t cap) noexcept {
|
||||
constexpr void deallocate(T *const items, std::size_t const cap) noexcept {
|
||||
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
|
||||
if (std::is_constant_evaluated()) {
|
||||
if (items) {
|
||||
@@ -103,10 +87,10 @@ template<typename T, typename Allocator>
|
||||
struct VectorAllocator<T, Allocator, 0> {
|
||||
protected:
|
||||
constexpr VectorAllocator() noexcept = default;
|
||||
constexpr VectorAllocator(const VectorAllocator&) noexcept = default;
|
||||
constexpr VectorAllocator(VectorAllocator const&) noexcept = default;
|
||||
constexpr VectorAllocator(VectorAllocator&&) noexcept = default;
|
||||
|
||||
constexpr void allocate(T **items, std::size_t cap) noexcept {
|
||||
constexpr void allocate(T **items, std::size_t const cap) noexcept {
|
||||
*items = Allocator{}.allocate(cap);
|
||||
}
|
||||
|
||||
@@ -114,15 +98,15 @@ struct VectorAllocator<T, Allocator, 0> {
|
||||
constexpr void moveConstructItemsFrom(
|
||||
T**,
|
||||
VectorAllocator*,
|
||||
const std::size_t,
|
||||
const std::size_t) noexcept {
|
||||
std::size_t const,
|
||||
std::size_t const) noexcept {
|
||||
}
|
||||
|
||||
[[maybe_unused]]
|
||||
constexpr void moveItemsFrom(T**, VectorAllocator*, const std::size_t, const std::size_t) noexcept {
|
||||
constexpr void moveItemsFrom(T**, VectorAllocator*, std::size_t const, std::size_t const) noexcept {
|
||||
}
|
||||
|
||||
constexpr void deallocate(T *items, std::size_t cap) noexcept {
|
||||
constexpr void deallocate(T *const items, std::size_t const cap) noexcept {
|
||||
if (items) {
|
||||
Allocator{}.deallocate(items, cap);
|
||||
}
|
||||
@@ -421,7 +405,7 @@ constexpr Vector<T, SmallVectorSize, Allocator> &Vector<T, SmallVectorSize, Allo
|
||||
m_size = other.m_size;
|
||||
m_cap = other.m_cap;
|
||||
m_items = other.m_items;
|
||||
this->moveItemsFrom(&m_items, &other, m_size, m_cap);
|
||||
this->moveConstructItemsFrom(&m_items, &other, m_size, m_cap);
|
||||
other.m_size = 0;
|
||||
other.m_cap = 0;
|
||||
other.m_items = nullptr;
|
||||
|
@@ -15,7 +15,7 @@ target_link_libraries(
|
||||
|
||||
target_compile_definitions(
|
||||
NostalgiaStudio PUBLIC
|
||||
OLYMPIC_APP_VERSION="d2025.07.0"
|
||||
OLYMPIC_APP_VERSION="dev build"
|
||||
)
|
||||
|
||||
install(
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<string>APPL</string>
|
||||
|
||||
<key>CFBundleVersion</key>
|
||||
<string>d2025.07.0</string>
|
||||
<string>dev build</string>
|
||||
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0.0</string>
|
||||
|
@@ -8,13 +8,18 @@ namespace studio {
|
||||
|
||||
void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept {
|
||||
ox::String path = std::move(filePath);
|
||||
if (beginsWith(path, "uuid://")) {
|
||||
if (keel::isUuidUrl(path)) {
|
||||
auto const [p, err] = keel::uuidUrlToPath(keelCtx(ctx), path);
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
path = p;
|
||||
}
|
||||
//if (
|
||||
// auto const [np, err] = ctx.navStack.back();
|
||||
// !err && np->filePath == path && np->navArgs == navArgs.view()) {
|
||||
// return;
|
||||
//}
|
||||
ctx.navStack.resize(ctx.navIdx + 1);
|
||||
ctx.navStack.emplace_back(ox::String{path}, ox::String{navArgs.view()});
|
||||
try {
|
||||
@@ -49,8 +54,9 @@ void navigateBack(Context &ctx) noexcept {
|
||||
}
|
||||
|
||||
void navigateForward(Context &ctx) noexcept {
|
||||
while (ctx.navIdx < ctx.navStack.size()) {
|
||||
auto const &n = ctx.navStack[ctx.navIdx];
|
||||
auto const nextIdx = ctx.navIdx + 1;
|
||||
while (nextIdx < ctx.navStack.size()) {
|
||||
auto const &n = ctx.navStack[nextIdx];
|
||||
try {
|
||||
ctx.navCallback(n.filePath, n.navArgs);
|
||||
} catch (std::exception const &e) {
|
||||
@@ -58,7 +64,7 @@ void navigateForward(Context &ctx) noexcept {
|
||||
oxErrf("navigateForward failed: {}", e.what());
|
||||
}
|
||||
if (!ctx.project->exists(n.filePath)) {
|
||||
std::ignore = ctx.navStack.erase(ctx.navIdx);
|
||||
std::ignore = ctx.navStack.erase(nextIdx);
|
||||
continue;
|
||||
}
|
||||
++ctx.navIdx;
|
||||
|
Reference in New Issue
Block a user