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

feat(c#): Multi-return support #794

Merged
merged 3 commits into from
Jan 13, 2024

Conversation

jsturtevant
Copy link
Collaborator

This adds the codegen test for multi-return with c#. It creates an interface like:

namespace wit_the_world.wit.exports.foo.foo.MultiReturn;

public interface IMultiReturn {
    static abstract void Mra();
    
    static abstract void Mrb();
    
    static abstract uint Mrc();
    
    static abstract uint Mrd();
    
    static abstract Tuple<uint, float> Mre();
    
}

and export interop looks like:

[UnmanagedCallersOnly(EntryPoint = "foo:foo/multi-return#mre")]
    public static int wasmExportMre() {
        
        Tuple<uint, float> result =  MultiReturnImpl.Mre();
        uint result0 = result.Item1;
        float result1 = result.Item2;
        
        var ptr = returnArea.AddrOfBuffer();
        returnArea.SetS32(0, unchecked((int)(result0)));
        returnArea.SetF32(4, result1);
        return (int)(ptr);
        
    }

@yowl
Copy link
Collaborator

yowl commented Jan 8, 2024

There's a bit of overlap here with #808 . I went with the (type1, type2, ..) syntax rather than Tuple, thinking that at some point we could name the elements rather than just Item1, Item2 etc.

@jsturtevant jsturtevant marked this pull request as ready for review January 12, 2024 22:31
@jsturtevant
Copy link
Collaborator Author

@yowl I've rebased on top of your changes for #808 and we are good to go. Thanks @silesmo for the float fix too!

Copy link
Collaborator

@yowl yowl left a comment

Choose a reason for hiding this comment

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

Looks good, thanks

@yowl yowl merged commit 3433f2d into bytecodealliance:main Jan 13, 2024
9 checks passed
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.

3 participants