Open spouliot opened 7 years ago
I'm not sure it's possible to implement virtual methods without some kind of runtime support:
public class A {
public virtual int X () { return 0; }
public static void ShowX (A a) { Console.WriteLine (a.X ()); }
}
public class B : A {
public override int X () { return 1; }
}
@interface C : B
-(int) X;
@end
@implementation C
{
-(int) X {
return 2;
}
int main ()
{
C *c = [[C alloc] init];
[A showX: c]; // this prints 1, even though C overrides X to return 2.
}
yeah, I'm not even sure if we want to go that deep - that's more than just embedding. Sadly it remains non-obvious from a library consumption point of view (which might not know about the embeddinator)
Maybe we should add comments that says that methods shouldn't be overridden: https://softwareengineering.stackexchange.com/a/183706?
Not ideal but, like your link mention, it's ObjC after all :)
There's quite a few more things we should auto-comment in the headers. Having a @warning on each (with a link to our docs to explain why) sounds like a reasonable approach.
Right now we can only make native consume managed API but there's no two way integration. E.g.
delegates: the C# (not ObjC) ones;
interface calls: when a native instance conforms to a protocol that is a .net interface;
subclassing: when a native instance overrides a managed member - that's trickier since everything is virtual in ObjC;