Commit 4e048fa
Add BigInt Support to Objective-C Turbo Module (#56020)
Summary:
Pull Request resolved: #56020
This diff adds BigInt method support to the Objective-C sample Turbo Module,
demonstrating how to use 64-bit integers with BigInt bridging on iOS.
Changes:
- Added getBigInt method declaration in RCTNativeSampleTurboModuleSpec.h
using C++ int64_t type
- Added host function binding in RCTNativeSampleTurboModuleSpec.mm using BigIntKind
- Implemented getBigInt in RCTSampleTurboModule.mm using
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD
- Fixed BigInt rendering in NativeCxxModuleExampleExample.js and
SampleTurboModuleExample.js — JSON.stringify() cannot serialize BigInt,
so bigint values are now rendered via .toString()
The ObjC bridge maps getBigInt to an NSNumber* return with BigIntKind, which
instructs the TurboModule infrastructure to convert via
jsi::BigInt::fromInt64().
## Conversion Table
| NSNumber Method | Underlying Type | Min | Max |
| --- | --- | --- | --- |
| numberWithChar: | char | -128 | 127 |
| numberWithShort: | short | -32,768 | 32,767 |
| numberWithInt: | int | -2,147,483,648 | 2,147,483,647 |
| numberWithLongLong: | long long | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 |
| numberWithUnsignedLongLong: | unsigned long long | 0 | 18,446,744,073,709,551,615 |
Changelog: [iOS][Added] - Add BigInt Support to Objective-C Turbo Module
Differential Revision: D952322661 parent e89b115 commit 4e048fa
4 files changed
Lines changed: 72 additions & 3 deletions
File tree
- packages/react-native/ReactCommon/react/nativemodule
- core/platform/ios/ReactCommon
- samples/platform/ios/ReactCommon
Lines changed: 52 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
191 | 202 | | |
192 | 203 | | |
193 | 204 | | |
| |||
526 | 537 | | |
527 | 538 | | |
528 | 539 | | |
529 | | - | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
530 | 548 | | |
531 | 549 | | |
532 | 550 | | |
| |||
630 | 648 | | |
631 | 649 | | |
632 | 650 | | |
633 | | - | |
| 651 | + | |
634 | 652 | | |
635 | | - | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
636 | 685 | | |
637 | 686 | | |
638 | 687 | | |
| |||
Lines changed: 2 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 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
217 | 227 | | |
218 | 228 | | |
219 | 229 | | |
| |||
275 | 285 | | |
276 | 286 | | |
277 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
278 | 291 | | |
279 | 292 | | |
280 | 293 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
| |||
0 commit comments