On 2014-11-07 17:05, Christian Schneider wrote:

Ha, awesome! It works! I'll add this to a wiki page in the DiveFramework
github repos.

Thanks again!

No problem :). This isn't mention in the DIP since this has nothing to do with Objective-C, it's rather plain C. This is documented here [1].

Oh, and btw, I was briefly looking into the DMD source for trying to fix
myself the issue with the protocol to class instance cast (trying to be
useful), but I am seriously completely not hardcore enough of digging
anything in there, lol.

I had no idea what I was doing when I started with this :)

Anyhow, if you got a hint, let me know. It's not
just in the example discussed in my other posts, I found it to be an
issue in other places as well, as often framework classes return id /
ObjcObject instead of a further typed instance. I don't remember where
exactly I had a problem, but I remember I used NSObject instead of
ObjcObject in these places, which of course is not the way to go.

I guess you have to live using NSObject for now, until I fixed that. But in practice NSObject is the only root class. So far I've seen one other class, NSProxy, that doesn't inherit from NSObject.

Ok, I had a quick look at this issue. It is implemented but it's not working. There is a test but that's only casting from a class to an interface, not the other way around. Either there's an issue in the druntime function "_dobjc_interface_cast" or in the compiler (most likely in the compiler).

It looks like the casting is implemented here [2], or at least parts of it.

[1] http://dlang.org/interfaceToC.html
[2] https://github.com/jacob-carlborg/dmd/blob/d-objc/src/e2ir.c#L3843-L3854

/Jacob Carlborg

Reply via email to