[nostalgia,olympic] Change macro names to comply with broader conventions
This commit is contained in:
@ -37,7 +37,7 @@ static ox::Error runApp(
|
||||
ox::StringViewCR appName,
|
||||
ox::StringViewCR projectDataDir,
|
||||
ox::UPtr<ox::FileSystem> &&fs) noexcept {
|
||||
oxRequireM(ctx, turbine::init(std::move(fs), appName));
|
||||
OX_REQUIRE_M(ctx, turbine::init(std::move(fs), appName));
|
||||
turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName);
|
||||
turbine::setKeyEventHandler(*ctx, keyEventHandler);
|
||||
turbine::setRefreshWithin(*ctx, 0);
|
||||
|
@ -16,16 +16,16 @@ static ox::Result<ox::UniquePtr<ProjectTreeModel>> buildProjectTreeModel(
|
||||
ox::StringView path,
|
||||
ProjectTreeModel *parent) noexcept {
|
||||
auto const fs = explorer.romFs();
|
||||
oxRequire(stat, fs->stat(path));
|
||||
OX_REQUIRE(stat, fs->stat(path));
|
||||
auto out = ox::make_unique<ProjectTreeModel>(explorer, ox::String(name), parent);
|
||||
if (stat.fileType == ox::FileType::Directory) {
|
||||
oxRequireM(children, fs->ls(path));
|
||||
OX_REQUIRE_M(children, fs->ls(path));
|
||||
std::sort(children.begin(), children.end());
|
||||
ox::Vector<ox::UniquePtr<ProjectTreeModel>> outChildren;
|
||||
for (auto const&childName : children) {
|
||||
if (childName[0] != '.') {
|
||||
auto const childPath = ox::sfmt("{}/{}", path, childName);
|
||||
oxRequireM(child, buildProjectTreeModel(explorer, childName, childPath, out.get()));
|
||||
OX_REQUIRE_M(child, buildProjectTreeModel(explorer, childName, childPath, out.get()));
|
||||
outChildren.emplace_back(std::move(child));
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,7 @@ void ProjectExplorer::setModel(ox::UPtr<ProjectTreeModel> &&model) noexcept {
|
||||
}
|
||||
|
||||
ox::Error ProjectExplorer::refreshProjectTreeModel(ox::StringViewCR) noexcept {
|
||||
oxRequireM(model, buildProjectTreeModel(*this, "Project", "/", nullptr));
|
||||
OX_REQUIRE_M(model, buildProjectTreeModel(*this, "Project", "/", nullptr));
|
||||
setModel(std::move(model));
|
||||
return ox::Error(0);
|
||||
}
|
||||
|
@ -36,12 +36,12 @@ struct StudioConfig {
|
||||
bool showProjectExplorer = true;
|
||||
};
|
||||
|
||||
oxModelBegin(StudioConfig)
|
||||
oxModelFieldRename(activeTabItemName, active_tab_item_name)
|
||||
oxModelFieldRename(projectPath, project_path)
|
||||
oxModelFieldRename(openFiles, open_files)
|
||||
oxModelFieldRename(showProjectExplorer, show_project_explorer)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(StudioConfig)
|
||||
OX_MODEL_FIELD_RENAME(activeTabItemName, active_tab_item_name)
|
||||
OX_MODEL_FIELD_RENAME(projectPath, project_path)
|
||||
OX_MODEL_FIELD_RENAME(openFiles, open_files)
|
||||
OX_MODEL_FIELD_RENAME(showProjectExplorer, show_project_explorer)
|
||||
OX_MODEL_END()
|
||||
|
||||
StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept:
|
||||
m_sctx(*this, ctx),
|
||||
@ -222,7 +222,7 @@ void StudioUI::drawTabs() noexcept {
|
||||
m_activeEditor = nullptr;
|
||||
}
|
||||
try {
|
||||
oxThrowError(m_editors.erase(it).moveTo(it));
|
||||
OX_THROW_ERROR(m_editors.erase(it).moveTo(it));
|
||||
} catch (ox::Exception const&ex) {
|
||||
oxErrf("Editor tab deletion failed: {} ({}:{})\n", ex.what(), ex.file, ex.line);
|
||||
} catch (std::exception const&ex) {
|
||||
@ -323,15 +323,15 @@ void StudioUI::handleKeyInput() noexcept {
|
||||
ox::Error StudioUI::createOpenProject(ox::StringViewCR path) noexcept {
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(toStdStringView(path), ec);
|
||||
oxReturnError(ox::Error(ec.value() != 0, "Could not create project directory"));
|
||||
oxReturnError(openProjectPath(path));
|
||||
OX_RETURN_ERROR(ox::Error(ec.value() != 0, "Could not create project directory"));
|
||||
OX_RETURN_ERROR(openProjectPath(path));
|
||||
return m_project->writeTypeStore();
|
||||
}
|
||||
|
||||
ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
||||
oxRequireM(fs, keel::loadRomFs(path.view()));
|
||||
oxReturnError(keel::setRomFs(keelCtx(m_ctx), std::move(fs)));
|
||||
oxReturnError(
|
||||
OX_REQUIRE_M(fs, keel::loadRomFs(path.view()));
|
||||
OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_ctx), std::move(fs)));
|
||||
OX_RETURN_ERROR(
|
||||
ox::make_unique_catch<studio::Project>(keelCtx(m_ctx), std::move(path), m_projectDataDir)
|
||||
.moveTo(m_project));
|
||||
auto const sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||
@ -366,7 +366,7 @@ ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool makeActiveTab)
|
||||
}
|
||||
return {};
|
||||
}
|
||||
oxRequire(ext, studio::fileExt(path));
|
||||
OX_REQUIRE(ext, studio::fileExt(path));
|
||||
// create Editor
|
||||
BaseEditor *editor = nullptr;
|
||||
auto const err = m_editorMakers.contains(ext) ?
|
||||
|
@ -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));
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user