Merge pull request #3391 from neobrain/fix_libfwd_custom_repack_nonstruct

Library Forwarding: Don't attempt custom repacking for non-struct types
This commit is contained in:
Ryan Houdek authored and GitHub committed 2024-01-30 08:52:21 -08:00
commit 2884337d85
1 file changed
+2 -3
+2 -3
View File
@@ -274,7 +274,7 @@ struct repack_wrapper {
~repack_wrapper() {
// TODO: Properly detect opaque types
if constexpr (requires(guest_layout<T> t, decltype(data) h) { t.get_pointer(); (bool)h; *data; }) {
if constexpr (std::is_class_v<std::remove_pointer_t<T>> && requires(guest_layout<T> t, decltype(data) h) { t.get_pointer(); (bool)h; *data; }) {
if (data) {
// NOTE: It's assumed that the native host library didn't modify any
// const-pointees, so we skip automatic exit repacking for them.
@@ -283,8 +283,7 @@ struct repack_wrapper {
// memory reserved on entry)
if (!fex_apply_custom_repacking_exit(*orig_arg.get_pointer(), *data)) {
if constexpr (!std::is_const_v<std::remove_pointer_t<T>>) { // Skip exit-repacking for const pointees
constexpr bool is_compatible = has_compatible_data_layout<T> && std::is_same_v<T, GuestT>;
if constexpr (!is_compatible && std::is_class_v<std::remove_pointer_t<T>>) {
if constexpr (!(has_compatible_data_layout<T> && std::is_same_v<T, GuestT>)) {
*orig_arg.get_pointer() = to_guest(*data); // TODO: Only if annotated as out-parameter
}
}