[nostalgia,olympic] Change macro names to comply with broader conventions

This commit is contained in:
2024-12-21 02:41:19 -06:00
parent 3e7a1266fa
commit 8c4f55621d
51 changed files with 383 additions and 383 deletions

View File

@@ -60,7 +60,7 @@ ox::Error writeConfig(keel::Context &ctx, ox::StringViewCR name, T const&data) n
//oxErrf("Could not create config directory: {} - {}\n", path, toStr(err));
return err;
}
oxRequireM(buff, ox::writeOC(data));
OX_REQUIRE_M(buff, ox::writeOC(data));
*buff.back().value = '\n';
if (auto const err = fs.write(path, buff.data(), buff.size())) {
//oxErrf("Could not read config file: {} - {}\n", path, toStr(err));

View File

@@ -35,7 +35,7 @@ ox::Result<T> getDragDropPayload(ox::CStringViewCR name) noexcept {
}
ox::Error setDragDropPayload(ox::CStringViewCR name, auto const&obj) noexcept {
oxRequire(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
OX_REQUIRE(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
ImGui::SetDragDropPayload(name.c_str(), buff.data(), buff.size());
return {};
}
@@ -223,7 +223,7 @@ bool ListBox(
* @param selIdx
* @return true if new value selected, false otherwise
*/
bool ListBox(ox::CStringViewCR name, ox::Span<const ox::String> const&list, size_t &selIdx) noexcept;
bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept;
class FilePicker {
private:

View File

@@ -79,7 +79,7 @@ class ItemMakerT: public ItemMaker {
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::StringView const pName) const noexcept override {
auto const path = itemPath(pName);
createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
oxReturnError(sctx.project->writeObj(path, m_item, m_fmt));
OX_RETURN_ERROR(sctx.project->writeObj(path, m_item, m_fmt));
return path;
}
};

View File

@@ -130,39 +130,39 @@ class Project {
template<typename T>
ox::Error Project::writeObj(ox::StringViewCR path, T const&obj, ox::ClawFormat fmt) noexcept {
oxRequireM(buff, ox::writeClaw(obj, fmt));
OX_REQUIRE_M(buff, ox::writeClaw(obj, fmt));
if (fmt == ox::ClawFormat::Organic) {
buff.pop_back();
}
// write to FS
oxReturnError(mkdir(parentDir(path)));
oxReturnError(writeBuff(path, buff));
OX_RETURN_ERROR(mkdir(parentDir(path)));
OX_RETURN_ERROR(writeBuff(path, buff));
// write type descriptor
if (m_typeStore.get<T>().error) {
oxReturnError(ox::buildTypeDef(m_typeStore, obj));
OX_RETURN_ERROR(ox::buildTypeDef(m_typeStore, obj));
}
oxRequire(desc, m_typeStore.get<T>());
OX_REQUIRE(desc, m_typeStore.get<T>());
auto const descPath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*desc));
auto const descExists = m_fs.exists(descPath);
if (!descExists) {
oxReturnError(writeTypeStore());
OX_RETURN_ERROR(writeTypeStore());
}
oxReturnError(keel::reloadAsset(m_ctx, path));
oxRequire(uuid, pathToUuid(m_ctx, path));
OX_RETURN_ERROR(keel::reloadAsset(m_ctx, path));
OX_REQUIRE(uuid, pathToUuid(m_ctx, path));
fileUpdated.emit(path, uuid);
return {};
}
template<typename T>
ox::Error Project::writeObj(ox::StringViewCR path, T const&obj) noexcept {
oxRequire(ext, fileExt(path));
OX_REQUIRE(ext, fileExt(path));
auto const fmt = m_typeFmt[ext].or_value(ox::ClawFormat::Metal);
return writeObj(path, obj, fmt);
}
template<typename T>
ox::Result<T> Project::loadObj(ox::StringViewCR path) const noexcept {
oxRequire(buff, loadBuff(path));
OX_REQUIRE(buff, loadBuff(path));
if constexpr(ox::is_same_v<T, ox::ModelObject>) {
return keel::readAsset(m_typeStore, buff);
} else {
@@ -180,7 +180,7 @@ ox::Error Project::subscribe(ProjectEvent e, ox::SignalHandler *tgt, Functor &&s
break;
case ProjectEvent::FileRecognized:
{
oxRequire(files, listFiles());
OX_REQUIRE(files, listFiles());
for (auto const&f : files) {
slot(f);
}

View File

@@ -33,7 +33,7 @@ constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) {
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
if constexpr(retErr) {
oxReturnError(cb(x, y));
OX_RETURN_ERROR(cb(x, y));
} else {
cb(x, y);
}
@@ -49,7 +49,7 @@ constexpr auto iterateSelectionRows(studio::Selection const&sel, auto const&cb)
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
if constexpr(retErr) {
oxReturnError(cb(x, y));
OX_RETURN_ERROR(cb(x, y));
} else {
cb(x, y);
}

View File

@@ -155,7 +155,7 @@ bool ListBox(
return out;
}
bool ListBox(ox::CStringViewCR name, ox::Span<const ox::String> const&list, size_t &selIdx) noexcept {
bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept {
return ListBox(name, [list](size_t i) -> ox::CStringView {
return list[i];
}, list.size(), selIdx);

View File

@@ -36,7 +36,7 @@ Project::Project(keel::Context &ctx, ox::String path, ox::StringViewCR projectDa
oxTracef("studio", "Project: {}", m_path);
generateTypes(m_typeStore);
if (ox::defines::Debug) {
oxThrowError(writeTypeStore());
OX_THROW_ERROR(writeTypeStore());
}
buildFileIndex();
}
@@ -58,7 +58,7 @@ ox::FileSystem &Project::romFs() noexcept {
ox::Error Project::mkdir(ox::StringViewCR path) const noexcept {
auto const [stat, err] = m_fs.stat(path);
if (err) {
oxReturnError(m_fs.mkdir(path, true));
OX_RETURN_ERROR(m_fs.mkdir(path, true));
fileUpdated.emit(path, {});
}
return stat.fileType == ox::FileType::Directory ?
@@ -79,12 +79,12 @@ ox::Vector<ox::String> const&Project::fileList(ox::StringViewCR ext) noexcept {
ox::Error Project::writeTypeStore() noexcept {
// write all descriptors because we don't know which types T depends on
oxReturnError(mkdir(m_typeDescPath));
OX_RETURN_ERROR(mkdir(m_typeDescPath));
for (auto const &t: m_typeStore.typeList()) {
oxRequire(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
OX_REQUIRE(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
// write to FS
auto const typePath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*t));
oxReturnError(writeBuff(typePath, {typeOut.data(), typeOut.size() - 1}));
OX_RETURN_ERROR(writeBuff(typePath, {typeOut.data(), typeOut.size() - 1}));
}
return {};
}
@@ -119,11 +119,11 @@ ox::Error Project::writeBuff(ox::StringViewCR path, ox::BufferView const&buff) n
ox::BufferWriter writer(&outBuff);
auto const [uuid, err] = pathToUuid(m_ctx, path);
if (!err) {
oxReturnError(keel::writeUuidHeader(writer, uuid));
OX_RETURN_ERROR(keel::writeUuidHeader(writer, uuid));
}
oxReturnError(writer.write(buff.data(), buff.size()));
OX_RETURN_ERROR(writer.write(buff.data(), buff.size()));
auto const newFile = m_fs.stat(path).error != 0;
oxReturnError(m_fs.write(path, outBuff.data(), outBuff.size(), ox::FileType::NormalFile));
OX_RETURN_ERROR(m_fs.write(path, outBuff.data(), outBuff.size(), ox::FileType::NormalFile));
if (newFile) {
fileAdded.emit(path);
indexFile(path);
@@ -138,16 +138,16 @@ ox::Result<ox::Buffer> Project::loadBuff(ox::StringViewCR path) const noexcept {
}
ox::Error Project::lsProcDir(ox::Vector<ox::String> *paths, ox::StringViewCR path) const noexcept {
oxRequire(files, m_fs.ls(path));
OX_REQUIRE(files, m_fs.ls(path));
for (auto const&name : files) {
auto fullPath = ox::sfmt("{}/{}", path, name);
oxRequire(stat, m_fs.stat(ox::StringView(fullPath)));
OX_REQUIRE(stat, m_fs.stat(ox::StringView(fullPath)));
switch (stat.fileType) {
case ox::FileType::NormalFile:
paths->emplace_back(std::move(fullPath));
break;
case ox::FileType::Directory:
oxReturnError(lsProcDir(paths, fullPath));
OX_RETURN_ERROR(lsProcDir(paths, fullPath));
break;
case ox::FileType::None:
break;
@@ -158,7 +158,7 @@ ox::Error Project::lsProcDir(ox::Vector<ox::String> *paths, ox::StringViewCR pat
ox::Result<ox::Vector<ox::String>> Project::listFiles(ox::StringViewCR path) const noexcept {
ox::Vector<ox::String> paths;
oxReturnError(lsProcDir(&paths, path));
OX_RETURN_ERROR(lsProcDir(&paths, path));
return paths;
}

View File

@@ -10,7 +10,7 @@ ox::Error UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
for (auto const i = m_stackIdx; i < m_stack.size();) {
std::ignore = m_stack.erase(i);
}
oxReturnError(cmd->redo());
OX_RETURN_ERROR(cmd->redo());
redoTriggered.emit(cmd.get());
changeTriggered.emit(cmd.get());
if (m_stack.empty() || !(*m_stack.back().value)->mergeWith(*cmd)) {
@@ -27,7 +27,7 @@ ox::Error UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
ox::Error UndoStack::redo() noexcept {
if (m_stackIdx < m_stack.size()) {
auto &c = m_stack[m_stackIdx];
oxReturnError(c->redo());
OX_RETURN_ERROR(c->redo());
++m_stackIdx;
redoTriggered.emit(c.get());
changeTriggered.emit(c.get());
@@ -38,7 +38,7 @@ ox::Error UndoStack::redo() noexcept {
ox::Error UndoStack::undo() noexcept {
if (m_stackIdx) {
auto &c = m_stack[--m_stackIdx];
oxReturnError(c->undo());
OX_RETURN_ERROR(c->undo());
undoTriggered.emit(c.get());
changeTriggered.emit(c.get());
}