-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix off-by-one error in cxx codegen (#36574)
Summary: Pull Request resolved: #36574 We would previously generate the following codegen for optional args ``` return static_cast<NativeAudioModuleCxxSpecJSI *>(&turboModule)->playAudio( rt, args[0].asString(rt), args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)), args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt)), args[3].asNumber(), count < 4 || args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asObject(rt)), count < 5 || args[5].isNull() || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asObject(rt)), count < 6 || args[6].isNull() || args[6].isUndefined() ? std::nullopt : std::make_optional(args[6].asBool()) ); ``` However, the counts checked are off-by-one, causing us to incorrectly process args. Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args Differential Revision: D44299193 fbshipit-source-id: f00b9f5e09c2f524f9393137346c256d8b6b2979
- Loading branch information
1 parent
4a15f90
commit 0a8164d
Showing
7 changed files
with
981 additions
and
243 deletions.
There are no files selected for viewing
1,000 changes: 800 additions & 200 deletions
1,000
...s/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleCpp-test.js.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
205 changes: 165 additions & 40 deletions
205
...ive-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters