Skip to content

Commit 7d51bd1

Browse files
Switched to use Unreal Engine's naming convention (#30)
* Initial naming refactor pass * Fixed build issues from the refactor * Started work on doing the partial refactor * Last renames * Added a few name aliases * Additional naming convention fixes * Additional generator fixes * Made it so COROUTINES can be toggled off theoretically * Fixed test case failures * Fixed a bad include
1 parent 92ba4a9 commit 7d51bd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3560
-3922
lines changed

RetroLib/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if (RETROLIB_WITH_MODULES)
88
src/RetroLib.ixx)
99
target_compile_definitions(RetroLib
1010
PUBLIC
11-
RETROLIB_WITH_MODULES=1)
11+
RETROLIB_WITH_MODULES=1
12+
RETROLIB_WITH_COROUTINES=1)
1213

1314
target_include_directories(RetroLib
1415
PUBLIC
@@ -21,6 +22,7 @@ else()
2122
${CMAKE_CURRENT_SOURCE_DIR}/include)
2223
target_compile_definitions(RetroLib
2324
INTERFACE
24-
RETROLIB_WITH_MODULES=0)
25+
RETROLIB_WITH_MODULES=0
26+
RETROLIB_WITH_COROUTINES=1)
2527
endif()
2628

RetroLib/include/RetroLib/Casting/ByteCast.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define RETROLIB_EXPORT
1717
#endif
1818

