update Filament headers to v1.58.0
This commit is contained in:
@@ -194,7 +194,7 @@ public:
|
||||
}
|
||||
|
||||
~LinearAllocatorWithFallback() noexcept {
|
||||
LinearAllocatorWithFallback::reset();
|
||||
reset();
|
||||
}
|
||||
|
||||
void* alloc(size_t size, size_t alignment = alignof(std::max_align_t));
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
}
|
||||
|
||||
void rewind(void* p) noexcept {
|
||||
if (p >= LinearAllocator::base() && p < LinearAllocator::end()) {
|
||||
if (p >= base() && p < end()) {
|
||||
LinearAllocator::rewind(p);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public:
|
||||
void free(void*, size_t) noexcept { }
|
||||
|
||||
bool isHeapAllocation(void* p) const noexcept {
|
||||
return p < LinearAllocator::base() || p >= LinearAllocator::end();
|
||||
return p < base() || p >= end();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -240,7 +240,6 @@ public:
|
||||
void push(void* p) noexcept {
|
||||
assert_invariant(p);
|
||||
assert_invariant(p >= mBegin && p < mEnd);
|
||||
// TODO: assert this is one of our pointer (i.e.: it's address match one of ours)
|
||||
Node* const head = static_cast<Node*>(p);
|
||||
head->next = mHead;
|
||||
mHead = head;
|
||||
@@ -718,13 +717,13 @@ public:
|
||||
// trivially destructible, since free() won't call the destructor and this is allocating
|
||||
// an array.
|
||||
template <typename T,
|
||||
typename = typename std::enable_if<std::is_trivially_destructible<T>::value>::type>
|
||||
typename = std::enable_if_t<std::is_trivially_destructible_v<T>>>
|
||||
T* alloc(size_t count, size_t alignment, size_t extra) noexcept {
|
||||
return (T*)alloc(count * sizeof(T), alignment, extra);
|
||||
}
|
||||
|
||||
template <typename T,
|
||||
typename = typename std::enable_if<std::is_trivially_destructible<T>::value>::type>
|
||||
typename = std::enable_if_t<std::is_trivially_destructible_v<T>>>
|
||||
T* alloc(size_t count, size_t alignment = alignof(T)) noexcept {
|
||||
return (T*)alloc(count * sizeof(T), alignment);
|
||||
}
|
||||
@@ -880,7 +879,7 @@ public:
|
||||
template<typename T, size_t ALIGN = alignof(T), typename... ARGS>
|
||||
T* make(ARGS&& ... args) noexcept {
|
||||
T* o = nullptr;
|
||||
if (std::is_trivially_destructible<T>::value) {
|
||||
if (std::is_trivially_destructible_v<T>) {
|
||||
o = mArena.template make<T, ALIGN>(std::forward<ARGS>(args)...);
|
||||
} else {
|
||||
void* const p = (Finalizer*)mArena.alloc(sizeof(T), ALIGN, sizeof(Finalizer));
|
||||
|
||||
@@ -41,32 +41,32 @@ size_t count();
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
inline constexpr int operator+(Enum value) noexcept {
|
||||
return int(value);
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
inline constexpr bool operator==(Enum lhs, size_t rhs) noexcept {
|
||||
using underlying_t = std::underlying_type_t<Enum>;
|
||||
return underlying_t(lhs) == rhs;
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
inline constexpr bool operator==(size_t lhs, Enum rhs) noexcept {
|
||||
return rhs == lhs;
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
inline constexpr bool operator!=(Enum lhs, size_t rhs) noexcept {
|
||||
return !(rhs == lhs);
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableIntegerOperators<Enum>::value, int> = 0>
|
||||
inline constexpr bool operator!=(size_t lhs, Enum rhs) noexcept {
|
||||
return rhs != lhs;
|
||||
}
|
||||
@@ -74,66 +74,66 @@ inline constexpr bool operator!=(size_t lhs, Enum rhs) noexcept {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr bool operator!(Enum rhs) noexcept {
|
||||
using underlying = std::underlying_type_t<Enum>;
|
||||
return underlying(rhs) == 0;
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr Enum operator~(Enum rhs) noexcept {
|
||||
using underlying = std::underlying_type_t<Enum>;
|
||||
return Enum(~underlying(rhs));
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr Enum operator|(Enum lhs, Enum rhs) noexcept {
|
||||
using underlying = std::underlying_type_t<Enum>;
|
||||
return Enum(underlying(lhs) | underlying(rhs));
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr Enum operator&(Enum lhs, Enum rhs) noexcept {
|
||||
using underlying = std::underlying_type_t<Enum>;
|
||||
return Enum(underlying(lhs) & underlying(rhs));
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr Enum operator^(Enum lhs, Enum rhs) noexcept {
|
||||
using underlying = std::underlying_type_t<Enum>;
|
||||
return Enum(underlying(lhs) ^ underlying(rhs));
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr Enum operator|=(Enum& lhs, Enum rhs) noexcept {
|
||||
return lhs = lhs | rhs;
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr Enum operator&=(Enum& lhs, Enum rhs) noexcept {
|
||||
return lhs = lhs & rhs;
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr Enum operator^=(Enum& lhs, Enum rhs) noexcept {
|
||||
return lhs = lhs ^ rhs;
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr bool none(Enum lhs) noexcept {
|
||||
return !lhs;
|
||||
}
|
||||
|
||||
template<typename Enum, typename std::enable_if_t<
|
||||
std::is_enum<Enum>::value && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
std::is_enum_v<Enum> && utils::EnableBitMaskOperators<Enum>::value, int> = 0>
|
||||
inline constexpr bool any(Enum lhs) noexcept {
|
||||
return !none(lhs);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
// NOTE: this header should not include STL headers
|
||||
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/ostream.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
@@ -181,6 +182,10 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
#if !defined(NDEBUG)
|
||||
friend io::ostream& operator<<(io::ostream& out, const CString& rhs);
|
||||
#endif
|
||||
|
||||
struct Data {
|
||||
size_type length;
|
||||
};
|
||||
|
||||
@@ -68,10 +68,10 @@ public:
|
||||
intptr_t operator [](size_t index) const;
|
||||
|
||||
/** Demangles a C++ type name */
|
||||
static utils::CString demangleTypeName(const char* mangled);
|
||||
static CString demangleTypeName(const char* mangled);
|
||||
|
||||
template<typename T>
|
||||
static utils::CString typeName() {
|
||||
static CString typeName() {
|
||||
#if UTILS_HAS_RTTI
|
||||
return demangleTypeName(typeid(T).name());
|
||||
#else
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
* This will print, when possible, the demangled names of functions corresponding to the
|
||||
* program-counter recorded.
|
||||
*/
|
||||
friend utils::io::ostream& operator <<(utils::io::ostream& stream, const CallStack& callstack);
|
||||
friend io::ostream& operator <<(io::ostream& stream, const CallStack& callstack);
|
||||
|
||||
bool operator <(const CallStack& rhs) const;
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
private:
|
||||
void update_gcc(size_t ignore) noexcept;
|
||||
|
||||
static utils::CString demangle(const char* mangled);
|
||||
static CString demangle(const char* mangled);
|
||||
|
||||
static constexpr size_t NUM_FRAMES = 20;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#ifndef TNT_UTILS_INVOKABLE_H
|
||||
#define TNT_UTILS_INVOKABLE_H
|
||||
|
||||
#include <utils/ostream.h>
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
@@ -81,6 +83,11 @@ public:
|
||||
explicit operator bool() const noexcept;
|
||||
|
||||
private:
|
||||
#if !defined(NDEBUG)
|
||||
friend io::ostream& operator<<(io::ostream& out, const Invocable&) {
|
||||
return out << "Invocable<>"; // TODO: is there a way to do better here?
|
||||
}
|
||||
#endif
|
||||
void* mInvocable = nullptr;
|
||||
void (*mDeleter)(void*) = nullptr;
|
||||
R (* mInvoker)(void*, Args...) = nullptr;
|
||||
|
||||
@@ -47,7 +47,7 @@ class EntityManager;
|
||||
* printf("%s\n", names->getName(names->getInstance(myEntity));
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
class UTILS_PUBLIC NameComponentManager : private SingleInstanceComponentManager<utils::CString> {
|
||||
class UTILS_PUBLIC NameComponentManager : private SingleInstanceComponentManager<CString> {
|
||||
public:
|
||||
using Instance = EntityInstance<NameComponentManager>;
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
const char* getName(Instance instance) const noexcept;
|
||||
|
||||
void gc(EntityManager& em) noexcept {
|
||||
SingleInstanceComponentManager<utils::CString>::gc(em, [this](Entity e) {
|
||||
SingleInstanceComponentManager<CString>::gc(em, [this](Entity e) {
|
||||
removeComponent(e);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
return getComponentCount() == 0;
|
||||
}
|
||||
|
||||
utils::Entity const* getEntities() const noexcept {
|
||||
Entity const* getEntities() const noexcept {
|
||||
return data<ENTITY_INDEX>() + 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
friend class IteratorValueRef;
|
||||
friend iterator;
|
||||
friend const_iterator;
|
||||
using Type = std::tuple<typename std::decay<Elements>::type...>;
|
||||
using Type = std::tuple<std::decay_t<Elements>...>;
|
||||
Type elements;
|
||||
|
||||
template<size_t ... Is>
|
||||
@@ -535,22 +535,22 @@ public:
|
||||
|
||||
private:
|
||||
template<std::size_t I = 0, typename FuncT, typename... Tp>
|
||||
inline typename std::enable_if<I == sizeof...(Tp), void>::type
|
||||
inline std::enable_if_t<I == sizeof...(Tp), void>
|
||||
for_each(std::tuple<Tp...>&, FuncT) {}
|
||||
|
||||
template<std::size_t I = 0, typename FuncT, typename... Tp>
|
||||
inline typename std::enable_if<I < sizeof...(Tp), void>::type
|
||||
inline std::enable_if_t<I < sizeof...(Tp), void>
|
||||
for_each(std::tuple<Tp...>& t, FuncT f) {
|
||||
f(I, std::get<I>(t));
|
||||
for_each<I + 1, FuncT, Tp...>(t, f);
|
||||
}
|
||||
|
||||
template<std::size_t I = 0, typename FuncT, typename... Tp>
|
||||
inline typename std::enable_if<I == sizeof...(Tp), void>::type
|
||||
inline std::enable_if_t<I == sizeof...(Tp), void>
|
||||
for_each_index(std::tuple<Tp...>&, FuncT) {}
|
||||
|
||||
template<std::size_t I = 0, typename FuncT, typename... Tp>
|
||||
inline typename std::enable_if<I < sizeof...(Tp), void>::type
|
||||
inline std::enable_if_t<I < sizeof...(Tp), void>
|
||||
for_each_index(std::tuple<Tp...>& t, FuncT f) {
|
||||
f.template operator()<I>(std::get<I>(t));
|
||||
for_each_index<I + 1, FuncT, Tp...>(t, f);
|
||||
@@ -597,7 +597,7 @@ private:
|
||||
|
||||
void construct_each(size_t from, size_t to) noexcept {
|
||||
forEach([from, to](auto p) {
|
||||
using T = typename std::decay<decltype(*p)>::type;
|
||||
using T = std::decay_t<decltype(*p)>;
|
||||
// note: scalar types like int/float get initialized to zero
|
||||
if constexpr (!std::is_trivially_default_constructible_v<T>) {
|
||||
for (size_t i = from; i < to; i++) {
|
||||
@@ -609,7 +609,7 @@ private:
|
||||
|
||||
void destroy_each(size_t from, size_t to) noexcept {
|
||||
forEach([from, to](auto p) {
|
||||
using T = typename std::decay<decltype(*p)>::type;
|
||||
using T = std::decay_t<decltype(*p)>;
|
||||
if constexpr (!std::is_trivially_destructible_v<T>) {
|
||||
for (size_t i = from; i < to; i++) {
|
||||
p[i].~T();
|
||||
@@ -624,7 +624,7 @@ private:
|
||||
if (mSize) {
|
||||
auto size = mSize; // placate a compiler warning
|
||||
forEach([buffer, &index, &offsets, size](auto p) {
|
||||
using T = typename std::decay<decltype(*p)>::type;
|
||||
using T = std::decay_t<decltype(*p)>;
|
||||
T* UTILS_RESTRICT b = static_cast<T*>(buffer);
|
||||
|
||||
// go through each element and move them from the old array to the new
|
||||
@@ -671,7 +671,7 @@ template<typename Allocator, typename... Elements>
|
||||
inline
|
||||
typename StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef&
|
||||
StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef::operator=(
|
||||
StructureOfArraysBase::IteratorValueRef const& rhs) {
|
||||
IteratorValueRef const& rhs) {
|
||||
return operator=(IteratorValue(rhs));
|
||||
}
|
||||
|
||||
@@ -679,7 +679,7 @@ template<typename Allocator, typename... Elements>
|
||||
inline
|
||||
typename StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef&
|
||||
StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef::operator=(
|
||||
StructureOfArraysBase::IteratorValueRef&& rhs) noexcept {
|
||||
IteratorValueRef&& rhs) noexcept {
|
||||
return operator=(IteratorValue(rhs));
|
||||
}
|
||||
|
||||
@@ -688,7 +688,7 @@ template<size_t... Is>
|
||||
inline
|
||||
typename StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef&
|
||||
StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef::assign(
|
||||
StructureOfArraysBase::IteratorValue const& rhs, std::index_sequence<Is...>) {
|
||||
IteratorValue const& rhs, std::index_sequence<Is...>) {
|
||||
// implements IteratorValueRef& IteratorValueRef::operator=(IteratorValue const& rhs)
|
||||
auto UTILS_UNUSED l = { (soa->elementAt<Is>(index) = std::get<Is>(rhs.elements), 0)... };
|
||||
return *this;
|
||||
@@ -699,7 +699,7 @@ template<size_t... Is>
|
||||
inline
|
||||
typename StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef&
|
||||
StructureOfArraysBase<Allocator, Elements...>::IteratorValueRef::assign(
|
||||
StructureOfArraysBase::IteratorValue&& rhs, std::index_sequence<Is...>) noexcept {
|
||||
IteratorValue&& rhs, std::index_sequence<Is...>) noexcept {
|
||||
// implements IteratorValueRef& IteratorValueRef::operator=(IteratorValue&& rhs) noexcept
|
||||
auto UTILS_UNUSED l = {
|
||||
(soa->elementAt<Is>(index) = std::move(std::get<Is>(rhs.elements)), 0)... };
|
||||
|
||||
@@ -39,7 +39,7 @@ constexpr inline T popcount(T v) noexcept {
|
||||
return (T) (v * (ONES / 255)) >> (sizeof(T) - 1) * CHAR_BIT;
|
||||
}
|
||||
|
||||
template<typename T, typename = std::enable_if_t<std::is_unsigned<T>::value>>
|
||||
template<typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>>
|
||||
constexpr inline T clz(T x) noexcept {
|
||||
static_assert(sizeof(T) * CHAR_BIT <= 128, "details::clz() only support up to 128 bits");
|
||||
x |= (x >> 1u);
|
||||
@@ -62,7 +62,7 @@ constexpr inline T clz(T x) noexcept {
|
||||
return T(sizeof(T) * CHAR_BIT) - details::popcount(x);
|
||||
}
|
||||
|
||||
template<typename T, typename = std::enable_if_t<std::is_unsigned<T>::value>>
|
||||
template<typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>>
|
||||
constexpr inline T ctz(T x) noexcept {
|
||||
static_assert(sizeof(T) * CHAR_BIT <= 64, "details::ctz() only support up to 64 bits");
|
||||
T c = sizeof(T) * CHAR_BIT;
|
||||
@@ -227,7 +227,7 @@ unsigned long long UTILS_ALWAYS_INLINE popcount(unsigned long long x) noexcept {
|
||||
}
|
||||
|
||||
template<typename T,
|
||||
typename = std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value>>
|
||||
typename = std::enable_if_t<std::is_integral_v<T> && std::is_unsigned_v<T>>>
|
||||
constexpr inline UTILS_PUBLIC UTILS_PURE
|
||||
T log2i(T x) noexcept {
|
||||
return (sizeof(x) * 8 - 1u) - clz(x);
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace utils {
|
||||
*/
|
||||
|
||||
template<typename T, size_t N = 1,
|
||||
typename = typename std::enable_if<std::is_integral<T>::value &&
|
||||
std::is_unsigned<T>::value>::type>
|
||||
typename = std::enable_if_t<std::is_integral_v<T> &&
|
||||
std::is_unsigned_v<T>>>
|
||||
class UTILS_PUBLIC bitset {
|
||||
T storage[N];
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace utils::io {
|
||||
|
||||
struct ostream_;
|
||||
|
||||
class UTILS_PUBLIC ostream : protected utils::PrivateImplementation<ostream_> {
|
||||
class UTILS_PUBLIC ostream : protected PrivateImplementation<ostream_> {
|
||||
friend struct ostream_;
|
||||
|
||||
public:
|
||||
@@ -123,7 +123,7 @@ private:
|
||||
};
|
||||
|
||||
// handles utils::bitset
|
||||
inline ostream& operator << (ostream& o, utils::bitset32 const& s) noexcept {
|
||||
inline ostream& operator << (ostream& o, bitset32 const& s) noexcept {
|
||||
return o << (void*)uintptr_t(s.getValue());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user