Compare commits

..

2 Commits

Author SHA1 Message Date
4d8466851c - Added More Documentation
- Added some more notes to the planning doc regarding shared libraries
 - Started adding unit tests for the C++ lang library.
2025-06-19 15:16:29 -04:00
909be55ed3 - Added More Documentation 2025-06-18 19:23:49 -04:00
37 changed files with 652 additions and 234 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.*/
/build/ /build/
/docs/ /docs/
/bin/ /bin/

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "external/sdl"]
path = external/sdl
url = https://github.com/libsdl-org/SDL.git

View File

@ -1,6 +1,12 @@
cmake_minimum_required(VERSION 3.30) cmake_minimum_required(VERSION 3.30)
project(fennec) project(fennec)
# External dependencies should be loaded here
# SDL is a dependency of the project, added as a git submodule
set(SDL_STATIC 1)
add_subdirectory(external/sdl)
set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD 26)
set(CMAKE_C_STANDARD 26) set(CMAKE_C_STANDARD 26)
@ -15,7 +21,8 @@ add_subdirectory(metaprogramming)
string(TOLOWER ${CMAKE_BUILD_TYPE} FENNEC_BUILD_NAME) string(TOLOWER ${CMAKE_BUILD_TYPE} FENNEC_BUILD_NAME)
set(CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/build/${CMAKE_PLATFORM_NO_VERSIONED_SONAME}) message(STATUS "OS: ${CMAKE_SYSTEM_NAME}")
message(STATUS "Build: ${FENNEC_BUILD_NAME}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/${FENNEC_BUILD_NAME}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/${FENNEC_BUILD_NAME})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/${FENNEC_BUILD_NAME}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/${FENNEC_BUILD_NAME})
@ -32,7 +39,10 @@ add_library(fennec STATIC
include/fennec/containers/dynarray.h include/fennec/containers/dynarray.h
# LANG =================================================================================================================h # LANG =================================================================================================================
include/fennec/lang/lang.h
include/fennec/lang/metaprogramming.h
include/fennec/lang/bits.h include/fennec/lang/bits.h
include/fennec/lang/constants.h include/fennec/lang/constants.h
include/fennec/lang/conditional_types.h include/fennec/lang/conditional_types.h
@ -44,11 +54,13 @@ add_library(fennec STATIC
include/fennec/lang/type_transforms.h include/fennec/lang/type_transforms.h
include/fennec/lang/types.h include/fennec/lang/types.h
include/fennec/lang/utility.h include/fennec/lang/utility.h
include/fennec/lang/variadics.h include/fennec/lang/type_sequences.h
include/fennec/lang/integer.h
include/fennec/lang/detail/__bits.h
include/fennec/lang/detail/__numeric_transforms.h include/fennec/lang/detail/__numeric_transforms.h
include/fennec/lang/detail/__type_traits.h include/fennec/lang/detail/__type_traits.h
include/fennec/lang/detail/__variadics.h include/fennec/lang/detail/__type_sequences.h
# MEMORY =============================================================================================================== # MEMORY ===============================================================================================================
@ -86,16 +98,15 @@ add_library(fennec STATIC
include/fennec/math/detail/__fwd.h include/fennec/math/detail/__fwd.h
include/fennec/math/detail/__types.h include/fennec/math/detail/__types.h
include/fennec/math/detail/__vector_traits.h include/fennec/math/detail/__vector_traits.h
include/fennec/lang/lang.h include/fennec/lang/assert.h
include/fennec/lang/detail/__bits.h source/lang/assert.cpp
include/fennec/lang/integer.h
) )
# add metaprogramming templates as a dependency and also force documentation to be generated when fennec is compiled # add metaprogramming templates as a dependency and also force documentation to be generated when fennec is compiled
if(DOXYGEN_FOUND) if(DOXYGEN_FOUND)
add_dependencies(fennec fennecdocs metaprogramming) add_dependencies(fennec fennecdocs metaprogramming SDL3-static)
else() else()
add_dependencies(fennec metaprogramming) add_dependencies(fennec metaprogramming SDL3-static)
endif() endif()
# Compiler Warning Flags # Compiler Warning Flags

View File

@ -41,6 +41,15 @@ assertions. **DO NOT USE EXCEPTIONS**.
System implementations should be independent of architecture or platforms. i.e. the code of the graphics system should System implementations should be independent of architecture or platforms. i.e. the code of the graphics system should
not care if OpenGL or Vulkan is used and should not use any direct calls to OpenGL or Vulkan. not care if OpenGL or Vulkan is used and should not use any direct calls to OpenGL or Vulkan.
The engine should not care about the types of objects loaded from a so/dll. In fact, most of the code should
be type independent. Any shared information among a collection of objects should be held either implicitly or explicitly
in the super-class. It will be the responsibility of the linked code to initialize and cleanup the objects related to it.
This principle should extend to the submodules of the engine.
It is also best to avoid objects having behaviour that is not defined by the system they are in. There are some exceptions
in extensions or mods and should be given configurability and programmability within those systems and their stages.
This however can be acheived using events at different stages of those engines that are on-demand.
@ -68,6 +77,9 @@ So far this is implemented on an as-needed basis. A full implementation should b
Implement math functions according to the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). Implement math functions according to the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf).
"Extensions" has a different meaning here. Extensions for the math library are any functions that are not defined within
the Specification.
Additional extensions should be implemented to provide standard definitions for functions predominantly related Additional extensions should be implemented to provide standard definitions for functions predominantly related
to Linear Algebra, Mathematical Analysis, and Discrete Analysis. Additional extensions will be implemented on a to Linear Algebra, Mathematical Analysis, and Discrete Analysis. Additional extensions will be implemented on a
as-needed basis. as-needed basis.
@ -107,7 +119,6 @@ Here are essential data-structures not specified in the C++ stdlib:
## Format Processing (`fproc`) ## Format Processing (`fproc`)
No, this won't include Machine Learning, it will mostly include tools for processing human-readable files.
fennec should be able to use Doxygen and LaTeX externally. Consider including binaries with releases. fennec should be able to use Doxygen and LaTeX externally. Consider including binaries with releases.
* String Analysis (`fproc/strings`) * String Analysis (`fproc/strings`)
@ -167,6 +178,7 @@ This will be the core of the engine.
- Event System - Event System
- Most events will fire at the start of the next tick, especially those related to physics and input. - Most events will fire at the start of the next tick, especially those related to physics and input.
- Events for graphics or audio should propagate immediately. - Events for graphics or audio should propagate immediately.
- Events for stages should also propagate immediately, this is to support extensions and mods.
- Core Engine Loop - Core Engine Loop
- System Manager - System Manager
- Ticks vs. Frames - Ticks vs. Frames

