Commit 56129fe
Respect enum values for TurboModule c++ codegen (facebook#56478)
Summary:
Pull Request resolved: facebook#56478
Changelog: [General] [Fixed] - Respect enum values for TurboModule c++ codegen
Defining an enum like this:
```js
export enum CustomPropertyEditor {
BitMask = 0,
Entity = 1,
Slider = 2,
AudioEvent = 3,
CollisionLayer = 4,
MaterialComponentDeprecatedProperty = 5,
MeshMaterialList = 6,
Submesh = 7,
// CoreUiLayout (8) removed — rendered identically to ClassOrList
MaterialMapJson = 9,
AnimationTable = 10,
SkeletonAsset = 11,
NavMeshAreaType = 12,
VFXAsset = 13,
Table = 14,
VariableTable = 15,
AudioBus = 16,
LodSettings = 17,
WorldSearch = 18,
EntityMaterialList = 19,
NpcId = 20,
LightingModelVersion = 21,
PlatformSelector = 22,
ComponentReference = 23,
}
```
(notice number 8 ), will cause the generated enum to actually look like:
```
enum class NativeEditableObjectModuleCustomPropertyEditor {
BitMask, Entity, Slider, AudioEvent, CollisionLayer,
MaterialComponentDeprecatedProperty, MeshMaterialList, Submesh,
MaterialMapJson, AnimationTable, ...
};
```
in other words, the values don't match up after the core ui value. This is quite dangerous and I'm surprised no one has ever noticed that
This diff fixes things such that if an integer value is explicitly assigned, the value is preserved in the generated enum.
Reviewed By: christophpurrer
Differential Revision: D101229471
fbshipit-source-id: 366ea2d16ac74e112f1b68c5ad3d0877dedb918c1 parent 6530092 commit 56129fe
3 files changed
Lines changed: 14 additions & 6 deletions
File tree
- packages/react-native-codegen
- e2e/deep_imports/__tests__/modules/__snapshots__
- src/generators/modules
- __tests__/__snapshots__
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
1749 | 1749 | | |
1750 | 1750 | | |
1751 | 1751 | | |
1752 | | - | |
| 1752 | + | |
1753 | 1753 | | |
1754 | 1754 | | |
1755 | 1755 | | |
| |||
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
540 | | - | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
541 | 549 | | |
542 | 550 | | |
543 | 551 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
1713 | 1713 | | |
1714 | 1714 | | |
1715 | 1715 | | |
1716 | | - | |
| 1716 | + | |
1717 | 1717 | | |
1718 | 1718 | | |
1719 | 1719 | | |
| |||
1741 | 1741 | | |
1742 | 1742 | | |
1743 | 1743 | | |
1744 | | - | |
| 1744 | + | |
1745 | 1745 | | |
1746 | 1746 | | |
1747 | 1747 | | |
| |||
0 commit comments