User`s guide

Calling Conventions
Calling Co nventions
This section describes t he calling conventions for MATLAB Builder for Excel
components, including mappings from the original M-functions to VBA. A
function call originating from an Excel worksheet is routed from a VBA
function into a compiled M-function.
Producing a COM Class
Producing a COM class requires the generation of a class definition file in
Interface Description Language (IDL) as well as the associated C++ class
definition/implementation files. (See the M icrosoft COM documentation for a
complete discussion of IDL and C++ coding rules for building COM objects.)
The b uilder automatically produces the necessary IDL and C/C++ code to
build each COM class in the component. This process is generally transparent
to the user.
As a final step, Excel Builder produces a VBA function wrapper for each
method, used to implement an Excel formula function. Formula functions are
useful when calling a method that returns a single scalar value with one
or more inputs. Use a general VBA subroutine when calling a method that
returns array data or multiple outputs.
IDL Mapping
The most generic MATLAB M-function is
function [Y1, Y2, ..., varargout] = foo(X1, X2, ..., varargin)
This function maps directly to the following IDL signature:
HRESULT foo([in] long nargout,
[in,out] VARIANT* Y1,
[in,out] VARIANT* Y2,
.
.
.
[in,out] VARIANT* varargout,
[in] VARIANT X1,
[in] VARIANT X2,
A-11