| 267 | // Allocates storage on the heap that must be de-allocated using delete[] or DeleteRepackedStructArray |
| 268 | template<bool NeedsRepack = true, typename T> |
| 269 | std::span<std::remove_cv_t<T>> RepackStructArray(uint32_t Count, const guest_layout<T*> GuestData) { |
| 270 | if (!GuestData.get_pointer() || Count == 0) { |
| 271 | return {}; |
| 272 | } |
| 273 | |
| 274 | auto HostData = new std::remove_cv_t<T>[Count]; |
| 275 | for (size_t i = 0; i < Count; ++i) { |
| 276 | auto& GuestElement = (const guest_layout<std::remove_cv_t<T>>&)GuestData.get_pointer()[i]; |
| 277 | auto Element = host_layout<std::remove_cv_t<T>> {GuestElement}; |
| 278 | if constexpr (NeedsRepack) { |
| 279 | fex_apply_custom_repacking_entry(Element, GuestElement); |
| 280 | } |
| 281 | HostData[i] = Element.data; |
| 282 | } |
| 283 | return {HostData, Count}; |
| 284 | } |
| 285 | |
| 286 | template<typename T> |
| 287 | void DeleteRepackedStructArray(uint32_t Count, T* HostData, guest_layout<T*>& GuestData) { |
no test coverage detected