Simplify C++ TM struct generation (#41645)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41645

Right now, when defining concrete structs and Bridging headers for Cxx TMs we need to define their member types twice:
```
using ConstantsStruct =
    NativeCxxModuleExampleCxxBaseConstantsStruct<bool, int32_t, std::string>;

template <>
struct Bridging<ConstantsStruct>
    : NativeCxxModuleExampleCxxBaseConstantsStructBridging<
          bool,
          int32_t,
          std::string> {};
```
Now we only need to define those once
```
using ConstantsStruct =
    NativeCxxModuleExampleCxxConstantsStruct<bool, int32_t, std::string>;

template <>
struct Bridging<ConstantsStruct>
    : NativeCxxModuleExampleCxxConstantsStructBridging<ConstantsStruct> {};
```

This change keeps the existing base types untouched - but they will be removed in the next RN version.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D51571453

fbshipit-source-id: 2783bd48bf786ffa80d322d06456b5d6f2d7ba8a
This commit is contained in:
Christoph Purrer
2023-11-27 03:43:28 -08:00
committed by Facebook GitHub Bot
parent b50a7093bc
commit ef9c164f5f
7 changed files with 1445 additions and 143 deletions
@@ -24,35 +24,27 @@ namespace facebook::react {
#pragma mark - Structs
using ConstantsStruct =
NativeCxxModuleExampleCxxBaseConstantsStruct<bool, int32_t, std::string>;
NativeCxxModuleExampleCxxConstantsStruct<bool, int32_t, std::string>;
template <>
struct Bridging<ConstantsStruct>
: NativeCxxModuleExampleCxxBaseConstantsStructBridging<
bool,
int32_t,
std::string> {};
: NativeCxxModuleExampleCxxConstantsStructBridging<ConstantsStruct> {};
using ObjectStruct = NativeCxxModuleExampleCxxBaseObjectStruct<
using ObjectStruct = NativeCxxModuleExampleCxxObjectStruct<
int32_t,
std::string,
std::optional<std::string>>;
template <>
struct Bridging<ObjectStruct>
: NativeCxxModuleExampleCxxBaseObjectStructBridging<
int32_t,
std::string,
std::optional<std::string>> {};
: NativeCxxModuleExampleCxxObjectStructBridging<ObjectStruct> {};
using ValueStruct =
NativeCxxModuleExampleCxxBaseValueStruct<double, std::string, ObjectStruct>;
NativeCxxModuleExampleCxxValueStruct<double, std::string, ObjectStruct>;
template <>
struct Bridging<ValueStruct> : NativeCxxModuleExampleCxxBaseValueStructBridging<
double,
std::string,
ObjectStruct> {};
struct Bridging<ValueStruct>
: NativeCxxModuleExampleCxxValueStructBridging<ValueStruct> {};
#pragma mark - enums
enum CustomEnumInt { A = 23, B = 42 };