Any way to access a C++ DLL?

mike vertex at gmx.at
Wed Sep 6 04:51:08 PDT 2006


Thanks!

I'll go the wrapper route (no COM for VST). I need to translate a lot of  
enums by hand, should mostly be copy/paste anyway.

-Mike

Am 06.09.2006, 13:28 Uhr, schrieb Steve Horne  
<stephenwantshornenospam100 at aol.com>:

> On Wed, 06 Sep 2006 13:03:40 +0200, mike <vertex at gmx.at> wrote:
>
>> Is there any way to access a C++ DLL (precisely: a VST plugin - for  
>> those
>> who don't know: VST is a plugin API for virtual synthesizers, audio/midi
>> effects, etc.) from D?
>
> I'm a newb, but I can still say yes - in principle.
>
>
> Worst case, you write an adaptor lib in C++ which provides a C level
> API. D can easily call that. On the C level, you see functions that
> take 'handles' as parameters.
>
> It's a lot like the Windows APIs - those window and device context
> handles are actually object pointers and, very likely, those C-like
> function calls use an underlying C++-style virtual function call in
> order to resolve what kind of window/device context/whatever they are
> dealing with.
>
> I haven't dealt with VST plugins, but for the main plugin mechanism I
> have used, there is a single exported function in the DLL. This is
> normally accessed through GetProcAddress, and when called it provides
> an object which is used as a kind of 'factory' for API objects.
>
> Mapping all of that to a C-compatible adaptor lib would be a pain, but
> not difficult as such. Just hassle.
>
> You could, of course, use SWIG. AFAIK it can't generate D wrappers
> yet, but it can generate an XML description of a C++ API which you
> could then translate to a D wrapper using XSLT. Of course this might
> take some time and fiddling around.
>
>
> Far better case - perhaps VST uses COM? After all, there aren't any
> big overheads to using COM, providing the interfaces are provided by a
> local DLL. All basic COM does is allow an executable or DLL to call
> create objects and call interfaces defined in another DLL. The calls
> are just C++-style virtual function calls through an interface object
> pointer.
>
> I believe D has built-in support for COM, making it easier to program
> COM in D than in C++, though I haven't used it.
>



-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list