Re: Problem with casting instance reference to void* and back.

2015-07-27 Thread Vlad Leberstein via Digitalmars-d-learn
auto self = cast(TestInterface)cast(Object) rawSelf Works like a charm! Thank you both!

Re: Problem with casting instance reference to void* and back.

2015-07-27 Thread Artur Skawina via Digitalmars-d-learn
On 07/27/15 14:03, Vlad Leberstein via Digitalmars-d-learn wrote: > Hi! My use case requires interaction with C API which in turn implies storing > object instance reference as void *. I'm using gdc 4.9.2 and everything > worked fine with "object -> void * -> object" conversion, but "object -> vo

Re: Problem with casting instance reference to void* and back.

2015-07-27 Thread anonymous via Digitalmars-d-learn
On Monday, 27 July 2015 at 13:11:33 UTC, anonymous wrote: In the first example, you pass a pointer to a class instance. You cannot get the vtbl entry for the interface like this. Instead try to do this in 2 steps: actually i meant you pass an untyped pointer, so when you cast as interface it'

Re: Problem with casting instance reference to void* and back.

2015-07-27 Thread anonymous via Digitalmars-d-learn
On Monday, 27 July 2015 at 12:03:06 UTC, Vlad Leberstein wrote: Hi! My use case requires interaction with C API which in turn implies storing object instance reference as void *. I'm using gdc 4.9.2 and everything worked fine with "object -> void * -> object" conversion, but "object -> void * -

Problem with casting instance reference to void* and back.

2015-07-27 Thread Vlad Leberstein via Digitalmars-d-learn
Hi! My use case requires interaction with C API which in turn implies storing object instance reference as void *. I'm using gdc 4.9.2 and everything worked fine with "object -> void * -> object" conversion, but "object -> void * -> interface" failed. The stripped-down example is something like