19-
namespace retro {
19+
namespace Retro {
2020
/**
2121
* Represents a type we see as a valid opaque byte pointer.
2222
*
@@ -26,9 +26,8 @@ namespace retro {
2626
concept ValidByteType =
2727
std::same_as<T, std::byte> || std::same_as<T, uint8_t> || std::same_as<T, int8_t> || std::same_as<T, void>;
2828

29-
template <typename T>
3029
/**
31-
* @class ByteCast
30+
* @class ByteCastFunction
3231
* @brief A utility class for casting various data types to byte representations.
3332
*
3433
* TByteCast provides functionality to cast different data types such as integers,
@@ -42,7 +41,8 @@ namespace retro {
4241
* - Ensure proper endianess during the casting process.
4342
* - Utility methods to handle casting of custom objects, if needed.
4443
*/
45-
struct ByteCast {
44+
template <typename T>
45+
struct ByteCastFunction {
4646
/**
4747
* @brief Casts a byte pointer to a specified data type.
4848
*
@@ -75,5 +75,5 @@ namespace retro {
7575
* - Provides additional functionality for custom object conversions if necessary.
7676
*/
7777
RETROLIB_EXPORT template <typename T>
78-
constexpr ByteCast<T> byte_cast;
78+
constexpr ByteCastFunction<T> ByteCast;
7979
} // namespace retro

RetroLib/include/RetroLib/Casting/ClassCast.h renamed to RetroLib/include/RetroLib/Casting/DynamicCast.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file ClassCast.h
2+
* @file DynamicCast.h
33
* @brief Functor for performing runtime conversions between types.
44
*
55
* @author Retro & Chill
@@ -20,7 +20,7 @@
2020
#define RETROLIB_EXPORT
2121
#endif
2222

23-
namespace retro {
23+
namespace Retro {
2424

2525
/**
2626
* Attempts to dynamically cast a reference of type U to a reference of type T.
@@ -38,16 +38,16 @@ namespace retro {
3838
* Optional reference to T is returned.
3939
*/
4040
RETROLIB_EXPORT template <Class T, Class U, bool Checked = false>
41-
constexpr decltype(auto) dyn_cast_ref(U &value) {
41+
constexpr decltype(auto) DynCastRef(U &Value) {
4242
if constexpr (std::is_base_of_v<T, U>) {
43-
return static_cast<T &>(value);
43+
return static_cast<T &>(Value);
4444
} else {
45-
auto ptr = dynamic_cast<T *>(&value);
45+
auto Ptr = dynamic_cast<T *>(&Value);
4646
if constexpr (Checked) {
47-
RETROLIB_ASSERT(valid_ptr(ptr));
48-
return dynamic_cast<T &>(value);
47+
RETROLIB_ASSERT(valid_ptr(Ptr));
48+
return dynamic_cast<T &>(Value);
4949
} else {
50-
return ptr != nullptr ? Optional<T &>(*ptr) : Optional<T &>();
50+
return Ptr != nullptr ? Optional<T &>(*Ptr) : Optional<T &>();
5151
}
5252
}
5353
}
@@ -63,19 +63,19 @@ namespace retro {
6363
* @tparam Checked A boolean template parameter to indicate whether to perform runtime checks during casting.
6464
*/
6565
template <Class T, bool Checked = false>
66-
struct ClassCast {
66+
struct DynamicCastFunction {
6767
/**
6868
* Overloaded function call operator which performs a dynamic cast of a reference type.
6969
* This function attempts to cast a reference of type U to a reference of type T.
7070
* If the Checked parameter is considered, it might involve runtime checks for safety.
71-
*
72-
* @param value A reference to a value of type U that is to be casted.
71+
*D
72+
* @param Value A reference to a value of type U that is to be casted.
7373
* @return The result of the dynamic cast to type T. The return is of the same reference type,
7474
* which is determined by the use of `decltype(auto)`.
7575
*/
7676
template <Class U>
77-
constexpr decltype(auto) operator()(U &value) {
78-
return dyn_cast_ref<T, U, Checked>(value);
77+
constexpr decltype(auto) operator()(U &Value) {
78+
return DynCastRef<T, U, Checked>(Value);
7979
}
8080

8181
/**
@@ -84,25 +84,25 @@ namespace retro {
8484
* This operator function checks if the provided value is a valid pointer, and depending on compile-time
8585
* conditions, it performs a dynamic cast or derives reference conversion.
8686
*
87-
* @param value A universal reference to a value that will be checked for validity and conditionally
87+
* @param Value A universal reference to a value that will be checked for validity and conditionally
8888
* transformed. This can be a pointer or a reference to an object.
8989
*
9090
* @return An Optional containing a reference to the object of type T if the pointer is valid and the
9191
* cast/conversion succeeds. If the pointer is invalid, an empty Optional is returned.
9292
*/
9393
template <PointerType U>
94-
constexpr decltype(auto) operator()(U &&value) const {
94+
constexpr decltype(auto) operator()(U &&Value) const {
9595
if constexpr (Checked) {
96-
RETROLIB_ASSERT(valid_ptr(std::forward<U>(value)));
97-
return dyn_cast_ref<T, std::remove_pointer_t<U>, Checked>(*std::forward<U>(value));
96+
RETROLIB_ASSERT(valid_ptr(std::forward<U>(Value)));
97+
return DynCastRef<T, std::remove_pointer_t<U>, Checked>(*std::forward<U>(Value));
9898
} else if constexpr (std::derived_from<std::decay_t<DereferencedType<U>>, std::decay_t<T>>) {
99-
return valid_ptr(std::forward<U>(value)) ? Optional<T &>(*std::forward<U>(value)) : Optional<T &>();
99+
return ValidPtr(std::forward<U>(Value)) ? Optional<T &>(*std::forward<U>(Value)) : Optional<T &>();
100100
} else {
101-
if (!valid_ptr(std::forward<U>(value))) {
101+
if (!ValidPtr(std::forward<U>(Value))) {
102102
return Optional<T &>();
103103
}
104104

105-
return dyn_cast_ref<T, std::decay_t<DereferencedType<U>>, Checked>(*std::forward<U>(value));
105+
return DynCastRef<T, std::decay_t<DereferencedType<U>>, Checked>(*std::forward<U>(Value));
106106
}
107107
}
108108

@@ -111,15 +111,15 @@ namespace retro {
111111
* to a Polymorphic object, effectively de-referencing it and invoking the functor on the
112112
* underlying object that the Polymorphic reference points to.
113113
*
114-
* @param value A reference to a Polymorphic<U> object, where U must be a type that supports
114+
* @param Value A reference to a Polymorphic<U> object, where U must be a type that supports
115115
* the operations defined within the functor.
116116
* @return The result of invoking the functor on the de-referenced object. The return type is
117117
* deduced using decltype(auto), meaning it will preserve the value category and type
118118
* of the final operation's result.
119119
*/
120120
template <Class U>
121-
constexpr decltype(auto) operator()(Polymorphic<U> &value) const {
122-
return (*this)(*value);
121+
constexpr decltype(auto) operator()(Polymorphic<U> &Value) const {
122+
return (*this)(*Value);
123123
}
124124

125125
/**
@@ -128,12 +128,12 @@ namespace retro {
128128
* This operator allows the functor to be called on a given polymorphic object,
129129
* effectively dereferencing it and calling the functor with its underlying value.
130130
*
131-
* @param value A constant reference to a Polymorphic object containing the value.
131+
* @param Value A constant reference to a Polymorphic object containing the value.
132132
* @return The result of applying the functor to the dereferenced value stored in the Polymorphic object.
133133
*/
134134
template <Class U>
135-
constexpr decltype(auto) operator()(const Polymorphic<U> &value) const {
136-
return (*this)(*value);
135+
constexpr decltype(auto) operator()(const Polymorphic<U> &Value) const {
136+
return (*this)(*Value);
137137
}
138138

139139
constexpr Optional<T &> operator()(std::nullptr_t) const
@@ -156,7 +156,7 @@ namespace retro {
156156
* @tparam T The target class type to which the casting is to be performed.
157157
*/
158158
RETROLIB_EXPORT template <Class T>
159-
constexpr ClassCast<T> class_cast;
159+
constexpr DynamicCastFunction<T> DynamicCast;
160160

161161
/**
162162
* @brief A compile-time constant expression representing a checked class cast operation.
@@ -170,6 +170,6 @@ namespace retro {
170170
* be specified to indicate the destination class type for the casting operation.
171171
*/
172172
RETROLIB_EXPORT template <Class T>
173-
constexpr ClassCast<T, true> class_cast_checked;
173+
constexpr DynamicCastFunction<T, true> ClassCastChecked;
174174

175175
} // namespace retro

RetroLib/include/RetroLib/Casting/InstanceOf.h

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,38 @@
1919
#define RETROLIB_EXPORT
2020
#endif
2121

22-
namespace retro {
22+
namespace Retro {
2323

24-
/**
25-
* Checks if the given instance of type U is a valid instance of the desired base type T.
26-
*
27-
* @param value The instance of type U to be checked for validity.
28-
* @return True if the instance is valid, meaning that U is derived from T or is an instance
29-
* that can be dynamically cast to T. Otherwise, returns false.
30-
*/
31-
RETROLIB_EXPORT template <Class T, Class U>
32-
constexpr bool is_valid_instance(const U &value) {
33-
if constexpr (std::derived_from<U, T>) {
34-
// Trivial case, U is derived from T, so we know with certainty that this is valid
35-
return true;
36-
} else {
24+
RETROLIB_EXPORT template <Class T>
25+
struct InstanceChecker {
26+
/**
27+
* Checks if the given instance of type U is a valid instance of the desired base type T.
28+
*
29+
* @param Value The instance of type U to be checked for validity.
30+
* @return True if the instance is valid, meaning that U is derived from T or is an instance
31+
* that can be dynamically cast to T. Otherwise, returns false.
32+
*/
33+
template <Class U>
34+
constexpr bool operator()(const U& Value) const {
35+
if constexpr (std::derived_from<U, T>) {
36+
// Trivial case, U is derived from T, so we know with certainty that this is valid
37+
return true;
38+
} else {
3739
#ifndef RTTI_ENABLED
38-
static_assert(false, "RTTI is disabled, but the type is not derived from T")
39-
#endif
40-
auto casted = dynamic_cast<const T *>(&value);
41-
return casted != nullptr;
40+
static_assert(false, "RTTI is disabled, but the type is not derived from T");
41+
#endif
42+
auto casted = dynamic_cast<const T *>(&Value);
43+
return casted != nullptr;
44+
}
4245
}
43-
}
46+
};
47+
48+
49+
template <Class T>
50+
static constexpr InstanceChecker<T> IsValidInstance;
4451

4552
/**
46-
* @struct InstanceOf
53+
* @struct InstanceOfFunction
4754
* @brief A utility to check if an object or a pointer is a valid instance of a specified type.
4855
*
4956
* The InstanceOf struct provides overloaded function call operators to determine if a given
@@ -52,16 +59,16 @@ namespace retro {
5259
* @tparam T The type against which the object's type is being checked.
5360
*/
5461
template <Class T>
55-
struct InstanceOf {
62+
struct InstanceOfFunction {
5663
/**
5764
* Checks if the given value is a valid instance of type U.
5865
*
59-
* @param value The value to be checked against the type U.
66+
* @param Value The value to be checked against the type U.
6067
* @return A boolean indicating whether the value is a valid instance of type U.
6168
*/
6269
template <Class U>
63-
constexpr bool operator()(const U &value) const {
64-
return is_valid_instance<T, U>(value);
70+
constexpr bool operator()(const U &Value) const {
71+
return IsValidInstance<T>(Value);
6572
}
6673

6774
/**
@@ -71,13 +78,13 @@ namespace retro {
7178
* to the `valid_ptr` function and whether the functor applied to the value pointed to by
7279
* the pointer is true.
7380
*
74-
* @param ptr Pointer to the object that needs to be checked.
81+
* @param Ptr Pointer to the object that needs to be checked.
7582
* @return true if the pointer is valid and the functor evaluates to true for the
7683
* dereferenced value, otherwise false.
7784
*/
7885
template <PointerType U>
79-
constexpr bool operator()(U &&ptr) const {
80-
return valid_ptr(std::forward<U>(ptr)) && (*this)(*std::forward<U>(ptr));
86+
constexpr bool operator()(U &&Ptr) const {
87+
return ValidPtr(std::forward<U>(Ptr)) && (*this)(*std::forward<U>(Ptr));
8188
}
8289

8390
/**
@@ -86,21 +93,21 @@ namespace retro {
8693
* This function is a callable operator that takes a polymorphic object
8794
* and applies this operator to its dereferenced value.
8895
*
89-
* @param polymorphic A Polymorphic object which contains a type U of
96+
* @param Polymorphic A Polymorphic object which contains a type U of
9097
* a certain size. The object will be dereferenced and the
9198
* result will be passed to the operator function.
9299
* @return A boolean value indicating the result of applying the operator
93100
* to the dereferenced value of the polymorphic object.
94101
*/
95102
template <Class U, size_t Size>
96-
constexpr bool operator()(const Polymorphic<U, Size> &polymorphic) const {
97-
return (*this)(*polymorphic);
103+
constexpr bool operator()(const Polymorphic<U, Size> &Polymorphic) const {
104+
return (*this)(*Polymorphic);
98105
}
99106

100107
/**
101108
* Determines the boolean value for a nullptr.
102109
*
103-
* @param A parameter of type std::nullptr_t representing a null pointer.
110+
* @param std::nullptr_t A parameter of type std::nullptr_t representing a null pointer.
104111
* @return Always returns false as null pointers are considered false.
105112
*/
106113
constexpr bool operator()(std::nullptr_t) const {
@@ -124,5 +131,5 @@ namespace retro {
124131
* are performed at compile-time.
125132
*/
126133
RETROLIB_EXPORT template <Class T>
127-
constexpr InstanceOf<T> instance_of;
134+
constexpr InstanceOfFunction<T> InstanceOf;
128135
} // namespace retro

0 commit comments

Comments
 (0)