- Added More Documentation
- Added some more notes to the planning doc regarding shared libraries - Started adding unit tests for the C++ lang library.
This commit is contained in:
parent
909be55ed3
commit
4d8466851c
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.*/
|
||||
/build/
|
||||
/docs/
|
||||
/bin/
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "external/sdl"]
|
||||
path = external/sdl
|
||||
url = https://github.com/libsdl-org/SDL.git
|
@ -1,6 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.30)
|
||||
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_C_STANDARD 26)
|
||||
|
||||
@ -15,7 +21,8 @@ add_subdirectory(metaprogramming)
|
||||
|
||||
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_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/${FENNEC_BUILD_NAME})
|
||||
@ -32,7 +39,10 @@ add_library(fennec STATIC
|
||||
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/constants.h
|
||||
include/fennec/lang/conditional_types.h
|
||||
@ -45,7 +55,9 @@ add_library(fennec STATIC
|
||||
include/fennec/lang/types.h
|
||||
include/fennec/lang/utility.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/__type_traits.h
|
||||
include/fennec/lang/detail/__type_sequences.h
|
||||
@ -86,16 +98,15 @@ add_library(fennec STATIC
|
||||
include/fennec/math/detail/__fwd.h
|
||||
include/fennec/math/detail/__types.h
|
||||
include/fennec/math/detail/__vector_traits.h
|
||||
include/fennec/lang/lang.h
|
||||
include/fennec/lang/detail/__bits.h
|
||||
include/fennec/lang/integer.h
|
||||
include/fennec/lang/assert.h
|
||||
source/lang/assert.cpp
|
||||
)
|
||||
|
||||
# add metaprogramming templates as a dependency and also force documentation to be generated when fennec is compiled
|
||||
if(DOXYGEN_FOUND)
|
||||
add_dependencies(fennec fennecdocs metaprogramming)
|
||||
add_dependencies(fennec fennecdocs metaprogramming SDL3-static)
|
||||
else()
|
||||
add_dependencies(fennec metaprogramming)
|
||||
add_dependencies(fennec metaprogramming SDL3-static)
|
||||
endif()
|
||||
|
||||
# Compiler Warning Flags
|
||||
|
14
PLANNING.md
14
PLANNING.md
@ -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
|
||||
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).
|
||||
|
||||
"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
|
||||
to Linear Algebra, Mathematical Analysis, and Discrete Analysis. Additional extensions will be implemented on a
|
||||
as-needed basis.
|
||||
@ -107,7 +119,6 @@ Here are essential data-structures not specified in the C++ stdlib:
|
||||
|
||||
## 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.
|
||||
|
||||
* String Analysis (`fproc/strings`)
|
||||
@ -167,6 +178,7 @@ This will be the core of the engine.
|
||||
- Event System
|
||||
- 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 stages should also propagate immediately, this is to support extensions and mods.
|
||||
- Core Engine Loop
|
||||
- System Manager
|
||||
- Ticks vs. Frames
|
||||
|
1
external/sdl
vendored
Submodule
1
external/sdl
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit d7939abf42de34fff409f5e7c4b77ace79dff4de
|
@ -33,8 +33,7 @@
|
||||
#define FENNEC_CONTAINERS_ARRAY_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <fennec/lang/assert.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
29
include/fennec/lang/assert.h
Normal file
29
include/fennec/lang/assert.h
Normal 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
|
@ -73,7 +73,6 @@ namespace fennec
|
||||
|
||||
// fennec::conditional =================================================================================================
|
||||
|
||||
///
|
||||
///
|
||||
/// \brief select between two types based on a condition
|
||||
///
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
///
|
||||
/// \file lang.h
|
||||
/// \brief fennec C++ Language Library
|
||||
/// \brief \ref fennec_lang
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
@ -31,6 +31,12 @@
|
||||
#ifndef 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
|
||||
///
|
||||
@ -45,21 +51,4 @@
|
||||
///
|
||||
///
|
||||
|
||||
///
|
||||
/// \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_sequences
|
||||
/// - \subpage fennec_lang_type_traits
|
||||
/// - \subpage fennec_lang_type_transforms
|
||||
///
|
||||
///
|
||||
|
||||
#endif // FENNEC_LANG_H
|
||||
|
52
include/fennec/lang/metaprogramming.h
Normal file
52
include/fennec/lang/metaprogramming.h
Normal 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
|
@ -219,179 +219,182 @@
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
// Basic Types =========================================================================================================
|
||||
|
||||
// Basic Types =========================================================================================================
|
||||
///
|
||||
/// \name Basic Types
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// \name Basic Types
|
||||
/// @{
|
||||
///
|
||||
/// \brief A conditional type
|
||||
using bool_t = bool;
|
||||
|
||||
///
|
||||
/// \brief A conditional type
|
||||
using bool_t = bool;
|
||||
///
|
||||
/// \brief A type capable of holding an ascii value
|
||||
using char_t = char;
|
||||
|
||||
///
|
||||
/// \brief A type capable of holding an ascii value
|
||||
using char_t = char;
|
||||
///
|
||||
/// \brief A type with the size of a char, capable of holding a signed 8-bit integer
|
||||
using schar_t = signed char;
|
||||
|
||||
///
|
||||
/// \brief A type with the size of a char, capable of holding a signed 8-bit integer
|
||||
using schar_t = signed char;
|
||||
///
|
||||
/// \brief A type with the size of a char, capable of holding an unsigned 8-bit integer
|
||||
using uchar_t = unsigned char;
|
||||
|
||||
///
|
||||
/// \brief A type with the size of a char, capable of holding an unsigned 8-bit integer
|
||||
using uchar_t = unsigned char;
|
||||
///
|
||||
/// \brief A signed short type, capable of holding signed 16-bit integer
|
||||
using short_t = signed short;
|
||||
|
||||
///
|
||||
/// \brief A signed short type, capable of holding signed 16-bit integer
|
||||
using short_t = signed short;
|
||||
///
|
||||
/// \brief An unsigned short type, capable of holding an unsigned signed 16-bit integer
|
||||
using ushort_t = unsigned short;
|
||||
|
||||
///
|
||||
/// \brief An unsigned short type, capable of holding an unsigned signed 16-bit integer
|
||||
using ushort_t = unsigned short;
|
||||
///
|
||||
/// \brief A signed integer type, size varies by implementation, but typically 32-bit
|
||||
using int_t = signed int;
|
||||
|
||||
///
|
||||
/// \brief A signed integer type, size varies by implementation, but typically 32-bit
|
||||
using int_t = signed int;
|
||||
///
|
||||
/// \brief An unsigned integer type, size varies by implementation, but typically 32-bit
|
||||
using uint_t = unsigned int;
|
||||
|
||||
///
|
||||
/// \brief An unsigned integer type, size varies by implementation, but typically 32-bit
|
||||
using uint_t = unsigned int;
|
||||
///
|
||||
/// \brief A signed integer type, with a size of at least 32-bits
|
||||
using long_t = signed long;
|
||||
|
||||
///
|
||||
/// \brief A signed integer type, with a size of at least 32-bits
|
||||
using long_t = signed long;
|
||||
///
|
||||
/// \brief An unsigned integer type, with a size of at least 32-bits
|
||||
using ulong_t = unsigned long;
|
||||
|
||||
///
|
||||
/// \brief An unsigned integer type, with a size of at least 32-bits
|
||||
using ulong_t = unsigned long;
|
||||
///
|
||||
/// \brief A signed integer type, with a size of 64-bits
|
||||
using llong_t = signed long long;
|
||||
|
||||
///
|
||||
/// \brief A signed integer type, with a size of 64-bits
|
||||
using llong_t = signed long long;
|
||||
///
|
||||
/// \brief An unsigned integer type, with a size of 64-bits
|
||||
using ullong_t = unsigned long long;
|
||||
|
||||
///
|
||||
/// \brief An unsigned integer type, with a size of 64-bits
|
||||
using ullong_t = unsigned long long;
|
||||
///
|
||||
/// \brief A single-precision floating-point type, typically with a size of 32-bits
|
||||
using float_t = float;
|
||||
|
||||
///
|
||||
/// \brief A single-precision floating-point type, typically with a size of 32-bits
|
||||
using float_t = float;
|
||||
|
||||
///
|
||||
/// \brief A double-point type, typically with a size of 64-bits
|
||||
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
|
||||
using int8_t = schar_t;
|
||||
///
|
||||
/// \brief Signed Integer Capable of Holding a Pointer to void
|
||||
using intptr_t = intptr_t;
|
||||
|
||||
///
|
||||
/// \brief Signed 16-bit integer
|
||||
using int16_t = short_t;
|
||||
///
|
||||
/// \brief Unsigned Integer Capable of Holding a Pointer to void
|
||||
using uintptr_t = uintptr_t;
|
||||
|
||||
///
|
||||
/// \brief Signed 32-bit integer
|
||||
using int32_t = long_t;
|
||||
///
|
||||
/// \brief Maximum Width Signed Integer Type
|
||||
using intmax_t = __INTMAX_TYPE__;
|
||||
|
||||
///
|
||||
/// \brief Signed signed 64-bit integer
|
||||
using int64_t = llong_t;
|
||||
///
|
||||
/// \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;
|
||||
|
||||
/// @}
|
||||
}
|
||||
|
||||
#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
|
||||
using uint8_t = uchar_t;
|
||||
///
|
||||
/// \brief Unsigned 8-bit integer
|
||||
using uint8_t = uchar_t;
|
||||
|
||||
///
|
||||
/// \brief Unsigned 16-bit integer
|
||||
using uint16_t = ushort_t;
|
||||
///
|
||||
/// \brief Unsigned 16-bit integer
|
||||
using uint16_t = ushort_t;
|
||||
|
||||
///
|
||||
/// \brief Unsigned 32-bit integer
|
||||
using uint32_t = ulong_t;
|
||||
///
|
||||
/// \brief Unsigned 32-bit integer
|
||||
using uint32_t = conditional_t<sizeof(uint_t) == 4, uint_t, ulong_t>;
|
||||
|
||||
///
|
||||
/// \brief Unsigned 64-bit integer
|
||||
using uint64_t = ullong_t;
|
||||
///
|
||||
/// \brief Unsigned 64-bit integer
|
||||
using uint64_t = ullong_t;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \name Sized Floating-Point Types
|
||||
/// @{
|
||||
///
|
||||
/// \name Sized Floating-Point Types
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// \brief A single-precision floating-point scalar
|
||||
using float32_t = float_t;
|
||||
///
|
||||
/// \brief A single-precision floating-point scalar
|
||||
using float32_t = float_t;
|
||||
|
||||
///
|
||||
/// \brief A double-precision floating-point scalar
|
||||
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;
|
||||
|
||||
/// @}
|
||||
///
|
||||
/// \brief A double-precision floating-point scalar
|
||||
using float64_t = double_t;
|
||||
/// @}
|
||||
|
||||
}
|
||||
|
||||
|
36
source/lang/assert.cpp
Normal file
36
source/lang/assert.cpp
Normal 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
12
test.sh
@ -41,7 +41,8 @@ Debug()
|
||||
cd ./build/debug
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -S ../.. -B .
|
||||
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 ../..
|
||||
}
|
||||
|
||||
@ -51,7 +52,8 @@ Release()
|
||||
cd ./build/release
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S ../.. -B .
|
||||
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 ../..
|
||||
}
|
||||
|
||||
@ -61,7 +63,8 @@ RelWithDebInfo()
|
||||
cd ./build/relwithdebinfo
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -S ../.. -B .
|
||||
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 ../..
|
||||
}
|
||||
|
||||
@ -71,7 +74,8 @@ MinSizeRel()
|
||||
cd ./build/minsizerel
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -S ../.. -B .
|
||||
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 ../..
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,8 @@ add_executable(fennec-test main.cpp
|
||||
tests/test_memory.h
|
||||
tests/test_math.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
|
||||
|
@ -31,6 +31,11 @@ int main(int, char **)
|
||||
|
||||
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_spacer(2);
|
||||
fennec::test::fennec_test_math();
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include <fennec/lang/limits.h>
|
||||
#include <fennec/math/common.h>
|
||||
@ -68,7 +67,7 @@ inline bool operator<=(const vector<ScalarT, IndicesV...>& lhs, const vector<Sca
|
||||
}
|
||||
|
||||
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 << '\t' << expression << " = " << result;
|
||||
|
49
test/tests/lang/test_bits.h
Normal file
49
test/tests/lang/test_bits.h
Normal 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
|
@ -19,6 +19,19 @@
|
||||
#ifndef 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
|
@ -33,8 +33,6 @@ namespace test
|
||||
|
||||
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(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(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));
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,4 +19,25 @@
|
||||
#ifndef 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
|
||||
|
@ -32,7 +32,6 @@ namespace test
|
||||
|
||||
inline void fennec_test_math()
|
||||
{
|
||||
|
||||
fennec_test_subheader("scalar tests");
|
||||
fennec_test_spacer(2);
|
||||
fennec_test_math_scalar();
|
||||
|
Loading…
x
Reference in New Issue
Block a user