views:

40

answers:

1

I'm creating a COM type library with over one hundred interfaces. Defining all of the interfaces and coclasses in a single library is unreasonable... the IDL file becomes thousands of lines long! So I'm trying the idea of putting each interface in its own file, and using imports to satisfy its dependencies.

What strategies can I use to manage this many interfaces? I'm trying to use import directives everywhere, but I'm stuck trying to get them included in the TLB. I've tried #include in the library, but things seem to get funky with dependencies.

ExampleA.idl

import "oaidl.idl", "ocidl.idl";
[ uuid(...) ] interface IExampleA : IDispatch { ... }

ExampleB.idl

import "oaidl.idl", "ocidl.idl", "IExampleA.idl";
[ uuid(...) ] interface IExampleB : IExampleA { ... }

ExampleLibrary.idl

// Should I put some imports here? They won't be included in the library.
import "IExampleA.idl";
import "IExampleB.idl";

[ uuid(...) ]
library InfrastructureLib
{
    // This? Imports in a library don't actually include the types
    import "IExampleA.idl";
    import "IExampleB.idl";

    // Or this? I get class redefinition errors trying #include 
    #include "IExampleA.idl"
    #include "IExampleB.idl"

    // Is there another way?
};
A: 

I think your plan to split up the interfaces into multiple tlb files is fine, however I dont understand why you appear to be generating the files by hand?

My suggestion would be to split the interfaces into multiple typelibraries but use a typelibrary editor to create them.

A type library editor comes with every version of Delphi, but if you dont have this there should be a few available on the net.

Toby Allen
I had no idea such a thing existed... is one included with Visual Studio? I am creating COM objects and interfaces using ATL.
emddudley
See updated answer.
Toby Allen