Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce export count by separating bridge and implementation #113

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

stevenbrix
Copy link
Collaborator

@stevenbrix stevenbrix commented Oct 26, 2023

this PR seperates the bridge and implementation and makes all implementation of interfaces internal.

prior to this pr the "implementation" served two purposes:

  1. defining how to translate between C<->swift for the InterfaceWrapper.
  2. providing Swift implementations for interfaces

The InterfaceWrapper has to be public so that it can be referenced across modules. However, we don't technically need to have the implementation be public. The only thing that needs to be public is the Bridge. The Bridge is what tells the wrapper how to translate between C pointers and Swift objects. The wrapper takes the contract specified by the Bridge and actually holds the VTable and Swift objects. This wrapper is passed to WinRT and is also what knows how to unwrap a pointer via checking for the ISwiftImplemented interface.

Future improvements could fold the bridge into the wrapper, but this is a good first step.

This reduces the number of exports in WinUI.dll by 7k. Since marking APIs as internal doesn't reduce exports in debug builds, future reductions would be to write types on a per file basis. This would let us mark certain details as fileprivate

FIXES WIN-915

@stevenbrix stevenbrix requested a review from a team as a code owner October 26, 2023 18:41
@linear
Copy link

linear bot commented Oct 26, 2023

Copy link
Contributor

@tristanlabelle tristanlabelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!! Looking forward to see the impact on the export count!

@stevenbrix stevenbrix merged commit cf78185 into main Oct 27, 2023
1 check passed
@stevenbrix stevenbrix deleted the steve/rename-impl-to-bridge branch October 27, 2023 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants