Commit 0dbb2c2
committed
winmd-inspect: render WinRT generic interfaces ABI-erased
The generic-interface rendering previously projected a generic ABI protocol
(`protocol Name<T…>` with `associatedtype`s) plus a wrapper forwarding own
methods — the shape-1 foundation, which the non-generic-closed-base wall made
a dead end for base inheritance. Pivot the rendering onto the ABI-erased shape
windows-rs draws, reusing the merged `SignatureType.abi(…)`/`classification`
keystone:
- The ABI protocol is now NON-generic. Each method requirement reads every
parameter/return through its ABI-erased spelling: a reference-typed slot
(an interface, runtime class, delegate, generic-interface instantiation, or
`System.Object`) is the opaque interface pointer, a value-typed slot keeps
its own ABI. No generic parameters, no associated types.
- The public generic `struct` wrapper `Name<T…>` keeps the typed Swift
surface: each method takes/returns the decoded typed parameters and casts
the typed value to the erased pointer (and the erased result back) as it
forwards through `base` — `unsafeBitCast`, the text analogue of
windows-rs's `transmute_copy` across the vtable. A value slot needs no cast
(its typed and erased spellings coincide), so it forwards unchanged.
- Base inheritance becomes trivial and is INCLUDED: a non-generic ABI
protocol inherits its base's non-generic ABI protocol by plain protocol
inheritance — a generic base inherits `<stripped>ABI` (no arguments, no
`where`-constraints), a non-generic base (`IInspectable`) is inherited
unchanged. The non-generic-closed-base wall cannot occur.
The `Database+SQL` decode layer gains erased-ABI (`abi(return:)`/
`abi(parameter:)`) and classification (`reference(return:)`/
`reference(parameter:)`) accessors beside the existing typed `decode(…)`, all
sharing the extracted signature-navigation. `Shell` composes the per-slot
erased/typed spellings and the forwarding cast into the render context; the
`com.mustache` `{{#generic}}` arm emits the erased protocol + casting wrapper.
The non-generic `{{^generic}}` path is byte-identical.
The generated Swift is swiftc-typecheck-verified for a simple generic
interface (erased/cast element return), a generic interface with a generic
base (plain non-generic ABI inheritance, wrapper casts), an out/interface-array
method (erased element under the pointer), and a keyword-named generic
parameter.1 parent f160ca0 commit 0dbb2c2
4 files changed
Lines changed: 409 additions & 137 deletions
File tree
- Sources/winmd-inspect
- Resources/Templates
- Tests/winmd-inspectTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
767 | | - | |
768 | | - | |
769 | | - | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
770 | 770 | | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
780 | 778 | | |
781 | 779 | | |
782 | 780 | | |
| |||
785 | 783 | | |
786 | 784 | | |
787 | 785 | | |
788 | | - | |
789 | | - | |
| 786 | + | |
790 | 787 | | |
791 | 788 | | |
792 | | - | |
793 | | - | |
794 | | - | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
795 | 793 | | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
800 | 798 | | |
801 | 799 | | |
802 | 800 | | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
809 | 804 | | |
810 | 805 | | |
811 | 806 | | |
| |||
829 | 824 | | |
830 | 825 | | |
831 | 826 | | |
832 | | - | |
833 | | - | |
834 | | - | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
835 | 901 | | |
836 | 902 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | | - | |
| 22 | + | |
18 | 23 | | |
19 | | - | |
20 | | - | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
0 commit comments