Files
react-native/ReactCommon/react/renderer/runtimescheduler/primitives.h
T
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00

42 lines
981 B
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <folly/dynamic.h>
#include <jsi/jsi.h>
#include <react/renderer/runtimescheduler/Task.h>
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> const &task) {
return jsi::Object::createFromHostObject(
runtime, std::make_shared<TaskWrapper>(task));
}
inline static std::shared_ptr<Task> taskFromValue(
jsi::Runtime &runtime,
jsi::Value const &value) {
if (value.isNull()) {
return nullptr;
}
return value.getObject(runtime).getHostObject<TaskWrapper>(runtime)->task;
}
} // namespace react
} // namespace facebook