Commit c24b24a
Add BigInt Support to C++ Turbo Module Example (#56017)
Summary:
Pull Request resolved: #56017
This diff adds BigInt method support to the C++ sample Turbo Module (NativeCxxModuleExample),
demonstrating how to use `facebook::react::BigInt` with the bridging layer.
Changes:
- Added getBigInt method to NativeCxxModuleExample.cpp/.h using
`facebook::react::BigInt` as the C++ type
- Added getBigInt to NativeCxxModuleExample.js spec
- Added BigIntKind to TurboModule.h for the method dispatch infrastructure
- Updated RCTTurboModule.mm to handle BigIntKind in the iOS TurboModule bridge
- Fixed BigInt rendering in NativeCxxModuleExampleExample.js — JSON.stringify()
cannot serialize BigInt, so bigint values are now rendered via .toString()
The `facebook::react::BigInt` wrapper class (introduced in the bridging diff)
stores values as `std::variant<int64_t, uint64_t>`, preserving signedness.
The `Bridging<BigInt>` specialization handles conversion to/from `jsi::BigInt`.
Example:
```cpp
BigInt NativeCxxModuleExample::getBigInt(jsi::Runtime& rt, BigInt arg) {
return arg;
}
```
Changelog: [General][Added] - Add BigInt bridging support for Turbo Modules
Differential Revision: D952322651 parent d999f18 commit c24b24a
7 files changed
Lines changed: 24 additions & 2 deletions
File tree
- packages
- react-native/ReactCommon/react/nativemodule/core
- ReactCommon
- platform/ios/ReactCommon
- rn-tester
- NativeCxxModuleExample
- js/examples/TurboModule
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
529 | 533 | | |
530 | 534 | | |
531 | 535 | | |
| |||
813 | 817 | | |
814 | 818 | | |
815 | 819 | | |
816 | | - | |
| 820 | + | |
| 821 | + | |
817 | 822 | | |
818 | 823 | | |
819 | 824 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
268 | 273 | | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| 126 | + | |
125 | 127 | | |
| 128 | + | |
| 129 | + | |
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
| |||
259 | 263 | | |
260 | 264 | | |
261 | 265 | | |
262 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
263 | 269 | | |
264 | 270 | | |
265 | 271 | | |
| |||
0 commit comments