I'm in the same situation as the person who posted about this 5 years ago: 
http://www.digitalmars.com/d/archives/digitalmars/D/learn/thiscall_calling_convention_4943.html

This isn't so much relevant to COM as it is to this ASIO implementation. The 
issue is that only Microsoft compilers can use the 'thiscall' calling 
convention which is used with ASIO, while for other compilers your best options 
are to either use inline assembly when calling functions, or to compile a DLL 
wrapper using a Microsoft compiler (there's OpenAsio which does exactly that).

I could use the OpenAsio DLL wrapper, but I'd like to see if this could be done 
with inline asm instead.

Here's what one call looks like for a C++ Borland compiler (see the 
Resolver::init wrapper function):
http://codepad.org/rArgvPZC

In D, I can call a function like IASIO.init() without issues, and some other 
functions such as "getDriverVersion" which take no parameters will work. But 
trying to use functions which take parameters will fail with an access 
violation, probably because D uses stdcall for COM methods, while these ASIO 
COM methods need to be called with 'thiscall' convention.

I've attempted to translate this to D's inline asm but I get back access 
violations. Here's my attempt:
http://codepad.org/gFLJ9RJd

I admit I barely know much asm but I thought I'd give it a shot. Calling 
"IASIO.init()" works for me, of course. But calling any IASIO methods which 
take parameters will fail since parameters are passed differently in the 
'thiscall' convention.

Anyone know how to translate that asm block to D so it's valid?

Reply via email to