GameDevTecnico / cubos

A still very barebones game engine focused on voxels and data-oriented programming
https://gamedevtecnico.github.io/cubos/
MIT License
83 stars 23 forks source link

refactor(reflection): no longer fallback to anonymous types automatically #1289

Closed RiscadoA closed 1 month ago

RiscadoA commented 1 month ago

Description

This change was necessary due to the previous system being highly error prone. Before, if reflect was called for a type T without defined reflection included, a placeholder definition would be used which returned an anonymous type. Sadly, due to the C++ One Definition Rule, this meant that other source files using reflect, could return an anonymous type, even if the type's reflection definition was included!

Basically, previously a simple mistake such as forgetting to include an external reflection header could lead to a random reflection failure in the core of the library, such as a missing trait error. Now, the users must define reflection for all types, as there is no longer a fallback. To simplify this for the previous 'anonymous types', a new CUBOS_ANONYMOUS_REFLECT macro was added.

Checklist

github-actions[bot] commented 1 month ago

PR Preview Action v1.4.7 :---: :rocket: Deployed preview to https://GameDevTecnico.github.io/cubos/preview/pr-1289/ on branch gh-pages at 2024-08-02 08:03 UTC

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 69.23077% with 12 lines in your changes missing coverage. Please review.

Project coverage is 36.26%. Comparing base (fedd0bf) to head (9392e47).

Files Patch % Lines
core/src/reflection/reflect.cpp 88.88% 2 Missing :warning:
engine/src/physics/fixed_substep/plugin.cpp 0.00% 1 Missing :warning:
engine/src/render/bloom/plugin.cpp 0.00% 1 Missing :warning:
engine/src/render/deferred_shading/plugin.cpp 0.00% 1 Missing :warning:
engine/src/render/g_buffer_rasterizer/plugin.cpp 0.00% 1 Missing :warning:
engine/src/render/mesh/plugin.cpp 0.00% 1 Missing :warning:
engine/src/render/ssao/plugin.cpp 0.00% 1 Missing :warning:
engine/src/render/tone_mapping/plugin.cpp 0.00% 1 Missing :warning:
engine/src/ui/canvas/plugin.cpp 0.00% 1 Missing :warning:
engine/src/ui/color_rect/plugin.cpp 0.00% 1 Missing :warning:
... and 1 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1289 +/- ## ========================================== - Coverage 36.27% 36.26% -0.01% ========================================== Files 376 376 Lines 30851 30864 +13 ========================================== + Hits 11191 11194 +3 - Misses 19660 19670 +10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.