-
Notifications
You must be signed in to change notification settings - Fork 265
Description
My suggestion does not touch cppfront at all, but is a transpiler parameter to automatically generate extern C functions to overcome the binary compatibility issues in C++.
The goal is to allow consuming C++ pure libraries from other languages without messing with the mangled names and risking breaking changes with future versions of the C++ libraries and/or compilers.
The generation should be restricted to:
- global or public member functions tagged by the user so that the generation is limited
- global or public member functions taking and returning basic types
- mapping the ctor/dtor to create/close functions taking care of allocating/freeing objects
If I understood correctly, cppfront makes the parameter direction clear using in and out. This metadata can be used to apply the patterns to correctly allocate/deallocate the memory for the parameters.
It could be also useful to define a "type transformer" that can be used by the transpiler to extend the types that can be used in the generation. For example, a std::vector<T> could be mapped to T* and length.