/* * 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 #include #include namespace facebook::react { struct ObjectStruct { int32_t a; std::string b; std::optional c; bool operator==(const ObjectStruct &other) const { return a == other.a && b == other.b && c == other.c; } }; template <> struct Bridging { static ObjectStruct fromJs( jsi::Runtime &rt, const jsi::Object &value, const std::shared_ptr &jsInvoker) { ObjectStruct result{ bridging::fromJs(rt, value.getProperty(rt, "a"), jsInvoker), bridging::fromJs( rt, value.getProperty(rt, "b"), jsInvoker), bridging::fromJs>( rt, value.getProperty(rt, "c"), jsInvoker)}; return result; } static jsi::Object toJs(jsi::Runtime &rt, const ObjectStruct &value) { auto result = facebook::jsi::Object(rt); result.setProperty(rt, "a", bridging::toJs(rt, value.a)); result.setProperty(rt, "b", bridging::toJs(rt, value.b)); if (value.c) { result.setProperty(rt, "c", bridging::toJs(rt, value.c.value())); } return result; } }; } // namespace facebook::react