D/Objective-C Bridge

Michel Fortin michel.fortin at michelf.com
Mon Sep 17 19:50:10 PDT 2007


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.

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.

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). 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.

If you're interested, here is the project page (with a download link):

http://michelf.com/projects/d-objc-bridge/

I've also written an introduction article on my blog attempting to 
explain how everything works without writing a book (it could be better 
written):

http://michelf.com/2007/d-objc-bridge/

Things are not documented much right now, but I look forward to improve 
that. The best documentation you can find currently about the internals 
are the many comments in the code, although it's easy to get lost in 
all these templates. The example application is pretty straightforward 
though, and I'm pretty sure the bridge can be used easily without 
having to understand much of how Objective-C works.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d-announce mailing list