Commit 07261d0
Use hasteModuleName for C++ Turbo Module structs (#44630)
Summary:
Pull Request resolved: #44630
Changelog:
[General][Breaking] Use hasteModuleName for C++ Turbo Module structs
This changes the names of C++ Turbo Modules structs to use the `hasteModuleName`.
Example: `NativeMyAbcModule.js` with this spec:
```
export type ValueStruct = {
x: number,
y: string,
z: ObjectStruct,
};
export interface Spec extends TurboModule {
+getValueStruct: () => ValueStruct
}
export default (TurboModuleRegistry.get<Spec>('MyAbcModuleCxx'): ?Spec);
```
Before now we generated a base C++ struct with the name:
```
MyAbcModuleCxxValueStruct
^^^
```
Now the generate name is:
```
NativeMyAbcModuleValueStruct
^^^^^^
```
## Changes:
- No `Cxx` injected anymore
- Ensure base struct is `Native` prefixed (all RN JS TM specs start with it)
## Why?
- The `Cxx` extension is a temporary hint to react-native-codegen to enable extra capabilities and might disappear eventually
- The C++ base struct name should be 'stable'
- The name of the exported TM JS spec `TurboModuleRegistry.get<Spec>(...)` is abritrary, the hasteName is not
- The name of the RN JS TM spec must start with `Native` which better guarantees a consistent naming scheme for these generated base class
- The C++ Turbo Module base class has now the same prefix as the generated structs - `NativeMyAbcModule` for the example above
Reviewed By: cipolleschi
Differential Revision: D57599257
fbshipit-source-id: 4fafe6c7e920737fa766bd7e8e68e521f608e7751 parent 95de14d commit 07261d0
7 files changed
Lines changed: 121 additions & 124 deletions
File tree
- packages
- react-native-codegen
- e2e/__tests__/modules/__snapshots__
- src/generators/modules
- __tests__/__snapshots__
- react-native/ReactCommon/react/nativemodule
- intersectionobserver
- mutationobserver
- webperformance
- rn-tester/NativeCxxModuleExample
Lines changed: 40 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
923 | 923 | | |
924 | 924 | | |
925 | 925 | | |
926 | | - | |
| 926 | + | |
927 | 927 | | |
928 | 928 | | |
929 | | - | |
| 929 | + | |
930 | 930 | | |
931 | | - | |
| 931 | + | |
932 | 932 | | |
933 | 933 | | |
934 | 934 | | |
935 | 935 | | |
936 | 936 | | |
937 | | - | |
| 937 | + | |
938 | 938 | | |
939 | 939 | | |
940 | 940 | | |
| |||
1117 | 1117 | | |
1118 | 1118 | | |
1119 | 1119 | | |
1120 | | - | |
| 1120 | + | |
1121 | 1121 | | |
1122 | 1122 | | |
1123 | | - | |
| 1123 | + | |
1124 | 1124 | | |
1125 | | - | |
| 1125 | + | |
1126 | 1126 | | |
1127 | 1127 | | |
1128 | 1128 | | |
1129 | 1129 | | |
1130 | 1130 | | |
1131 | | - | |
| 1131 | + | |
1132 | 1132 | | |
1133 | 1133 | | |
1134 | 1134 | | |
| |||
1311 | 1311 | | |
1312 | 1312 | | |
1313 | 1313 | | |
1314 | | - | |
| 1314 | + | |
1315 | 1315 | | |
1316 | 1316 | | |
1317 | | - | |
| 1317 | + | |
1318 | 1318 | | |
1319 | | - | |
| 1319 | + | |
1320 | 1320 | | |
1321 | 1321 | | |
1322 | 1322 | | |
1323 | 1323 | | |
1324 | 1324 | | |
1325 | | - | |
| 1325 | + | |
1326 | 1326 | | |
1327 | 1327 | | |
1328 | 1328 | | |
| |||
1505 | 1505 | | |
1506 | 1506 | | |
1507 | 1507 | | |
1508 | | - | |
| 1508 | + | |
1509 | 1509 | | |
1510 | 1510 | | |
1511 | | - | |
| 1511 | + | |
1512 | 1512 | | |
1513 | | - | |
| 1513 | + | |
1514 | 1514 | | |
1515 | 1515 | | |
1516 | 1516 | | |
1517 | 1517 | | |
1518 | 1518 | | |
1519 | | - | |
| 1519 | + | |
1520 | 1520 | | |
1521 | 1521 | | |
1522 | 1522 | | |
| |||
1701 | 1701 | | |
1702 | 1702 | | |
1703 | 1703 | | |
1704 | | - | |
| 1704 | + | |
1705 | 1705 | | |
1706 | 1706 | | |
1707 | | - | |
| 1707 | + | |
1708 | 1708 | | |
1709 | | - | |
| 1709 | + | |
1710 | 1710 | | |
1711 | 1711 | | |
1712 | 1712 | | |
1713 | 1713 | | |
1714 | 1714 | | |
1715 | | - | |
| 1715 | + | |
1716 | 1716 | | |
1717 | 1717 | | |
1718 | 1718 | | |
| |||
2877 | 2877 | | |
2878 | 2878 | | |
2879 | 2879 | | |
2880 | | - | |
| 2880 | + | |
2881 | 2881 | | |
2882 | 2882 | | |
2883 | | - | |
| 2883 | + | |
2884 | 2884 | | |
2885 | | - | |
| 2885 | + | |
2886 | 2886 | | |
2887 | 2887 | | |
2888 | 2888 | | |
2889 | 2889 | | |
2890 | 2890 | | |
2891 | | - | |
| 2891 | + | |
2892 | 2892 | | |
2893 | 2893 | | |
2894 | 2894 | | |
| |||
3071 | 3071 | | |
3072 | 3072 | | |
3073 | 3073 | | |
3074 | | - | |
| 3074 | + | |
3075 | 3075 | | |
3076 | 3076 | | |
3077 | | - | |
| 3077 | + | |
3078 | 3078 | | |
3079 | | - | |
| 3079 | + | |
3080 | 3080 | | |
3081 | 3081 | | |
3082 | 3082 | | |
3083 | 3083 | | |
3084 | 3084 | | |
3085 | | - | |
| 3085 | + | |
3086 | 3086 | | |
3087 | 3087 | | |
3088 | 3088 | | |
| |||
3265 | 3265 | | |
3266 | 3266 | | |
3267 | 3267 | | |
3268 | | - | |
| 3268 | + | |
3269 | 3269 | | |
3270 | 3270 | | |
3271 | | - | |
| 3271 | + | |
3272 | 3272 | | |
3273 | | - | |
| 3273 | + | |
3274 | 3274 | | |
3275 | 3275 | | |
3276 | 3276 | | |
3277 | 3277 | | |
3278 | 3278 | | |
3279 | | - | |
| 3279 | + | |
3280 | 3280 | | |
3281 | 3281 | | |
3282 | 3282 | | |
| |||
3459 | 3459 | | |
3460 | 3460 | | |
3461 | 3461 | | |
3462 | | - | |
| 3462 | + | |
3463 | 3463 | | |
3464 | 3464 | | |
3465 | | - | |
| 3465 | + | |
3466 | 3466 | | |
3467 | | - | |
| 3467 | + | |
3468 | 3468 | | |
3469 | 3469 | | |
3470 | 3470 | | |
3471 | 3471 | | |
3472 | 3472 | | |
3473 | | - | |
| 3473 | + | |
3474 | 3474 | | |
3475 | 3475 | | |
3476 | 3476 | | |
| |||
3655 | 3655 | | |
3656 | 3656 | | |
3657 | 3657 | | |
3658 | | - | |
| 3658 | + | |
3659 | 3659 | | |
3660 | 3660 | | |
3661 | | - | |
| 3661 | + | |
3662 | 3662 | | |
3663 | | - | |
| 3663 | + | |
3664 | 3664 | | |
3665 | 3665 | | |
3666 | 3666 | | |
3667 | 3667 | | |
3668 | 3668 | | |
3669 | | - | |
| 3669 | + | |
3670 | 3670 | | |
3671 | 3671 | | |
3672 | 3672 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| |||
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
533 | | - | |
| 533 | + | |
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
| |||
0 commit comments