Repository navigation
Concretize bindings templates - #788
Merged
TheBlueMatt merged 10 commits intoFeb 11, 2021
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## main #788 +/- ##
==========================================
+ Coverage 90.75% 90.80% +0.04%
==========================================
Files 44 44
Lines 24119 24073 -46
==========================================
- Hits 21890 21859 -31
+ Misses 2229 2214 -15
Continue to review full report at Codecov.
|
valentinewallace
approved these changes
Feb 10, 2021
valentinewallace
left a comment
Contributor
There was a problem hiding this comment.
Not my most meticulous review, but this LGTM 🥇
Exciting to get closer to support for wasm_bindgen + nice code simplifications
While the type aliasing trick works great for cbindgen, wasm_bindgen doesn't support it and requires fully-concrete types. In order to better support wasm_bindgen in the future, we do so here, adding a function which manually writes out almost the exact thing which was templated previously in concrete form. As a nice side-effect, we no longer have to allocate and free a u8 for generic parameters which were `()` (though we still do in some conversion functions, which we can get rid of when we similarly concretize all generics fully).
Previously we'd segfault trying to deref the NULL page, but there is no reason to not simply clone by creating another opaque instance with a null inner. This comes up specifically when cloning ChannelSigners as the pubkeys instance is NULL on construction before get_pubkeys is called.
TheBlueMatt
force-pushed
the
2020-02-concrete-bindings
branch
from
February 11, 2021 03:28
26a2260 to
1d089ca
Compare
Collaborator
Author
The only API change outside of additional derives is to change the inner field in `DecodeError::Io()` to an `std::io::ErrorKind` instead of an `std::io::Error`. While `std::io::Error` obviously makes more sense in context, it doesn't support Clone, and the inner error largely doesn't have a lot of value on its own.
TheBlueMatt
force-pushed
the
2020-02-concrete-bindings
branch
from
February 11, 2021 03:34
1d089ca to
0816cf4
Compare
TheBlueMatt
force-pushed
the
2020-02-concrete-bindings
branch
from
February 11, 2021 03:39
0816cf4 to
c2fd683
Compare
Collaborator
Author
|
No reason to sit on this given its Basically Just Bindings (tm). Gonna merge. Non-bindings diff is below. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(based on #787 because I'm too lazy to rebase).
This concertizes the templates in the bindings, making the bindings Rust code a little closer to what we end up with in C, leaning a little less on cbindgen. It also significantly reduces the template-specific type resolution logic, which is a big win.
Finally, while we're at it, we add _clone methods for template types, making downstream usage much simpler.