PreviousNext

Parameter Declarations

A parameter_declaration is used in an operation declaration to declare a parameter of the operation. A parameter_declaration takes the form:

[parameter_attribute, ...] type_specifier parameter_declarator

If an interface does not use implicit handles or use interface-based binding, the first parameter must be an explicit handle that gives the object UUID and location. The handle parameter can be of a primitive handle type, handle-t, or a nonprimitive user-defined handle type.

A parameter_attribute can be any of the following:

· array_attribute: One of several attributes that specifies the characteristics of arrays.

· in: The parameter is an input attribute.

· out: The parameter is an output attribute.

· ref: The parameter is a reference pointer: it cannot be NULL and cannot be an alias.

· ptr: The parameter is a full pointer; it can be NULL and can be an alias.

· unique: The parameter is a unique pointer; it can be NULL.

· string: The parameter is a string.

· context_handle: The parameter is a context handle.

· switch is:

The directional attributes in and out specify the directions in which a parameter is to be passed. The in attribute specifies that the parameter is passed from the caller to the callee. The out attribute specifies that the parameter is passed from the callee to the caller.

An output parameter must be passed by reference and therefore must be declared with an explicit *. (Note that an array is implicitly passed by reference and so an output array does not require an explicit *.) At least one directional attribute must be specified for each parameter of an operation.

An explicit handle parameter must have at least the in attribute.

For more information, see Pointer Attributes, Strings, and The context_handle Attribute.

The type_specifier in a parameter declaration specifies the data type of the parameter.

The declarator in a parameter declaration can be any simple or complex declarator.

A parameter with the out attribute must be either an array or an explicitly declared pointer. An explicitly declared pointer is declared by a pointer_declarator, rather than by a simple_declarator with a named pointer type as its type_specifier.

For information on the semantics of pointers as operation parameters, refer to Pointers.