[ox] Rename UniquePtr to UPtr
This commit is contained in:
6
deps/ox/src/ox/claw/read.cpp
vendored
6
deps/ox/src/ox/claw/read.cpp
vendored
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
ox::Result<ox::StringView> readClawTypeId(ox::BufferView buff) noexcept {
|
||||
Result<StringView> readClawTypeId(BufferView const buff) noexcept {
|
||||
auto buffRaw = buff.data();
|
||||
auto buffLen = buff.size();
|
||||
size_t outSz{};
|
||||
@@ -43,7 +43,7 @@ ox::Result<ox::StringView> readClawTypeId(ox::BufferView buff) noexcept {
|
||||
return {{buff.data() + fmtSz, outSz - fmtSz - 1}};
|
||||
}
|
||||
|
||||
Result<ClawHeader> readClawHeader(ox::BufferView buff) noexcept {
|
||||
Result<ClawHeader> readClawHeader(BufferView const buff) noexcept {
|
||||
auto buffRaw = buff.data();
|
||||
auto buffLen = buff.size();
|
||||
const auto s1End = ox::strchr(buffRaw, ';', buffLen);
|
||||
@@ -87,7 +87,7 @@ Result<ClawHeader> readClawHeader(ox::BufferView buff) noexcept {
|
||||
return hdr;
|
||||
}
|
||||
|
||||
Result<BufferView> stripClawHeader(ox::BufferView buff) noexcept {
|
||||
Result<BufferView> stripClawHeader(BufferView const buff) noexcept {
|
||||
OX_REQUIRE(header, readClawHeader(buff));
|
||||
return {{header.data, header.dataSize}};
|
||||
}
|
||||
|
||||
4
deps/ox/src/ox/event/signal.hpp
vendored
4
deps/ox/src/ox/event/signal.hpp
vendored
@@ -122,7 +122,7 @@ class Signal {
|
||||
}
|
||||
};
|
||||
|
||||
mutable Vector<UniquePtr<BaseSlot>> m_slots;
|
||||
mutable Vector<UPtr<BaseSlot>> m_slots;
|
||||
|
||||
public:
|
||||
~Signal() noexcept;
|
||||
@@ -303,7 +303,7 @@ class Signal<Error(Args...)> {
|
||||
}
|
||||
};
|
||||
|
||||
mutable Vector<UniquePtr<BaseSlot>> m_slots;
|
||||
mutable Vector<UPtr<BaseSlot>> m_slots;
|
||||
|
||||
public:
|
||||
~Signal() noexcept;
|
||||
|
||||
2
deps/ox/src/ox/fs/tool.cpp
vendored
2
deps/ox/src/ox/fs/tool.cpp
vendored
@@ -34,7 +34,7 @@ static ox::Result<Buff> loadFsBuff(const char *path) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
static ox::Result<ox::UniquePtr<ox::FileSystem>> loadFs(const char *path) noexcept {
|
||||
static ox::Result<ox::UPtr<ox::FileSystem>> loadFs(const char *path) noexcept {
|
||||
OX_REQUIRE(buff, loadFsBuff(path));
|
||||
return {ox::make_unique<ox::FileSystem32>(buff.data, buff.size)};
|
||||
}
|
||||
|
||||
2
deps/ox/src/ox/model/descwrite.hpp
vendored
2
deps/ox/src/ox/model/descwrite.hpp
vendored
@@ -51,7 +51,7 @@ constexpr auto buildSubscriptStack(const T**, SubscriptStack *s) noexcept {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr auto buildSubscriptStack(const UniquePtr<T>*, SubscriptStack *s) noexcept {
|
||||
constexpr auto buildSubscriptStack(const UPtr<T>*, SubscriptStack *s) noexcept {
|
||||
s->push_back({.subscriptType = Subscript::SubscriptType::Ptr});
|
||||
}
|
||||
|
||||
|
||||
12
deps/ox/src/ox/model/modelvalue.hpp
vendored
12
deps/ox/src/ox/model/modelvalue.hpp
vendored
@@ -519,7 +519,7 @@ class ModelObject {
|
||||
protected:
|
||||
OX_MODEL_FRIEND(ModelObject);
|
||||
friend ModelValue;
|
||||
Vector<UniquePtr<Field>> m_fieldsOrder;
|
||||
Vector<UPtr<Field>> m_fieldsOrder;
|
||||
HashMap<String, ModelValue*> m_fields;
|
||||
const DescriptorType *m_type = nullptr;
|
||||
|
||||
@@ -692,7 +692,7 @@ class ModelUnion {
|
||||
};
|
||||
friend constexpr Error model(auto *h, CommonPtrWith<ModelUnion> auto *obj) noexcept;
|
||||
friend ModelValue;
|
||||
Vector<UniquePtr<Field>> m_fieldsOrder;
|
||||
Vector<UPtr<Field>> m_fieldsOrder;
|
||||
HashMap<String, Field*> m_fields;
|
||||
const DescriptorType *m_type = nullptr;
|
||||
int m_unionIdx = -1;
|
||||
@@ -718,14 +718,14 @@ class ModelUnion {
|
||||
m_unionIdx = other.m_unionIdx;
|
||||
}
|
||||
|
||||
static constexpr Result<UniquePtr<ModelUnion>> make(const DescriptorType *type) noexcept {
|
||||
UniquePtr<ModelUnion> out(new ModelUnion);
|
||||
static constexpr Result<UPtr<ModelUnion>> make(const DescriptorType *type) noexcept {
|
||||
UPtr<ModelUnion> out(new ModelUnion);
|
||||
OX_RETURN_ERROR(out->setType(type));
|
||||
return out;
|
||||
}
|
||||
|
||||
static constexpr Result<UniquePtr<ModelUnion>> make(const ModelUnion &other) noexcept {
|
||||
return UniquePtr<ModelUnion>(new ModelUnion(other));
|
||||
static constexpr Result<UPtr<ModelUnion>> make(const ModelUnion &other) noexcept {
|
||||
return UPtr<ModelUnion>(new ModelUnion(other));
|
||||
}
|
||||
|
||||
constexpr ox::Result<ModelValue*> at(StringView const&k) noexcept {
|
||||
|
||||
2
deps/ox/src/ox/model/types.hpp
vendored
2
deps/ox/src/ox/model/types.hpp
vendored
@@ -161,7 +161,7 @@ template<typename T>
|
||||
constexpr bool isSmartPtr_v = false;
|
||||
|
||||
template<typename T>
|
||||
constexpr bool isSmartPtr_v<::ox::UniquePtr<T>> = true;
|
||||
constexpr bool isSmartPtr_v<::ox::UPtr<T>> = true;
|
||||
|
||||
#if __has_include(<array>)
|
||||
template<typename T>
|
||||
|
||||
10
deps/ox/src/ox/model/typestore.hpp
vendored
10
deps/ox/src/ox/model/typestore.hpp
vendored
@@ -21,7 +21,7 @@ namespace ox {
|
||||
|
||||
class TypeStore {
|
||||
private:
|
||||
HashMap<String, UniquePtr<DescriptorType>> m_cache;
|
||||
HashMap<String, UPtr<DescriptorType>> m_cache;
|
||||
|
||||
public:
|
||||
constexpr TypeStore() noexcept = default;
|
||||
@@ -86,12 +86,12 @@ class TypeStore {
|
||||
return getLoad(typeName, typeVersion);
|
||||
}
|
||||
|
||||
constexpr void set(const auto &typeId, UniquePtr<DescriptorType> dt) noexcept {
|
||||
constexpr void set(const auto &typeId, UPtr<DescriptorType> dt) noexcept {
|
||||
m_cache[typeId] = std::move(dt);
|
||||
}
|
||||
|
||||
constexpr void set(const auto &typeId, DescriptorType *dt) noexcept {
|
||||
m_cache[typeId] = UniquePtr<DescriptorType>(dt);
|
||||
m_cache[typeId] = UPtr<DescriptorType>(dt);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
@@ -105,11 +105,11 @@ class TypeStore {
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual Result<UniquePtr<DescriptorType>> loadDescriptor(ox::StringView) noexcept {
|
||||
virtual Result<UPtr<DescriptorType>> loadDescriptor(ox::StringView) noexcept {
|
||||
return ox::Error(1);
|
||||
}
|
||||
|
||||
Result<UniquePtr<DescriptorType>> loadDescriptor(ox::StringViewCR name, int version,
|
||||
Result<UPtr<DescriptorType>> loadDescriptor(ox::StringViewCR name, int version,
|
||||
const ox::TypeParamPack &typeParams) noexcept {
|
||||
const auto typeId = buildTypeId(name, version, typeParams);
|
||||
return loadDescriptor(typeId);
|
||||
|
||||
2
deps/ox/src/ox/oc/read.hpp
vendored
2
deps/ox/src/ox/oc/read.hpp
vendored
@@ -282,7 +282,7 @@ Error readOC(BufferView const buff, auto &val) noexcept {
|
||||
try {
|
||||
Json::Value doc;
|
||||
Json::CharReaderBuilder parserBuilder;
|
||||
auto parser = UniquePtr<Json::CharReader>(parserBuilder.newCharReader());
|
||||
auto parser = UPtr<Json::CharReader>(parserBuilder.newCharReader());
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
if (!parser->parse(buff.data(), buff.data() + buff.size(), &doc, nullptr)) {
|
||||
OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
|
||||
6
deps/ox/src/ox/preloader/preloader.hpp
vendored
6
deps/ox/src/ox/preloader/preloader.hpp
vendored
@@ -74,7 +74,7 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>, OpType::Reflect> {
|
||||
const Preloader &operator=(const Preloader &src) = delete;
|
||||
const Preloader &operator=(Preloader &&src) = delete;
|
||||
|
||||
constexpr static ox::Result<ox::UniquePtr<Preloader>> make(ox::ios_base::seekdir anchor = ox::ios_base::cur,
|
||||
constexpr static ox::Result<ox::UPtr<Preloader>> make(ox::ios_base::seekdir anchor = ox::ios_base::cur,
|
||||
std::size_t sz = 0) noexcept;
|
||||
|
||||
template<typename T>
|
||||
@@ -141,9 +141,9 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>, OpType::Reflect> {
|
||||
};
|
||||
|
||||
template<typename PlatSpec>
|
||||
constexpr ox::Result<ox::UniquePtr<Preloader<PlatSpec>>>
|
||||
constexpr ox::Result<ox::UPtr<Preloader<PlatSpec>>>
|
||||
Preloader<PlatSpec>::make(ox::ios_base::seekdir anchor, std::size_t sz) noexcept {
|
||||
auto p = ox::UniquePtr<Preloader>(new Preloader);
|
||||
auto p = ox::UPtr<Preloader>(new Preloader);
|
||||
if (const auto err = p->m_writer.seekp(0, anchor)) {
|
||||
return {std::move(p), err};
|
||||
}
|
||||
|
||||
43
deps/ox/src/ox/std/memory.hpp
vendored
43
deps/ox/src/ox/std/memory.hpp
vendored
@@ -179,26 +179,26 @@ constexpr bool operator!=(std::nullptr_t, const SharedPtr<T> &p2) noexcept {
|
||||
|
||||
|
||||
template<typename T, typename Deleter = DefaultDelete>
|
||||
class UniquePtr {
|
||||
class UPtr {
|
||||
|
||||
private:
|
||||
T *m_t = nullptr;
|
||||
|
||||
public:
|
||||
using value_type = T;
|
||||
explicit constexpr UniquePtr(T *t = nullptr) noexcept: m_t(t) {
|
||||
explicit constexpr UPtr(T *t = nullptr) noexcept: m_t(t) {
|
||||
}
|
||||
|
||||
constexpr UniquePtr(UniquePtr&) = delete;
|
||||
constexpr UPtr(UPtr&) = delete;
|
||||
|
||||
constexpr UniquePtr(const UniquePtr&) = delete;
|
||||
constexpr UPtr(const UPtr&) = delete;
|
||||
|
||||
template<typename U, typename UDeleter>
|
||||
constexpr UniquePtr(UniquePtr<U, UDeleter> &&other) noexcept {
|
||||
constexpr UPtr(UPtr<U, UDeleter> &&other) noexcept {
|
||||
m_t = other.release();
|
||||
}
|
||||
|
||||
constexpr ~UniquePtr() {
|
||||
constexpr ~UPtr() {
|
||||
Deleter()(m_t);
|
||||
}
|
||||
|
||||
@@ -213,24 +213,24 @@ class UniquePtr {
|
||||
return m_t;
|
||||
}
|
||||
|
||||
constexpr void reset(UniquePtr &&other = UniquePtr()) {
|
||||
constexpr void reset(UPtr &&other = UPtr()) {
|
||||
auto t = m_t;
|
||||
m_t = other.release();
|
||||
Deleter()(t);
|
||||
}
|
||||
|
||||
constexpr UniquePtr &operator=(UniquePtr const&other) = delete;
|
||||
constexpr UPtr &operator=(UPtr const&other) = delete;
|
||||
|
||||
template<typename U, typename UDeleter>
|
||||
constexpr UniquePtr &operator=(UniquePtr<U, UDeleter> const&other) = delete;
|
||||
constexpr UPtr &operator=(UPtr<U, UDeleter> const&other) = delete;
|
||||
|
||||
constexpr UniquePtr &operator=(UniquePtr<T> &&other) noexcept {
|
||||
constexpr UPtr &operator=(UPtr<T> &&other) noexcept {
|
||||
reset(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename U, typename UDeleter>
|
||||
constexpr UniquePtr &operator=(UniquePtr<U, UDeleter> &&other) noexcept {
|
||||
constexpr UPtr &operator=(UPtr<U, UDeleter> &&other) noexcept {
|
||||
reset(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
@@ -249,37 +249,34 @@ class UniquePtr {
|
||||
|
||||
};
|
||||
|
||||
template<typename T, typename Deleter = DefaultDelete>
|
||||
using UPtr = UniquePtr<T, Deleter>;
|
||||
|
||||
template<typename T>
|
||||
constexpr bool operator==(const UniquePtr<T> &p1, const UniquePtr<T> &p2) noexcept {
|
||||
constexpr bool operator==(const UPtr<T> &p1, const UPtr<T> &p2) noexcept {
|
||||
return p1.get() == p2.get();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr bool operator==(const UniquePtr<T> &p1, std::nullptr_t) noexcept {
|
||||
constexpr bool operator==(const UPtr<T> &p1, std::nullptr_t) noexcept {
|
||||
return p1.get() == nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr bool operator==(std::nullptr_t, const UniquePtr<T> &p2) noexcept {
|
||||
constexpr bool operator==(std::nullptr_t, const UPtr<T> &p2) noexcept {
|
||||
return p2.get() == nullptr;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
constexpr bool operator!=(const UniquePtr<T> &p1, const UniquePtr<T> &p2) noexcept {
|
||||
constexpr bool operator!=(const UPtr<T> &p1, const UPtr<T> &p2) noexcept {
|
||||
return p1.get() != p2.get();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr bool operator!=(const UniquePtr<T> &p1, std::nullptr_t) noexcept {
|
||||
constexpr bool operator!=(const UPtr<T> &p1, std::nullptr_t) noexcept {
|
||||
return !p1.get();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr bool operator!=(std::nullptr_t, const UniquePtr<T> &p2) noexcept {
|
||||
constexpr bool operator!=(std::nullptr_t, const UPtr<T> &p2) noexcept {
|
||||
return !p2.get();
|
||||
}
|
||||
|
||||
@@ -287,14 +284,14 @@ constexpr bool operator!=(std::nullptr_t, const UniquePtr<T> &p2) noexcept {
|
||||
template<typename T, typename U = T, typename ...Args>
|
||||
[[nodiscard]]
|
||||
constexpr auto make_unique(Args&&... args) {
|
||||
return UniquePtr<U>(new T(ox::forward<Args>(args)...));
|
||||
return UPtr<U>(new T(ox::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<typename T, typename U = T, typename ...Args>
|
||||
[[nodiscard]]
|
||||
constexpr Result<UniquePtr<U>> make_unique_catch(Args&&... args) noexcept {
|
||||
constexpr Result<UPtr<U>> make_unique_catch(Args&&... args) noexcept {
|
||||
try {
|
||||
return UniquePtr<U>(new T(ox::forward<Args>(args)...));
|
||||
return UPtr<U>(new T(ox::forward<Args>(args)...));
|
||||
} catch (ox::Exception const&ex) {
|
||||
return ex.toError();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user