ffig icon indicating copy to clipboard operation
ffig copied to clipboard

Handle functions that return objects by std::move-ing them to the heap

Open jbcoe opened this issue 9 years ago • 1 comments

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();
}

jbcoe avatar Oct 02 '16 19:10 jbcoe

I've got proof of concept working in sandbox. All we need now is Django templates to generate this.

jbcoe avatar Dec 15 '16 08:12 jbcoe