@@ -104,8 +104,9 @@ template <typename ReturnType, typename... Args>
104
104
struct JSIConverter <std::function<ReturnType(Args...)>> {
105
105
static std::function<ReturnType(Args...)> fromJSI (jsi::Runtime& runtime, const jsi::Value& arg) {
106
106
jsi::Function function = arg.asObject (runtime).asFunction (runtime);
107
- return [&runtime, function = std::move (function)] (Args... args) -> ReturnType {
108
- jsi::Value result = function.call (runtime, JSIConverter<Args>::toJSI (runtime, args)...);
107
+ std::shared_ptr<jsi::Function> sharedFunction = std::make_shared<jsi::Function>(std::move (function));
108
+ return [&runtime, sharedFunction] (Args... args) -> ReturnType {
109
+ jsi::Value result = sharedFunction->call (runtime, JSIConverter<Args>::toJSI (runtime, args)...);
109
110
if constexpr (std::is_same_v<ReturnType, void >) {
110
111
return ;
111
112
} else {
@@ -114,19 +115,20 @@ struct JSIConverter<std::function<ReturnType(Args...)>> {
114
115
};
115
116
}
116
117
117
- template <size_t ... Is>
118
+ /* template<size_t... Is>
118
119
static jsi::Value callHybridFunction(const std::function<ReturnType(Args...)>& function, jsi::Runtime& runtime, const jsi::Value* args, std::index_sequence<Is...>) {
119
120
ReturnType result = function(JSIConverter<Args>::fromJSI(runtime, args[Is])...);
120
121
return JSIConverter<ReturnType>::toJSI(runtime, result);
121
- }
122
+ }*/
122
123
static jsi::Value toJSI (jsi::Runtime& runtime, std::function<ReturnType(Args...)> function) {
123
- jsi::HostFunctionType jsFunction = [function = std::move (function)] (jsi::Runtime& runtime,
124
+ return jsi::Value::undefined ();
125
+ /* jsi::HostFunctionType jsFunction = [function = std::move(function)] (jsi::Runtime& runtime,
124
126
const jsi::Value& thisValue,
125
127
const jsi::Value* args,
126
128
size_t count) -> jsi::Value {
127
129
callHybridFunction(function, runtime, args, std::index_sequence_for<Args...>{});
128
130
};
129
- return jsi::Function::createFromHostFunction (runtime, jsi::PropNameID::forUtf8 (runtime, " hostFunction" ), sizeof ...(Args), jsFunction);
131
+ return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "hostFunction"), sizeof...(Args), jsFunction);*/
130
132
}
131
133
};
132
134
0 commit comments