D/Objective-C Bridge

BLS nanali at nospam-wanadoo.fr
Mon Sep 17 23:51:28 PDT 2007


Michel Fortin schrieb:
> 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.
> 
Bonjour Michel,
Un bon travail!

In your Blog you wrote :
/D is a statically-typed language, in the same spirit as C++. This means 
that very little information is known at runtime about D objects: their 
name, their members, their methods, almost all of this disappear once 
the program has been compiled. This also mean that you can’t dynamically 
add classes or methods like you can do in Objective-C ..../


I am not that sure. I guess it is possible to implement runtime 
reflection based upon  compiletime reflection using D 2.x __traits.
Kirk (PyD) is most probabely the one who can tell you more.

There is also a project called flectioned on DSource
http://www.dsource.org/projects/flectioned

Bjoern



More information about the Digitalmars-d-announce mailing list