Skip to content

Commit

Permalink
fixed swap_columns() fast-path breaking data()
Browse files Browse the repository at this point in the history
also:
- refactoring
  • Loading branch information
marzer committed Aug 13, 2023
1 parent b314fa4 commit 6e1cb2d
Show file tree
Hide file tree
Showing 17 changed files with 1,081 additions and 906 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Unreleased

- Used CRTP mixins in generated classes to reduce generated code size
- Fixed `swap_columns` fast-path breaking `data()`
- Used more CRTP mixins in generated classes
- Binary size improvements

## v0.5.0

Expand Down
24 changes: 10 additions & 14 deletions examples/entities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ namespace soagen::detail
SOAGEN_MAKE_NAME(pos);
#endif

SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::entities, 0, id);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::entities, 1, name);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::entities, 2, pos);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::entities, 3, orient);

template <>
struct table_traits_type_<soagen::examples::entities>
{
Expand All @@ -156,24 +161,15 @@ namespace soagen::detail
using type = soagen::allocator;
};

template <>
struct is_soa_<soagen::examples::entities> : std::true_type
{};

template <>
struct columns_always_aligned_<soagen::examples::entities> : std::true_type
{};

SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::entities, 0, id);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::entities, 1, name);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::entities, 2, pos);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::entities, 3, orient);

template <>
struct table_type_<soagen::examples::entities>
{
using type = table<table_traits_type<soagen::examples::entities>, soagen::allocator>;
using type = table<table_traits_type<soagen::examples::entities>, allocator_type<soagen::examples::entities>>;
};

template <>
struct is_soa_<soagen::examples::entities> : std::true_type
{};
}

// clang-format on
Expand Down
54 changes: 23 additions & 31 deletions examples/shapes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ namespace soagen::detail
SOAGEN_MAKE_NAME(radius);
#endif

SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 0, center_x);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 1, center_y);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 2, center_z);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 3, extents_x);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 4, extents_y);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 5, extents_z);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 6, mass);

template <>
struct table_traits_type_<soagen::examples::boxes>
{
Expand All @@ -180,26 +188,20 @@ namespace soagen::detail
};

template <>
struct is_soa_<soagen::examples::boxes> : std::true_type
{};
struct table_type_<soagen::examples::boxes>
{
using type = table<table_traits_type<soagen::examples::boxes>, allocator_type<soagen::examples::boxes>>;
};

template <>
struct columns_always_aligned_<soagen::examples::boxes> : std::true_type
struct is_soa_<soagen::examples::boxes> : std::true_type
{};

SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 0, center_x);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 1, center_y);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 2, center_z);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 3, extents_x);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 4, extents_y);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 5, extents_z);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::boxes, 6, mass);

template <>
struct table_type_<soagen::examples::boxes>
{
using type = table<table_traits_type<soagen::examples::boxes>, soagen::allocator>;
};
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 0, center_x);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 1, center_y);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 2, center_z);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 3, radius);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 4, mass);

template <>
struct table_traits_type_<soagen::examples::spheres>
Expand All @@ -218,25 +220,15 @@ namespace soagen::detail
using type = soagen::allocator;
};

template <>
struct is_soa_<soagen::examples::spheres> : std::true_type
{};

template <>
struct columns_always_aligned_<soagen::examples::spheres> : std::true_type
{};

SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 0, center_x);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 1, center_y);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 2, center_z);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 3, radius);
SOAGEN_MAKE_NAMED_COLUMN(soagen::examples::spheres, 4, mass);

template <>
struct table_type_<soagen::examples::spheres>
{
using type = table<table_traits_type<soagen::examples::spheres>, soagen::allocator>;
using type = table<table_traits_type<soagen::examples::spheres>, allocator_type<soagen::examples::spheres>>;
};

template <>
struct is_soa_<soagen::examples::spheres> : std::true_type
{};
}

// clang-format on
Expand Down
Loading

0 comments on commit 6e1cb2d

Please sign in to comment.