Compare commits
9 Commits
acd93337d4
...
e30ebce4c0
| Author | SHA1 | Date | |
|---|---|---|---|
| e30ebce4c0 | |||
| 7163947efd | |||
| 0a0a6e306d | |||
| 97bc9332d3 | |||
| 9caf7099b6 | |||
| fda1280d29 | |||
| 59aa4ad21a | |||
| 1a8afa1a98 | |||
| cdbc2d6cc8 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@
|
||||
.stfolder
|
||||
.stignore
|
||||
scripts/__pycache__
|
||||
pyenv
|
||||
CMakeLists.txt.user
|
||||
ROM.oxfs
|
||||
Session.vim
|
||||
|
||||
54
deps/ox/deps/cityhash/include/cityhash/city.h
vendored
54
deps/ox/deps/cityhash/include/cityhash/city.h
vendored
@@ -100,27 +100,52 @@ typedef uint32_t uintptr_t;
|
||||
#error intptr_t, and uintptr_t undefined
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
using size_t = decltype(alignof(int));
|
||||
|
||||
|
||||
|
||||
#if __has_include(<utility>)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace cityhash::detail {
|
||||
|
||||
template<typename T>
|
||||
struct remove_reference {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct remove_reference<T&> {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct remove_reference<T&&> {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using remove_reference_t = typename remove_reference<T>::type;
|
||||
|
||||
template<typename T>
|
||||
constexpr remove_reference_t<T> &&move(T &&t) noexcept {
|
||||
return static_cast<remove_reference_t<T>&&>(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using remove_reference_t = typename remove_reference<T>::type;
|
||||
template<typename T1, typename T2>
|
||||
struct pair {
|
||||
T1 first{};
|
||||
T2 second{};
|
||||
constexpr pair() noexcept = default;
|
||||
constexpr pair(T1 a, T2 b) noexcept: first(std::move(a)), second(std::move(b)) {}
|
||||
constexpr pair(T1 a, T2 b) noexcept: first(detail::move(a)), second(detail::move(b)) {}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
constexpr void swap(T &a, T &b) noexcept {
|
||||
auto temp = detail::move(a);
|
||||
a = detail::move(b);
|
||||
b = detail::move(temp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace cityhash {
|
||||
@@ -129,13 +154,6 @@ using uint128 = cityhash::detail::pair<uint64_t, uint64_t>;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
constexpr void swap(T &a, T &b) noexcept {
|
||||
auto temp = std::move(a);
|
||||
a = std::move(b);
|
||||
b = std::move(temp);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]]
|
||||
constexpr T byteSwap(T i) noexcept {
|
||||
@@ -290,7 +308,7 @@ constexpr uint32_t Hash32Len0to4(const char *s, size_t len) noexcept {
|
||||
uint32_t b = 0;
|
||||
uint32_t c = 9;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
signed char v = static_cast<signed char>(s[i]);
|
||||
auto const v = static_cast<signed char>(s[i]);
|
||||
b = b * detail::c1 + static_cast<uint32_t>(v);
|
||||
c ^= b;
|
||||
}
|
||||
|
||||
75
deps/ox/src/ox/std/istring.hpp
vendored
75
deps/ox/src/ox/std/istring.hpp
vendored
@@ -10,17 +10,17 @@
|
||||
|
||||
#include "ignore.hpp"
|
||||
#include "memops.hpp"
|
||||
#include "ox/std/error.hpp"
|
||||
#include "stringview.hpp"
|
||||
#include "strops.hpp"
|
||||
#include "typetraits.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
// Inline String
|
||||
template<std::size_t buffLen>
|
||||
template<std::size_t StrCap>
|
||||
class IString {
|
||||
private:
|
||||
char m_buff[buffLen + 1];
|
||||
char m_buff[StrCap + 1];
|
||||
size_t m_size{};
|
||||
|
||||
public:
|
||||
@@ -87,6 +87,8 @@ class IString {
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t bytes() const noexcept;
|
||||
|
||||
constexpr ox::Error resize(size_t sz) noexcept;
|
||||
|
||||
/**
|
||||
* Returns the capacity of bytes for this string.
|
||||
*/
|
||||
@@ -192,38 +194,38 @@ constexpr IString<size> IString<size>::operator+(Integer_c auto i) const noexcep
|
||||
return this->operator+(str);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool IString<buffLen>::operator==(const char *other) const noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr bool IString<StrCap>::operator==(const char *other) const noexcept {
|
||||
return ox::StringView(*this) == other;
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool IString<buffLen>::operator==(const OxString_c auto &other) const noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr bool IString<StrCap>::operator==(const OxString_c auto &other) const noexcept {
|
||||
return ox::StringView(*this) == ox::StringView(other);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool IString<buffLen>::operator!=(const char *other) const noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr bool IString<StrCap>::operator!=(const char *other) const noexcept {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool IString<buffLen>::operator!=(const OxString_c auto &other) noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr bool IString<StrCap>::operator!=(const OxString_c auto &other) noexcept {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr char IString<buffLen>::operator[](std::size_t i) const noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr char IString<StrCap>::operator[](std::size_t i) const noexcept {
|
||||
return m_buff[i];
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr char &IString<buffLen>::operator[](std::size_t i) noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr char &IString<StrCap>::operator[](std::size_t i) noexcept {
|
||||
return m_buff[i];
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr Error IString<buffLen>::append(const char *str, std::size_t strLen) noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr Error IString<StrCap>::append(const char *str, std::size_t strLen) noexcept {
|
||||
Error err;
|
||||
auto currentLen = len();
|
||||
if (cap() < currentLen + strLen + 1) {
|
||||
@@ -236,26 +238,26 @@ constexpr Error IString<buffLen>::append(const char *str, std::size_t strLen) no
|
||||
return err;
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr const char *IString<buffLen>::data() const noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr const char *IString<StrCap>::data() const noexcept {
|
||||
return static_cast<const char*>(m_buff);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr char *IString<buffLen>::data() noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr char *IString<StrCap>::data() noexcept {
|
||||
return static_cast<char*>(m_buff);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr const char *IString<buffLen>::c_str() const noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr const char *IString<StrCap>::c_str() const noexcept {
|
||||
return static_cast<const char*>(m_buff);
|
||||
}
|
||||
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr std::size_t IString<buffLen>::len() const noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr std::size_t IString<StrCap>::len() const noexcept {
|
||||
std::size_t length = 0;
|
||||
for (std::size_t i = 0; i < buffLen; i++) {
|
||||
for (std::size_t i = 0; i < StrCap; i++) {
|
||||
uint8_t b = static_cast<uint8_t>(m_buff[i]);
|
||||
if (b) {
|
||||
const auto asciiChar = (b & 128) == 0;
|
||||
@@ -270,16 +272,25 @@ constexpr std::size_t IString<buffLen>::len() const noexcept {
|
||||
return length;
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr std::size_t IString<buffLen>::bytes() const noexcept {
|
||||
template<std::size_t StrCap>
|
||||
constexpr std::size_t IString<StrCap>::bytes() const noexcept {
|
||||
std::size_t i = 0;
|
||||
for (i = 0; i < buffLen && m_buff[i]; i++);
|
||||
for (i = 0; i < StrCap && m_buff[i]; i++);
|
||||
return i + 1; // add one for null terminator
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr std::size_t IString<buffLen>::cap() const noexcept {
|
||||
return buffLen;
|
||||
template<std::size_t StrCap>
|
||||
constexpr ox::Error IString<StrCap>::resize(size_t sz) noexcept {
|
||||
if (sz > StrCap) {
|
||||
return OxError(1, "Trying to extend IString beyond its cap");
|
||||
}
|
||||
m_size = sz;
|
||||
return {};
|
||||
}
|
||||
|
||||
template<std::size_t StrCap>
|
||||
constexpr std::size_t IString<StrCap>::cap() const noexcept {
|
||||
return StrCap;
|
||||
}
|
||||
|
||||
template<size_t sz>
|
||||
|
||||
15
deps/ox/src/ox/std/strops.hpp
vendored
15
deps/ox/src/ox/std/strops.hpp
vendored
@@ -14,26 +14,23 @@
|
||||
#include "stringview.hpp"
|
||||
#include "types.hpp"
|
||||
#include "vector.hpp"
|
||||
#include "writer.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
template<OxString_c Str>
|
||||
[[nodiscard]]
|
||||
constexpr Str substr(Str const&str, std::size_t pos) noexcept {
|
||||
constexpr ox::StringView substr(ox::StringView const&str, std::size_t pos) noexcept {
|
||||
if (str.len() >= pos) {
|
||||
return Str(str.data() + pos, str.len() - pos);
|
||||
return {str.data() + pos, str.len() - pos};
|
||||
}
|
||||
return Str();
|
||||
return {};
|
||||
}
|
||||
|
||||
template<OxString_c Str>
|
||||
[[nodiscard]]
|
||||
constexpr ox::StringView substr(Str const&str, std::size_t start, std::size_t end) noexcept {
|
||||
constexpr ox::StringView substr(ox::StringView const&str, std::size_t start, std::size_t end) noexcept {
|
||||
if (str.len() >= start && end >= start) {
|
||||
return Str(str.data() + start, end - start);
|
||||
return {str.data() + start, end - start};
|
||||
}
|
||||
return Str();
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Integer>
|
||||
|
||||
5
deps/ox/src/ox/std/uuid.hpp
vendored
5
deps/ox/src/ox/std/uuid.hpp
vendored
@@ -8,12 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "array.hpp"
|
||||
#include "istring.hpp"
|
||||
#include "buffer.hpp"
|
||||
#include "random.hpp"
|
||||
#include "ranges.hpp"
|
||||
#include "stringview.hpp"
|
||||
#include "strops.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
@@ -80,7 +80,8 @@ constexpr ox::IString<2> toHex(uint8_t v) noexcept {
|
||||
'e',
|
||||
'f',
|
||||
};
|
||||
ox::Array<char, 3> out;
|
||||
ox::IString<2> out;
|
||||
std::ignore = out.resize(2);
|
||||
out[0] = valMap[static_cast<unsigned>((v & 0xf0) / 16)];
|
||||
out[1] = valMap[static_cast<unsigned>(v & 0x0f)];
|
||||
out[2] = 0;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "pages",
|
||||
"subscriptLevels" : 2,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint16;0"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.core.Palette",
|
||||
"typeVersion" : 2
|
||||
}
|
||||
@@ -27,7 +27,7 @@ struct TileSheetV1 {
|
||||
int rows = 1;
|
||||
int columns = 1;
|
||||
ox::FileAddress defaultPalette;
|
||||
Palette pal;
|
||||
PaletteV1 pal;
|
||||
ox::Vector<uint8_t> pixels = {};
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ static ox::Error pathToInode(
|
||||
return {};
|
||||
}
|
||||
if (beginsWith(path, "uuid://")) {
|
||||
auto const uuid = substr<ox::StringView>(path, 7);
|
||||
auto const uuid = ox::substr(path, 7);
|
||||
oxReturnError(keel::uuidToPath(ctx, uuid).moveTo(path));
|
||||
}
|
||||
oxRequire(s, dest.stat(path));
|
||||
|
||||
@@ -13,5 +13,6 @@
|
||||
#include <studio/popup.hpp>
|
||||
#include <studio/project.hpp>
|
||||
#include <studio/task.hpp>
|
||||
#include <studio/undocommand.hpp>
|
||||
#include <studio/undostack.hpp>
|
||||
#include <studio/widget.hpp>
|
||||
|
||||
19
src/olympic/studio/modlib/include/studio/undocommand.hpp
Normal file
19
src/olympic/studio/modlib/include/studio/undocommand.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace studio {
|
||||
|
||||
class UndoCommand {
|
||||
public:
|
||||
virtual ~UndoCommand() noexcept = default;
|
||||
virtual void redo() noexcept = 0;
|
||||
virtual void undo() noexcept = 0;
|
||||
[[nodiscard]]
|
||||
virtual int commandId() const noexcept = 0;
|
||||
virtual bool mergeWith(UndoCommand const*cmd) noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -9,17 +9,9 @@
|
||||
#include <ox/std/memory.hpp>
|
||||
#include <ox/std/vector.hpp>
|
||||
|
||||
namespace studio {
|
||||
#include "undocommand.hpp"
|
||||
|
||||
class UndoCommand {
|
||||
public:
|
||||
virtual ~UndoCommand() noexcept = default;
|
||||
virtual void redo() noexcept = 0;
|
||||
virtual void undo() noexcept = 0;
|
||||
[[nodiscard]]
|
||||
virtual int commandId() const noexcept = 0;
|
||||
virtual bool mergeWith(UndoCommand const*cmd) noexcept;
|
||||
};
|
||||
namespace studio {
|
||||
|
||||
class UndoStack {
|
||||
private:
|
||||
|
||||
@@ -7,6 +7,7 @@ add_library(
|
||||
popup.cpp
|
||||
project.cpp
|
||||
task.cpp
|
||||
undocommand.cpp
|
||||
undostack.cpp
|
||||
filedialog_nfd.cpp
|
||||
)
|
||||
|
||||
10
src/olympic/studio/modlib/src/undocommand.cpp
Normal file
10
src/olympic/studio/modlib/src/undocommand.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
#include <studio/undocommand.hpp>
|
||||
|
||||
namespace studio {
|
||||
|
||||
bool UndoCommand::mergeWith(UndoCommand const*) noexcept {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,10 +6,6 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
bool UndoCommand::mergeWith(UndoCommand const*) noexcept {
|
||||
return false;
|
||||
}
|
||||
|
||||
void UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
||||
for (auto const i = m_stackIdx; i < m_stack.size();) {
|
||||
std::ignore = m_stack.erase(i);
|
||||
|
||||
Reference in New Issue
Block a user