1
external/sdl vendored Submodule

@ -0,0 +1 @@
Subproject commit d7939abf42de34fff409f5e7c4b77ace79dff4de

View File

@ -33,8 +33,7 @@
#define FENNEC_CONTAINERS_ARRAY_H #define FENNEC_CONTAINERS_ARRAY_H
#include <fennec/lang/types.h> #include <fennec/lang/types.h>
#include <fennec/lang/assert.h>
#include <cassert>
namespace fennec namespace fennec
{ {

View File

@ -0,0 +1,29 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_LANG_ASSERT_H
#define FENNEC_LANG_ASSERT_H
using assert_handler = void (*)(const char *, const char *, int , const char *);
extern void set_assert_handler(assert_handler handler);
extern void __assert_impl(const char* expression, const char* file, int line, const char* function);
#define assert(expression) if(not(expression)) { __assert_impl(#expression, __FILE__, __LINE__, __PRETTY_FUNCTION__); }
#endif // FENNEC_LANG_ASSERT_H

View File

@ -18,7 +18,7 @@
/// ///
/// \file bits.h /// \file bits.h
/// \brief bit-wise operations /// \brief \ref fennec_lang_bit_manipulation
/// ///
/// ///
/// \details /// \details

View File

@ -18,7 +18,7 @@
/// ///
/// \file conditional_types.h /// \file conditional_types.h
/// \brief metaprogramming to conditionally set a type /// \brief \ref fennec_lang_conditional_types
/// ///
/// ///
/// \details /// \details
@ -73,7 +73,6 @@ namespace fennec
// fennec::conditional ================================================================================================= // fennec::conditional =================================================================================================
///
/// ///
/// \brief select between two types based on a condition /// \brief select between two types based on a condition
/// ///

View File

@ -18,7 +18,7 @@
/// ///
/// \file constants.h /// \file constants.h
/// \brief metaprogramming constants /// \brief \ref fennec_lang_constants
/// ///
/// ///
/// \details /// \details

View File

@ -16,8 +16,8 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#ifndef FENNEC_LANG_DETAIL_VARIADICS_H #ifndef FENNEC_LANG_DETAIL_TYPE_SEQUENCES_H
#define FENNEC_LANG_DETAIL_VARIADICS_H #define FENNEC_LANG_DETAIL_TYPE_SEQUENCES_H
#include <fennec/lang/type_transforms.h> #include <fennec/lang/type_transforms.h>
@ -33,4 +33,4 @@ template<typename FirstT, typename... RestT> struct __first_element : type_trans
} }
#endif // FENNEC_LANG_DETAIL_VARIADICS_H #endif // FENNEC_LANG_DETAIL_TYPE_SEQUENCES_H

View File

@ -18,8 +18,7 @@
/// ///
/// \file intrinsics.h /// \file intrinsics.h
/// \brief This header contains definitions for compiler intrinsics necessary for implementing functions of the /// \brief \ref fennec_lang_intrinsics
/// C++ stdlib.
/// ///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) /// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
/// ///
@ -34,6 +33,8 @@
/// \brief This header contains definitions for compiler intrinsics necessary for implementing functions of the /// \brief This header contains definitions for compiler intrinsics necessary for implementing functions of the
/// C++ stdlib. /// C++ stdlib.
/// ///
/// \code{.cpp}#include <fennec/lang/intrinsics.h>\endcode
///
/// ///
/// <table width="100%" class="fieldtable" id="table_fennec_lang_intrinsics"> /// <table width="100%" class="fieldtable" id="table_fennec_lang_intrinsics">
/// <tr><th style="vertical-align: top">Syntax /// <tr><th style="vertical-align: top">Syntax

View File

@ -18,7 +18,7 @@
/// ///
/// \file lang.h /// \file lang.h
/// \brief fennec C++ language library /// \brief \ref fennec_lang
/// ///
/// ///
/// \details /// \details
@ -31,6 +31,12 @@
#ifndef FENNEC_LANG_H #ifndef FENNEC_LANG_H
#define FENNEC_LANG_H #define FENNEC_LANG_H
#include <fennec/lang/bits.h>
#include <fennec/lang/intrinsics.h>
#include <fennec/lang/limits.h>
#include <fennec/lang/types.h>
#include <fennec/lang/utility.h>
/// ///
/// \page fennec_lang C++ Language Library /// \page fennec_lang C++ Language Library
/// ///
@ -41,21 +47,7 @@
/// - \subpage fennec_lang_limits /// - \subpage fennec_lang_limits
/// - \subpage fennec_lang_metaprogramming /// - \subpage fennec_lang_metaprogramming
/// - \subpage fennec_lang_types /// - \subpage fennec_lang_types
/// /// - \subpage fennec_lang_utility
///
///
/// \page fennec_lang_metaprogramming Metaprogramming
///
/// Metaprogramming is a method of obtaining information about the structure of the code at compile time.
/// This includes getting traits of types, such as with \ref fennec::numeric_limits. You may even
/// \ref fennec_lang_conditional_types "programmatically enable" functions based on the info of the types that the function uses.
///
/// - \subpage fennec_lang_constants
/// - \subpage fennec_lang_conditional_types
/// - \subpage fennec_lang_numeric_transforms
/// - \subpage fennec_lang_sequences
/// - \subpage fennec_lang_type_traits
/// ///
/// ///

View File

