Commit c34fa34
Add BigInt Support to C++ Turbo Module Example
Summary:
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 2cc47e7 commit c34fa34
13 files changed
Lines changed: 31 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: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
585 | 589 | | |
586 | 590 | | |
587 | 591 | | |
| |||
870 | 874 | | |
871 | 875 | | |
872 | 876 | | |
873 | | - | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
874 | 880 | | |
875 | 881 | | |
876 | 882 | | |
| |||
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 | |
|---|---|---|---|
| |||
6591 | 6591 | | |
6592 | 6592 | | |
6593 | 6593 | | |
| 6594 | + | |
6594 | 6595 | | |
6595 | 6596 | | |
6596 | 6597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6582 | 6582 | | |
6583 | 6583 | | |
6584 | 6584 | | |
| 6585 | + | |
6585 | 6586 | | |
6586 | 6587 | | |
6587 | 6588 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8781 | 8781 | | |
8782 | 8782 | | |
8783 | 8783 | | |
| 8784 | + | |
8784 | 8785 | | |
8785 | 8786 | | |
8786 | 8787 | | |
| |||
0 commit comments