typed vtable
Denis Koroskin
2korden at gmail.com
Tue Nov 18 06:48:00 PST 2008
On Tue, 18 Nov 2008 17:17:36 +0300, Michel Fortin
<michel.fortin at michelf.com> wrote:
> On 2008-11-17 13:56:55 -0500, Harry Vennik <htvennik at zonnet.nl> said:
>
>> Hi,
>> One of the things D claims is that it eliminates the need for IDL. And
>> yeah, it does a lot in that direction, but I found something that's
>> missing while trying to actually implement some sense of RPC...
>> To get a good view of an interface that can be used to construct the
>> necessary stub code, you need to have a typed vtable. And D almost
>> provides it... You can get the untyped vtable, you can get a typed list
>> of virtual function overloads by name, and you can get the names of all
>> interface members... So you can get all what's needed, except that
>> there is no way to know the vtable index of a member function!!!
>> My proposal to fix this is to allow an expression like:
>> __traits(getVirtualFunctions, T) // no second argument!
>> where T is an interface or class type (or an expression of such a
>> type). Such an expression should then return all virtual member
>> functions in vtable order, thus making it possible to relate the
>> function itself to its vtable index.
>
> Personally, I had to work around the same problem in the D/Objective-C
> bridge and thus I could probably simplify a few things by having this,
> except that what I need in my case is always the vtable index of a
> particular function. I guess it could be implemented from the above
> __traits syntax, but I'd wish for a simpler solution to my problem, such
> as:
>
> __traits(getVTableIndex, T.foo);
>
> along with a way to check if a function is virtual, possibly by checking
> they're not final:
>
> static if (is(T.foo == final)) ...;
>
> This way I could build a pointer template-struct to a virtual member
> function (without knowing the target object in advance as with
> delegates).
>
>
What if class T has multiple foo() overloads, half of which are virtual
and half are not?
More information about the Digitalmars-d
mailing list