Thread overview | |||||
---|---|---|---|---|---|
|
March 11, 2014 Objective-C runtime: bindings are possible? | ||||
---|---|---|---|---|
| ||||
Hi all, I'm wondering if it is possible to directly interface with the objective-c runtime, as I've read [1] and I have some random crashes in my code right now. Someone can share some experience? I'm on 10.9... Thanks, Paolo [1] http://d.puremagic.com/issues/show_bug.cgi?id=9931 |
March 11, 2014 Re: Objective-C runtime: bindings are possible? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paolo Invernizzi | On 2014-03-11 16:12, Paolo Invernizzi wrote: > Hi all, > > I'm wondering if it is possible to directly interface with the > objective-c runtime, as I've read [1] and I have some random crashes in > my code right now. Yes, it's possible since the Objective-C runtime is plain C functions. You need to show us some code to be able to help you. > Someone can share some experience? I'm on 10.9... To interface with Objective-C there are three options: * Use the Objective-C runtime functions directly [1] + Works now, no language or library support is needed - Cumbersome - Verbose - Easy to make mistakes * Use an Objective-C/D bridge [2] + Fairly simple to use - Bloat, both template and virtual method bloat. We're talking 60MB Hello World * Extend the language to be ABI compatible [3, 4] + The compiler outputs the same code as the Objective-C compiler would + Easy to use (or as easy as using Objective-C would be, sometimes easier) - Requires language support I tried all of these options and personally I think the third options is the best. As of a coincident I just finished (except for exceptions) porting D/Objective-C to 64bit. [1] https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html [2] http://www.dsource.org/projects/dstep [3] http://wiki.dlang.org/DIP43 [4] https://github.com/jacob-carlborg/dmd/tree/d-objc -- /Jacob Carlborg |
March 12, 2014 Re: Objective-C runtime: bindings are possible? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Tuesday, 11 March 2014 at 17:22:59 UTC, Jacob Carlborg wrote:
> On 2014-03-11 16:12, Paolo Invernizzi wrote:
>> Hi all,
>>
>> I'm wondering if it is possible to directly interface with the
>> objective-c runtime, as I've read [1] and I have some random crashes in
>> my code right now.
>
> Yes, it's possible since the Objective-C runtime is plain C functions. You need to show us some code to be able to help you.
>
>> Someone can share some experience? I'm on 10.9...
>
> To interface with Objective-C there are three options:
>
> * Use the Objective-C runtime functions directly [1]
> + Works now, no language or library support is needed
> - Cumbersome
> - Verbose
> - Easy to make mistakes
>
> * Use an Objective-C/D bridge [2]
> + Fairly simple to use
> - Bloat, both template and virtual method bloat. We're talking 60MB Hello World
>
> * Extend the language to be ABI compatible [3, 4]
> + The compiler outputs the same code as the Objective-C compiler would
> + Easy to use (or as easy as using Objective-C would be, sometimes easier)
> - Requires language support
>
> I tried all of these options and personally I think the third options is the best. As of a coincident I just finished (except for exceptions) porting D/Objective-C to 64bit.
>
> [1] https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html
>
> [2] http://www.dsource.org/projects/dstep
> [3] http://wiki.dlang.org/DIP43
> [4] https://github.com/jacob-carlborg/dmd/tree/d-objc
Hi Jacob,
Actually I'm using [1], that's why I was wandering about eventual problems related to objc_msgSend_stret.
But I think that now the plan is to tryout [3]: that's the most logical solution after all...
- Paolo
|
Copyright © 1999-2021 by the D Language Foundation