Skip to content

Commit

Permalink
fix: Properly forward move-only types (future!) (#104)
Browse files Browse the repository at this point in the history
* fix: Properly forward types (future!)

* Forward
  • Loading branch information
mrousavy authored Sep 6, 2024
1 parent 6138ab6 commit ded7c08
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class HybridFunction final {
} else {
// It's returning some C++ type, we need to convert that to a JSI value now.
ReturnType result = (obj->*method)(JSIConverter<std::decay_t<Args>>::fromJSI(runtime, Is < argsSize ? args[Is] : defaultValue)...);
return JSIConverter<std::decay_t<ReturnType>>::toJSI(runtime, std::move(result));
return JSIConverter<ReturnType>::toJSI(runtime, std::forward<ReturnType>(result));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct JSIConverter<std::function<ReturnType(Args...)>> final {
} else {
// it is a custom type, parse it to a JS value
ReturnType result = function(JSIConverter<std::decay_t<Args>>::fromJSI(runtime, args[Is])...);
return JSIConverter<ReturnType>::toJSI(runtime, result);
return JSIConverter<ReturnType>::toJSI(runtime, std::forward<ReturnType>(result));
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct JSIConverter<std::future<TResult>> final {
} else {
// it's returning a custom type, convert it to a jsi::Value
TResult result = sharedFuture->get();
jsi::Value jsResult = JSIConverter<TResult>::toJSI(runtime, result);
jsi::Value jsResult = JSIConverter<TResult>::toJSI(runtime, std::forward<TResult>(result));
promise->resolve(runtime, std::move(jsResult));
}
} catch (const std::exception& exception) {
Expand Down

0 comments on commit ded7c08

Please sign in to comment.