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 (facebook#36030)

Summary:
Pull Request resolved: facebook#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: 18890e2f12c337d32c7e31a27604249027c1ec37
  • Loading branch information
vzaidman authored and facebook-github-bot committed Feb 1, 2023
1 parent 8c53b7f commit e4eb7b7
Show file tree
Hide file tree
Showing 4 changed files with 702 additions and 56 deletions.
Loading

0 comments on commit e4eb7b7

Please sign in to comment.