You can create a server that supports more than one dispinterface as follows.
define constant my-coclass-type-info =
make(<coclass-type-info>,
uuid: make-GUID(...), // Class ID
interfaces:
vector(make(<component-interface-description>,
class: <my-dispatch-object1>,
typeinfo: make(<disp-type-info>, ...)),
make(<component-interface-description>,
class: <my-dispatch-object2>,
typeinfo: make(<disp-type-info>,
uuid: make-GUID(...), ...), ...)
...
));
...
let factory = make-object-factory(my-type-info);
Each element of the interfaces: sequence specifies a dispinterface with type information, and the Dylan class that must be instantiated to implement it.
By default, the first dispinterface listed will be the default interface that will be returned if a client application calls QueryInterface on $IID-IDispatch (although it can specify an alternate uuid: too).
The type information for the remaining dispinterfaces must specify the uuid: option, supplying the ID that a client application can use to select them.
Note too that each type information instance must provide a value for the name: option, so that it has a distinguished name in the type library. See "Type libraries and type information" on page 174 a description of a type library.
By default, the class factory instantiates the class <simple-component-object>, page 213, but you can specify a user-defined subclass thereof with the class: initialization keyword for <coclass-type-info>, page 211. This is a subclass of <IUnknown>, so its initialize method could create additional interfaces using it as the controlling unknown if you want your OLE object to support other interfaces besides IDispatch. Also, <coclass-type-info> accepts all of the same optional keywords as <disp-type-info>, page 203, which can be used to provide type library documentation for the object as a whole. This might be a reason to use it even if there is only one interface. For example:
make-object-factory(
make(<coclass-type-info>,
name: "foo", documentation: "la de dah",
major-version: 1, minor-version: 2,
...
Alternatively, the type information can be specified by using the macro define coclass. For example:
define coclass my-coclass name "foo"; uuid make-GUID(...); // Class ID default interface <interface-1>; interface <interface-2>; end;
where each interface class was defined by define dispatch-interface.