Squashed 'deps/nostalgia/' changes from 161640fa..a75c4a11
a75c4a11 [nfde] Address CMake warning, remove unwanted logging 347a1657 [sample_project] Update type descriptors fd64bfae [keel] Fix a use after free, cleanup aaeec20a [nostalgia/player] Fix build 37030f9c [keel] Cleanup pack tool 462f2bca [nostalgia,olympic] Change macro names to comply with broader conventions dc72500b [glutils] Change macro names to comply with broader conventions 962fe8bc [ox] Change macro names to comply with broader conventions 305eb626 [studio] Fix build 4754359a [ox/std] Cleanup Vec2 dc07f3d5 [studio] Change FilePicker consturctor to take StringParams fcdcfd10 [ox/std] Run liccor b74f6a7a [studio,turbine] Run liccor ac7e5be1 [ox] Remove OxException ed910c0b [nostalgia/core/studio/tilesheeteditor] Fix access overflow on out of bounds Fill command 345fb038 [ox] Remove OxError 9881253f [glutils] Cleanup OxError 96d27eec [nostalgia,olympic] Cleanup 28ebe93b [ox/std] Make source_location::current only init if valid e849e7a3 [ox/std] Add source_location e6777b0a [cityhash] Add install rule c488c336 [turbine/glfw] Fix mandatoryRefreshPeriodEnd tracking 003f9720 [turbine/glfw] Move MandatoryRefreshPeriod to config.hpp d85a10af [nostalgia/core/studio] Cleanup ff05d860 [turbine/glfw] Replace uninterruptedRefreshes with mandatoryRefreshPeriodEnd 76794037 [turbine] Add init wrapper that takes FS path c51a45e1 [olympic] Cleanup a6e24ff2 [ox/std] Add CString type alias e0ec9e0c [nostalgia,olympic] Move olympic::run to global namespace 9a42a9b9 [nfde] Fix Windows warnings 03a05c51 Merge commit '4ccdfc3a6e5bd501968903a01f7d8141b6f88375' bd91137d [nostalgia,olympic] Fix pack tool build for Windows 2b7d1294 [nostalgia/core/studio] Fix MSVC build git-subtree-dir: deps/nostalgia git-subtree-split: a75c4a11d3c555f4d3bed1ea1f70bb29fe49e99c
This commit is contained in:
82
deps/ox/ox-docs.md
vendored
82
deps/ox/ox-docs.md
vendored
@ -97,12 +97,12 @@ ox::Result<uint64_t> caller8(int i) {
|
||||
```
|
||||
|
||||
Lastly, there are a few macros available to help in passing ```ox::Error```s
|
||||
back up the call stack, ```oxReturnError```, ```oxThrowError```, and
|
||||
```oxRequire```.
|
||||
back up the call stack, ```OX_RETURN_ERROR```, ```OX_THROW_ERROR```, and
|
||||
```OX_REQUIRE```.
|
||||
|
||||
```oxReturnError``` is by far the more helpful of the two.
|
||||
```oxReturnError``` will return an ```ox::Error``` if it is not 0 and
|
||||
```oxThrowError``` will throw an ```ox::Error``` if it is not 0.
|
||||
```OX_RETURN_ERROR``` is by far the more helpful of the two.
|
||||
```OX_RETURN_ERROR``` will return an ```ox::Error``` if it is not 0 and
|
||||
```OX_THROW_ERROR``` will throw an ```ox::Error``` if it is not 0.
|
||||
|
||||
Since ```ox::Error``` is always nodiscard, you must do something with them.
|
||||
In rare cases, you may not have anything you can do with them or you may know
|
||||
@ -113,13 +113,13 @@ This should be used sparingly.
|
||||
```cpp
|
||||
void studioCode() {
|
||||
auto [val, err] = foo(1);
|
||||
oxThrowError(err);
|
||||
OX_THROW_ERROR(err);
|
||||
doStuff(val);
|
||||
}
|
||||
|
||||
ox::Error engineCode() noexcept {
|
||||
auto [val, err] = foo(1);
|
||||
oxReturnError(err);
|
||||
OX_RETURN_ERROR(err);
|
||||
doStuff(val);
|
||||
return {};
|
||||
}
|
||||
@ -136,19 +136,19 @@ Both macros will also take the ```ox::Result``` directly:
|
||||
```cpp
|
||||
void studioCode() {
|
||||
auto valerr = foo(1);
|
||||
oxThrowError(valerr);
|
||||
OX_THROW_ERROR(valerr);
|
||||
doStuff(valerr.value);
|
||||
}
|
||||
|
||||
ox::Error engineCode() noexcept {
|
||||
auto valerr = foo(1);
|
||||
oxReturnError(valerr);
|
||||
OX_RETURN_ERROR(valerr);
|
||||
doStuff(valerr.value);
|
||||
return {};
|
||||
}
|
||||
```
|
||||
|
||||
Ox also has the ```oxRequire``` macro, which will initialize a value if there is no error, and return if there is.
|
||||
Ox also has the ```OX_REQUIRE``` macro, which will initialize a value if there is no error, and return if there is.
|
||||
It aims to somewhat emulate the ```?``` operator in Rust and Swift.
|
||||
|
||||
Rust ```?``` operator:
|
||||
@ -163,23 +163,23 @@ fn f2() -> Result<i32, i32> {
|
||||
}
|
||||
```
|
||||
|
||||
```oxRequire```:
|
||||
```OX_REQUIRE```:
|
||||
```cpp
|
||||
ox::Result<int> f() noexcept {
|
||||
// do stuff
|
||||
}
|
||||
|
||||
ox::Result<int> f2() noexcept {
|
||||
oxRequire(i, f()); // const auto [out, oxConcat(oxRequire_err_, __LINE__)] = x; oxReturnError(oxConcat(oxRequire_err_, __LINE__))
|
||||
OX_REQUIRE(i, f()); // const auto [out, OX_CONCAT(oxRequire_err_, __LINE__)] = x; OX_RETURN_ERROR(OX_CONCAT(oxRequire_err_, __LINE__))
|
||||
return i + 4;
|
||||
}
|
||||
```
|
||||
```oxRequire``` is not quite as versatile, but it should still cleanup a lot of otherwise less ideal code.
|
||||
```OX_REQUIRE``` is not quite as versatile, but it should still cleanup a lot of otherwise less ideal code.
|
||||
|
||||
```oxRequire``` by default creates a const, but there is also an ```oxRequireM``` (oxRequire Mutable)
|
||||
```OX_REQUIRE``` by default creates a const, but there is also an ```OX_REQUIRE_M``` (OX_REQUIRE Mutable)
|
||||
variant for creating a non-const value.
|
||||
|
||||
* ```oxRequireM``` - oxRequire Mutable
|
||||
* ```OX_REQUIRE_M``` - OX_REQUIRE Mutable
|
||||
|
||||
### Logging and Output
|
||||
|
||||
@ -268,19 +268,19 @@ constexpr ox::Error model(T *h, ox::CommonPtrWith<NostalgiaPalette> auto *pal) n
|
||||
h->template setTypeInfo<NostalgiaPalette>();
|
||||
// it is also possible to provide the type name and type version as function arguments
|
||||
//h->setTypeInfo("net.drinkingtea.nostalgia.core.NostalgiaPalette", 1);
|
||||
oxReturnError(h->field("colors", &pal->colors));
|
||||
OX_RETURN_ERROR(h->field("colors", &pal->colors));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr ox::Error model(T *h, ox::CommonPtrWith<NostalgiaGraphic> auto *ng) noexcept {
|
||||
h->template setTypeInfo<NostalgiaGraphic>();
|
||||
oxReturnError(h->field("bpp", &ng->bpp));
|
||||
oxReturnError(h->field("rows", &ng->rows));
|
||||
oxReturnError(h->field("columns", &ng->columns));
|
||||
oxReturnError(h->field("defaultPalette", &ng->defaultPalette));
|
||||
oxReturnError(h->field("pal", &ng->pal));
|
||||
oxReturnError(h->field("pixels", &ng->pixels));
|
||||
OX_RETURN_ERROR(h->field("bpp", &ng->bpp));
|
||||
OX_RETURN_ERROR(h->field("rows", &ng->rows));
|
||||
OX_RETURN_ERROR(h->field("columns", &ng->columns));
|
||||
OX_RETURN_ERROR(h->field("defaultPalette", &ng->defaultPalette));
|
||||
OX_RETURN_ERROR(h->field("pal", &ng->pal));
|
||||
OX_RETURN_ERROR(h->field("pixels", &ng->pixels));
|
||||
return {};
|
||||
}
|
||||
```
|
||||
@ -315,9 +315,9 @@ class FileAddress {
|
||||
template<typename T>
|
||||
constexpr Error model(T *h, ox::CommonPtrWith<FileAddress::Data> auto *obj) noexcept {
|
||||
h->template setTypeInfo<FileAddress::Data>();
|
||||
oxReturnError(h->fieldCString("path", &obj->path));
|
||||
oxReturnError(h->fieldCString("constPath", &obj->path));
|
||||
oxReturnError(h->field("inode", &obj->inode));
|
||||
OX_RETURN_ERROR(h->fieldCString("path", &obj->path));
|
||||
OX_RETURN_ERROR(h->fieldCString("constPath", &obj->path));
|
||||
OX_RETURN_ERROR(h->field("inode", &obj->inode));
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -327,13 +327,13 @@ constexpr Error model(T *io, ox::CommonPtrWith<FileAddress> auto *fa) noexcept {
|
||||
// cannot read from object in Reflect operation
|
||||
if constexpr(ox_strcmp(T::opType(), OpType::Reflect) == 0) {
|
||||
int8_t type = 0;
|
||||
oxReturnError(io->field("type", &type));
|
||||
oxReturnError(io->field("data", UnionView(&fa->m_data, 0)));
|
||||
OX_RETURN_ERROR(io->field("type", &type));
|
||||
OX_RETURN_ERROR(io->field("data", UnionView(&fa->m_data, 0)));
|
||||
} else {
|
||||
auto type = static_cast<int8_t>(fa->m_type);
|
||||
oxReturnError(io->field("type", &type));
|
||||
OX_RETURN_ERROR(io->field("type", &type));
|
||||
fa->m_type = static_cast<FileAddressType>(type);
|
||||
oxReturnError(io->field("data", UnionView(&fa->m_data, static_cast<int>(fa->m_type))));
|
||||
OX_RETURN_ERROR(io->field("data", UnionView(&fa->m_data, static_cast<int>(fa->m_type))));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@ -343,13 +343,13 @@ constexpr Error model(T *io, ox::CommonPtrWith<FileAddress> auto *fa) noexcept {
|
||||
There are also macros in ```<ox/model/def.hpp>``` for simplifying the declaration of models:
|
||||
|
||||
```cpp
|
||||
oxModelBegin(NostalgiaGraphic)
|
||||
oxModelField(bpp)
|
||||
oxModelField(rows)
|
||||
oxModelField(columns)
|
||||
oxModelField(defaultPalette)
|
||||
oxModelField(pal)
|
||||
oxModelField(pixels)
|
||||
OX_MODEL_BEGIN(NostalgiaGraphic)
|
||||
OX_MODEL_FIELD(bpp)
|
||||
OX_MODEL_FIELD(rows)
|
||||
OX_MODEL_FIELD(columns)
|
||||
OX_MODEL_FIELD(defaultPalette)
|
||||
OX_MODEL_FIELD(pal)
|
||||
OX_MODEL_FIELD(pixels)
|
||||
oxModelEnd()
|
||||
```
|
||||
|
||||
@ -392,7 +392,7 @@ ox::Result<NostalgiaPalette> loadPalette1(ox::BufferView const&buff) noexcept {
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette2(ox::BufferView const&buff) noexcept {
|
||||
NostalgiaPalette pal;
|
||||
oxReturnError(ox::readMC(buff, pal));
|
||||
OX_RETURN_ERROR(ox::readMC(buff, pal));
|
||||
return pal;
|
||||
}
|
||||
```
|
||||
@ -405,7 +405,7 @@ ox::Result<NostalgiaPalette> loadPalette2(ox::BufferView const&buff) noexcept {
|
||||
ox::Result<ox::Buffer> writeSpritePalette1(NostalgiaPalette const&pal) noexcept {
|
||||
ox::Buffer buffer(ox::units::MB);
|
||||
std::size_t sz = 0;
|
||||
oxReturnError(ox::writeMC(buffer.data(), buffer.size(), pal, &sz));
|
||||
OX_RETURN_ERROR(ox::writeMC(buffer.data(), buffer.size(), pal, &sz));
|
||||
buffer.resize(sz);
|
||||
return buffer;
|
||||
}
|
||||
@ -428,7 +428,7 @@ ox::Result<NostalgiaPalette> loadPalette1(ox::BufferView const&buff) noexcept {
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette2(ox::BufferView const&buff) noexcept {
|
||||
NostalgiaPalette pal;
|
||||
oxReturnError(ox::readOC(buff, &pal));
|
||||
OX_RETURN_ERROR(ox::readOC(buff, &pal));
|
||||
return pal;
|
||||
}
|
||||
```
|
||||
@ -440,7 +440,7 @@ ox::Result<NostalgiaPalette> loadPalette2(ox::BufferView const&buff) noexcept {
|
||||
|
||||
ox::Result<ox::Buffer> writeSpritePalette1(NostalgiaPalette const&pal) noexcept {
|
||||
ox::Buffer buffer(ox::units::MB);
|
||||
oxReturnError(ox::writeOC(buffer.data(), buffer.size(), pal));
|
||||
OX_RETURN_ERROR(ox::writeOC(buffer.data(), buffer.size(), pal));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -462,7 +462,7 @@ ox::Result<NostalgiaPalette> loadPalette1(ox::BufferView const&buff) noexcept {
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette2(ox::BufferView const&buff) noexcept {
|
||||
NostalgiaPalette pal;
|
||||
oxReturnError(ox::readClaw(buff, pal));
|
||||
OX_RETURN_ERROR(ox::readClaw(buff, pal));
|
||||
return pal;
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user