COM2D Wrapper

evilrat via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 27 18:37:59 PDT 2017


On Monday, 27 March 2017 at 21:02:05 UTC, Nierjerson wrote:
> On Friday, 24 March 2017 at 18:17:31 UTC, Nierjerson wrote:
>> I'd like to present the following D library I am working on:
>>
>> https://github.com/IllusionSoftware/COM2D
>
> I get access violations when trying to call the functions on 
> the returned interfaces.
>

Why are your photoshop interfaces not extern(Windows)? I saw some 
mixin magic with extern(Windows), so you are generating 
extern(Windows) stuff from plain D interface? Are you sure that 
your code calls generated stuff instead of using D interface? 
Because if it calls the latter it crashes due to ABI mismatch.

And the most important thing, if you are making D class derived 
from COM interface and calls its interface functions - you are 
out of luck, there is probably a way to get correct offset for 
vptr(something like Class.SomeInterface.offsetof?), D classes has 
virtual methods alreay(5 or so), so your COM functions called 
with wrong ptr offset that of course crashes. To test if this is 
an actual issue pick any function you want to try, get 5 
functions back, forge its signature to the function you are 
testing and call it. I assume it will work, but, no guarantees... 
But if it works please open an issue in bugtracker (if nothing 
yet there)

The possible workaround is making C-style COM class where 
functions takes 'this' as first arg, which also involves filling 
up COM vtable manually, search the internets, I can't help you 
with that.


More information about the Digitalmars-d-learn mailing list