@ -18,7 +18,7 @@
/// ///
/// \file limits.h /// \file limits.h
/// \brief contains the limits of builtin data types to C++ /// \brief \ref fennec_lang_limits
/// ///
/// ///
/// \details /// \details

View File

@ -0,0 +1,52 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file metaprogramming.h
/// \brief \ref fennec_lang
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_LANG_METAPROGRAMMING_H
#define FENNEC_LANG_METAPROGRAMMING_H
///
/// \page fennec_lang_metaprogramming Metaprogramming Library
///
/// This is a sub-library of the fennec \ref fennec_lang. Metaprogramming is a method of obtaining information about the
/// structure of the code and changing its behaviour at compile time. This includes getting traits of types, such as with
/// \ref fennec::is_signed. You may even \ref fennec_lang_conditional_types "programmatically enable" functions
/// based on the info of the types that the function uses.
///
/// - \subpage fennec_lang_constants
/// - \subpage fennec_lang_conditional_types
/// - \subpage fennec_lang_numeric_transforms
/// - \subpage fennec_lang_sequences
/// - \subpage fennec_lang_type_sequences
/// - \subpage fennec_lang_type_traits
/// - \subpage fennec_lang_type_transforms
///
///
#endif // FENNEC_LANG_METAPROGRAMMING_H

View File

@ -18,7 +18,7 @@
/// ///
/// \file numeric_transforms.h /// \file numeric_transforms.h
/// \brief modify numeric types at compile time /// \brief \ref fennec_lang_numeric_transforms
/// ///
/// ///
/// \details /// \details

View File

@ -18,7 +18,7 @@
/// ///
/// \file sequences.h /// \file sequences.h
/// \brief metaprogramming sequences /// \brief \ref fennec_lang_sequences
/// ///
/// ///
/// \details /// \details

View File

