D/Objective-C Bridge

Anders F Björklund afb at algonet.se
Tue Sep 18 00:19:22 PDT 2007


Michel Fortin wrote:

> I've been working on creating a usable bridge between D and Objective-C 
> for some time and decided today it was working well enough for a first 
> release. The bridge is written entirely in D and attempts to provides a 
> mostly transparent environment in which Objective-C objects and classes 
> are accessible as regular D objects. You can freely send D objects to 
> Objective-C method calls and vice-versa, all 
> conversions/wrapping/encapsulation being done automatically for you with 
> some template-magic.

Is this based anything on the earlier similar work called "Docoa" ?

http://dsource.org/projects/docoa

> The goal is mostly to make it workable for writing Mac OS X applications 
> using Cocoa. The bridge allows D objects to be instantiated from nib 
> files, with outlets and actions being connected as any Cocoa programmer 
> would expect.

The program seems to be using "objc_msgSendSuper_fpret", which I'm
not sure if it even exists ? At least that's what I googled up on:
http://lists.apple.com/archives/Objc-language/2006/Jun/msg00012.html
alias objc_msgSendSuper objc_msgSendSuper_fpret; // workaround ?

> There are still a few round corners, missing thread-safty, performance 
> issues and possibly the lack of Intel support (I don't have an Intel Mac 
> to test).

The project compiled (after the above), but the adder doesn't... add.
So it seems to be missing some interaction with the action binding ?
It does send the event though, so it might just be "a cocoa thing".
(i.e. printing out the value to the console in the controller works)

On Intel, this was.

> There is also much to be written: the bridge requires writing 
> a wrapper class for each class in the Cocoa framework we want to make 
> available. It's pretty easy thanks to all the templates, but it's still 
> time-consuming.

How do you intend to get around the copyright / distribution problem ?
The way it was originally planned for Carbon was with auto-conversion.
So that you'd download a program you could run on "your own" headers...
Possibly something like SWIG, with auto-generation plus some patches.

Nice work!
--anders



More information about the Digitalmars-d-announce mailing list