0c0ccd1a [nostalgia/core/studio] Cleanup scratchpad code 1b629da8 [ox/std] Make Vector::contains always noexcept 32e4702d [ox] Improve hasing and MaybeView 6b47133c [nostalgia] Cleanup StudioModules 0764720f [nostalgia,olympic] Update for Ox changes 78955376 [glutils] Update for Ox changes a00a0bd2 [ox] Rename BString to IString ed4f0e1f [nostalgia,olympic] Replace oxIgnoreError with std::ignore ea1feb72 [ox] Remove oxIgnoreError e9a6a096 [ox] Run liccor d7f30975 Merge commit 'c0baf7efca0e4c3a86a018ad2564d9df7b07c133' eeb2a5a1 [olympic/studio] Add new ImGui util functions 453f2750 [nostalgia/core/studio] Cleanup context types 189ba4c5 [olympic/studio] Make studio::run static 05773808 [olympic] Change TypeId building to use constexpr globals 272eabc7 [nostalgia/core/opengl] Unbind vertex arrays when done with them a0256669 [glutils] Remove trailing whitespace 6808adc8 [ox/std] Replace ox::ignore with std::ignore abc076d6 [ox/std] Cleanup 1b790a34 [ox/std] Fix Signed_c and Unsigned_c 92202716 [nostalgia/core] Update pack transforms to use ModelTypeId_v 7941a514 [ox/model] Add constexpr ModelTypeId_v 0c09c530 [ox/std] Fix sfmt constexpr problems 3ff91af8 [ox/std] Sort of fix custom assert 79b42e1d [ox/std] Fix some Vector constexpr problems 5eec9085 [ox/std] Add nodiscard to some string functions af7c8956 [ox/std] Add ox::ignore git-subtree-dir: deps/nostalgia git-subtree-split: 0c0ccd1a692169d99beb8c238b8b2c466e81a13d
87 lines
3.4 KiB
C++
87 lines
3.4 KiB
C++
/*
|
|
* Copyright 2015 - 2024 gary@drinkingtea.net
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
// Logging
|
|
|
|
#define oxLogError(...) ox::trace::logError(__FILE__, __LINE__, __VA_ARGS__)
|
|
|
|
#define oxTrace(...) ox::trace::TraceStream(__FILE__, __LINE__, __VA_ARGS__)
|
|
#define oxOut(...) ox::trace::OutStream(__FILE__, __LINE__, "stdout", __VA_ARGS__)
|
|
#define oxErr(...) ox::trace::OutStream(__FILE__, __LINE__, "stderr", __VA_ARGS__)
|
|
|
|
#define oxTracef(ch, fmt, ...) ox::trace::TraceStream(__FILE__, __LINE__, ch, ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), __VA_ARGS__)
|
|
#define oxOutf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "stdout", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), __VA_ARGS__)
|
|
#define oxErrf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "stderr", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), __VA_ARGS__)
|
|
|
|
#define oxInfo(...) oxTrace("info", __VA_ARGS__)
|
|
#define oxInfof(...) oxTracef("info", __VA_ARGS__)
|
|
#define oxError(...) oxTrace("error", __VA_ARGS__)
|
|
#define oxErrorf(...) oxTracef("error", __VA_ARGS__)
|
|
|
|
#ifndef OX_NODEBUG
|
|
#define oxDebug(...) ox::trace::OutStream(__FILE__, __LINE__, "debug", __VA_ARGS__)
|
|
#define oxDebugf(fmt, ...) ox::trace::OutStream(__FILE__, __LINE__, "debug", ox::detail::fmtSegments<ox::detail::argCount(fmt)+1>(fmt), __VA_ARGS__)
|
|
#else
|
|
#define oxDebug(...) static_assert(false, "Debug prints were checked in.");
|
|
#define oxDebugf(...) static_assert(false, "Debug prints were checked in.");
|
|
#endif
|
|
|
|
|
|
// Error handling
|
|
|
|
#define oxReturnError(x) { if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] return _ox_error; } (void) 0
|
|
#define oxThrowError(x) { if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] throw ox::Exception(_ox_error); } (void) 0
|
|
#define oxConcatImpl(a, b) a##b
|
|
#define oxConcat(a, b) oxConcatImpl(a, b)
|
|
// oxRequire Mutable
|
|
#define oxRequireM(out, x) auto [out, oxConcat(oxRequire_err_, __LINE__)] = x; oxReturnError(oxConcat(oxRequire_err_, __LINE__))
|
|
#define oxRequire(out, x) const oxRequireM(out, x)
|
|
// oxRequire Mutable Throw
|
|
#define oxRequireMT(out, x) auto [out, oxConcat(oxRequire_err_, __LINE__)] = x; oxThrowError(oxConcat(oxRequire_err_, __LINE__))
|
|
// oxRequire Throw
|
|
#define oxRequireT(out, x) const oxRequireMT(out, x)
|
|
|
|
|
|
// Asserts
|
|
|
|
#define oxPanic(errCode, msg) ox::panic(__FILE__, __LINE__, msg, errCode)
|
|
#ifndef NDEBUG
|
|
#define oxAssert(pass, msg) ox::assertFunc(__FILE__, __LINE__, pass, #pass, msg)
|
|
#else
|
|
namespace ox {
|
|
struct [[nodiscard]] Error;
|
|
}
|
|
constexpr void oxAssert(bool, const char*) noexcept {}
|
|
constexpr void oxAssert(const ox::Error&, const char*) noexcept {}
|
|
#endif
|
|
|
|
#define oxExpect(actual, expected) ox::expect(__FILE__, __LINE__, actual, expected)
|
|
|
|
// Alloca
|
|
|
|
#if defined(_MSC_VER)
|
|
#define ox_alloca(size) _alloca(size)
|
|
#elif OX_USE_STDLIB
|
|
#define ox_alloca(size) alloca(size)
|
|
#else
|
|
#define ox_alloca(size) __builtin_alloca(size)
|
|
#endif
|
|
|
|
/**
|
|
* @return an ox::MallocaPtr of the given type pointing to the requested size memory allocation
|
|
*/
|
|
#if defined(OX_USE_STDLIB)
|
|
#define ox_malloca(size, Type, ...) ox::MallocaPtr<Type>(size > ox::MallocaStackLimit, new (size > ox::MallocaStackLimit ? new uint8_t[size] : ox_alloca(size)) Type(__VA_ARGS__))
|
|
#else
|
|
#define ox_malloca(size, Type, ...) ox::MallocaPtr<Type>(false, new (ox_alloca(size)) Type(__VA_ARGS__))
|
|
#endif
|
|
|