Squashed 'deps/nostalgia/' changes from eed115b2..7d9f363b
7d9f363b [nostalgia/core/studio] Show color names in TileSheetEditor ababc2a7 [nostalgia/core/studio] Add Name to colors table in PaletteEditor bfd4bc3c [nostalgia/core] Revise Palette system, give TileSheetEditor a config file 8826d51e [studio] Add configio.hpp to studio.hpp c021e5e7 [ox/oc] Fix OC not dealing with certain int types properly 7d8a8e0e [keel] Cleanup 95a69b72 [ox/std] Fix String::c_str to always retrun a valid C str e4c38660 [nostalgia/core] Fix subsheet resize not to read garbage 67cf3ae8 [ox/std] Ensure ox::String always has at least a null terminator 2761f23d [nostalgia/developer-handbook] Update serialization notes 6c170d31 [nostalgia/developer-handbook] Update serialization notes d20bfc77 [nostalgia/developer-handbook] Update serialization notes 07ecbde1 [nostalgia/developer-handbook] Update notes on error handling fbe2fcd3 [nostalgia/developer-handbook] Update notes on error handling a8bb99b6 [turbine] Remove ClipboardObject::typeMatches 667dd21a [turbine] Make ClipboardObject::typId return a StringView 5d89370c [turbine] Rework getClipboardObject to use ox::ModelTypeId_v b968ec8a [keel] Remove redundant move ec45ffb7 [studio] Fix build error 97dc0274 [nostalgia/core/studio] Add acceptsClipboardPayload to TileSheetEditor a138f60f [studio] Add acceptsClipboardPayload to Editor 791d1950 [turbine] Make ClipboardObject use ox::ModelTypeId_v for typeId 78eb8fca [keel] Cleanup pack logging 0b8051b6 [ox/preloader] Fix alignment issue 5a426829 [nostalgia/core/studio] Cleanup TileSheet selection, fix copy/paste bug 9d2fe0e8 [studio] Add size function to Selection f1894699 [keel] Remove setAsset 27b38ed2 [keel,studio] Fix hotloading for files that get loaded as multiple types 2bb7c514 [studio/modlib] Fix type desc writing logic inversion 5177cfb0 [studio/modlib] Make Project::mkdir only mkdir if dir does not exist f9a14433 [studio/modlib] Add variant of ComboBox that takes callback e62426b0 [keel] Ensure consistent asset IDs in AssetManager af634bd4 [ox/fs] Add FileSystem::exists 49b859ec [studio/modlib] Give Selection constructors 19a41201 [studio/modlib] Make iterateSelection return errors properly f69b8afa [nostalgia] Remove use of deleted function 9c98b5e2 [studio/modlib] Remove color.hpp 1f87216d [nostalgia/core] Add applySelectionColor 94c59604 [nostalgia/core/opengl] Fix for Ox changes 8ee016c1 [studio/modlib] Add SelectionTracker dc20c667 [ox/std] Add conversion functions for geo types, cleanup 407e5424 [ox/std] Remove SmallMap dtor, replace timing code with steady_clock 3b188696 [ox/claw] Remove enum type from ClawFormat 0fab6c7c [ox/preloader] Remove debug code a72b865d [studio/modlib] Add function for exporting selection color c0479604 [studio,nostalgia/studio] Make executing UndoCommands report errors a1c89906 [nostalgia/studio] Make UndoCommand undo/redo return ox::Error 7fb0549c [nostalgia/core] Revert some auto formatting done by CLion... 37e65ab0 [nostalgia/core/studio] Fix Subsheet width to update properly 9105b1ec [ox/std] Fix Linux build fbeb0815 [ox/model] Fix type params in buildTypeId b882a47e [ox/std] Fix resize to set null terminator 660f2f56 [ox/std] Rework FileReader into StreamReader aa83c2a6 [nostalgia/core/studio] Remove some unnecessary copying 4a2b1fd7 [studio,keel] Make fileChanged emit UUID as well as path, add uuidUrlToUuid 08f958fb [ox/std] Add IntegerRange_c a651d45a [ox/std] Fix Vector insert functions 9e9f317c [studio] Make UndoCommand::mergeWith take a reference f5a02ce9 [nostalgia/core/gba] Fix build 6971c310 [studio] Add NoChangeException c47f48eb [keel] Add/cleanup UUID/path lookup functions 76771e7b [nostalgia/core] Add tileColumns and tileRows functions f6a0ae20 [ox/std] Fix some Windows warnings 752c8c1d [glutils] Fix type conversion that happened on Windows af3bff1a [glutils] Add FrameBuffer::sizef 87416e13 [ox/std] Make MallocaPtr call destructor 047b4396 [ox/std] Make Point and Size members int32_t 40b8da4d [studio/modlib] Cleanup 123c4125 [ox/std] Add SmallMap::pairs(), SmallMap model 963ec5d3 [ox/std] Add operator-> to SpanIterator 6df77a23 [glutils] Add size function to FrameBuffer df412cf8 [ox/std] Add missing typenames ae30ef36 Merge commit 'b66cef7127e97269fc6072a6f66ccc08990f6d2e' 095a1135 Merge commit 'f48824793cfce315971fe2e699ece198c7a79407' ce1836ab Merge commit '1e041bd2ebfe5ace7bed3906faf60345aa98a8bc' 7d1641fa Merge commit '420fa96463f59c4a4a7cd66b16b0ad01ab0d55e6' 423212b2 [studio] Add missing include 60da1063 Merge commit 'bd416f82e25f1b710ab2b7890274571dd3fcd53d' 60d1996f [keel] Minor optimization git-subtree-dir: deps/nostalgia git-subtree-split: 7d9f363bfa7a2c64f5c4bcfd0b6686f3f5678119
This commit is contained in:
@ -162,18 +162,10 @@ classes in question.
|
||||
|
||||
### Error Handling
|
||||
|
||||
Exceptions are clean and nice in userland code running in environments with
|
||||
expansive system resources, but they are a bit of a pain in small bare metal
|
||||
environments.
|
||||
The GBA build has them disabled.
|
||||
Exceptions cause also the compiler to generate a great deal of extra code that
|
||||
inflates the size of the binary.
|
||||
The binary size bloat is often cited as one of the main reasons why many
|
||||
embedded developers prefer C to C++.
|
||||
|
||||
Instead of throwing exceptions, all engine code must return Ox error codes.
|
||||
For the sake of consistency, try to stick to Ox error codes in non-engine code
|
||||
as well.
|
||||
The GBA build has exceptions disabled.
|
||||
Instead of throwing exceptions, all engine code must return ```ox::Error```s.
|
||||
For the sake of consistency, try to stick to ```ox::Error``` in non-engine code
|
||||
as well, but non-engine code is free to use exceptions when they make sense.
|
||||
Nostalgia and Ox both use ```ox::Error``` to report errors. ```ox::Error``` is
|
||||
a struct that has overloaded operators to behave like an integer error code,
|
||||
plus some extra fields to enhance debuggability.
|
||||
@ -219,6 +211,30 @@ int caller2() {
|
||||
std::cout << val << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
||||
ox::Error caller3(int &i) {
|
||||
return foo(i).moveTo(i);
|
||||
}
|
||||
|
||||
ox::Error caller4(int &i) {
|
||||
return foo(i).copyTo(i);
|
||||
}
|
||||
|
||||
int caller5(int i) {
|
||||
return foo(i).unwrap(); // unwrap will kill the program if there is an error
|
||||
}
|
||||
|
||||
int caller6(int i) {
|
||||
return foo(i).unwrapThrow(); // unwrap will throw if there is an error
|
||||
}
|
||||
|
||||
int caller7(int i) {
|
||||
return foo(i).or_value(0); // will return 0 if foo returned an error
|
||||
}
|
||||
|
||||
ox::Result<uint64_t> caller8(int i) {
|
||||
return foo(i).to<uint64_t>(); // will convert the result of foo to uint64_t
|
||||
}
|
||||
```
|
||||
|
||||
Lastly, there are a few macros available to help in passing ```ox::Error```s
|
||||
@ -275,6 +291,7 @@ ox::Error engineCode() noexcept {
|
||||
return OxError(0);
|
||||
}
|
||||
```
|
||||
|
||||
Ox also has the ```oxRequire``` 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.
|
||||
|
||||
@ -309,6 +326,9 @@ ox::Result<int> f2() noexcept {
|
||||
* ```oxRequireT``` - oxRequire Throw
|
||||
* ```oxRequireMT``` - oxRequire Mutable Throw
|
||||
|
||||
The throw variants of ```oxRequire``` are generally legacy code.
|
||||
```ox::Result::unwrapThrow``` is generally preferred now.
|
||||
|
||||
### Logging and Output
|
||||
|
||||
Ox provides for logging and debug prints via the ```oxTrace```, ```oxDebug```, and ```oxError``` macros.
|
||||
@ -526,19 +546,13 @@ a wrapper around the bare formats.
|
||||
```cpp
|
||||
#include <ox/mc/read.hpp>
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette1(const Buffer &buff) noexcept {
|
||||
ox::Result<NostalgiaPalette> loadPalette1(ox::BufferView const&buff) noexcept {
|
||||
return ox::readMC<NostalgiaPalette>(buff);
|
||||
}
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette2(const Buffer &buff) noexcept {
|
||||
return ox::readMC<NostalgiaPalette>(buff.data(), buff.size());
|
||||
}
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette3(const Buffer &buff) noexcept {
|
||||
ox::Result<NostalgiaPalette> loadPalette2(ox::BufferView const&buff) noexcept {
|
||||
NostalgiaPalette pal;
|
||||
std::size_t sz = 0;
|
||||
oxReturnError(ox::readMC(buff.data(), buff.size(), &pal, &sz));
|
||||
buffer.resize(sz);
|
||||
oxReturnError(ox::readMC(buff, pal));
|
||||
return pal;
|
||||
}
|
||||
```
|
||||
@ -548,7 +562,7 @@ ox::Result<NostalgiaPalette> loadPalette3(const Buffer &buff) noexcept {
|
||||
```cpp
|
||||
#include <ox/mc/write.hpp>
|
||||
|
||||
ox::Result<ox::Buffer> writeSpritePalette1(NostalgiaPalette *pal) 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));
|
||||
@ -556,7 +570,7 @@ ox::Result<ox::Buffer> writeSpritePalette1(NostalgiaPalette *pal) noexcept {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
ox::Result<ox::Buffer> writeSpritePalette2(NostalgiaPalette *pal) noexcept {
|
||||
ox::Result<ox::Buffer> writeSpritePalette2(NostalgiaPalette const&pal) noexcept {
|
||||
return ox::writeMC(pal);
|
||||
}
|
||||
```
|
||||
@ -568,17 +582,13 @@ ox::Result<ox::Buffer> writeSpritePalette2(NostalgiaPalette *pal) noexcept {
|
||||
```cpp
|
||||
#include <ox/oc/read.hpp>
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette1(const Buffer &buff) noexcept {
|
||||
ox::Result<NostalgiaPalette> loadPalette1(ox::BufferView const&buff) noexcept {
|
||||
return ox::readOC<NostalgiaPalette>(buff);
|
||||
}
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette2(const Buffer &buff) noexcept {
|
||||
return ox::readOC<NostalgiaPalette>(buff.data(), buff.size());
|
||||
}
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette3(const Buffer &buff) noexcept {
|
||||
ox::Result<NostalgiaPalette> loadPalette2(ox::BufferView const&buff) noexcept {
|
||||
NostalgiaPalette pal;
|
||||
oxReturnError(ox::readOC(buff.data(), buff.size(), &pal));
|
||||
oxReturnError(ox::readOC(buff, &pal));
|
||||
return pal;
|
||||
}
|
||||
```
|
||||
@ -588,13 +598,13 @@ ox::Result<NostalgiaPalette> loadPalette3(const Buffer &buff) noexcept {
|
||||
```cpp
|
||||
#include <ox/oc/write.hpp>
|
||||
|
||||
ox::Result<ox::Buffer> writeSpritePalette1(NostalgiaPalette *pal) noexcept {
|
||||
ox::Result<ox::Buffer> writeSpritePalette1(NostalgiaPalette const&pal) noexcept {
|
||||
ox::Buffer buffer(ox::units::MB);
|
||||
oxReturnError(ox::writeOC(buffer.data(), buffer.size(), pal));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
ox::Result<ox::Buffer> writeSpritePalette2(NostalgiaPalette *pal) noexcept {
|
||||
ox::Result<ox::Buffer> writeSpritePalette2(NostalgiaPalette const&pal) noexcept {
|
||||
return ox::writeOC(pal);
|
||||
}
|
||||
```
|
||||
@ -606,17 +616,13 @@ ox::Result<ox::Buffer> writeSpritePalette2(NostalgiaPalette *pal) noexcept {
|
||||
```cpp
|
||||
#include <ox/claw/read.hpp>
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette1(const Buffer &buff) noexcept {
|
||||
ox::Result<NostalgiaPalette> loadPalette1(ox::BufferView const&buff) noexcept {
|
||||
return ox::readClaw<NostalgiaPalette>(buff);
|
||||
}
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette2(const Buffer &buff) noexcept {
|
||||
return ox::readClaw<NostalgiaPalette>(buff.data(), buff.size());
|
||||
}
|
||||
|
||||
ox::Result<NostalgiaPalette> loadPalette3(const Buffer &buff) noexcept {
|
||||
ox::Result<NostalgiaPalette> loadPalette2(ox::BufferView const&buff) noexcept {
|
||||
NostalgiaPalette pal;
|
||||
oxReturnError(ox::readClaw(buff.data(), buff.size(), &pal));
|
||||
oxReturnError(ox::readClaw(buff, pal));
|
||||
return pal;
|
||||
}
|
||||
```
|
||||
@ -626,8 +632,8 @@ ox::Result<NostalgiaPalette> loadPalette3(const Buffer &buff) noexcept {
|
||||
```cpp
|
||||
#include <ox/claw/write.hpp>
|
||||
|
||||
ox::Result<ox::Buffer> writeSpritePalette(NostalgiaPalette *pal) noexcept {
|
||||
return ox::writeClaw(&pal);
|
||||
ox::Result<ox::Buffer> writeSpritePalette(NostalgiaPalette const&pal) noexcept {
|
||||
return ox::writeClaw(pal);
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user