[gmpi] Re: low level API - Abstract Factory summary

  • From: "B.J. Buchalter" <bj@xxxxxxxxxx>
  • To: "gmpi@xxxxxxxxxxxxx" <gmpi@xxxxxxxxxxxxx>
  • Date: Thu, 10 Feb 2005 14:58:16 -0500

on 2/10/05 2:38 PM, Jeff McClintock at jeffmcc@xxxxxxxxxx wrote:

> As to C++ compilers supporting COM. I suggest GMPI uses plain C at the
> lowest level (with a C++ wrapper on top).
>  COM interfaces declared in C are 100% ansii C, and compatible with
> *all* compilers.  It's a bit more long-winded, but thats C for you...
> 
> // INTERFACES (abstract base classes)
> typedef struct
> {
>    struct IFooVtbl *IGMPI_PluginVtbl;
> } IGMPI_Plugin;
> 
> typedef struct
> {
>    // IUnknown methods
>    GMPI_RESULT     (*QueryInterface) (IGMPI_Plugin *, const
> _GMPI_GUID, void **);
>    unsigned long   (*AddRef)         (IGMPI_Plugin *);
>    unsigned long   (*Release)        (IGMPI_Plugin *);
> 
>    // IGMPI_Plugin methods
>    unsigned long   (*Placeholder1)   (IGMPI_Plugin *, int);
>    unsigned long   (*Placeholder2)   (IGMPI_Plugin *, int *);
> } IGMPI_PluginVtbl;

Agree, but note that the vtable format is platform dependent. On Mac OS X
the first member of the vtable is a reserved void* (see
<CoreFoundation/CFPlugIn.h>), and is apparently part of Microsoft's binary
run-time spec for COM on MacOS. So this specification needs to be:

typedef struct
{
    #ifdef MACOSX // or maybe just MACOS
          void *_reserved; /* The _reserved field is part of the Microsoft
                              COM binary standard on Macintosh. */
    #endif

     // IUnknown methods
     GMPI_RESULT     (*QueryInterface) (IGMPI_Plugin *,
                                        const  _GMPI_GUID, void **);
     unsigned long   (*AddRef)         (IGMPI_Plugin *);
     unsigned long   (*Release)        (IGMPI_Plugin *);

     // IGMPI_Plugin methods
     unsigned long   (*Placeholder1)   (IGMPI_Plugin *, int);
     unsigned long   (*Placeholder2)   (IGMPI_Plugin *, int *);
} IGMPI_PluginVtbl;

Best regards,


B.J. Buchalter

Metric Halo
5 Donovan Drive
Hopewell Junction, NY 12533 USA
tel +1 845 223-6112
fax +1 603 250-2451


----------------------------------------------------------------------
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: