Jump to page: 1 2
Thread overview
D/Objective-C Bridge
Sep 18, 2007
Michel Fortin
Sep 18, 2007
BCS
Sep 18, 2007
Carlos Santander
Sep 18, 2007
Michel Fortin
Sep 18, 2007
kris
Sep 18, 2007
Mark Wrenn
Sep 18, 2007
Walter Bright
Sep 18, 2007
BLS
Sep 18, 2007
Michel Fortin
Sep 18, 2007
Michel Fortin
September 18, 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@michelf.com
http://michelf.com/

September 18, 2007
Reply to Michel,

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

404 error


September 18, 2007
This sounds awesome!

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.
> 
> 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.
> 
September 18, 2007
BCS escribió:
> Reply to Michel,
> 
>>
>> http://michelf.com/2007/d-objc-bridge/
>>
> 
> 404 error
> 
> 

It's http://michelf.com/weblog/2007/d-objc-bridge/
The link in the homepage is also wrong.

-- 
Carlos Santander Bernal
September 18, 2007
On 2007-09-17 23:01:28 -0400, BCS <ao@pathlink.com> said:

> Reply to Michel,
> 
>> http://michelf.com/2007/d-objc-bridge/
> 
> 404 error

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


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

September 18, 2007
This is so cool.  I was just wondering about using D for ObjC.

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.
September 18, 2007
Too good to not post it to Reddit!

http://programming.reddit.com/new
September 18, 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
September 18, 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
September 18, 2007
> 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)

"floatValue" didn't work, for some reason. But intValue/doubleValue did.

--anders
« First   ‹ Prev
1 2