-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(go): stop emitting unused fields in go structs (#2612)
Go struct fields used to be emitted for all properties of any type, including for go structs merely there to act as a proxy to a JS object. Those properties were never accessed (neither set not read), and could have been cause for confusion. They additionally needlessly increased the memory footprint of such data types. This changes the code generation to no longer emit fields on go structs that are intended as proxies to JS objects, instead embedding the base type(s) (super-class and/or super-interfaces) to properly inherit their methods without duplicating every declaration; and uses a `byte` placeholder when needed to ensure no 0-width struct is ever generated (go would have those take 0 bytes of memory, and as a consequence, any such vlaue is deemed equal to any other, which is not what we want). In cases when a member is inherited from more than one parent, that member is re-declared on the descendant type, as otherwise the promotion is ambiguous. This implied making a change to the method registration functions, such that each type (class and interface) registers a proxy `maker` function that is used by the runtime library to properly initialize jsii proxy instances of objects without requiring user intervention. This makes it safe to operate even when embedding data structures from other libraries. Additionally, it enables hiding the JS proxy structs from the exported APIs, which further reduces the risk of mis-use.
- Loading branch information
1 parent
1f8f022
commit adfe8b9
Showing
17 changed files
with
3,799 additions
and
3,690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.