Skip to content

Commit 7be0ab7

Browse files
authored
chore(🧹): minor cleanup (#279)
1 parent 3d1c8b0 commit 7be0ab7

2 files changed

Lines changed: 1 addition & 46 deletions

File tree

‎packages/webgpu/cpp/jsi/RNFJSIConverter.h‎

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -224,52 +224,6 @@ template <> struct JSIConverter<rnwgpu::async::AsyncTaskHandle> {
224224
}
225225
};
226226

227-
228-
// [](Args...) -> T {} <> (Args...) => T
229-
template <typename ReturnType, typename... Args> struct JSIConverter<std::function<ReturnType(Args...)>> {
230-
static std::function<ReturnType(Args...)> fromJSI(jsi::Runtime& runtime, const jsi::Value& arg, bool outOfBound) {
231-
jsi::Function function = arg.asObject(runtime).asFunction(runtime);
232-
233-
std::shared_ptr<jsi::Function> sharedFunction = JSIHelper::createSharedJsiFunction(runtime, std::move(function));
234-
return [&runtime, sharedFunction, outOfBound](Args... args) -> ReturnType {
235-
jsi::Value result = sharedFunction->call(runtime, JSIConverter<std::decay_t<Args>>::toJSI(runtime, args)...);
236-
if constexpr (std::is_same_v<ReturnType, void>) {
237-
// it is a void function (returns undefined)
238-
return;
239-
} else {
240-
// it returns a custom type, parse it from the JSI value.
241-
return JSIConverter<ReturnType>::fromJSI(runtime, std::move(result), outOfBound);
242-
}
243-
};
244-
}
245-
246-
template <size_t... Is>
247-
static jsi::Value callHybridFunction(const std::function<ReturnType(Args...)>& function, jsi::Runtime& runtime, const jsi::Value* args,
248-
std::index_sequence<Is...>, size_t count) {
249-
if constexpr (std::is_same_v<ReturnType, void>) {
250-
// it is a void function (will return undefined in JS)
251-
function(JSIConverter<std::decay_t<Args>>::fromJSI(runtime, args[Is], Is >= count)...);
252-
return jsi::Value::undefined();
253-
} else {
254-
// it is a custom type, parse it to a JS value
255-
ReturnType result = function(JSIConverter<std::decay_t<Args>>::fromJSI(runtime, args[Is], Is >= count)...);
256-
return JSIConverter<ReturnType>::toJSI(runtime, result);
257-
}
258-
}
259-
static jsi::Value toJSI(jsi::Runtime& runtime, const std::function<ReturnType(Args...)>& function) {
260-
jsi::HostFunctionType jsFunction = [function = std::move(function)](jsi::Runtime& runtime, const jsi::Value& thisValue,
261-
const jsi::Value* args, size_t count) -> jsi::Value {
262-
if (count != sizeof...(Args)) {
263-
[[unlikely]];
264-
throw jsi::JSError(runtime, "Function expected " + std::to_string(sizeof...(Args)) + " arguments, but received " +
265-
std::to_string(count) + "!");
266-
}
267-
return callHybridFunction(function, runtime, args, std::index_sequence_for<Args...>{}, count);
268-
};
269-
return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "hostFunction"), sizeof...(Args), jsFunction);
270-
}
271-
};
272-
273227
// std::map<std::string, T> <> Record<string, T>
274228
template <typename ValueType> struct JSIConverter<std::map<std::string, ValueType>> {
275229
static std::map<std::string, ValueType> fromJSI(jsi::Runtime& runtime, const jsi::Value& arg, bool outOfBound) {

‎packages/webgpu/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"files": [
1111
"src/**",
1212
"lib/**",
13+
"!**/__tests__/**",
1314
"android/build.gradle",
1415
"android/CMakeLists.txt",
1516
"android/cpp/**",

0 commit comments

Comments
 (0)