[gmpi] Re: calling C from C++

  • From: "Ron Kuper" <RonKuper@xxxxxxxxxxxx>
  • To: <gmpi@xxxxxxxxxxxxx>
  • Date: Mon, 14 Feb 2005 09:54:35 -0500

>>>
      /* STEP 2: Locate entrypoint */
        r = GMPI_DllSymbol( &dll_handle, "DllGetClassObject",
&dll_entry_point );
<<<

The symbol name "DllGetClassObject", besides being very platform
specific, might be different on different platforms.  Are exported
symbols decorated?  Is it really "_DllGetClassObject" or maybe
"DllGetClassObject@12"?

I think what need is a method more like:

        r = GMPI_GetEntryPoint( dll_handle, &dll_entry_point );

... but all that aside ...

I think the host code for instantiation ought to make more use of the
meta data.  IOW the host app never knows where the plugin lives (DLL,
etc).  It just asks some "base class" to cough up an entry point given a
UUID.  Perhaps the same API can deal with factory issues:

UUID gmpiBinaryID = /* obtained by meta data enum */;
UUID gmpiPluginID = /* obtained by plugin enum of gmpiBinaryID */

GMPI_PlugIn* loadedPlug;

loadedPlug = GMPI_Create( gmpiBinaryID, gmpiPluginID );

GMPI_Create has lots of magic in it, probably a good amount of cross
platform code.

Thoughts?

-----Original Message-----
From: gmpi-bounce@xxxxxxxxxxxxx [mailto:gmpi-bounce@xxxxxxxxxxxxx] On
Behalf Of Jeff McClintock
Sent: Monday, February 14, 2005 12:26 AM
To: gmpi@xxxxxxxxxxxxx
Subject: [gmpi] Re: calling C from C++

Cheers All,

--------------gmpi.c--------------------------------------
#include <stdio.h>
#include "gmpi.h"

//int _tmain(int argc, _TCHAR* argv[])
int main(int argc, char* argv[])
{
        /* signature of Factory construction function */
        GMPI_DllEntry dll_entry_point;
        GMPI_DllHandle dll_handle;
        IGMPI_Factory *factory;
        IGMPI_Plugin *my_plugin;
        GMPI_RESULT r;

        /* format of plugin unique ID undecided. for now using GUID */
        /* {5CC85CAD-DC0C-42c2-80FD-DC3ADBC70641} */
        static const GUID IID_GMPI_Prototype_DSP =
        { 0x5cc85cad, 0xdc0c, 0x42c2, { 0x80, 0xfd, 0xdc, 0x3a, 0xdb,
0xc7, 
0x6, 0x41 } };


     /* STEP 1: Load DLL */
        r = GMPI_DllLoad( &dll_handle,
"../test_plugin/debug/test_plugin.dll" );

     /* STEP 2: Locate entrypoint */
        r = GMPI_DllSymbol( &dll_handle, "DllGetClassObject",
&dll_entry_point );


     /* STEP 3: Create factory */
        r = (dll_entry_point)( &IID_GMPI_Factory, &IID_GMPI_Factory,
(void**) 
&factory );


     /* STEP 4: Ask factory to instantiate plugin */
        r = (factory->Vtable->CreateInstance)(factory,
&IID_GMPI_Prototype_DSP, 
(void**) &my_plugin);


        // test a call into plugin
        r = (my_plugin->Vtable->Placeholder1)(my_plugin, 42);


     /* STEP 5: delete factory and plugin */
        r = (my_plugin->Vtable->Release)(my_plugin);
        r = (factory->Vtable->Release)(factory);
        
        return 0;
}


----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your
own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe


----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: