diff --git a/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleH-test.js.snap index 344b22b8866d77..ca285481d2374c 100644 --- a/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleH-test.js.snap @@ -324,7 +324,7 @@ struct Bridging { #pragma mark - NativeEnumTurboModuleBaseStateType template -struct NativeEnumTurboModuleBaseStateType { +struct [[deprecated(\\"Use NativeEnumTurboModuleStateType instead.\\")]] NativeEnumTurboModuleBaseStateType { P0 state; bool operator==(const NativeEnumTurboModuleBaseStateType &other) const { return state == other.state; @@ -332,7 +332,7 @@ struct NativeEnumTurboModuleBaseStateType { }; template -struct NativeEnumTurboModuleBaseStateTypeBridging { +struct [[deprecated(\\"Use NativeEnumTurboModuleStateTypeBridging instead.\\")]] NativeEnumTurboModuleBaseStateTypeBridging { static NativeEnumTurboModuleBaseStateType fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -363,7 +363,7 @@ struct NativeEnumTurboModuleBaseStateTypeBridging { #pragma mark - NativeEnumTurboModuleBaseStateTypeWithEnums template -struct NativeEnumTurboModuleBaseStateTypeWithEnums { +struct [[deprecated(\\"Use NativeEnumTurboModuleStateTypeWithEnums instead.\\")]] NativeEnumTurboModuleBaseStateTypeWithEnums { P0 state; P1 regular; P2 str; @@ -375,7 +375,7 @@ struct NativeEnumTurboModuleBaseStateTypeWithEnums { }; template -struct NativeEnumTurboModuleBaseStateTypeWithEnumsBridging { +struct [[deprecated(\\"Use NativeEnumTurboModuleStateTypeWithEnumsBridging instead.\\")]] NativeEnumTurboModuleBaseStateTypeWithEnumsBridging { static NativeEnumTurboModuleBaseStateTypeWithEnums fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -425,6 +425,115 @@ struct NativeEnumTurboModuleBaseStateTypeWithEnumsBridging { } }; + +#pragma mark - NativeEnumTurboModuleStateType + +template +struct NativeEnumTurboModuleStateType { + P0 state; + bool operator==(const NativeEnumTurboModuleStateType &other) const { + return state == other.state; + } +}; + +template +struct NativeEnumTurboModuleStateTypeBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"state\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String stateToJs(jsi::Runtime &rt, decltype(types.state) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"state\\", bridging::toJs(rt, value.state, jsInvoker)); + return result; + } +}; + + + +#pragma mark - NativeEnumTurboModuleStateTypeWithEnums + +template +struct NativeEnumTurboModuleStateTypeWithEnums { + P0 state; + P1 regular; + P2 str; + P3 num; + P4 fraction; + bool operator==(const NativeEnumTurboModuleStateTypeWithEnums &other) const { + return state == other.state && regular == other.regular && str == other.str && num == other.num && fraction == other.fraction; + } +}; + +template +struct NativeEnumTurboModuleStateTypeWithEnumsBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"state\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"regular\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"str\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"num\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"fraction\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String stateToJs(jsi::Runtime &rt, decltype(types.state) value) { + return bridging::toJs(rt, value); + } + + static jsi::String regularToJs(jsi::Runtime &rt, decltype(types.regular) value) { + return bridging::toJs(rt, value); + } + + static jsi::String strToJs(jsi::Runtime &rt, decltype(types.str) value) { + return bridging::toJs(rt, value); + } + + static int numToJs(jsi::Runtime &rt, decltype(types.num) value) { + return bridging::toJs(rt, value); + } + + static double fractionToJs(jsi::Runtime &rt, decltype(types.fraction) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"state\\", bridging::toJs(rt, value.state, jsInvoker)); + result.setProperty(rt, \\"regular\\", bridging::toJs(rt, value.regular, jsInvoker)); + result.setProperty(rt, \\"str\\", bridging::toJs(rt, value.str, jsInvoker)); + result.setProperty(rt, \\"num\\", bridging::toJs(rt, value.num, jsInvoker)); + result.setProperty(rt, \\"fraction\\", bridging::toJs(rt, value.fraction, jsInvoker)); + return result; + } +}; + class JSI_EXPORT NativeEnumTurboModuleCxxSpecJSI : public TurboModule { protected: NativeEnumTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); @@ -794,7 +903,7 @@ private: #pragma mark - NativePartialAnnotationTurboModuleBaseSomeObj template -struct NativePartialAnnotationTurboModuleBaseSomeObj { +struct [[deprecated(\\"Use NativePartialAnnotationTurboModuleSomeObj instead.\\")]] NativePartialAnnotationTurboModuleBaseSomeObj { P0 a; P1 b; bool operator==(const NativePartialAnnotationTurboModuleBaseSomeObj &other) const { @@ -803,7 +912,7 @@ struct NativePartialAnnotationTurboModuleBaseSomeObj { }; template -struct NativePartialAnnotationTurboModuleBaseSomeObjBridging { +struct [[deprecated(\\"Use NativePartialAnnotationTurboModuleSomeObjBridging instead.\\")]] NativePartialAnnotationTurboModuleBaseSomeObjBridging { static NativePartialAnnotationTurboModuleBaseSomeObj fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -837,6 +946,55 @@ struct NativePartialAnnotationTurboModuleBaseSomeObjBridging { } }; + +#pragma mark - NativePartialAnnotationTurboModuleSomeObj + +template +struct NativePartialAnnotationTurboModuleSomeObj { + P0 a; + P1 b; + bool operator==(const NativePartialAnnotationTurboModuleSomeObj &other) const { + return a == other.a && b == other.b; + } +}; + +template +struct NativePartialAnnotationTurboModuleSomeObjBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"a\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"b\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String aToJs(jsi::Runtime &rt, decltype(types.a) value) { + return bridging::toJs(rt, value); + } + + static bool bToJs(jsi::Runtime &rt, decltype(types.b) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"a\\", bridging::toJs(rt, value.a, jsInvoker)); + if (value.b) { + result.setProperty(rt, \\"b\\", bridging::toJs(rt, value.b.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT NativePartialAnnotationTurboModuleCxxSpecJSI : public TurboModule { protected: NativePartialAnnotationTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); @@ -969,7 +1127,7 @@ private: #pragma mark - SampleTurboModuleBaseAnimal template -struct SampleTurboModuleBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleAnimal instead.\\")]] SampleTurboModuleBaseAnimal { P0 name; bool operator==(const SampleTurboModuleBaseAnimal &other) const { return name == other.name; @@ -977,7 +1135,7 @@ struct SampleTurboModuleBaseAnimal { }; template -struct SampleTurboModuleBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleAnimalBridging instead.\\")]] SampleTurboModuleBaseAnimalBridging { static SampleTurboModuleBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -1003,6 +1161,46 @@ struct SampleTurboModuleBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleAnimal + +template +struct SampleTurboModuleAnimal { + P0 name; + bool operator==(const SampleTurboModuleAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name, jsInvoker)); + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); @@ -1161,7 +1359,7 @@ private: #pragma mark - SampleTurboModuleArraysBaseAnimal template -struct SampleTurboModuleArraysBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleArraysAnimal instead.\\")]] SampleTurboModuleArraysBaseAnimal { P0 name; bool operator==(const SampleTurboModuleArraysBaseAnimal &other) const { return name == other.name; @@ -1169,7 +1367,7 @@ struct SampleTurboModuleArraysBaseAnimal { }; template -struct SampleTurboModuleArraysBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleArraysAnimalBridging instead.\\")]] SampleTurboModuleArraysBaseAnimalBridging { static SampleTurboModuleArraysBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -1195,6 +1393,46 @@ struct SampleTurboModuleArraysBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleArraysAnimal + +template +struct SampleTurboModuleArraysAnimal { + P0 name; + bool operator==(const SampleTurboModuleArraysAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleArraysAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name, jsInvoker)); + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleArraysCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleArraysCxxSpecJSI(std::shared_ptr jsInvoker); @@ -1353,7 +1591,7 @@ private: #pragma mark - SampleTurboModuleNullableBaseAnimal template -struct SampleTurboModuleNullableBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleNullableAnimal instead.\\")]] SampleTurboModuleNullableBaseAnimal { P0 name; bool operator==(const SampleTurboModuleNullableBaseAnimal &other) const { return name == other.name; @@ -1361,7 +1599,7 @@ struct SampleTurboModuleNullableBaseAnimal { }; template -struct SampleTurboModuleNullableBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleNullableAnimalBridging instead.\\")]] SampleTurboModuleNullableBaseAnimalBridging { static SampleTurboModuleNullableBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -1387,6 +1625,46 @@ struct SampleTurboModuleNullableBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleNullableAnimal + +template +struct SampleTurboModuleNullableAnimal { + P0 name; + bool operator==(const SampleTurboModuleNullableAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleNullableAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static std::optional nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name, jsInvoker)); + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleNullableCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleNullableCxxSpecJSI(std::shared_ptr jsInvoker); @@ -1545,7 +1823,7 @@ private: #pragma mark - SampleTurboModuleNullableAndOptionalBaseAnimal template -struct SampleTurboModuleNullableAndOptionalBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleNullableAndOptionalAnimal instead.\\")]] SampleTurboModuleNullableAndOptionalBaseAnimal { P0 name; bool operator==(const SampleTurboModuleNullableAndOptionalBaseAnimal &other) const { return name == other.name; @@ -1553,7 +1831,7 @@ struct SampleTurboModuleNullableAndOptionalBaseAnimal { }; template -struct SampleTurboModuleNullableAndOptionalBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleNullableAndOptionalAnimalBridging instead.\\")]] SampleTurboModuleNullableAndOptionalBaseAnimalBridging { static SampleTurboModuleNullableAndOptionalBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -1581,6 +1859,48 @@ struct SampleTurboModuleNullableAndOptionalBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleNullableAndOptionalAnimal + +template +struct SampleTurboModuleNullableAndOptionalAnimal { + P0 name; + bool operator==(const SampleTurboModuleNullableAndOptionalAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleNullableAndOptionalAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static std::optional nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + if (value.name) { + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleNullableAndOptionalCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleNullableAndOptionalCxxSpecJSI(std::shared_ptr jsInvoker); @@ -1739,7 +2059,7 @@ private: #pragma mark - SampleTurboModuleOptionalBaseAnimal template -struct SampleTurboModuleOptionalBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleOptionalAnimal instead.\\")]] SampleTurboModuleOptionalBaseAnimal { P0 name; bool operator==(const SampleTurboModuleOptionalBaseAnimal &other) const { return name == other.name; @@ -1747,7 +2067,7 @@ struct SampleTurboModuleOptionalBaseAnimal { }; template -struct SampleTurboModuleOptionalBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleOptionalAnimalBridging instead.\\")]] SampleTurboModuleOptionalBaseAnimalBridging { static SampleTurboModuleOptionalBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -1775,6 +2095,48 @@ struct SampleTurboModuleOptionalBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleOptionalAnimal + +template +struct SampleTurboModuleOptionalAnimal { + P0 name; + bool operator==(const SampleTurboModuleOptionalAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleOptionalAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + if (value.name) { + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleOptionalCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleOptionalCxxSpecJSI(std::shared_ptr jsInvoker); @@ -2296,49 +2658,156 @@ struct Bridging { } } - static jsi::Value toJs(jsi::Runtime &rt, NativeEnumTurboModuleStatusFractionEnum value) { - if (value == NativeEnumTurboModuleStatusFractionEnum::Active) { - return bridging::toJs(rt, 0.2f); - } else if (value == NativeEnumTurboModuleStatusFractionEnum::Paused) { - return bridging::toJs(rt, 0.1f); - } else if (value == NativeEnumTurboModuleStatusFractionEnum::Off) { - return bridging::toJs(rt, 0f); - } else { - throw jsi::JSError(rt, \\"No appropriate enum member found for enum value\\"); - } + static jsi::Value toJs(jsi::Runtime &rt, NativeEnumTurboModuleStatusFractionEnum value) { + if (value == NativeEnumTurboModuleStatusFractionEnum::Active) { + return bridging::toJs(rt, 0.2f); + } else if (value == NativeEnumTurboModuleStatusFractionEnum::Paused) { + return bridging::toJs(rt, 0.1f); + } else if (value == NativeEnumTurboModuleStatusFractionEnum::Off) { + return bridging::toJs(rt, 0f); + } else { + throw jsi::JSError(rt, \\"No appropriate enum member found for enum value\\"); + } + } +}; + +#pragma mark - NativeEnumTurboModuleBaseStateType + +template +struct [[deprecated(\\"Use NativeEnumTurboModuleStateType instead.\\")]] NativeEnumTurboModuleBaseStateType { + P0 state; + bool operator==(const NativeEnumTurboModuleBaseStateType &other) const { + return state == other.state; + } +}; + +template +struct [[deprecated(\\"Use NativeEnumTurboModuleStateTypeBridging instead.\\")]] NativeEnumTurboModuleBaseStateTypeBridging { + static NativeEnumTurboModuleBaseStateType fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + NativeEnumTurboModuleBaseStateType result{ + bridging::fromJs(rt, value.getProperty(rt, \\"state\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String stateToJs(jsi::Runtime &rt, P0 value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const NativeEnumTurboModuleBaseStateType &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"state\\", bridging::toJs(rt, value.state, jsInvoker)); + return result; + } +}; + + + +#pragma mark - NativeEnumTurboModuleBaseStateTypeWithEnums + +template +struct [[deprecated(\\"Use NativeEnumTurboModuleStateTypeWithEnums instead.\\")]] NativeEnumTurboModuleBaseStateTypeWithEnums { + P0 state; + P1 regular; + P2 str; + P3 num; + P4 fraction; + bool operator==(const NativeEnumTurboModuleBaseStateTypeWithEnums &other) const { + return state == other.state && regular == other.regular && str == other.str && num == other.num && fraction == other.fraction; + } +}; + +template +struct [[deprecated(\\"Use NativeEnumTurboModuleStateTypeWithEnumsBridging instead.\\")]] NativeEnumTurboModuleBaseStateTypeWithEnumsBridging { + static NativeEnumTurboModuleBaseStateTypeWithEnums fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + NativeEnumTurboModuleBaseStateTypeWithEnums result{ + bridging::fromJs(rt, value.getProperty(rt, \\"state\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"regular\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"str\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"num\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"fraction\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String stateToJs(jsi::Runtime &rt, P0 value) { + return bridging::toJs(rt, value); + } + + static jsi::String regularToJs(jsi::Runtime &rt, P1 value) { + return bridging::toJs(rt, value); + } + + static jsi::String strToJs(jsi::Runtime &rt, P2 value) { + return bridging::toJs(rt, value); + } + + static int numToJs(jsi::Runtime &rt, P3 value) { + return bridging::toJs(rt, value); + } + + static double fractionToJs(jsi::Runtime &rt, P4 value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const NativeEnumTurboModuleBaseStateTypeWithEnums &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"state\\", bridging::toJs(rt, value.state, jsInvoker)); + result.setProperty(rt, \\"regular\\", bridging::toJs(rt, value.regular, jsInvoker)); + result.setProperty(rt, \\"str\\", bridging::toJs(rt, value.str, jsInvoker)); + result.setProperty(rt, \\"num\\", bridging::toJs(rt, value.num, jsInvoker)); + result.setProperty(rt, \\"fraction\\", bridging::toJs(rt, value.fraction, jsInvoker)); + return result; } }; - -#pragma mark - NativeEnumTurboModuleBaseStateType + + +#pragma mark - NativeEnumTurboModuleStateType template -struct NativeEnumTurboModuleBaseStateType { +struct NativeEnumTurboModuleStateType { P0 state; - bool operator==(const NativeEnumTurboModuleBaseStateType &other) const { + bool operator==(const NativeEnumTurboModuleStateType &other) const { return state == other.state; } }; -template -struct NativeEnumTurboModuleBaseStateTypeBridging { - static NativeEnumTurboModuleBaseStateType fromJs( +template +struct NativeEnumTurboModuleStateTypeBridging { + static T types; + + static T fromJs( jsi::Runtime &rt, const jsi::Object &value, const std::shared_ptr &jsInvoker) { - NativeEnumTurboModuleBaseStateType result{ - bridging::fromJs(rt, value.getProperty(rt, \\"state\\"), jsInvoker)}; + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"state\\"), jsInvoker)}; return result; } #ifdef DEBUG - static jsi::String stateToJs(jsi::Runtime &rt, P0 value) { + static jsi::String stateToJs(jsi::Runtime &rt, decltype(types.state) value) { return bridging::toJs(rt, value); } #endif static jsi::Object toJs( jsi::Runtime &rt, - const NativeEnumTurboModuleBaseStateType &value, + const T &value, const std::shared_ptr &jsInvoker) { auto result = facebook::jsi::Object(rt); result.setProperty(rt, \\"state\\", bridging::toJs(rt, value.state, jsInvoker)); @@ -2348,60 +2817,62 @@ struct NativeEnumTurboModuleBaseStateTypeBridging { -#pragma mark - NativeEnumTurboModuleBaseStateTypeWithEnums +#pragma mark - NativeEnumTurboModuleStateTypeWithEnums template -struct NativeEnumTurboModuleBaseStateTypeWithEnums { +struct NativeEnumTurboModuleStateTypeWithEnums { P0 state; P1 regular; P2 str; P3 num; P4 fraction; - bool operator==(const NativeEnumTurboModuleBaseStateTypeWithEnums &other) const { + bool operator==(const NativeEnumTurboModuleStateTypeWithEnums &other) const { return state == other.state && regular == other.regular && str == other.str && num == other.num && fraction == other.fraction; } }; -template -struct NativeEnumTurboModuleBaseStateTypeWithEnumsBridging { - static NativeEnumTurboModuleBaseStateTypeWithEnums fromJs( +template +struct NativeEnumTurboModuleStateTypeWithEnumsBridging { + static T types; + + static T fromJs( jsi::Runtime &rt, const jsi::Object &value, const std::shared_ptr &jsInvoker) { - NativeEnumTurboModuleBaseStateTypeWithEnums result{ - bridging::fromJs(rt, value.getProperty(rt, \\"state\\"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, \\"regular\\"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, \\"str\\"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, \\"num\\"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, \\"fraction\\"), jsInvoker)}; + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"state\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"regular\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"str\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"num\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"fraction\\"), jsInvoker)}; return result; } #ifdef DEBUG - static jsi::String stateToJs(jsi::Runtime &rt, P0 value) { + static jsi::String stateToJs(jsi::Runtime &rt, decltype(types.state) value) { return bridging::toJs(rt, value); } - static jsi::String regularToJs(jsi::Runtime &rt, P1 value) { + static jsi::String regularToJs(jsi::Runtime &rt, decltype(types.regular) value) { return bridging::toJs(rt, value); } - static jsi::String strToJs(jsi::Runtime &rt, P2 value) { + static jsi::String strToJs(jsi::Runtime &rt, decltype(types.str) value) { return bridging::toJs(rt, value); } - static int numToJs(jsi::Runtime &rt, P3 value) { + static int numToJs(jsi::Runtime &rt, decltype(types.num) value) { return bridging::toJs(rt, value); } - static double fractionToJs(jsi::Runtime &rt, P4 value) { + static double fractionToJs(jsi::Runtime &rt, decltype(types.fraction) value) { return bridging::toJs(rt, value); } #endif static jsi::Object toJs( jsi::Runtime &rt, - const NativeEnumTurboModuleBaseStateTypeWithEnums &value, + const T &value, const std::shared_ptr &jsInvoker) { auto result = facebook::jsi::Object(rt); result.setProperty(rt, \\"state\\", bridging::toJs(rt, value.state, jsInvoker)); @@ -2782,7 +3253,7 @@ private: #pragma mark - NativePartialAnnotationTurboModuleBaseSomeObj template -struct NativePartialAnnotationTurboModuleBaseSomeObj { +struct [[deprecated(\\"Use NativePartialAnnotationTurboModuleSomeObj instead.\\")]] NativePartialAnnotationTurboModuleBaseSomeObj { P0 a; P1 b; bool operator==(const NativePartialAnnotationTurboModuleBaseSomeObj &other) const { @@ -2791,7 +3262,7 @@ struct NativePartialAnnotationTurboModuleBaseSomeObj { }; template -struct NativePartialAnnotationTurboModuleBaseSomeObjBridging { +struct [[deprecated(\\"Use NativePartialAnnotationTurboModuleSomeObjBridging instead.\\")]] NativePartialAnnotationTurboModuleBaseSomeObjBridging { static NativePartialAnnotationTurboModuleBaseSomeObj fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -2825,6 +3296,55 @@ struct NativePartialAnnotationTurboModuleBaseSomeObjBridging { } }; + +#pragma mark - NativePartialAnnotationTurboModuleSomeObj + +template +struct NativePartialAnnotationTurboModuleSomeObj { + P0 a; + P1 b; + bool operator==(const NativePartialAnnotationTurboModuleSomeObj &other) const { + return a == other.a && b == other.b; + } +}; + +template +struct NativePartialAnnotationTurboModuleSomeObjBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"a\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"b\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String aToJs(jsi::Runtime &rt, decltype(types.a) value) { + return bridging::toJs(rt, value); + } + + static bool bToJs(jsi::Runtime &rt, decltype(types.b) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"a\\", bridging::toJs(rt, value.a, jsInvoker)); + if (value.b) { + result.setProperty(rt, \\"b\\", bridging::toJs(rt, value.b.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT NativePartialAnnotationTurboModuleCxxSpecJSI : public TurboModule { protected: NativePartialAnnotationTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); @@ -2957,7 +3477,7 @@ private: #pragma mark - SampleTurboModuleBaseAnimal template -struct SampleTurboModuleBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleAnimal instead.\\")]] SampleTurboModuleBaseAnimal { P0 name; bool operator==(const SampleTurboModuleBaseAnimal &other) const { return name == other.name; @@ -2965,7 +3485,7 @@ struct SampleTurboModuleBaseAnimal { }; template -struct SampleTurboModuleBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleAnimalBridging instead.\\")]] SampleTurboModuleBaseAnimalBridging { static SampleTurboModuleBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -2991,6 +3511,46 @@ struct SampleTurboModuleBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleAnimal + +template +struct SampleTurboModuleAnimal { + P0 name; + bool operator==(const SampleTurboModuleAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name, jsInvoker)); + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); @@ -3149,7 +3709,7 @@ private: #pragma mark - SampleTurboModuleArraysBaseAnimal template -struct SampleTurboModuleArraysBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleArraysAnimal instead.\\")]] SampleTurboModuleArraysBaseAnimal { P0 name; bool operator==(const SampleTurboModuleArraysBaseAnimal &other) const { return name == other.name; @@ -3157,7 +3717,7 @@ struct SampleTurboModuleArraysBaseAnimal { }; template -struct SampleTurboModuleArraysBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleArraysAnimalBridging instead.\\")]] SampleTurboModuleArraysBaseAnimalBridging { static SampleTurboModuleArraysBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -3183,6 +3743,46 @@ struct SampleTurboModuleArraysBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleArraysAnimal + +template +struct SampleTurboModuleArraysAnimal { + P0 name; + bool operator==(const SampleTurboModuleArraysAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleArraysAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name, jsInvoker)); + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleArraysCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleArraysCxxSpecJSI(std::shared_ptr jsInvoker); @@ -3341,7 +3941,7 @@ private: #pragma mark - SampleTurboModuleNullableBaseAnimal template -struct SampleTurboModuleNullableBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleNullableAnimal instead.\\")]] SampleTurboModuleNullableBaseAnimal { P0 name; bool operator==(const SampleTurboModuleNullableBaseAnimal &other) const { return name == other.name; @@ -3349,7 +3949,7 @@ struct SampleTurboModuleNullableBaseAnimal { }; template -struct SampleTurboModuleNullableBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleNullableAnimalBridging instead.\\")]] SampleTurboModuleNullableBaseAnimalBridging { static SampleTurboModuleNullableBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -3375,6 +3975,46 @@ struct SampleTurboModuleNullableBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleNullableAnimal + +template +struct SampleTurboModuleNullableAnimal { + P0 name; + bool operator==(const SampleTurboModuleNullableAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleNullableAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static std::optional nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name, jsInvoker)); + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleNullableCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleNullableCxxSpecJSI(std::shared_ptr jsInvoker); @@ -3533,7 +4173,7 @@ private: #pragma mark - SampleTurboModuleNullableAndOptionalBaseAnimal template -struct SampleTurboModuleNullableAndOptionalBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleNullableAndOptionalAnimal instead.\\")]] SampleTurboModuleNullableAndOptionalBaseAnimal { P0 name; bool operator==(const SampleTurboModuleNullableAndOptionalBaseAnimal &other) const { return name == other.name; @@ -3541,7 +4181,7 @@ struct SampleTurboModuleNullableAndOptionalBaseAnimal { }; template -struct SampleTurboModuleNullableAndOptionalBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleNullableAndOptionalAnimalBridging instead.\\")]] SampleTurboModuleNullableAndOptionalBaseAnimalBridging { static SampleTurboModuleNullableAndOptionalBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -3569,6 +4209,48 @@ struct SampleTurboModuleNullableAndOptionalBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleNullableAndOptionalAnimal + +template +struct SampleTurboModuleNullableAndOptionalAnimal { + P0 name; + bool operator==(const SampleTurboModuleNullableAndOptionalAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleNullableAndOptionalAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static std::optional nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + if (value.name) { + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleNullableAndOptionalCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleNullableAndOptionalCxxSpecJSI(std::shared_ptr jsInvoker); @@ -3727,7 +4409,7 @@ private: #pragma mark - SampleTurboModuleOptionalBaseAnimal template -struct SampleTurboModuleOptionalBaseAnimal { +struct [[deprecated(\\"Use SampleTurboModuleOptionalAnimal instead.\\")]] SampleTurboModuleOptionalBaseAnimal { P0 name; bool operator==(const SampleTurboModuleOptionalBaseAnimal &other) const { return name == other.name; @@ -3735,7 +4417,7 @@ struct SampleTurboModuleOptionalBaseAnimal { }; template -struct SampleTurboModuleOptionalBaseAnimalBridging { +struct [[deprecated(\\"Use SampleTurboModuleOptionalAnimalBridging instead.\\")]] SampleTurboModuleOptionalBaseAnimalBridging { static SampleTurboModuleOptionalBaseAnimal fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -3763,6 +4445,48 @@ struct SampleTurboModuleOptionalBaseAnimalBridging { } }; + +#pragma mark - SampleTurboModuleOptionalAnimal + +template +struct SampleTurboModuleOptionalAnimal { + P0 name; + bool operator==(const SampleTurboModuleOptionalAnimal &other) const { + return name == other.name; + } +}; + +template +struct SampleTurboModuleOptionalAnimalBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + if (value.name) { + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleOptionalCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleOptionalCxxSpecJSI(std::shared_ptr jsInvoker); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js index 6dd3289216aadc..31b29998105089 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js @@ -232,33 +232,36 @@ function createStructsString( enumMap, ); - return Object.keys(aliasMap) - .map(alias => { - const value = aliasMap[alias]; - if (value.properties.length === 0) { - return ''; - } - const structName = `${moduleName}Base${alias}`; - const templateParameterWithTypename = value.properties - .map((v, i) => `typename P${i}`) - .join(', '); - const templateParameter = value.properties - .map((v, i) => 'P' + i) - .join(', '); - const debugParameterConversion = value.properties - .map( - (v, i) => ` static ${getCppType(v)} ${ - v.name - }ToJs(jsi::Runtime &rt, P${i} value) { + // TODO: T171006733 [Begin] Remove deprecated Cxx TMs structs after a new release. + return ( + Object.keys(aliasMap) + .map(alias => { + const value = aliasMap[alias]; + if (value.properties.length === 0) { + return ''; + } + const structName = `${moduleName}Base${alias}`; + const structNameNew = `${moduleName}${alias}`; + const templateParameterWithTypename = value.properties + .map((v, i) => `typename P${i}`) + .join(', '); + const templateParameter = value.properties + .map((v, i) => 'P' + i) + .join(', '); + const debugParameterConversion = value.properties + .map( + (v, i) => ` static ${getCppType(v)} ${ + v.name + }ToJs(jsi::Runtime &rt, P${i} value) { return bridging::toJs(rt, value); }`, - ) - .join('\n\n'); - return ` + ) + .join('\n\n'); + return ` #pragma mark - ${structName} template <${templateParameterWithTypename}> -struct ${structName} { +struct [[deprecated("Use ${structNameNew} instead.")]] ${structName} { ${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')}; bool operator==(const ${structName} &other) const { return ${value.properties @@ -268,7 +271,7 @@ ${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')}; }; template <${templateParameterWithTypename}> -struct ${structName}Bridging { +struct [[deprecated("Use ${structNameNew}Bridging instead.")]] ${structName}Bridging { static ${structName}<${templateParameter}> fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -308,8 +311,87 @@ ${value.properties }; `; - }) - .join('\n'); + }) + .join('\n') + + // TODO: T171006733 [End] Remove deprecated Cxx TMs structs after a new release. + Object.keys(aliasMap) + .map(alias => { + const value = aliasMap[alias]; + if (value.properties.length === 0) { + return ''; + } + const structName = `${moduleName}${alias}`; + const templateParameterWithTypename = value.properties + .map((v, i) => `typename P${i}`) + .join(', '); + const debugParameterConversion = value.properties + .map( + (v, i) => ` static ${getCppType(v)} ${ + v.name + }ToJs(jsi::Runtime &rt, decltype(types.${v.name}) value) { + return bridging::toJs(rt, value); + }`, + ) + .join('\n\n'); + return ` +#pragma mark - ${structName} + +template <${templateParameterWithTypename}> +struct ${structName} { +${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')}; + bool operator==(const ${structName} &other) const { + return ${value.properties + .map(v => `${v.name} == other.${v.name}`) + .join(' && ')}; + } +}; + +template +struct ${structName}Bridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ +${value.properties + .map( + (v, i) => + ` bridging::fromJs(rt, value.getProperty(rt, "${v.name}"), jsInvoker)`, + ) + .join(',\n')}}; + return result; + } + +#ifdef DEBUG +${debugParameterConversion} +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); +${value.properties + .map((v, i) => { + if (v.optional) { + return ` if (value.${v.name}) { + result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}.value(), jsInvoker)); + }`; + } else { + return ` result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}, jsInvoker));`; + } + }) + .join('\n')} + return result; + } +}; + +`; + }) + .join('\n') + ); } type NativeEnumMemberValueType = 'std::string' | 'int32_t' | 'float'; diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap index 75e2dd9187d176..aa012fe2c151e3 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap @@ -300,7 +300,7 @@ struct Bridging { #pragma mark - SampleTurboModuleCxxBaseObjectAlias template -struct SampleTurboModuleCxxBaseObjectAlias { +struct [[deprecated(\\"Use SampleTurboModuleCxxObjectAlias instead.\\")]] SampleTurboModuleCxxBaseObjectAlias { P0 x; bool operator==(const SampleTurboModuleCxxBaseObjectAlias &other) const { return x == other.x; @@ -308,7 +308,7 @@ struct SampleTurboModuleCxxBaseObjectAlias { }; template -struct SampleTurboModuleCxxBaseObjectAliasBridging { +struct [[deprecated(\\"Use SampleTurboModuleCxxObjectAliasBridging instead.\\")]] SampleTurboModuleCxxBaseObjectAliasBridging { static SampleTurboModuleCxxBaseObjectAlias fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -334,6 +334,46 @@ struct SampleTurboModuleCxxBaseObjectAliasBridging { } }; + +#pragma mark - SampleTurboModuleCxxObjectAlias + +template +struct SampleTurboModuleCxxObjectAlias { + P0 x; + bool operator==(const SampleTurboModuleCxxObjectAlias &other) const { + return x == other.x; + } +}; + +template +struct SampleTurboModuleCxxObjectAliasBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"x\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static double xToJs(jsi::Runtime &rt, decltype(types.x) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"x\\", bridging::toJs(rt, value.x, jsInvoker)); + return result; + } +}; + class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); @@ -509,7 +549,7 @@ namespace react { #pragma mark - AliasTurboModuleBaseOptions template -struct AliasTurboModuleBaseOptions { +struct [[deprecated(\\"Use AliasTurboModuleOptions instead.\\")]] AliasTurboModuleBaseOptions { P0 offset; P1 size; P2 displaySize; @@ -521,7 +561,7 @@ struct AliasTurboModuleBaseOptions { }; template -struct AliasTurboModuleBaseOptionsBridging { +struct [[deprecated(\\"Use AliasTurboModuleOptionsBridging instead.\\")]] AliasTurboModuleBaseOptionsBridging { static AliasTurboModuleBaseOptions fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -577,6 +617,80 @@ struct AliasTurboModuleBaseOptionsBridging { } }; + +#pragma mark - AliasTurboModuleOptions + +template +struct AliasTurboModuleOptions { + P0 offset; + P1 size; + P2 displaySize; + P3 resizeMode; + P4 allowExternalStorage; + bool operator==(const AliasTurboModuleOptions &other) const { + return offset == other.offset && size == other.size && displaySize == other.displaySize && resizeMode == other.resizeMode && allowExternalStorage == other.allowExternalStorage; + } +}; + +template +struct AliasTurboModuleOptionsBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"offset\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"size\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"displaySize\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"resizeMode\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"allowExternalStorage\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::Object offsetToJs(jsi::Runtime &rt, decltype(types.offset) value) { + return bridging::toJs(rt, value); + } + + static jsi::Object sizeToJs(jsi::Runtime &rt, decltype(types.size) value) { + return bridging::toJs(rt, value); + } + + static jsi::Object displaySizeToJs(jsi::Runtime &rt, decltype(types.displaySize) value) { + return bridging::toJs(rt, value); + } + + static jsi::String resizeModeToJs(jsi::Runtime &rt, decltype(types.resizeMode) value) { + return bridging::toJs(rt, value); + } + + static bool allowExternalStorageToJs(jsi::Runtime &rt, decltype(types.allowExternalStorage) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"offset\\", bridging::toJs(rt, value.offset, jsInvoker)); + result.setProperty(rt, \\"size\\", bridging::toJs(rt, value.size, jsInvoker)); + if (value.displaySize) { + result.setProperty(rt, \\"displaySize\\", bridging::toJs(rt, value.displaySize.value(), jsInvoker)); + } + if (value.resizeMode) { + result.setProperty(rt, \\"resizeMode\\", bridging::toJs(rt, value.resizeMode.value(), jsInvoker)); + } + if (value.allowExternalStorage) { + result.setProperty(rt, \\"allowExternalStorage\\", bridging::toJs(rt, value.allowExternalStorage.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT AliasTurboModuleCxxSpecJSI : public TurboModule { protected: AliasTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); @@ -661,7 +775,7 @@ namespace react { #pragma mark - CameraRollManagerBasePhotoIdentifierImage template -struct CameraRollManagerBasePhotoIdentifierImage { +struct [[deprecated(\\"Use CameraRollManagerPhotoIdentifierImage instead.\\")]] CameraRollManagerBasePhotoIdentifierImage { P0 uri; P1 playableDuration; P2 width; @@ -674,7 +788,7 @@ struct CameraRollManagerBasePhotoIdentifierImage { }; template -struct CameraRollManagerBasePhotoIdentifierImageBridging { +struct [[deprecated(\\"Use CameraRollManagerPhotoIdentifierImageBridging instead.\\")]] CameraRollManagerBasePhotoIdentifierImageBridging { static CameraRollManagerBasePhotoIdentifierImage fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -737,7 +851,7 @@ struct CameraRollManagerBasePhotoIdentifierImageBridging { #pragma mark - CameraRollManagerBasePhotoIdentifier template -struct CameraRollManagerBasePhotoIdentifier { +struct [[deprecated(\\"Use CameraRollManagerPhotoIdentifier instead.\\")]] CameraRollManagerBasePhotoIdentifier { P0 node; bool operator==(const CameraRollManagerBasePhotoIdentifier &other) const { return node == other.node; @@ -745,7 +859,7 @@ struct CameraRollManagerBasePhotoIdentifier { }; template -struct CameraRollManagerBasePhotoIdentifierBridging { +struct [[deprecated(\\"Use CameraRollManagerPhotoIdentifierBridging instead.\\")]] CameraRollManagerBasePhotoIdentifierBridging { static CameraRollManagerBasePhotoIdentifier fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -776,7 +890,7 @@ struct CameraRollManagerBasePhotoIdentifierBridging { #pragma mark - CameraRollManagerBasePhotoIdentifiersPage template -struct CameraRollManagerBasePhotoIdentifiersPage { +struct [[deprecated(\\"Use CameraRollManagerPhotoIdentifiersPage instead.\\")]] CameraRollManagerBasePhotoIdentifiersPage { P0 edges; P1 page_info; bool operator==(const CameraRollManagerBasePhotoIdentifiersPage &other) const { @@ -785,7 +899,7 @@ struct CameraRollManagerBasePhotoIdentifiersPage { }; template -struct CameraRollManagerBasePhotoIdentifiersPageBridging { +struct [[deprecated(\\"Use CameraRollManagerPhotoIdentifiersPageBridging instead.\\")]] CameraRollManagerBasePhotoIdentifiersPageBridging { static CameraRollManagerBasePhotoIdentifiersPage fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -822,7 +936,7 @@ struct CameraRollManagerBasePhotoIdentifiersPageBridging { #pragma mark - CameraRollManagerBaseGetPhotosParams template -struct CameraRollManagerBaseGetPhotosParams { +struct [[deprecated(\\"Use CameraRollManagerGetPhotosParams instead.\\")]] CameraRollManagerBaseGetPhotosParams { P0 first; P1 after; P2 groupName; @@ -836,7 +950,7 @@ struct CameraRollManagerBaseGetPhotosParams { }; template -struct CameraRollManagerBaseGetPhotosParamsBridging { +struct [[deprecated(\\"Use CameraRollManagerGetPhotosParamsBridging instead.\\")]] CameraRollManagerBaseGetPhotosParamsBridging { static CameraRollManagerBaseGetPhotosParams fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -910,6 +1024,267 @@ struct CameraRollManagerBaseGetPhotosParamsBridging { } }; + +#pragma mark - CameraRollManagerPhotoIdentifierImage + +template +struct CameraRollManagerPhotoIdentifierImage { + P0 uri; + P1 playableDuration; + P2 width; + P3 height; + P4 isStored; + P5 filename; + bool operator==(const CameraRollManagerPhotoIdentifierImage &other) const { + return uri == other.uri && playableDuration == other.playableDuration && width == other.width && height == other.height && isStored == other.isStored && filename == other.filename; + } +}; + +template +struct CameraRollManagerPhotoIdentifierImageBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"uri\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"playableDuration\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"width\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"height\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"isStored\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"filename\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String uriToJs(jsi::Runtime &rt, decltype(types.uri) value) { + return bridging::toJs(rt, value); + } + + static double playableDurationToJs(jsi::Runtime &rt, decltype(types.playableDuration) value) { + return bridging::toJs(rt, value); + } + + static double widthToJs(jsi::Runtime &rt, decltype(types.width) value) { + return bridging::toJs(rt, value); + } + + static double heightToJs(jsi::Runtime &rt, decltype(types.height) value) { + return bridging::toJs(rt, value); + } + + static bool isStoredToJs(jsi::Runtime &rt, decltype(types.isStored) value) { + return bridging::toJs(rt, value); + } + + static jsi::String filenameToJs(jsi::Runtime &rt, decltype(types.filename) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"uri\\", bridging::toJs(rt, value.uri, jsInvoker)); + result.setProperty(rt, \\"playableDuration\\", bridging::toJs(rt, value.playableDuration, jsInvoker)); + result.setProperty(rt, \\"width\\", bridging::toJs(rt, value.width, jsInvoker)); + result.setProperty(rt, \\"height\\", bridging::toJs(rt, value.height, jsInvoker)); + if (value.isStored) { + result.setProperty(rt, \\"isStored\\", bridging::toJs(rt, value.isStored.value(), jsInvoker)); + } + result.setProperty(rt, \\"filename\\", bridging::toJs(rt, value.filename, jsInvoker)); + return result; + } +}; + + + +#pragma mark - CameraRollManagerPhotoIdentifier + +template +struct CameraRollManagerPhotoIdentifier { + P0 node; + bool operator==(const CameraRollManagerPhotoIdentifier &other) const { + return node == other.node; + } +}; + +template +struct CameraRollManagerPhotoIdentifierBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"node\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::Object nodeToJs(jsi::Runtime &rt, decltype(types.node) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"node\\", bridging::toJs(rt, value.node, jsInvoker)); + return result; + } +}; + + + +#pragma mark - CameraRollManagerPhotoIdentifiersPage + +template +struct CameraRollManagerPhotoIdentifiersPage { + P0 edges; + P1 page_info; + bool operator==(const CameraRollManagerPhotoIdentifiersPage &other) const { + return edges == other.edges && page_info == other.page_info; + } +}; + +template +struct CameraRollManagerPhotoIdentifiersPageBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"edges\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"page_info\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::Array edgesToJs(jsi::Runtime &rt, decltype(types.edges) value) { + return bridging::toJs(rt, value); + } + + static jsi::Object page_infoToJs(jsi::Runtime &rt, decltype(types.page_info) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"edges\\", bridging::toJs(rt, value.edges, jsInvoker)); + result.setProperty(rt, \\"page_info\\", bridging::toJs(rt, value.page_info, jsInvoker)); + return result; + } +}; + + + +#pragma mark - CameraRollManagerGetPhotosParams + +template +struct CameraRollManagerGetPhotosParams { + P0 first; + P1 after; + P2 groupName; + P3 groupTypes; + P4 assetType; + P5 maxSize; + P6 mimeTypes; + bool operator==(const CameraRollManagerGetPhotosParams &other) const { + return first == other.first && after == other.after && groupName == other.groupName && groupTypes == other.groupTypes && assetType == other.assetType && maxSize == other.maxSize && mimeTypes == other.mimeTypes; + } +}; + +template +struct CameraRollManagerGetPhotosParamsBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"first\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"after\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"groupName\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"groupTypes\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"assetType\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"maxSize\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"mimeTypes\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static double firstToJs(jsi::Runtime &rt, decltype(types.first) value) { + return bridging::toJs(rt, value); + } + + static jsi::String afterToJs(jsi::Runtime &rt, decltype(types.after) value) { + return bridging::toJs(rt, value); + } + + static jsi::String groupNameToJs(jsi::Runtime &rt, decltype(types.groupName) value) { + return bridging::toJs(rt, value); + } + + static jsi::String groupTypesToJs(jsi::Runtime &rt, decltype(types.groupTypes) value) { + return bridging::toJs(rt, value); + } + + static jsi::String assetTypeToJs(jsi::Runtime &rt, decltype(types.assetType) value) { + return bridging::toJs(rt, value); + } + + static double maxSizeToJs(jsi::Runtime &rt, decltype(types.maxSize) value) { + return bridging::toJs(rt, value); + } + + static jsi::Array mimeTypesToJs(jsi::Runtime &rt, decltype(types.mimeTypes) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"first\\", bridging::toJs(rt, value.first, jsInvoker)); + if (value.after) { + result.setProperty(rt, \\"after\\", bridging::toJs(rt, value.after.value(), jsInvoker)); + } + if (value.groupName) { + result.setProperty(rt, \\"groupName\\", bridging::toJs(rt, value.groupName.value(), jsInvoker)); + } + if (value.groupTypes) { + result.setProperty(rt, \\"groupTypes\\", bridging::toJs(rt, value.groupTypes.value(), jsInvoker)); + } + if (value.assetType) { + result.setProperty(rt, \\"assetType\\", bridging::toJs(rt, value.assetType.value(), jsInvoker)); + } + if (value.maxSize) { + result.setProperty(rt, \\"maxSize\\", bridging::toJs(rt, value.maxSize.value(), jsInvoker)); + } + if (value.mimeTypes) { + result.setProperty(rt, \\"mimeTypes\\", bridging::toJs(rt, value.mimeTypes.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT NativeCameraRollManagerCxxSpecJSI : public TurboModule { protected: NativeCameraRollManagerCxxSpecJSI(std::shared_ptr jsInvoker); @@ -987,7 +1362,7 @@ private: #pragma mark - ExceptionsManagerBaseStackFrame template -struct ExceptionsManagerBaseStackFrame { +struct [[deprecated(\\"Use ExceptionsManagerStackFrame instead.\\")]] ExceptionsManagerBaseStackFrame { P0 column; P1 file; P2 lineNumber; @@ -999,7 +1374,7 @@ struct ExceptionsManagerBaseStackFrame { }; template -struct ExceptionsManagerBaseStackFrameBridging { +struct [[deprecated(\\"Use ExceptionsManagerStackFrameBridging instead.\\")]] ExceptionsManagerBaseStackFrameBridging { static ExceptionsManagerBaseStackFrame fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -1060,7 +1435,7 @@ struct ExceptionsManagerBaseStackFrameBridging { #pragma mark - ExceptionsManagerBaseExceptionData template -struct ExceptionsManagerBaseExceptionData { +struct [[deprecated(\\"Use ExceptionsManagerExceptionData instead.\\")]] ExceptionsManagerBaseExceptionData { P0 message; P1 originalMessage; P2 name; @@ -1075,7 +1450,7 @@ struct ExceptionsManagerBaseExceptionData { }; template -struct ExceptionsManagerBaseExceptionDataBridging { +struct [[deprecated(\\"Use ExceptionsManagerExceptionDataBridging instead.\\")]] ExceptionsManagerBaseExceptionDataBridging { static ExceptionsManagerBaseExceptionData fromJs( jsi::Runtime &rt, const jsi::Object &value, @@ -1145,6 +1520,172 @@ struct ExceptionsManagerBaseExceptionDataBridging { } }; + +#pragma mark - ExceptionsManagerStackFrame + +template +struct ExceptionsManagerStackFrame { + P0 column; + P1 file; + P2 lineNumber; + P3 methodName; + P4 collapse; + bool operator==(const ExceptionsManagerStackFrame &other) const { + return column == other.column && file == other.file && lineNumber == other.lineNumber && methodName == other.methodName && collapse == other.collapse; + } +}; + +template +struct ExceptionsManagerStackFrameBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"column\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"file\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"lineNumber\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"methodName\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"collapse\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static double columnToJs(jsi::Runtime &rt, decltype(types.column) value) { + return bridging::toJs(rt, value); + } + + static jsi::String fileToJs(jsi::Runtime &rt, decltype(types.file) value) { + return bridging::toJs(rt, value); + } + + static double lineNumberToJs(jsi::Runtime &rt, decltype(types.lineNumber) value) { + return bridging::toJs(rt, value); + } + + static jsi::String methodNameToJs(jsi::Runtime &rt, decltype(types.methodName) value) { + return bridging::toJs(rt, value); + } + + static bool collapseToJs(jsi::Runtime &rt, decltype(types.collapse) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + if (value.column) { + result.setProperty(rt, \\"column\\", bridging::toJs(rt, value.column.value(), jsInvoker)); + } + result.setProperty(rt, \\"file\\", bridging::toJs(rt, value.file, jsInvoker)); + if (value.lineNumber) { + result.setProperty(rt, \\"lineNumber\\", bridging::toJs(rt, value.lineNumber.value(), jsInvoker)); + } + result.setProperty(rt, \\"methodName\\", bridging::toJs(rt, value.methodName, jsInvoker)); + if (value.collapse) { + result.setProperty(rt, \\"collapse\\", bridging::toJs(rt, value.collapse.value(), jsInvoker)); + } + return result; + } +}; + + + +#pragma mark - ExceptionsManagerExceptionData + +template +struct ExceptionsManagerExceptionData { + P0 message; + P1 originalMessage; + P2 name; + P3 componentStack; + P4 stack; + P5 id; + P6 isFatal; + P7 extraData; + bool operator==(const ExceptionsManagerExceptionData &other) const { + return message == other.message && originalMessage == other.originalMessage && name == other.name && componentStack == other.componentStack && stack == other.stack && id == other.id && isFatal == other.isFatal && extraData == other.extraData; + } +}; + +template +struct ExceptionsManagerExceptionDataBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, \\"message\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"originalMessage\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"name\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"componentStack\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"stack\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"id\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"isFatal\\"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, \\"extraData\\"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::String messageToJs(jsi::Runtime &rt, decltype(types.message) value) { + return bridging::toJs(rt, value); + } + + static jsi::String originalMessageToJs(jsi::Runtime &rt, decltype(types.originalMessage) value) { + return bridging::toJs(rt, value); + } + + static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) { + return bridging::toJs(rt, value); + } + + static jsi::String componentStackToJs(jsi::Runtime &rt, decltype(types.componentStack) value) { + return bridging::toJs(rt, value); + } + + static jsi::Array stackToJs(jsi::Runtime &rt, decltype(types.stack) value) { + return bridging::toJs(rt, value); + } + + static double idToJs(jsi::Runtime &rt, decltype(types.id) value) { + return bridging::toJs(rt, value); + } + + static bool isFatalToJs(jsi::Runtime &rt, decltype(types.isFatal) value) { + return bridging::toJs(rt, value); + } + + static jsi::Object extraDataToJs(jsi::Runtime &rt, decltype(types.extraData) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, \\"message\\", bridging::toJs(rt, value.message, jsInvoker)); + result.setProperty(rt, \\"originalMessage\\", bridging::toJs(rt, value.originalMessage, jsInvoker)); + result.setProperty(rt, \\"name\\", bridging::toJs(rt, value.name, jsInvoker)); + result.setProperty(rt, \\"componentStack\\", bridging::toJs(rt, value.componentStack, jsInvoker)); + result.setProperty(rt, \\"stack\\", bridging::toJs(rt, value.stack, jsInvoker)); + result.setProperty(rt, \\"id\\", bridging::toJs(rt, value.id, jsInvoker)); + result.setProperty(rt, \\"isFatal\\", bridging::toJs(rt, value.isFatal, jsInvoker)); + if (value.extraData) { + result.setProperty(rt, \\"extraData\\", bridging::toJs(rt, value.extraData.value(), jsInvoker)); + } + return result; + } +}; + class JSI_EXPORT NativeExceptionsManagerCxxSpecJSI : public TurboModule { protected: NativeExceptionsManagerCxxSpecJSI(std::shared_ptr jsInvoker); diff --git a/packages/react-native/Libraries/IntersectionObserver/NativeIntersectionObserver.h b/packages/react-native/Libraries/IntersectionObserver/NativeIntersectionObserver.h index 20cd6e63db3fa9..1281f60db29fe1 100644 --- a/packages/react-native/Libraries/IntersectionObserver/NativeIntersectionObserver.h +++ b/packages/react-native/Libraries/IntersectionObserver/NativeIntersectionObserver.h @@ -20,7 +20,7 @@ using NativeIntersectionObserverIntersectionObserverId = int32_t; using RectAsTuple = std::tuple; using NativeIntersectionObserverObserveOptions = - NativeIntersectionObserverCxxBaseNativeIntersectionObserverObserveOptions< + NativeIntersectionObserverCxxNativeIntersectionObserverObserveOptions< // intersectionObserverId NativeIntersectionObserverIntersectionObserverId, // targetShadowNode @@ -30,16 +30,11 @@ using NativeIntersectionObserverObserveOptions = template <> struct Bridging - : NativeIntersectionObserverCxxBaseNativeIntersectionObserverObserveOptionsBridging< - // intersectionObserverId - NativeIntersectionObserverIntersectionObserverId, - // targetShadowNode - jsi::Object, - // thresholds - std::vector> {}; + : NativeIntersectionObserverCxxNativeIntersectionObserverObserveOptionsBridging< + NativeIntersectionObserverObserveOptions> {}; using NativeIntersectionObserverEntry = - NativeIntersectionObserverCxxBaseNativeIntersectionObserverEntry< + NativeIntersectionObserverCxxNativeIntersectionObserverEntry< // intersectionObserverId NativeIntersectionObserverIntersectionObserverId, // targetInstanceHandle @@ -57,21 +52,8 @@ using NativeIntersectionObserverEntry = template <> struct Bridging - : NativeIntersectionObserverCxxBaseNativeIntersectionObserverEntryBridging< - // intersectionObserverId - NativeIntersectionObserverIntersectionObserverId, - // targetInstanceHandle - jsi::Value, - // targetRect - RectAsTuple, - // rootRect - RectAsTuple, - // intersectionRect - std::optional, - // isIntersectingAboveThresholds - bool, - // time - double> {}; + : NativeIntersectionObserverCxxNativeIntersectionObserverEntryBridging< + NativeIntersectionObserverEntry> {}; class NativeIntersectionObserver : public NativeIntersectionObserverCxxSpec, diff --git a/packages/react-native/Libraries/MutationObserver/NativeMutationObserver.h b/packages/react-native/Libraries/MutationObserver/NativeMutationObserver.h index cbf7120a49d56a..b7c2eab986d930 100644 --- a/packages/react-native/Libraries/MutationObserver/NativeMutationObserver.h +++ b/packages/react-native/Libraries/MutationObserver/NativeMutationObserver.h @@ -17,7 +17,7 @@ namespace facebook::react { using NativeMutationObserverObserveOptions = - NativeMutationObserverCxxBaseNativeMutationObserverObserveOptions< + NativeMutationObserverCxxNativeMutationObserverObserveOptions< // mutationObserverId MutationObserverId, // targetShadowNode @@ -27,15 +27,10 @@ using NativeMutationObserverObserveOptions = template <> struct Bridging - : NativeMutationObserverCxxBaseNativeMutationObserverObserveOptionsBridging< - // mutationObserverId - MutationObserverId, - // targetShadowNode - jsi::Object, - // subtree - bool> {}; - -using NativeMutationRecord = NativeMutationObserverCxxBaseNativeMutationRecord< + : NativeMutationObserverCxxNativeMutationObserverObserveOptionsBridging< + NativeMutationObserverObserveOptions> {}; + +using NativeMutationRecord = NativeMutationObserverCxxNativeMutationRecord< // mutationObserverId MutationObserverId, // target @@ -47,15 +42,8 @@ using NativeMutationRecord = NativeMutationObserverCxxBaseNativeMutationRecord< template <> struct Bridging - : NativeMutationObserverCxxBaseNativeMutationRecordBridging< - // mutationObserverId - MutationObserverId, - // target - jsi::Value, - // addedNodes - std::vector, - // removedNodes - std::vector> {}; + : NativeMutationObserverCxxNativeMutationRecordBridging< + NativeMutationRecord> {}; class NativeMutationObserver : public NativeMutationObserverCxxSpec, diff --git a/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.h b/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.h index bc55f2476d2132..c5e7c3cc4b8ec4 100644 --- a/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.h +++ b/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.h @@ -20,7 +20,7 @@ class PerformanceEntryReporter; using RawPerformanceEntryType = int32_t; -using RawPerformanceEntry = NativePerformanceObserverCxxBaseRawPerformanceEntry< +using RawPerformanceEntry = NativePerformanceObserverCxxRawPerformanceEntry< std::string, RawPerformanceEntryType, double, @@ -32,25 +32,18 @@ using RawPerformanceEntry = NativePerformanceObserverCxxBaseRawPerformanceEntry< template <> struct Bridging - : NativePerformanceObserverCxxBaseRawPerformanceEntryBridging< - std::string, - RawPerformanceEntryType, - double, - double, - std::optional, - std::optional, - std::optional> {}; + : NativePerformanceObserverCxxRawPerformanceEntryBridging< + RawPerformanceEntry> {}; using GetPendingEntriesResult = - NativePerformanceObserverCxxBaseGetPendingEntriesResult< + NativePerformanceObserverCxxGetPendingEntriesResult< std::vector, uint32_t>; template <> struct Bridging - : NativePerformanceObserverCxxBaseGetPendingEntriesResultBridging< - std::vector, - uint32_t> {}; + : NativePerformanceObserverCxxGetPendingEntriesResultBridging< + GetPendingEntriesResult> {}; #pragma mark - implementation diff --git a/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.h b/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.h index a13f8336b5fa9a..ed2e3aaaf91c69 100644 --- a/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.h +++ b/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.h @@ -24,35 +24,27 @@ namespace facebook::react { #pragma mark - Structs using ConstantsStruct = - NativeCxxModuleExampleCxxBaseConstantsStruct; + NativeCxxModuleExampleCxxConstantsStruct; template <> struct Bridging - : NativeCxxModuleExampleCxxBaseConstantsStructBridging< - bool, - int32_t, - std::string> {}; + : NativeCxxModuleExampleCxxConstantsStructBridging {}; -using ObjectStruct = NativeCxxModuleExampleCxxBaseObjectStruct< +using ObjectStruct = NativeCxxModuleExampleCxxObjectStruct< int32_t, std::string, std::optional>; template <> struct Bridging - : NativeCxxModuleExampleCxxBaseObjectStructBridging< - int32_t, - std::string, - std::optional> {}; + : NativeCxxModuleExampleCxxObjectStructBridging {}; using ValueStruct = - NativeCxxModuleExampleCxxBaseValueStruct; + NativeCxxModuleExampleCxxValueStruct; template <> -struct Bridging : NativeCxxModuleExampleCxxBaseValueStructBridging< - double, - std::string, - ObjectStruct> {}; +struct Bridging + : NativeCxxModuleExampleCxxValueStructBridging {}; #pragma mark - enums enum CustomEnumInt { A = 23, B = 42 };