LispWorks COM/Automation User Guide and Reference Manual > 1 Using COM > 1.7 Calling COM interface methods > 1.7.1 Data conversion when calling COM methods

NextPrevUpTopContentsIndex

1.7.1.1 In parameters

In parameters are passed as positional arguments in the order they are specified and do not affect the return values.

For example, given the IDL

import "unknwn.idl";
 
[ object,
  uuid(E37A70A0-EFC9-11D5-BF02-000347024BE1)
]
interface IArgumentExamples : IUnknown
{
  typedef [string] char *argString;
 
  HRESULT inMethod([in] int inInt,
                   [in] argString inString,
                   [in] int inArraySize,
                   [in, size_is(inArraySize)] int *inArray);
}

the method in-method can be called with Lisp objects like this:

(let ((array #(7 6)))
  (call-com-interface (arg-example i-argument-examples
                                   in-method)
                      42
                      "the answer"
                      (length array)
                      array))

or with foreign pointers like this:

(fli:with-dynamic-foreign-objects ()
  (let* ((farray-size 2)
         (farray (fli:allocate-dynamic-foreign-object
                  :type :int
                  :nelems farray-size
                  :initial-contents '(7 6))))
    (fli:with-foreign-string (fstring elt-count byte-count)
        "the answer"
      (declare (ignore elt-count byte-count))
      (call-com-interface (arg-example i-argument-examples
                                       in-method)
                          42
                          fstring
                          farray-size
                          farray))))

Note that the int arguments are always passed as Lisp integer because int is a primitive type.


LispWorks COM/Automation User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex