All Manuals > LispWorks COM/Automation User Guide and Reference Manual > 1 Using COM > 1.8 Implementing COM interfaces in Lisp > 1.8.5 Inheritance

NextPrevUpTopContentsIndex An example of multiple inheritance

The inheritance rules may lead to unexpected results in the case of multiple inheritance. For example, consider the following IDL:

// IDL definition of IFoo
import "unknwn.idl";
[ uuid(7D9EB760-E4E5-11D5-BF02-000347024BE1) ]
interface IFoo : IUnknown
  HRESULT meth1();
  HRESULT meth2();
  HRESULT meth3();

and these three (partial) implementations of the interface i-foo .

  1. An implementation with no definition of meth2:
  2. (define-com-implementation foo-impl-1 ()
      (:interfaces i-foo))
    (define-com-method meth1 ((this foo-impl-1))
    (define-com-method meth3 ((this foo-impl-1))
  3. An implementation with no definition except meth2 :
  4. (define-com-implementation foo-impl-2 ()
      (:interfaces i-foo))
    (define-com-method meth2 ((this foo-impl-2))
  5. A combined implementation, inheriting from steps 1 and 2 .
(define-com-implementation foo-impl-12 (foo-impl-1
  (:interfaces i-foo))

In step 3 , the class foo-impl-12 implements the interface i-foo , but inherits all the i-foo method definitions from foo-impl-1 , which is the first class in the class precedence list that implements that interface. These method definitions include the "unimplemented" definition of meth2 in foo-impl-1 , which hides the definition in the other superclass foo-impl-2 . As a result, when the following form is evaluated with p-foo created from an instance of foo-impl-12 :

(let ((object (make-instance 'foo-impl-12)))
  (with-temp-interface (p-foo)
      (nth-value 1 (query-object-interface
    (with-com-interface (call-p-foo i-foo) p-foo
      (values (call-p-foo meth1)
              (call-p-foo meth2)
              (call-p-foo meth3)))))

the three values are S_OK , E_NOTIMPL and S_OK .

LispWorks COM/Automation User Guide and Reference Manual - 19 Dec 2011