June 06, 2010
Am 06.06.2010 11:33, schrieb Simen kjaeraas:
> Also, pointers to delegates can be passed to C-linkage functions. A
> delegate is nothing but a struct, and as such there is no reason for
> it not to be passable to a C-linkage function.

my fault - yes its possible to use delegates in non D but delegat-struct knowing languages (and a small pice of special calling code), sorry Zarathrustra i missed the point of your post in whole

>I say this is a bug.

me too

are delegats part of the ABI, i can't find a delegat calling scheme in the ABI-Description - should this be in EAX, as last/first part on stack, ECX?

wouldn't it be nice to have an complete call/use D features through c example around?





June 06, 2010
> my fault - yes its possible to use delegates in non D but delegat-struct knowing languages (and a small pice of special calling code), sorry Zarathrustra i missed the point of your post in whole
No problem, I'm glad that we have reached an agreement.

> wouldn't it be nice to have an complete call/use D features through c example around?
It would be great, if the DMC will provide such extensions like the dthiscall (for
member functions) and the dcall (for static functions). Additionally would be
great if DMC will works on other OS than MSWindows. But probably there are only my
dreams ;)

Btw.
I think there is a good chance for create the set examples which show how to use D
features on the C level. I will thinking about it in my free time :) The idea is
really interesting and it would be useful(especially to better understand these
mechanisms) for some people.

> are delegats part of the ABI, i can't find a delegat calling scheme in the ABI-Description - should this be in EAX, as last/first part on stack, ECX?
The delegates are called by exactly same way as any other member function. Put ptr = 'this'(context pointer) to EAX and call funcptr (pointer to function). If I remember well, the 'this' pointer is passed to functions by ECX in C++. The delegate structure layout is described in ABI. ABI, disassembler and trail-end-error method will give you (and me too, because I still need to explore many things) an answer to many questions.

> I say this is a bug.
Thanks for confirming my suspicions.
June 06, 2010
Zarathustra:
> I think there is a good chance for create the set examples which show how to use D features on the C level. I will thinking about it in my free time :) The idea is really interesting and it would be useful(especially to better understand these mechanisms) for some people.

I have asked for something similar. In such explanations I'd even like some boxes&arrows diagrams that show the data structures with the pointers, etc. Even few of such images can improve the understanding.

Bye,
bearophile
June 06, 2010
Am 06.06.2010 17:30, schrieb Zarathustra:
>>  are delegats part of the ABI, i can't find a delegat calling scheme in
>>  the ABI-Description - should this be in EAX, as last/first part on
>>  stack, ECX?
> The delegates are called by exactly same way as any other member function. Put ptr
> = 'this'(context pointer) to EAX and call funcptr (pointer to function). If I
> remember well, the 'this' pointer is passed to functions by ECX in C++. The
> delegate structure layout is described in ABI. ABI, disassembler and
> trail-end-error method will give you (and me too, because I still need to explore
> many things) an answer to many questions.

ok and it would be nice to have an clear description of this ABI+disasm
trial-error-reusults in the ABI-Description - i think your example is needed to show walter the missing parts of the ABI-Doc

June 07, 2010
Simen kjaeraas wrote:
> dennis luehring <dl.soluz@gmx.net> wrote:
> 
>> D still won't accept an delegat in an extern C because this type does not exists in the C world
> 
> Nor do classes, and those certainly can be passed to a C-linkage
> function.

Yes, but I think that's a bug too. Quite a horrible one, in fact, since the class may get GC'd.

On the "interfaceToC" page, class, type[], type[type] and delegate() are listed as having no C equivalent. They should all fail to compile.
1 2
Next ›   Last »