Skip to content

overall improvements #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Test

on:
merge_group:
push:
branches:
- master
pull_request:
branches:
- master

jobs:

# FIXME: We're having a linker error wrt. Catch2 on Windows with MSVC
# windows-msvc:
# name: "Windows - MSVC"
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v4
# - name: Install dependencies
# run: choco install ninja
# - name: configure
# run: cmake --preset windows-cl-release
# - name: build
# run: cmake --build --preset windows-cl-release
# - name: test
# run: ctest --preset windows-cl-release -VV

ubuntu24-clang:
name: "Ubuntu Linux - Clang ${{ matrix.clang_version }}"
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
clang_version: [17, 18]
steps:
- uses: actions/checkout@v4
- name: Install clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.clang_version }}
- name: Install ninja
run: sudo apt-get install ninja-build
- name: configure
run: cmake --preset linux-clang-release
- name: build
run: cmake --build --preset linux-clang-release
- name: test
run: ctest --preset linux-clang-release -VV

ubuntu24-gcc:
name: "Ubuntu Linux - GCC ${{ matrix.gcc_version }}"
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
gcc_version: [13, 14]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install ninja-build g++-${{ matrix.gcc_version }}
- name: configure
run: cmake --preset linux-gcc-release
- name: build
run: cmake --build --preset linux-gcc-release
- name: test
run: ctest --preset linux-gcc-release -VV
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if(BOXED_TESTING)
test-reflection-cpp.cpp
)
target_compile_features(test-reflection-cpp INTERFACE cxx_std_20)
target_link_libraries(test-reflection-cpp reflection-cpp Catch2::Catch2WithMain)
target_link_libraries(test-reflection-cpp reflection-cpp Catch2::Catch2 Catch2::Catch2WithMain)
add_test(test-reflection-cpp ./test-reflection-cpp)
endif()
message(STATUS "[reflection-cpp] Compile unit tests: ${BOXED_TESTING}")
1 change: 0 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"name": "windows-common",
"hidden": true,
"inherits": ["common"],
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
Expand Down
15 changes: 8 additions & 7 deletions include/reflection-cpp/Reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace detail
constexpr auto joined_arr = []() {
constexpr size_t len = (Strs.size() + ... + 0);
std::array<char, len + 1> arr {};
auto append = [i = 0, &arr](const auto& s) mutable {
auto append = [i = 0u, &arr](const auto& s) mutable {
for (auto c: s)
arr[i++] = c;
};
Expand Down Expand Up @@ -356,13 +356,13 @@ consteval std::string_view GetName()
#if defined(_MSC_VER) && !defined(__clang__)
if constexpr (std::is_member_object_pointer_v<decltype(P)>)
{
using T = remove_member_pointer<std::decay_t<decltype(P)>>::type;
using T = detail::remove_member_pointer<std::decay_t<decltype(P)>>::type;
constexpr auto p = P;
return detail::get_name_msvc<T, &(detail::External<T>.*p)>();
}
else
{
using T = remove_member_pointer<std::decay_t<decltype(P)>>::type;
using T = detail::remove_member_pointer<std::decay_t<decltype(P)>>::type;
return detail::func_name_msvc<T, P>();
}
#else
Expand All @@ -384,8 +384,9 @@ consteval auto GetName()
str = str.substr(str.rfind("::") + 2);
return str.substr(0, str.find('>'));
#else
constexpr auto MarkerStart = std::string_view { "E = " };
std::string_view str = REFLECTION_PRETTY_FUNCTION;
str = str.substr(str.rfind("::") + 2 + 15);
str = str.substr(str.rfind(MarkerStart) + MarkerStart.size());
str = str.substr(0, str.find(']'));
return str;
#endif
Expand All @@ -396,8 +397,8 @@ std::string Inspect(Object const& object)
{
return [&]<size_t... I>(std::index_sequence<I...>) {
std::string str;
auto onMember = [&str](auto&& name, auto&& value) {
auto onValue = [&str]<typename T>(T&& arg) {
auto const onMember = [&str]<typename Name, typename Value>(Name&& name, Value&& value) {
auto const InspectValue = [&str]<typename T>(T&& arg) {
// clang-format off
if constexpr (std::is_convertible_v<T, std::string>
|| std::is_convertible_v<T, std::string_view>
Expand All @@ -410,7 +411,7 @@ std::string Inspect(Object const& object)
str += ' ';
str += name;
str += '=';
onValue(value);
InspectValue(value);
};
(onMember(MemberNameOf<I, Object>, std::get<I>(Reflection::ToTuple(object))), ...);
return str;
Expand Down