Pergunta

What's the difference among [in], [out], [in, out] and [out, retval] ?

From some codes that I've read, I think that [in] is used to pass a parameter to one method. [out, retval] is to return one value. [in, out] is used to say that we can overwrite on this parameter and that it is the returned one. But, I've seem that this last attribute can be used more that once on the method's creation, why then? And, what's [out] in this case?

I suppose that I'm in the wrong track, can someone explain the difference among these attributes, please?

Foi útil?

Solução

These are MIDL language attributes for specification of COM-interface methods parameters in IDL file. The meaning of the specifiers goes from their names, and generally can be understood as passing parameters by value (in), by reference(in, out), and as return value (out, retval). out means only return value - but passed through the parameter, so the method can return several values.

In documentation: [in] attribute specifies input parameter, [out] - only output parameter, [in, out]- input and output, [out, retval] - return value. Do not forget that low level IDL description then can be used in different languages using this COM-object. For instance, we can have the IDL description (not strict):

// [out, retval] must be last
genererate([in] item_name, [out] size, [out, retval] res); 

and the usage will be:

var sz; // will be initialized in the COM-method
var res = FooObj.generate("new_item", sz); // FooObj is our COM-object
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top