Skip to content

Commit

Permalink
Generate enum types instead of using string/number in c++ turbo modul…
Browse files Browse the repository at this point in the history
…es generators (#36030)

Summary:
Pull Request resolved: #36030

Generate enum types in c++ turbo modules.

This would export enums to TM H files such as:
```
enum class NativeEnumTurboModuleStatusNumEnum { Active = 2, Paused = 1, Off = 0 };
```
And then use these enums in the TM schema such as:
```
public:
  virtual StatusStrEnum getStatus(jsi::Runtime &rt, jsi::Object statusProp) = 0;
  virtual StatusNumEnum getStatusState(jsi::Runtime &rt, jsi::Object statusProp) = 0;
  virtual jsi::Object getStateType(jsi::Runtime &rt, StatusStrEnum a, StatusNumEnum b) = 0;
```
Previously, we've only supporting generating these as jsi::String / double, ignoring the enum members.
```
public:
  virtual jsi::String getStatus(jsi::Runtime &rt, jsi::Object statusProp) = 0;
  virtual double getStatusState(jsi::Runtime &rt, jsi::Object statusProp) = 0;
  virtual jsi::Object getStateType(jsi::Runtime &rt, jsi::String a, double b) = 0;
```

Changelog: [General] [Added] Generate enum types instead of using string/number in c++ turbo modules generators

Differential Revision: D42884147

fbshipit-source-id: 730203057a60e586da3083930e643d7301a794b9
  • Loading branch information
vzaidman authored and facebook-github-bot committed Feb 1, 2023
1 parent d0aec9a commit 4274bd0
Show file tree
Hide file tree
Showing 4 changed files with 702 additions and 56 deletions.
Loading

0 comments on commit 4274bd0

Please sign in to comment.