Commit 552ae4d
Add BigInt Support to C++ Turbo Module Example
Summary:
X-link: #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 565076a commit 552ae4d
13 files changed
Lines changed: 30 additions & 2 deletions
File tree
- packages
- react-native/ReactCommon/react/nativemodule/core
- ReactCommon
- platform/ios/ReactCommon
- rn-tester
- NativeCxxModuleExample
- js/examples/TurboModule
- scripts/cxx-api/api-snapshots
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 | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
327 | 328 | | |
328 | 329 | | |
329 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
330 | 335 | | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| 154 | + | |
153 | 155 | | |
| 156 | + | |
| 157 | + | |
154 | 158 | | |
155 | 159 | | |
156 | 160 | | |
| |||
287 | 291 | | |
288 | 292 | | |
289 | 293 | | |
290 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
291 | 297 | | |
292 | 298 | | |
293 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6590 | 6590 | | |
6591 | 6591 | | |
6592 | 6592 | | |
| 6593 | + | |
6593 | 6594 | | |
6594 | 6595 | | |
6595 | 6596 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6581 | 6581 | | |
6582 | 6582 | | |
6583 | 6583 | | |
| 6584 | + | |
6584 | 6585 | | |
6585 | 6586 | | |
6586 | 6587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8780 | 8780 | | |
8781 | 8781 | | |
8782 | 8782 | | |
| 8783 | + | |
8783 | 8784 | | |
8784 | 8785 | | |
8785 | 8786 | | |
| |||
0 commit comments