ffig
ffig copied to clipboard
Handle functions that return objects by std::move-ing them to the heap
C++ functions returning objects by value should be represented by a C-API function that returns a void*. The object will need std::moveing to the heap in order to do this.
struct A {};
struct B {
A foo() { return A(); } // return by value
}
void* B_c_foo(void* obj) {
auto b = reinterpret_cast...
A a = b->foo();
auto p = std::unique_ptr<A>(std::move(a));
return p.release();
}
I've got proof of concept working in sandbox. All we need now is Django templates to generate this.