Skip to content

Conversation

@kpreisser
Copy link
Contributor

@kpreisser kpreisser commented Oct 10, 2022

Hi, this is a PR to fix the following issues when using Function.FromCallback() and Linker.DefineFunction():

  • Instead of invoking callback.Method (that may have a different parameter count than the callback), invoke the callback's Invoke method.
  • Handle an ITuple return value only when GetFunctionType() determined that the function returns a tuple, to correctly return a boxed ValueTuple as externref.
  • Support nested levels of ValueTuples, so that it's possible e.g. to return a ValueTulple<..., ValueTuple<..., ValueTuple<...>>> (15 values).

Fixes #158
Fixes #159

Thank you!

- Instead of invoking callback.Method (that may have a different parameter count than the callback), invoke the callback's Invoke() method.
- Handle a ITuple return value only when GetFunctionType determined that the function returns a tuple, to correctly return a boxed ValueTuple as externref.
- Support nested levels of ValueTuples, so that it's possible e.g. to return a ValueTulple<..., ValueTuple<..., ValueTuple<...>>> (15 values).

Fixes bytecodealliance#158
Fixes bytecodealliance#159
@kpreisser kpreisser changed the title Fix issues in Function.FromCallback() and Linker.DefineFunction() Fix issues in Function.FromCallback() and Linker.DefineFunction() Oct 10, 2022
@peterhuene peterhuene self-requested a review October 20, 2022 20:45
Copy link
Member

@peterhuene peterhuene left a comment

Choose a reason for hiding this comment

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

Excellent, thanks for these fixes!

@peterhuene peterhuene merged commit b709269 into bytecodealliance:main Oct 20, 2022
@kpreisser kpreisser deleted the fixCallbackIssues branch October 20, 2022 21:25
kpreisser added a commit to kpreisser/wasmtime-dotnet that referenced this pull request Oct 21, 2022
peterhuene pushed a commit that referenced this pull request Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants