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

C++ Multi-Value support via Tuples & Struct-mapping #306

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

HailToDodongo
Copy link
Contributor

@HailToDodongo HailToDodongo commented Jan 22, 2022

C++ Multivalue

(Needs changes from #305)

The goal is to have easy support for multi-return values in the c++ binding.
Getting the values can either be done via tuples or structure-mapping.

E.g.

// C++17
auto [x,y] = func_a.call_tuple<f32, i32>();
auto [x,y] = func_b.call_tuple<i32, i32>(42.0f);

or

struct Vec3 { f32 x; f32 y; f32 z; };
auto vec = func_a.call_mapped<Vec3>();
auto vec = func_b.call_mapped<Vec3>(42.0f);

TODOs:

  • m3 function to map stack to struct
  • Unit-tests for internal m3 map function
  • C++ multival structure mapping
  • C++ multival tuple mapping
  • Add Docs

Open Questions:

For unit tests, i assume test/internal/m3_test.c was unused since it wasn't referenced anywhere.
I converted it to a catch2 test which can be run locally and in github actions.
What was the original plan for this file?

@HailToDodongo HailToDodongo changed the title C++ Multi-Value support via Tuples & Struct-mapping WIP: C++ Multi-Value support via Tuples & Struct-mapping Jan 22, 2022
@HailToDodongo HailToDodongo changed the title WIP: C++ Multi-Value support via Tuples & Struct-mapping C++ Multi-Value support via Tuples & Struct-mapping Jan 23, 2022
@HailToDodongo HailToDodongo marked this pull request as ready for review January 23, 2022 16:35
@vshymanskyy
Copy link
Member

@HailToDodongo sorry for the huge delay. I decided to perform a maintenance release of wasm3, so I hope to review and merge PRs like this finally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants