Objective-C runtime: bindings are possible?
Jacob Carlborg
doob at me.com
Tue Mar 11 10:22:58 PDT 2014
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
More information about the Digitalmars-d-learn
mailing list