Lars Ivar Igesund wrote:
No, you misunderstand. I said safely call, not exceptionally
efficient. To me a virtual call would be acceptable. However, at
least in my cases, there would normally not be more than one
imlemented interface and such it would be a tiny vtable.
Ok, so the scope is reducing nicely. We now have a few problems to solve
(some details glossed over for simplicity).
a) Get from void* to the TypeInfo that's typing that void*. This will
involve a search as the void* could point really anywhere, including
untyped memory. So we have a core function:
TypeInfo fromAddress(void * p);
b) Starting from a TypeInfo, get an interface in case the underlying
struct implements that interface:
Object TypeInfo.QueryInterface(TypeInfo someInterface);
c) Finally, given a void* and an interface, invoke a method of that
interface:
T structCast!(Interface)(p).method(arguments);
where T is the result type of Interface.method.
Is this what you want?
Andrei