[feature] #2491: Enum support in FFi#2625
Merged
mversic merged 1 commit intohyperledger-iroha:iroha2-devfrom Sep 29, 2022
Merged
[feature] #2491: Enum support in FFi#2625mversic merged 1 commit intohyperledger-iroha:iroha2-devfrom
mversic merged 1 commit intohyperledger-iroha:iroha2-devfrom
Conversation
mversic
commented
Aug 15, 2022
mversic
commented
Aug 15, 2022
Erigara
reviewed
Aug 16, 2022
Erigara
reviewed
Aug 17, 2022
appetrosyan
reviewed
Aug 22, 2022
e58b137 to
1922773
Compare
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 23, 2022
77372a5 to
65b190d
Compare
This was referenced Sep 26, 2022
Closed
c391cd2 to
aff21d0
Compare
appetrosyan
reviewed
Sep 27, 2022
7a169ac to
5b4f3ae
Compare
This was referenced Sep 28, 2022
Signed-off-by: Marin Veršić <marin.versic101@gmail.com> add support for data-carrying enums Signed-off-by: Marin Veršić <marin.versic101@gmail.com> refactor ffi library implementation Signed-off-by: Marin Veršić <marin.versic101@gmail.com> improve wasm types FFI serialization Signed-off-by: Marin Veršić <marin.versic101@gmail.com> introduce Opaque and out-pointers in IR Signed-off-by: Marin Veršić <marin.versic101@gmail.com> introduce Transparent in IR, use it for fieldless enums Signed-off-by: Marin Veršić <marin.versic101@gmail.com> remove Transmute in favor of Transparent Signed-off-by: Marin Veršić <marin.versic101@gmail.com> Extend IR, make generic impls for slices and vectors Signed-off-by: Marin Veršić <marin.versic101@gmail.com> add implementation for data-carrying enum Signed-off-by: Marin Veršić <marin.versic101@gmail.com> separate FfiType and FfiConvert traits Signed-off-by: Marin Veršić <marin.versic101@gmail.com> implement support for arrays Signed-off-by: Marin Veršić <marin.versic101@gmail.com> prevent use-after-free in FFI method return Signed-off-by: Marin Veršić <marin.versic101@gmail.com> fix review comments Signed-off-by: Marin Veršić <marin.versic101@gmail.com>
Erigara
approved these changes
Sep 29, 2022
appetrosyan
approved these changes
Sep 29, 2022
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.
Description of the Change
wasmfeature flag fortarget_type. After some discussion with @Erigara this was decided to be preferableIntoFfiandTryFromReprCwithFfiTypeandFfiConverttraits. Previous separation couldn't be worked with mostly due to conflicting requirements on lifetimes on data carrying enums. Maybe GATs would have been of help here, not sure anymore. If neededFfiConvertcan be split intoTryFromFfi/IntoFfiReprCtypes (namelySliceRef/SliceMut). It was too noisy and difficult to deal with but I think it can (should?) be reintroduced nownon_robust_ref_mutfeature flag. Might be useful to disallow mutation for non-robust typesNonLocalType challenges
There is no specialization or HKTs in
Rust, so it's very difficult to properly delineate type categories. But it can be emulated in the type system. This is what theIrtrait is for.Rusttype is first wrapped in the correctIrtype after which static dispatch on IR marker types provides an optimal(zero-copy when possible) implementation ofFFIType.Issue
Closes #2491 #2629
Benefits
optimal conversion, enums support
Possible Drawbacks
I'm not sure if it's more complex than before of just a different perspective
Usage Examples or Tests [optional]
This is what a conversion for data-carrying enum would produce (it is not even required it is
repr(C):There was a suggestion to use a different enum representation. It can be modified. At the moment I found this easier to implement
Alternate Designs [optional]
I've tried some but all failed in expresivity