[keel,nostalgia/tools,studio] Convert some pointers to references
This commit is contained in:
parent
26a2d340d6
commit
1505d7ea37
@ -6,7 +6,7 @@
|
||||
|
||||
namespace keel {
|
||||
|
||||
ox::Result<ox::UUID> readUuidHeader(const ox::Buffer &buff) noexcept {
|
||||
ox::Result<ox::UUID> readUuidHeader(ox::Buffer const&buff) noexcept {
|
||||
return readUuidHeader(buff.data(), buff.size());
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ ox::Result<ox::UUID> readUuidHeader(const char *buff, std::size_t buffLen) noexc
|
||||
return ox::UUID::fromString(ox::StringView(buff + k1Hdr.bytes(), 36));
|
||||
}
|
||||
|
||||
ox::Result<ox::ModelObject> readAsset(ox::TypeStore *ts, const ox::Buffer &buff) noexcept {
|
||||
ox::Result<ox::ModelObject> readAsset(ox::TypeStore *ts, ox::Buffer const&buff) noexcept {
|
||||
std::size_t offset = 0;
|
||||
if (!readUuidHeader(buff).error) {
|
||||
offset = K1HdrSz;
|
||||
@ -39,7 +39,7 @@ ox::Result<AssetHdr> readAssetHeader(const char *buff, std::size_t buffLen) noex
|
||||
return out;
|
||||
}
|
||||
|
||||
ox::Result<AssetHdr> readAssetHeader(const ox::Buffer &buff) noexcept {
|
||||
ox::Result<AssetHdr> readAssetHeader(ox::Buffer const&buff) noexcept {
|
||||
return readAssetHeader(buff.data(), buff.size());
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@ class AssetContainer {
|
||||
explicit constexpr AssetContainer(Args&&... args): m_obj(ox::forward<Args>(args)...) {
|
||||
}
|
||||
|
||||
AssetContainer(AssetContainer&) = delete;
|
||||
AssetContainer(AssetContainer const&) = delete;
|
||||
AssetContainer(AssetContainer&&) = delete;
|
||||
AssetContainer& operator=(AssetContainer&) = delete;
|
||||
AssetContainer& operator=(AssetContainer const&) = delete;
|
||||
AssetContainer& operator=(AssetContainer&&) = delete;
|
||||
|
||||
[[nodiscard]]
|
||||
@ -55,7 +55,7 @@ class AssetContainer {
|
||||
m_obj = std::move(val);
|
||||
}
|
||||
|
||||
constexpr void set(const T &val) {
|
||||
constexpr void set(T const&val) {
|
||||
m_obj = val;
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ class AssetRef: public ox::SignalHandler {
|
||||
|
||||
explicit constexpr AssetRef(const AssetContainer<T> *c = nullptr) noexcept;
|
||||
|
||||
constexpr AssetRef(const AssetRef &h) noexcept;
|
||||
constexpr AssetRef(AssetRef const&h) noexcept;
|
||||
|
||||
constexpr AssetRef(AssetRef &&h) noexcept;
|
||||
|
||||
@ -111,7 +111,7 @@ class AssetRef: public ox::SignalHandler {
|
||||
return m_ctr->get();
|
||||
}
|
||||
|
||||
AssetRef &operator=(const AssetRef &h) noexcept {
|
||||
AssetRef &operator=(AssetRef const&h) noexcept {
|
||||
if (this == &h) {
|
||||
return *this;
|
||||
}
|
||||
@ -160,7 +160,7 @@ constexpr AssetRef<T>::AssetRef(const AssetContainer<T> *c) noexcept: m_ctr(c) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr AssetRef<T>::AssetRef(const AssetRef &h) noexcept {
|
||||
constexpr AssetRef<T>::AssetRef(AssetRef const&h) noexcept {
|
||||
m_ctr = h.m_ctr;
|
||||
if (m_ctr) {
|
||||
m_ctr->updated.connect(this, &AssetRef::emitUpdated);
|
||||
@ -187,16 +187,16 @@ class AssetManager {
|
||||
template<typename T>
|
||||
class AssetTypeManager: public AssetTypeManagerBase {
|
||||
private:
|
||||
ox::HashMap<ox::String, ox::UniquePtr<AssetContainer<T>>> m_cache;
|
||||
ox::HashMap<ox::String, ox::UPtr<AssetContainer<T>>> m_cache;
|
||||
|
||||
public:
|
||||
ox::Result<AssetRef<T>> getAsset(const ox::StringView &assetId) const noexcept {
|
||||
ox::Result<AssetRef<T>> getAsset(ox::StringView const&assetId) const noexcept {
|
||||
auto out = m_cache.at(assetId);
|
||||
oxReturnError(out);
|
||||
return AssetRef<T>(out.value->get());
|
||||
}
|
||||
|
||||
ox::Result<AssetRef<T>> setAsset(const ox::StringView &assetId, const T &obj) noexcept {
|
||||
ox::Result<AssetRef<T>> setAsset(ox::StringView const&assetId, const T &obj) noexcept {
|
||||
auto &p = m_cache[assetId];
|
||||
if (!p) {
|
||||
p = ox::make_unique<AssetContainer<T>>(obj);
|
||||
@ -207,7 +207,7 @@ class AssetManager {
|
||||
return AssetRef<T>(p.get());
|
||||
}
|
||||
|
||||
ox::Result<AssetRef<T>> setAsset(const ox::StringView &assetId, T &&obj) noexcept {
|
||||
ox::Result<AssetRef<T>> setAsset(ox::StringView const&assetId, T &&obj) noexcept {
|
||||
auto &p = m_cache[assetId];
|
||||
if (!p) {
|
||||
p = ox::make_unique<AssetContainer<T>>(obj);
|
||||
@ -228,7 +228,7 @@ class AssetManager {
|
||||
}
|
||||
};
|
||||
|
||||
ox::HashMap<ox::String, ox::UniquePtr<AssetTypeManagerBase>> m_assetTypeManagers;
|
||||
ox::HashMap<ox::String, ox::UPtr<AssetTypeManagerBase>> m_assetTypeManagers;
|
||||
|
||||
template<typename T>
|
||||
AssetTypeManager<T> *getTypeManager() noexcept {
|
||||
@ -255,7 +255,7 @@ class AssetManager {
|
||||
}
|
||||
|
||||
void gc() noexcept {
|
||||
for (const auto &amk : m_assetTypeManagers.keys()) {
|
||||
for (auto const&amk : m_assetTypeManagers.keys()) {
|
||||
auto &am = m_assetTypeManagers[amk];
|
||||
am->gc();
|
||||
}
|
||||
@ -265,7 +265,7 @@ class AssetManager {
|
||||
template<typename T>
|
||||
class AssetRef {
|
||||
private:
|
||||
const T *m_obj = nullptr;
|
||||
const T *const m_obj = nullptr;
|
||||
|
||||
public:
|
||||
constexpr AssetRef() noexcept = default;
|
||||
|
@ -29,9 +29,9 @@ class Context {
|
||||
#endif
|
||||
|
||||
constexpr Context() noexcept = default;
|
||||
Context(const Context&) noexcept = delete;
|
||||
Context(Context const&) noexcept = delete;
|
||||
Context(Context&&) noexcept = delete;
|
||||
Context &operator=(const Context&) noexcept = delete;
|
||||
Context &operator=(Context const&) noexcept = delete;
|
||||
Context &operator=(Context&&) noexcept = delete;
|
||||
constexpr virtual ~Context() noexcept = default;
|
||||
};
|
||||
|
@ -171,7 +171,7 @@ ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, const ox::FileAddress
|
||||
|
||||
namespace keel {
|
||||
|
||||
ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> fs) noexcept {
|
||||
ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> &&fs) noexcept {
|
||||
ctx.rom = std::move(fs);
|
||||
clearUuidMap(ctx);
|
||||
return buildUuidMap(ctx);
|
||||
|
@ -29,7 +29,7 @@ oxModelBegin(PreloadPtr)
|
||||
oxModelField(preloadAddr)
|
||||
oxModelEnd()
|
||||
|
||||
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, const ox::FileAddress &file) noexcept;
|
||||
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::FileAddress const&file) noexcept;
|
||||
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::CRStringView file) noexcept;
|
||||
|
||||
#ifndef OX_BARE_METAL
|
||||
@ -158,7 +158,7 @@ ox::Error writeObj(
|
||||
return ctx.rom->write(file, objBuff.data(), objBuff.size());
|
||||
}
|
||||
|
||||
ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> fs) noexcept;
|
||||
ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> &&fs) noexcept;
|
||||
|
||||
ox::Result<ox::UniquePtr<ox::FileSystem>> loadRomFs(ox::CRStringView path) noexcept;
|
||||
|
||||
|
@ -11,19 +11,19 @@
|
||||
|
||||
namespace keel {
|
||||
|
||||
using TypeDescGenerator = ox::Error(*)(ox::TypeStore*);
|
||||
using TypeDescGenerator = ox::Error(*)(ox::TypeStore&);
|
||||
|
||||
template<typename T>
|
||||
ox::Error generateTypeDesc(ox::TypeStore *ts) noexcept {
|
||||
return ox::buildTypeDef<T>(ts).error;
|
||||
ox::Error generateTypeDesc(ox::TypeStore &ts) noexcept {
|
||||
return ox::buildTypeDef<T>(&ts).error;
|
||||
}
|
||||
|
||||
class Module {
|
||||
public:
|
||||
constexpr Module() noexcept = default;
|
||||
Module(const Module&) noexcept = delete;
|
||||
Module(Module const&) noexcept = delete;
|
||||
Module(Module&&) noexcept = delete;
|
||||
Module &operator=(const Module&) noexcept = delete;
|
||||
Module &operator=(Module const&) noexcept = delete;
|
||||
Module &operator=(Module&&) noexcept = delete;
|
||||
constexpr virtual ~Module() noexcept = default;
|
||||
|
||||
|
@ -44,7 +44,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::StringView path) noexcept {
|
||||
static ox::Error generateTypes(ox::TypeStore *ts) noexcept {
|
||||
for (const auto mod : keel::modules()) {
|
||||
for (auto gen : mod->types()) {
|
||||
oxReturnError(gen(ts));
|
||||
oxReturnError(gen(*ts));
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
static void generateTypes(ox::TypeStore *ts) noexcept {
|
||||
static void generateTypes(ox::TypeStore &ts) noexcept {
|
||||
for (const auto mod : keel::modules()) {
|
||||
for (auto gen : mod->types()) {
|
||||
oxLogError(gen(ts));
|
||||
@ -28,7 +28,7 @@ Project::Project(keel::Context &ctx, ox::String path, ox::CRStringView projectDa
|
||||
m_typeStore(*m_ctx.rom, ox::sfmt("/.{}/type_descriptors", projectDataDir)),
|
||||
m_fs(*m_ctx.rom) {
|
||||
oxTracef("studio", "Project: {}", m_path);
|
||||
generateTypes(&m_typeStore);
|
||||
generateTypes(m_typeStore);
|
||||
buildFileIndex();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user