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.3 In-out parameters

In-out parameters are always of type pointer in COM and are handled as a mixture of in and out . In particular, they have both a positional parameter and a keyword parameter, which can be used to control the value passed and conversion of the value returned respectively. Each in-out parameter generates a return value, which will be eq to the value of the keyword argument if it was passed and otherwise depends on the type of the parameter as below.

For example, given the IDL

import "unknwn.idl";
 
[ object,
  uuid(E37A70A0-EFC9-11D5-BF02-000347024BE1)
]
interface IArgumentExamples : IUnknown
{
  typedef [string] char *argString;
 
  HRESULT inoutMethod([in, out] int *inoutInt,
                      [in, out] argString *inoutString,
                      [in] int inoutArraySize,
                      [in, out, size_is(inoutArraySize)]
                      int *inoutArray);
}

the method inout-method can receive and return Lisp objects like this:

(let ((in-array #(7 6)))
  (multiple-value-bind (hres int string array)
      (call-com-interface (arg-example i-argument-examples
                          inout-method)
                          42
                          "the answer"
                          (length in-array)
                          in-array)
    ;; int is of type integer
    ;; string is of type string
    ;; array is of type array
    ))

or fill an existing array like this:

(let* ((in-array #(7 6))
       (out-array (make-array (length in-array))))
  (multiple-value-bind (hres int string array)
      (call-com-interface (arg-example i-argument-examples
                                       inout-method)
                          42
                          "the answer"
                          (length in-array)
                          in-array
                          :inout-array out-array)
    ;; int is of type integer
    ;; string is of type string
    ;; array is eq to out-array, which was filled
    ))

or update an existing array like this:

(let* ((inout-array #(7 6)))
  (multiple-value-bind (hres int string array)
      (call-com-interface (arg-example i-argument-examples
                                       inout-method)
                          42
                          "the answer"
                          (length inout-array)
                          inout-array
                          :inout-array inout-array)
    ;; int is of type integer
    ;; string is of type string
    ;; array is eq to inout-array, which was updated
    ))

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

NextPrevUpTopContentsIndex