@ -17,8 +17,8 @@
// ===================================================================================================================== // =====================================================================================================================
/// ///
/// \file variadics.h /// \file type_sequences.h
/// \brief basic types of the c++ language /// \brief \ref fennec_lang_type_sequences
/// ///
/// ///
/// \details /// \details
@ -28,10 +28,35 @@
/// ///
/// ///
#ifndef FENNEC_LANG_VARIADICS_H #ifndef FENNEC_LANG_TYPE_SEQUENCES_H
#define FENNEC_LANG_VARIADICS_H #define FENNEC_LANG_TYPE_SEQUENCES_H
#include <fennec/lang/detail/__variadics.h> ///
/// \page fennec_lang_type_sequences Type Sequences
///
/// \brief This header is part of the metaprogramming library. It defines structures for sequences of types, used during compile time.
///
/// \code #include <fennec/lang/type_sequences.h> \endcode
///
/// <table width="100%" class="fieldtable" id="table_fennec_lang_constants">
/// <tr><th style="vertical-align: top">Syntax
/// <th style="vertical-align: top">Description
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::first_element "typename first_element<ValueT, Values...>::type"<br>
/// \ref fennec::first_element_t "first_element_t<ValueT, Values...>"
/// <td width="50%" style="vertical-align: top">
/// \copydoc fennec::first_element
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::replace_first_element "typename replace_first_element<ClassT, SubT, OriginT, RestT...>::type"<br>
/// <td width="50%" style="vertical-align: top">
/// \copydoc fennec::replace_first_element
///
/// </table>
///
#include <fennec/lang/detail/__type_sequences.h>
namespace fennec namespace fennec
{ {

View File

@ -18,7 +18,7 @@
/// ///
/// \file type_traits.h /// \file type_traits.h
/// \brief get info about types at compile-time /// \brief \ref fennec_lang_type_traits
/// ///
/// ///
/// \details /// \details
@ -92,6 +92,18 @@
/// <td width="50%" style="vertical-align: top"> /// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::is_same /// \copydetails fennec::is_same
/// ///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::can_convert "can_convert<TypeT0, TypeT1>::value"<br>
/// \ref fennec::can_convert_v "can_convert_v<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::can_convert
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::is_constructible "is_constructible<ClassT, ArgsT...>::value"<br>
/// \ref fennec::is_constructible_v "is_constructible_v<ClassT, ArgsT...>"
/// <td width="50%" style="vertical-align: top">
/// \copydoc fennec::is_constructible
///
/// </table> /// </table>
/// ///
@ -157,7 +169,7 @@ template<typename T> constexpr bool_t is_integral_v
/// ///
/// \brief check if \p T is of a signed integral /// \brief check if \p T is of a signed integral
/// ///
/// \details /// \details Checks if type `T` is a signed type i.e. `T(-1) < T(0)` and stores it in `is_same::value`.
/// \tparam T type to check /// \tparam T type to check
template<typename T> struct is_signed template<typename T> struct is_signed
: detail::__is_signed<remove_cvr_t<T>> {}; : detail::__is_signed<remove_cvr_t<T>> {};
@ -172,7 +184,7 @@ template<typename T> constexpr bool_t is_signed_v
/// ///
/// \brief check if \p T is of an unsigned integral /// \brief check if \p T is of an unsigned integral
/// ///
/// \details /// \details Checks if type `T` is an unsigned type i.e. `T(-1) > T(0)` and stores it in `is_same::value`.
/// \tparam T type to check /// \tparam T type to check
template<typename T> struct is_unsigned template<typename T> struct is_unsigned
: detail::__is_unsigned<remove_cvr_t<T>> {}; : detail::__is_unsigned<remove_cvr_t<T>> {};
@ -190,7 +202,7 @@ template<typename T> constexpr bool_t is_unsigned_v
/// ///
/// \brief check if \p T is of a floating point type /// \brief check if \p T is of a floating point type
/// ///
/// \details /// \details Checks if type `T` is a floating point type and store it in `is_same::value`.
/// \tparam T type to check /// \tparam T type to check
template<typename T> struct is_floating_point template<typename T> struct is_floating_point
: detail::__is_floating_point<remove_cvr_t<T>>{}; : detail::__is_floating_point<remove_cvr_t<T>>{};
@ -208,7 +220,7 @@ template<typename T> constexpr bool_t is_floating_point_v
/// ///
/// \brief check if \p T is an arithmetic type /// \brief check if \p T is an arithmetic type
/// ///
/// \details /// \details Checks if type `T` is a built-in type with arithmetic operators and store it in `is_same::value`.
/// \tparam T type to check /// \tparam T type to check
template<typename T> struct is_arithmetic template<typename T> struct is_arithmetic
: bool_constant<is_integral_v<T> or is_floating_point_v<T>>{}; : bool_constant<is_integral_v<T> or is_floating_point_v<T>>{};
@ -224,8 +236,9 @@ template<typename T> constexpr bool_t is_arithmetic_v
/// ///
/// \brief check if the two types are identical /// \brief check if the two types are identical
/// ///
/// \details /// \details Checks if `T0` and `T1` are identical and store it in `is_same::value`
/// \tparam T type to check /// \tparam T0 first type to check
/// \tparam T1 second type to check
template<typename T0, typename T1> struct is_same template<typename T0, typename T1> struct is_same
: false_type {}; : false_type {};
@ -243,17 +256,19 @@ template<typename T0, typename T1> constexpr bool_t is_same_v
/// ///
/// \brief check if type `T0` can be converted `T1` /// \brief check if type `T0` can be converted `T1`
/// \tparam T0 First type ///
/// \tparam T1 Second type /// \details Checks if `TypeT0`
template<typename T0, typename T1> struct can_convert /// \tparam FromT First type
: bool_constant<FENNEC_BUILTIN_IS_CONVERTIBLE(T0, T1)> {}; /// \tparam ToT Second type
template<typename FromT, typename ToT> struct is_convertible
: bool_constant<FENNEC_BUILTIN_IS_CONVERTIBLE(FromT, ToT)> {};
/// ///
/// \brief shorthand /// \brief shorthand for `can_convert<TypeT0, TypeT1>::value`
/// \param T0 First type /// \param FromT First type
/// \param T1 Second type /// \param ToT Second type
template<typename T0, typename T1> using can_convert_v template<typename FromT, typename ToT> using is_convertible_v
= typename can_convert<T0, T1>::type; = typename is_convertible<FromT, ToT>::type;
// fennec::is_constructible =============================================================================================== // fennec::is_constructible ===============================================================================================
@ -266,6 +281,8 @@ template<typename T0, typename T1> using can_convert_v
template<typename ClassT, typename...ArgsT> struct is_constructible template<typename ClassT, typename...ArgsT> struct is_constructible
: bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT, ArgsT...)> {}; : bool_constant<FENNEC_BUILTIN_IS_CONSTRUCTIBLE(ClassT, ArgsT...)> {};
///
/// \brief Shorthand for `is_constructible<ClassT, ArgsT...>::value`
template<typename ClassT, typename...ArgsT> constexpr bool_t is_constructible_v template<typename ClassT, typename...ArgsT> constexpr bool_t is_constructible_v
= is_constructible<ClassT, ArgsT...>{}; = is_constructible<ClassT, ArgsT...>{};

View File

@ -18,7 +18,7 @@
/// ///
/// \file type_transforms.h /// \file type_transforms.h
/// \brief modify types at compile time /// \brief \ref fennec_lang_type_transforms
/// ///
/// ///
/// \details /// \details
@ -31,6 +31,100 @@
#ifndef FENNEC_LANG_TYPE_TRANSFORMS_H #ifndef FENNEC_LANG_TYPE_TRANSFORMS_H
#define FENNEC_LANG_TYPE_TRANSFORMS_H #define FENNEC_LANG_TYPE_TRANSFORMS_H
///
/// \page fennec_lang_type_transforms Type Transforms
///
/// \brief Part of the fennec metaprogramming library. This header defines structures for copying types with different traits
/// or rather, transform them, at compile time.
///
/// \code #include <fennec/lang/type_transforms.h> \endcode
///
///
/// <table width="100%" class="fieldtable" id="table_fennec_lang_constants">
/// <tr><th style="vertical-align: top">Syntax
/// <th style="vertical-align: top">Description
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::type_transform "type_transform<TypeT>::type"<br>
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::type_transform
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::add_pointer "add_pointer<TypeT>::type"<br>
/// \ref fennec::add_pointer_t "add_pointer_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::add_pointer
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::remove_pointer "remove_pointer<TypeT>::type"<br>
/// \ref fennec::remove_pointer_t "remove_pointer_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::remove_pointer
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::add_reference "add_reference<TypeT>::type"<br>
/// \ref fennec::add_reference_t "add_reference_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::add_reference
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::remove_reference "remove_reference<TypeT>::type"<br>
/// \ref fennec::remove_reference_t "remove_reference_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::remove_reference
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::add_const "add_const<TypeT>::type"<br>
/// \ref fennec::add_const_t "add_const_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::add_const
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::remove_const "remove_const<TypeT>::type"<br>
/// \ref fennec::remove_const_t "remove_const_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::remove_const
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::add_volatile "add_volatile<TypeT>::type"<br>
/// \ref fennec::add_volatile_t "add_volatile_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::add_volatile
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::remove_volatile "remove_volatile<TypeT>::type"<br>
/// \ref fennec::remove_volatile_t "remove_volatile_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::remove_volatile
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::add_cv "add_cv<TypeT>::type"<br>
/// \ref fennec::add_cv_t "add_cv_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::add_cv
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::remove_cv "remove_cv<TypeT>::type"<br>
/// \ref fennec::remove_cv_t "remove_cv_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::remove_cv
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::add_cvr "add_cvr<TypeT>::type"<br>
/// \ref fennec::add_cvr_t "add_cvr_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::add_cvr
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::remove_cvr "remove_cvr<TypeT>::type"<br>
/// \ref fennec::remove_cvr_t "remove_cvr_t<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::remove_cvr
///
/// </table>
///
namespace fennec namespace fennec
{ {
@ -40,7 +134,7 @@ namespace fennec
/// \struct fennec::type_transform /// \struct fennec::type_transform
/// \brief Base Class for Type Transformations /// \brief Base Class for Type Transformations
/// ///
/// \details resembles a transformation from one type to T, the result is stored in the typedef type_transform::type /// \details resembles a transformation from one type to T, the result is stored in the member type_transform::type
/// \tparam T Resultant Type /// \tparam T Resultant Type
template<typename T> struct type_transform { template<typename T> struct type_transform {

View File

@ -18,7 +18,7 @@
/// ///
/// \file types.h /// \file types.h
/// \brief basic types of the c++ language /// \brief \ref fennec_lang_types
/// ///
/// ///
/// \details /// \details
@ -34,10 +34,10 @@
/// ///
/// \page fennec_lang_types Types /// \page fennec_lang_types Types
/// ///
/// \brief This header contains definitions for built-in types. /// \brief This header contains definitions for the built-in types of the C++ language.
/// ///
/// <table width="100%" class="fieldtable" id="table_fennec_lang_types"> /// <table width="100%" class="fieldtable" id="table_fennec_lang_types">
/// <tr><th style="vertical-align: top">Member /// <tr><th style="vertical-align: top">Type
/// <th style="vertical-align: top">Description /// <th style="vertical-align: top">Description
/// ///
/// <tr><th colspan=2 style="text-align: center;">Basic Types /// <tr><th colspan=2 style="text-align: center;">Basic Types
@ -219,179 +219,182 @@
namespace fennec namespace fennec
{ {
// Basic Types =========================================================================================================
// Basic Types ========================================================================================================= ///
/// \name Basic Types
/// @{
/// ///
/// \name Basic Types /// \brief A conditional type
/// @{ using bool_t = bool;
/// ///
/// \brief A conditional type /// \brief A type capable of holding an ascii value
using bool_t = bool; using char_t = char;
/// ///
/// \brief A type capable of holding an ascii value /// \brief A type with the size of a char, capable of holding a signed 8-bit integer
using char_t = char; using schar_t = signed char;
/// ///
/// \brief A type with the size of a char, capable of holding a signed 8-bit integer /// \brief A type with the size of a char, capable of holding an unsigned 8-bit integer
using schar_t = signed char; using uchar_t = unsigned char;
/// ///
/// \brief A type with the size of a char, capable of holding an unsigned 8-bit integer /// \brief A signed short type, capable of holding signed 16-bit integer
using uchar_t = unsigned char; using short_t = signed short;
/// ///
/// \brief A signed short type, capable of holding signed 16-bit integer /// \brief An unsigned short type, capable of holding an unsigned signed 16-bit integer
using short_t = signed short; using ushort_t = unsigned short;
/// ///
/// \brief An unsigned short type, capable of holding an unsigned signed 16-bit integer /// \brief A signed integer type, size varies by implementation, but typically 32-bit
using ushort_t = unsigned short; using int_t = signed int;
/// ///
/// \brief A signed integer type, size varies by implementation, but typically 32-bit /// \brief An unsigned integer type, size varies by implementation, but typically 32-bit
using int_t = signed int; using uint_t = unsigned int;
/// ///
/// \brief An unsigned integer type, size varies by implementation, but typically 32-bit /// \brief A signed integer type, with a size of at least 32-bits
using uint_t = unsigned int; using long_t = signed long;
/// ///
/// \brief A signed integer type, with a size of at least 32-bits /// \brief An unsigned integer type, with a size of at least 32-bits
using long_t = signed long; using ulong_t = unsigned long;
/// ///
/// \brief An unsigned integer type, with a size of at least 32-bits /// \brief A signed integer type, with a size of 64-bits
using ulong_t = unsigned long; using llong_t = signed long long;
/// ///
/// \brief A signed integer type, with a size of 64-bits /// \brief An unsigned integer type, with a size of 64-bits
using llong_t = signed long long; using ullong_t = unsigned long long;
/// ///
/// \brief An unsigned integer type, with a size of 64-bits /// \brief A single-precision floating-point type, typically with a size of 32-bits
using ullong_t = unsigned long long; using float_t = float;
/// ///
/// \brief A single-precision floating-point type, typically with a size of 32-bits /// \brief A double-point type, typically with a size of 64-bits
using float_t = float; using double_t = double;
/// @}
///
/// \brief A double-point type, typically with a size of 64-bits
using double_t = double;
/// @}
// Sized Arithmetic Types ============================================================================================== ///
/// \name Special Types
/// @{
/// ///
/// \name Sized Integer Types /// \brief Null Pointer Type
/// @{ using nullptr_t = decltype(nullptr);
/// ///
/// \brief Signed 8-bit integer /// \brief Signed Integer Capable of Holding a Pointer to void
using int8_t = schar_t; using intptr_t = intptr_t;
/// ///
/// \brief Signed 16-bit integer /// \brief Unsigned Integer Capable of Holding a Pointer to void
using int16_t = short_t; using uintptr_t = uintptr_t;
/// ///
/// \brief Signed 32-bit integer /// \brief Maximum Width Signed Integer Type
using int32_t = long_t; using intmax_t = __INTMAX_TYPE__;
/// ///
/// \brief Signed signed 64-bit integer /// \brief Maximum Width Unsigned Integer Type
using int64_t = llong_t; using uintmax_t = __UINTMAX_TYPE__;
/// @} ///
/// \brief Unsigned Integer Type Returned By `sizeof`, `sizeof...`, and `alignof`
using size_t = __SIZE_TYPE__;
///
/// \brief Signed Integer Type Returned by the Subtraction of two Pointers
using ptrdiff_t = __PTRDIFF_TYPE__;
///
/// \brief undefined class for SFINAE
class undefined_t;
///
/// \brief Void type used for SFINAE
template<typename...>
using void_t = void;
/// @}
}
#include <fennec/lang/conditional_types.h>
namespace fennec
{
// Sized Arithmetic Types ==============================================================================================
///
/// \name Sized Integer Types
/// @{
///
/// \brief Signed 8-bit integer
using int8_t = schar_t;
///
/// \brief Signed 16-bit integer
using int16_t = short_t;
///
/// \brief Signed 32-bit integer
using int32_t = conditional_t<sizeof(int_t) == 4, int_t, long_t>;
///
/// \brief Signed signed 64-bit integer
using int64_t = llong_t;
/// @}
/// ///
/// \name Sized Unsigned Integer Types /// \name Sized Unsigned Integer Types
/// @{ /// @{
/// ///
/// \brief Unsigned 8-bit integer /// \brief Unsigned 8-bit integer
using uint8_t = uchar_t; using uint8_t = uchar_t;
/// ///
/// \brief Unsigned 16-bit integer /// \brief Unsigned 16-bit integer
using uint16_t = ushort_t; using uint16_t = ushort_t;
/// ///
/// \brief Unsigned 32-bit integer /// \brief Unsigned 32-bit integer
using uint32_t = ulong_t; using uint32_t = conditional_t<sizeof(uint_t) == 4, uint_t, ulong_t>;
/// ///
/// \brief Unsigned 64-bit integer /// \brief Unsigned 64-bit integer
using uint64_t = ullong_t; using uint64_t = ullong_t;
/// @} /// @}
/// ///
/// \name Sized Floating-Point Types /// \name Sized Floating-Point Types
/// @{ /// @{
/// ///
/// \brief A single-precision floating-point scalar /// \brief A single-precision floating-point scalar
using float32_t = float_t; using float32_t = float_t;
/// ///
/// \brief A double-precision floating-point scalar /// \brief A double-precision floating-point scalar
using float64_t = double_t; using float64_t = double_t;
/// @} /// @}
///
/// \name Special Types
/// @{
///
/// \brief Null Pointer Type
using nullptr_t = decltype(nullptr);
///
/// \brief Signed Integer Capable of Holding a Pointer to void
using intptr_t = intptr_t;
///
/// \brief Unsigned Integer Capable of Holding a Pointer to void
using uintptr_t = uintptr_t;
///
/// \brief Maximum Width Signed Integer Type
using intmax_t = __INTMAX_TYPE__;
///
/// \brief Maximum Width Unsigned Integer Type
using uintmax_t = __UINTMAX_TYPE__;
///
/// \brief Unsigned Integer Type Returned By `sizeof`, `sizeof...`, and `alignof`
using size_t = __SIZE_TYPE__;
///
/// \brief Signed Integer Type Returned by the Subtraction of two Pointers
using ptrdiff_t = __PTRDIFF_TYPE__;
///
/// \brief undefined class for SFINAE
class undefined_t;
///
/// \brief Void type used for SFINAE
template<typename...>
using void_t = void;
/// @}
} }

View File

@ -18,7 +18,7 @@
/// ///
/// \file utility.h /// \file utility.h
/// \brief common utility functions related to the c++ language /// \brief \ref fennec_lang_utility
/// ///
/// ///
/// \details /// \details
@ -31,46 +31,67 @@
#ifndef FENNEC_LANG_UTILITY_H #ifndef FENNEC_LANG_UTILITY_H
#define FENNEC_LANG_UTILITY_H #define FENNEC_LANG_UTILITY_H
///
/// \page fennec_lang_utility Utility
///
/// \brief This header contains common utility functions related to the C++ language.
///
/// \code #include <fennec/lang/utility.h> \endcode
///
/// <table width="100%" class="fieldtable" id="table_fennec_lang_constants">
/// <tr><th style="vertical-align: top">Syntax
/// <th style="vertical-align: top">Description
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::forward "T&& forward(x)"<br>
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::forward
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::move "T&& move(x)"<br>
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::move
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::copy "const T& copy(x)"<br>
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::copy
///
/// </table>
///
#include <fennec/lang/type_transforms.h> #include <fennec/lang/type_transforms.h>
namespace fennec namespace fennec
{ {
/// ///
/// \brief forwards reference types to extend their lifetime
/// ///
/// \details /// \details forwards reference types to extend their lifetime
/// \tparam T base type of the object /// \tparam T base type of the object
/// \param x reference to the object /// \param x reference to the object
/// \returns /// \returns
template<typename T> constexpr T&& forward(remove_reference_t<T>& x) noexcept { return x; } template<typename T> constexpr T&& forward(remove_reference_t<T>& x) noexcept { return x; }
/// // specialization for T&&
///
/// \brief forwards reference types to extend their lifetime
///
/// \details
/// \tparam T base type of the object
/// \param x reference to the object
/// \returns
template<typename T> constexpr T&& forward(remove_reference_t<T>&& x) noexcept { return x; } template<typename T> constexpr T&& forward(remove_reference_t<T>&& x) noexcept { return x; }
///
/// ///
/// \brief produces an x-value type to indicate \p x may be "moved" /// \brief produces an x-value type to indicate \p x may be "moved"
/// ///
/// \details /// \details produces an x-value type to indicate \p x may be "moved"
/// \tparam T base type of the object /// \tparam T base type of the object
/// \param x object to be moved /// \param x object to be moved
/// \returns `static_cast<remove_reference_t<T>&&>(x)` /// \returns `static_cast<remove_reference_t<T>&&>(x)`
template<typename T> constexpr remove_reference_t<T>&& move(T&& x) noexcept { return static_cast<remove_reference_t<T>&&>(x); } template<typename T> constexpr remove_reference_t<T>&& move(T&& x) noexcept { return static_cast<remove_reference_t<T>&&>(x); }
///
/// ///
/// \brief produces an r-value type to indicate \p x may be "copied" /// \brief produces an r-value type to indicate \p x may be "copied"
/// ///
/// \details /// \details produces an r-value type to indicate \p x may be "copied"
/// \tparam T base type of the object /// \tparam T base type of the object
/// \param x object to be copied /// \param x object to be copied
/// \returns const r-value /// \returns const r-value

View File

@ -18,7 +18,7 @@
/// ///
/// \file math.h /// \file math.h
/// \brief main math header which includes the main modules /// \brief fennec Math Library
/// ///
/// ///
/// \details This header includes the following modules of \ref fennec_math : /// \details This header includes the following modules of \ref fennec_math :

View File

@ -18,7 +18,7 @@
/// ///
/// \file swizzle.h /// \file swizzle.h
/// \brief part of the \ref fennec_math_vector, /// \brief \ref fennec_math_swizzle
/// ///
/// ///
/// \details /// \details

View File

@ -18,7 +18,7 @@
/// ///
/// \file vector_traits.h /// \file vector_traits.h
/// \brief part of the \ref fennec_math_vector /// \brief
/// ///
/// ///
/// \details this header implements functions to test vector types at compile time /// \details this header implements functions to test vector types at compile time
@ -31,6 +31,39 @@
#ifndef FENNEC_MATH_VECTOR_TRAITS_H #ifndef FENNEC_MATH_VECTOR_TRAITS_H
#define FENNEC_MATH_VECTOR_TRAITS_H #define FENNEC_MATH_VECTOR_TRAITS_H
///
/// \page fennec_math_vector_traits Vector Traits
///
/// \brief Part of the fennec math library. This header defines structures for metaprogramming with vectors.
///
/// \code #include <fennec/math/vector_traits.h> \endcode
///
///
/// <table width="100%" class="fieldtable" id="table_fennec_lang_constants">
/// <tr><th style="vertical-align: top">Syntax
/// <th style="vertical-align: top">Description
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::is_vector "is_vector<TypeT>::value"<br>
/// \ref fennec::is_vector_v "is_vector_v<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::is_vector
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::component_count "component_count<TypeT>::value"<br>
/// \ref fennec::component_count_v "component_count_v<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::component_count
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
/// \ref fennec::total_component_count "total_component_count<TypeT>::value"<br>
/// \ref fennec::total_component_count_v "total_component_count_v<TypeT>"
/// <td width="50%" style="vertical-align: top">
/// \copydetails fennec::total_component_count
///
/// </table>
///
#include <fennec/math/detail/__vector_traits.h> #include <fennec/math/detail/__vector_traits.h>
namespace fennec namespace fennec

View File

@ -22,7 +22,7 @@
#include <fennec/lang/conditional_types.h> #include <fennec/lang/conditional_types.h>
#include <fennec/lang/types.h> #include <fennec/lang/types.h>
#include <fennec/lang/type_traits.h> #include <fennec/lang/type_traits.h>
#include <fennec/lang/variadics.h> #include <fennec/lang/type_sequences.h>
namespace fennec namespace fennec
{ {

View File

@ -34,7 +34,7 @@ struct default_delete
/// ///
/// \brief Conversion Constructor /// \brief Conversion Constructor
/// \tparam ConvT of other deleter /// \tparam ConvT of other deleter
template<class ConvT> requires requires { can_convert<ConvT*, TypeT*>{}.value == true; } template<class ConvT> requires requires { is_convertible<ConvT*, TypeT*>{}.value == true; }
constexpr default_delete(const default_delete<ConvT>&) noexcept {} constexpr default_delete(const default_delete<ConvT>&) noexcept {}
/// ///
@ -58,13 +58,13 @@ struct default_delete<TypeT[]>
/// ///
/// \brief Conversion Constructor /// \brief Conversion Constructor
/// \tparam ConvT of other deleter /// \tparam ConvT of other deleter
template<class ConvT> requires requires { can_convert<ConvT(*)[], TypeT(*)[]>{}.value == true; } template<class ConvT> requires requires { is_convertible<ConvT(*)[], TypeT(*)[]>{}.value == true; }
constexpr default_delete(const default_delete<ConvT(*)[]>&) noexcept {} constexpr default_delete(const default_delete<ConvT(*)[]>&) noexcept {}
/// ///
/// \brief Function Call Operator, calls `delete` on `ptr` /// \brief Function Call Operator, calls `delete` on `ptr`
/// \param ptr Memory resource to delete /// \param ptr Memory resource to delete
template<class ArrT> requires requires { can_convert<ArrT(*)[], TypeT(*)[]>{}.value == true; } template<class ArrT> requires requires { is_convertible<ArrT(*)[], TypeT(*)[]>{}.value == true; }
constexpr void operator()(TypeT* ptr) const noexcept constexpr void operator()(TypeT* ptr) const noexcept
{ {
static_assert(not is_void_v<TypeT>, "cannot delete a pointer to an incomplete type"); static_assert(not is_void_v<TypeT>, "cannot delete a pointer to an incomplete type");

36
source/lang/assert.cpp Normal file
View File

@ -0,0 +1,36 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#include <stdlib.h>
using assert_handler = void (*)(const char *, const char *, int , const char *);
static assert_handler __priv_handler = nullptr;
void set_assert_handler(assert_handler handler)
{
__priv_handler = handler;
}
void __assert_impl(const char* expression, const char* file, int line, const char* function)
{
if (__priv_handler)
__priv_handler(expression, file, line, function);
abort();
}

12
test.sh
View File

@ -41,7 +41,8 @@ Debug()
cd ./build/debug cd ./build/debug
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -S ../.. -B . cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -S ../.. -B .
cmake --build . --target fennec-test cmake --build . --target fennec-test
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test/fennec-test cd ../../bin/debug/
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt fennec-test
cd ../.. cd ../..
} }
@ -51,7 +52,8 @@ Release()
cd ./build/release cd ./build/release
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S ../.. -B . cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S ../.. -B .
cmake --build . --target fennec-test cmake --build . --target fennec-test
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test/fennec-test cd ../../bin/release/
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt fennec-test
cd ../.. cd ../..
} }
@ -61,7 +63,8 @@ RelWithDebInfo()
cd ./build/relwithdebinfo cd ./build/relwithdebinfo
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -S ../.. -B . cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -S ../.. -B .
cmake --build . --target fennec-test cmake --build . --target fennec-test
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test/fennec-test cd ../../bin/relwithdebinfo/
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt fennec-test
cd ../.. cd ../..
} }
@ -71,7 +74,8 @@ MinSizeRel()
cd ./build/minsizerel cd ./build/minsizerel
cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -S ../.. -B . cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -S ../.. -B .
cmake --build . --target fennec-test cmake --build . --target fennec-test
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt ./test/fennec-test cd ../../bin/minsizerel/
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.txt fennec-test
cd ../.. cd ../..
} }

View File

@ -12,7 +12,8 @@ add_executable(fennec-test main.cpp
tests/test_memory.h tests/test_memory.h
tests/test_math.h tests/test_math.h
tests/test_lang.h tests/test_lang.h
tests/lang/conditional_types.h tests/lang/test_conditional_types.h
tests/lang/test_bits.h
) )
target_link_libraries(fennec-test PRIVATE target_link_libraries(fennec-test PRIVATE

View File

@ -31,6 +31,11 @@ int main(int, char **)
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_header("c++ language library");
fennec_test_spacer(2);
fennec::test::fennec_test_lang();
fennec_test_spacer(3);
fennec_test_header("math library"); fennec_test_header("math library");
fennec_test_spacer(2); fennec_test_spacer(2);
fennec::test::fennec_test_math(); fennec::test::fennec_test_math();

View File

@ -22,7 +22,6 @@
#include <iostream> #include <iostream>
#include <ostream> #include <ostream>
#include <string> #include <string>
#include <cassert>
#include <fennec/lang/limits.h> #include <fennec/lang/limits.h>
#include <fennec/math/common.h> #include <fennec/math/common.h>
@ -68,7 +67,7 @@ inline bool operator<=(const vector<ScalarT, IndicesV...>& lhs, const vector<Sca
} }
template<typename ResultT> template<typename ResultT>
inline void __fennec_test_run(const std::string& expression, ResultT result, ResultT expected) inline void __fennec_test_run(const std::string& expression, const ResultT result, const ResultT expected)
{ {
std::cout << std::boolalpha; std::cout << std::boolalpha;
std::cout << '\t' << expression << " = " << result; std::cout << '\t' << expression << " = " << result;

View File

@ -0,0 +1,49 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_TEST_LANG_BITS_H
#define FENNEC_TEST_LANG_BITS_H
#include <fennec/lang/assert.h>
#include <fennec/lang/bits.h>
#include "../../test.h"
namespace fennec
{
namespace test
{
void fennec_test_lang_bits()
{
int a = 0x48ef13ad;
int b = 0x23e5ab9c;
fennec_test_run(fennec::bit_cast<float>(0x3ee00000), 0.4375f);
fennec_test_run(*static_cast<int*>(fennec::bit_and(&a, &b, sizeof(int))), 0x48ef13ad & 0x23e5ab9c);
fennec_test_run(*static_cast<int*>(fennec::bit_or(&a, &b, sizeof(int))), (0x48ef13ad & 0x23e5ab9c) | 0x23e5ab9c);
fennec_test_run(*static_cast<int*>(fennec::bit_xor(&a, &b, sizeof(int))), ((0x48ef13ad & 0x23e5ab9c) | 0x23e5ab9c) ^ 0x23e5ab9c);
}
}
}
#endif // FENNEC_TEST_LANG_BITS_H

View File

@ -19,6 +19,19 @@
#ifndef FENNEC_TEST_LANG_CONDITIONAL_TYPES_H #ifndef FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
#define FENNEC_TEST_LANG_CONDITIONAL_TYPES_H #define FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
namespace fennec
{
namespace test
{
inline void fennec_test_lang_conditional_types()
{
}
}
}
#endif // FENNEC_TEST_LANG_CONDITIONAL_TYPES_H #endif // FENNEC_TEST_LANG_CONDITIONAL_TYPES_H

View File

@ -33,8 +33,6 @@ namespace test
inline void fennec_test_math_geometric() inline void fennec_test_math_geometric()
{ {
/*
fennec_test_spacer(1);
fennec_test_run(fennec::dot(vec2(1, 2), vec2(1, 2)), 5.0f); fennec_test_run(fennec::dot(vec2(1, 2), vec2(1, 2)), 5.0f);
fennec_test_run(fennec::dot(vec3(1, 2, 3), vec3(1, 2, 3)), 14.0f); fennec_test_run(fennec::dot(vec3(1, 2, 3), vec3(1, 2, 3)), 14.0f);
@ -69,7 +67,7 @@ inline void fennec_test_math_geometric()
fennec_test_run(fennec::normalize(vec2(1, 1)), vec2(sqrt(2.0f) / 2.0f, sqrt(2.0f) / 2.0f)); fennec_test_run(fennec::normalize(vec2(1, 1)), vec2(sqrt(2.0f) / 2.0f, sqrt(2.0f) / 2.0f));
fennec_test_run(fennec::normalize(vec3(1, 1, 1)), vec3(sqrt(3.0f) / 3.0f, sqrt(3.0f) / 3.0f, sqrt(3.0f) / 3.0f)); fennec_test_run(fennec::normalize(vec3(1, 1, 1)), vec3(sqrt(3.0f) / 3.0f, sqrt(3.0f) / 3.0f, sqrt(3.0f) / 3.0f));
fennec_test_run(fennec::normalize(vec4(1, 1, 1, 1)), vec4(0.5f, 0.5f, 0.5f, 0.5f)); fennec_test_run(fennec::normalize(vec4(1, 1, 1, 1)), vec4(0.5f, 0.5f, 0.5f, 0.5f));
*/
} }
} }

View File

@ -19,4 +19,25 @@
#ifndef FENNEC_TEST_LANG_H #ifndef FENNEC_TEST_LANG_H
#define FENNEC_TEST_LANG_H #define FENNEC_TEST_LANG_H
#include "lang/test_bits.h"
#include "lang/test_conditional_types.h"
namespace fennec
{
namespace test
{
inline void fennec_test_lang()
{
fennec_test_subheader("bit tests");
fennec_test_spacer(2);
fennec_test_lang_bits();
fennec_test_spacer(3);
}
}
}
#endif // FENNEC_TEST_LANG_H #endif // FENNEC_TEST_LANG_H

View File

@ -32,7 +32,6 @@ namespace test
inline void fennec_test_math() inline void fennec_test_math()
{ {
fennec_test_subheader("scalar tests"); fennec_test_subheader("scalar tests");
fennec_test_spacer(2); fennec_test_spacer(2);
fennec_test_math_scalar(); fennec_test_math_scalar();