[LOCAL] Do not use NativeState as JSC does not implement it

This commit is contained in:
Riccardo Cipolleschi
2023-05-25 18:17:41 +01:00
parent ee177cab75
commit dc6a2c384d
2 changed files with 10 additions and 5 deletions
@@ -79,7 +79,7 @@ jsi::Value RuntimeSchedulerBinding::get(
jsi::Runtime &runtime,
jsi::Value const &,
jsi::Value const *arguments,
size_t) noexcept -> jsi::Value {
size_t count) noexcept -> jsi::Value {
SchedulerPriority priority = fromRawValue(arguments[0].getNumber());
auto callback = arguments[1].getObject(runtime).getFunction(runtime);
@@ -13,12 +13,17 @@
namespace facebook {
namespace react {
struct TaskWrapper : public jsi::HostObject {
TaskWrapper(std::shared_ptr<Task> const &task) : task(task) {}
std::shared_ptr<Task> task;
};
inline static jsi::Value valueFromTask(
jsi::Runtime &runtime,
std::shared_ptr<Task> task) {
jsi::Object obj(runtime);
obj.setNativeState(runtime, std::move(task));
return obj;
return jsi::Object::createFromHostObject(
runtime, std::make_shared<TaskWrapper>(task));
}
inline static std::shared_ptr<Task> taskFromValue(
@@ -28,7 +33,7 @@ inline static std::shared_ptr<Task> taskFromValue(
return nullptr;
}
return value.getObject(runtime).getNativeState<Task>(runtime);
return value.getObject(runtime).getHostObject<TaskWrapper>(runtime)->task;
}
} // namespace react