www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - COM2D Wrapper

reply Nierjerson <no-reply IllusionSoftware.is> writes:
I'd like to present the following D library I am working on:

https://github.com/IllusionSoftware/COM2D

It attempts to automate COM in D.

It has some problems but does partially work. Those with a recent 
version of Adobe Photoshop and an interest in COM can try it out 
and make contributions if they would like to see it progress.

The goal is to completely remove the necessity to use COM api in 
D and simply use D directly.

When executing the application, photoshop should start up. One 
must use a debugger or modify the main.d app to see what is 
happening. So far, only the top most interface is working as 
aggregates have not been handled.

If anyone is interested in seeing this through, maybe we can 
collaborate to get a fully functional implementation.
Mar 24 2017
parent reply Nierjerson <Nierjerson somewhere.com> writes:
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

 It attempts to automate COM in D.

 It has some problems but does partially work. Those with a 
 recent version of Adobe Photoshop and an interest in COM can 
 try it out and make contributions if they would like to see it 
 progress.

 The goal is to completely remove the necessity to use COM api 
 in D and simply use D directly.

 When executing the application, photoshop should start up. One 
 must use a debugger or modify the main.d app to see what is 
 happening. So far, only the top most interface is working as 
 aggregates have not been handled.

 If anyone is interested in seeing this through, maybe we can 
 collaborate to get a fully functional implementation.
Anyone can help get this working? I think the issue maybe that the interface pointer returned by the COM interface is "C-like" and doesn't match what D expects an interface to be. I get access violations when trying to call the functions on the returned interfaces. Not sure about this though. Thanks.
Mar 27 2017
next sibling parent evilrat <evilrat666 gmail.com> writes:
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.
Mar 27 2017
prev sibling next sibling parent John Chapman <johnch_atms hotmail.com> writes:
On Monday, 27 March 2017 at 21:02:05 UTC, Nierjerson wrote:
 Anyone can help get this working? I think the issue maybe that 
 the interface pointer returned by the COM interface is "C-like" 
 and doesn't match what D expects an interface to be. I get 
 access violations when trying to call the functions on the 
 returned interfaces. Not sure about this though.
I don't have Photoshop so I can't verify this, however I think Photoshop only declares dispinterfaces, meaning those methods aren't present in the vtable, so every method will have to be called using IDispatch.Invoke. (I'm guessing IDL2D doesn't distinguish between dual and disp- interfaces and just emits any functions it sees.)
Mar 28 2017
prev sibling parent reply Kagamin <spam here.lot> writes:
On Monday, 27 March 2017 at 21:02:05 UTC, Nierjerson wrote:
 Anyone can help get this working? I think the issue maybe that 
 the interface pointer returned by the COM interface is "C-like" 
 and doesn't match what D expects an interface to be. I get 
 access violations when trying to call the functions on the 
 returned interfaces. Not sure about this though.
First write code that works, then write generator for it. It won't work the other way around.
Mar 28 2017
parent Nierjerson <Nierjerson somewhere.com> writes:
On Tuesday, 28 March 2017 at 12:09:23 UTC, Kagamin wrote:
 On Monday, 27 March 2017 at 21:02:05 UTC, Nierjerson wrote:
 Anyone can help get this working? I think the issue maybe that 
 the interface pointer returned by the COM interface is 
 "C-like" and doesn't match what D expects an interface to be. 
 I get access violations when trying to call the functions on 
 the returned interfaces. Not sure about this though.
First write code that works, then write generator for it. It won't work the other way around.
Thanks, I'm sure you think this was suppose to help. I actually write **ALL** my code in doubly generated(has to go through two generations of code generation before it is generated). I also make sure it doesn't work before I go through that process and I through in a few bugs in the generation code just to waste more of my time. Of course, I know it works that way because I'm a genius! In any case, I found my problem, thanks to you. You were a great help! I had to decode your answer from Base64 and use the inigma cryptic encoding function to actually find your COM expertise in there though. But thanks anyways! I really appreciate it!
Mar 28 2017