mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook GitHub Bot
parent
b50a7093bc
commit
ef9c164f5f
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user