wasm-c-api icon indicating copy to clipboard operation
wasm-c-api copied to clipboard

Invert C/C++ API layering

Open AndrewScheidecker opened this issue 5 years ago • 2 comments

The current C API is implemented in terms of the C++ API, but I think it would be better to invert that layering:

  • The C API is the only interface defined between users and runtimes.
  • Define a C++ header-only library that wraps the C API.

This means that users can use a C++-style API if they like, but runtimes only need to implement the C API.

AndrewScheidecker avatar Jun 17 '19 13:06 AndrewScheidecker

Note that this adapter implementation is not part of the proposal but only of the prototype. The only reason I did it in that direction was that it was somewhat easier to get right, esp on top of an engine that is already in C++. I can imagine engines supporting both interfaces natively. I'd also be totally fine with adding an adapter for the other direction, as you suggest. Happy to accept patches. ;)

rossberg avatar Jun 17 '19 14:06 rossberg

I can imagine engines supporting both interfaces natively.

That's what I'd like to avoid.

I'd also be totally fine with adding an adapter for the other direction, as you suggest. Happy to accept patches. ;)

To be clear, I would prefer to just get rid of the C++ API entirely. I'm not sure you want me writing the C++ adapter. :)

AndrewScheidecker avatar Jun 17 '19 18:06 AndrewScheidecker