Commit 1a8afa6
[vm/ffi] Allow omitting native types for
This change simplifies working with `@Native`-annotated functions by allowing the native type to be omitted when it can be inferred from the Dart function's signature. While this was previously supported for `@Native` fields, it now applies to functions as well.
Before this change, you needed to specify the native type explicitly:
```
@Native<Void Function(Pointer)>()
external void free(Pointer p);
```
After this change, the native type can now be omitted if it's clear from the Dart signature:
```
@Native()
external void free(Pointer p);
```
TEST=tests/ffi/native_assets/*
CoreLibraryReviewExempt: VM only
Closes: #54810
Change-Id: Ied5407fcd2f49d85284cb7817f0c8cad2a73626b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400840
Reviewed-by: Daco Harkes <[email protected]>
Commit-Queue: Daco Harkes <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
Reviewed-by: Moritz Sümmermann <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>@Native functions1 parent 31f97ea commit 1a8afa6
File tree
24 files changed
+762
-118
lines changed- pkg
- analysis_server/lib/src/services/correction
- analyzer
- lib/src
- dart/error
- error
- generated
- test/src/diagnostics
- tool/diagnostics
- front_end
- vm
- lib/modular/transformations/ffi
- testcases/transformations/ffi
- sdk/lib/ffi
- tests/ffi
- native_assets
- static_checks
- tools
24 files changed
+762
-118
lines changedLines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6647 | 6647 | | |
6648 | 6648 | | |
6649 | 6649 | | |
| 6650 | + | |
| 6651 | + | |
| 6652 | + | |
| 6653 | + | |
| 6654 | + | |
| 6655 | + | |
| 6656 | + | |
| 6657 | + | |
| 6658 | + | |
| 6659 | + | |
| 6660 | + | |
| 6661 | + | |
6650 | 6662 | | |
6651 | 6663 | | |
6652 | 6664 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1792 | 1792 | | |
1793 | 1793 | | |
1794 | 1794 | | |
| 1795 | + | |
| 1796 | + | |
1795 | 1797 | | |
1796 | 1798 | | |
1797 | 1799 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
390 | 400 | | |
391 | 401 | | |
392 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
| 635 | + | |
635 | 636 | | |
636 | 637 | | |
637 | 638 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
| |||
493 | 496 | | |
494 | 497 | | |
495 | 498 | | |
496 | | - | |
497 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
498 | 529 | | |
499 | 530 | | |
500 | 531 | | |
| |||
512 | 543 | | |
513 | 544 | | |
514 | 545 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | 546 | | |
519 | 547 | | |
520 | 548 | | |
| |||
683 | 711 | | |
684 | 712 | | |
685 | 713 | | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
691 | 728 | | |
692 | 729 | | |
693 | 730 | | |
| |||
1707 | 1744 | | |
1708 | 1745 | | |
1709 | 1746 | | |
1710 | | - | |
1711 | | - | |
1712 | | - | |
1713 | | - | |
1714 | | - | |
1715 | | - | |
1716 | | - | |
1717 | | - | |
1718 | | - | |
| 1747 | + | |
| 1748 | + | |
1719 | 1749 | | |
1720 | 1750 | | |
1721 | 1751 | | |
1722 | 1752 | | |
1723 | 1753 | | |
1724 | 1754 | | |
1725 | 1755 | | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
1726 | 1762 | | |
1727 | 1763 | | |
1728 | | - | |
1729 | | - | |
1730 | | - | |
1731 | | - | |
1732 | | - | |
1733 | | - | |
1734 | | - | |
1735 | | - | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
1739 | 1780 | | |
1740 | | - | |
1741 | | - | |
1742 | 1781 | | |
1743 | | - | |
1744 | | - | |
1745 | | - | |
1746 | | - | |
1747 | | - | |
1748 | | - | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
1749 | 1811 | | |
1750 | 1812 | | |
1751 | 1813 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19212 | 19212 | | |
19213 | 19213 | | |
19214 | 19214 | | |
| 19215 | + | |
| 19216 | + | |
| 19217 | + | |
| 19218 | + | |
| 19219 | + | |
| 19220 | + | |
| 19221 | + | |
| 19222 | + | |
| 19223 | + | |
| 19224 | + | |
| 19225 | + | |
| 19226 | + | |
| 19227 | + | |
| 19228 | + | |
| 19229 | + | |
| 19230 | + | |
| 19231 | + | |
| 19232 | + | |
| 19233 | + | |
| 19234 | + | |
| 19235 | + | |
| 19236 | + | |
| 19237 | + | |
| 19238 | + | |
| 19239 | + | |
| 19240 | + | |
| 19241 | + | |
| 19242 | + | |
| 19243 | + | |
| 19244 | + | |
| 19245 | + | |
| 19246 | + | |
| 19247 | + | |
| 19248 | + | |
| 19249 | + | |
| 19250 | + | |
| 19251 | + | |
| 19252 | + | |
| 19253 | + | |
| 19254 | + | |
| 19255 | + | |
| 19256 | + | |
| 19257 | + | |
19215 | 19258 | | |
19216 | 19259 | | |
19217 | 19260 | | |
| |||
0 commit comments