2

I am planning to use D for creating native applications on Mac OS X. For that, of course, D must interact with the Cocoa API. I have no knowledge of how this bindings could be done. I've already looked at Cocado and do know the Michel Fortin's D-ObjC bridge, and would like to be enlightened about some details:

  • What is their (or any other possible) approach of porting Cocoa to D? — here I essentially ask for technical reading sources (books/articles/references, etc);

  • Is it possible to establish an ABI compatibility with ObjC directly or through the C ABI? — There's a question on stackoverflow where the answers describe what could be achieved with Objective-C's Runtime Reference;

  • Is it feasible to make this kind of stuff work nicely and get the level of performance and stability like, e.g., with Qt framework on Mac OS X?

I have no experience at all in this field so forgive me any technical faults. Any help would be appreciable.

Thanks in advance for your responses.

Community
  • 1
  • 1
Rizo
  • 3,003
  • 5
  • 34
  • 49

2 Answers2

1
  • what most ports of Cocoa ports will do is translate the .h into .di and provide a thin wrapper and general utils,

    this will possibly include some syntactic sugar through the opDispatch(string sel,A...)(A args) overload that will translate obj.call1(arg1).call2(arg2) to the correct obj_msgsend(obj.ptr,NSSelectorFromString(sel),args) calls

  • it is possible through the C ABI you can read more about that in the D spec

  • sure it's possible however many things that the Obj. C compiler can check the D compiler cannot check requiring unittests to find those

ratchet freak
  • 47,288
  • 5
  • 68
  • 106
  • Thank you for your response! That's indeed the way the port should be implemented, but due to the problems described by Jacob Carlborg (see my own answer for this question), I will try to use a modified version of the D compiler to get the things work. – Rizo Apr 18 '12 at 14:07
1

I've got a more detailed answer to this question on the dlang.org forum from Jacob Carlborg.

Rizo
  • 3,003
  • 5
  • 34
  • 49