-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stdlibs): remove support for linkedType in native bindings (#1700)
Split from #1695 for ease of reviewing. Related to #814. Merge order: 1. #1700 (this one!) 2. #1702 3. #1695 I scrapped the "linked identifier" feature of native bindings. The reasoning mostly stems from the changes subsequently implemented in #1695, as having "linked identifiers" means that: - the Gno linked types must have a different name from Go's if they are within the same package, so their names don't conflict after transpilation - in order for the "linked types" to match in the generated code, the AST has to be rewritten to make a type alias (ie. `type Address = crypto.Bech32Address`) - while still allowing the type to be "modifiable" by the std package, because we want to add our own methods -- this is not possible for imported types, obviously - and if we try removing methods, this [creates errors](https://drop.howl.moe/9ba0d53115-Screenshot_from_2024-02-27_23-50-34.png) because the methods on the original types don't match 1-1 those implemented in AST Although, I think a decent case can be made besides easing our (my) life in transpiling: - Under the hood, the linked type mechanism works with `Store.AddGno2GoMapping`. This uses gonative (read: the bane of my existence -- #1361). If we remove all linked types, we can still pass data between Go and Gno using type literals, which don't incur in naming conflicts. - This also makes the workings of "native bindings" clearer in general, as they don't have any special linked types (which were currently hardcoded in the misc/genstd source) ## Reviewing notes - `Banker` got severely refactored as it was mapping entire go interfaces into Go; it now uses simple elementary functions, with its old behaviour split between Go and Gno. - many other functions (std/native.gno) have also been changed so that their native function only uses primitive types (so everything that used an Address, now uses a string). - Due to the naming conflicts already mentioned, Go's Banker has been changed to `BankerInterface` so that it doesn't conflict. - AddGo2GnoMapping is unused in the codebase. This has been removed from Store to disencourage any further usage; removal of Go2Gno code is out of scope for this PR (see #1361)
- Loading branch information
Showing
21 changed files
with
696 additions
and
1,004 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
Oops, something went wrong.