Hi all,
While trying to interface C++ and D, I have to new a few D objects in C++ code. I am doing this using a D function: "XXX createXXX(...) { return new XXX(...); }". I am sure there must be some great way to automatically generate these creator functions, but I don't know how to do it.

In the C++-header I will write manually:
  XXX* createXXX(int a, int b);
  XXX* createXXX(bool flag);

In D source:
  extern (C++) class XXX {
    this(int a, int b) { /+...+/ }
    this(bool flag) { /+...+/ }
  }

// Somehow define these guys automatically, "genCreateCtors!(XXX)" ?
  XXX createXXX(int a, int b) { return new XXX(a, b); }
  XXX createXXX(bool flag) { return new XXX(flag); }

Thanks a lot!
  Johan

Reply via email to