COM IDL定义中的[in,out]和[out,retval]之间的差异 [英] Differences between [in, out] and [out, retval] in COM IDL definitions
问题描述
在一些IDL中,我注意到有两种方法标记返回值的惯例 - [in,out]
和
HRESULT MyMethod(
[in] long InputParam,
[in,out] long * OutputParam1,
[in,out] long * OutputParam2
);
看起来 [out,retval]
当只有一个返回值时使用,例如:
HRESULT MyMethod2(
[in] long InputParam ,
[out,retval] long * OutputParam1
);
这是COM IDL约定还是我正在使用的代码中的约定?
在代码中是否有两个符号产生的功能差异,还是完全可以互换?
[in,out]
表示当方法被调用并且有效值存在时传递一个有效值点)当方法返回成功。 [out]
表示指向的值可以是调用方法时的值,但在方法返回成功时将有效。参数必须是指针 - 它们的值不变并且有效,并且有效性是有效的。 [out]
和
[out,retval]
是一个语法糖,用于表示当创建一个本地COM支持包装器这个非常参数应该转换为一个返回值。例如
HRESULT MyMethod([out] long * OutParam1,[out,retval] long * OutParam2);
成为
long IWrappedInterface :: MyMethod(long * OutParam1);
如果您不将其标记 [retval]
包装器将包含具有原始签名的方法:
HRESULT IWrappedInterface :: MyMethod(long * OutParam1,long * OutParam2 );
只有最后一个 [out]
可以标记为 [out,retval]
。 [in,out]
参数不能标记为 [retval]
。
In some of the IDL I work with I have noticed that there are 2 conventions for marking return values in methods - [in, out]
and [out, retval]
.
It appears that [in, out]
is used when there are multiple return values, for example:
HRESULT MyMethod(
[in] long InputParam,
[in, out] long* OutputParam1,
[in, out] long* OutputParam2
);
It appears that [out, retval]
is used when there is only a single return value, for example:
HRESULT MyMethod2(
[in] long InputParam,
[out, retval] long* OutputParam1
);
Is this a COM IDL convention or just a convention in the code I am working with?
Is there a functional difference in the code that will be generated from the 2 notations, or are they completely interchangeable?
[in, out]
means that a valid value is passed when the method is called and a valid value is there (where the pointer points) when the method returns success. [out]
means that the value pointed to can be whatever when the method is called but it will be valid when the method returns success. Both [out]
and [in, out]
parameters must be pointers - their values are unchanged and valid and the validity requirements only apply to the variables they point to.
[out, retval]
is a syntactic sugar to indicate that when creating a Native COM Support wrapper this very parameter should be converted to a return value. For example
HRESULT MyMethod( [out] long* OutParam1, [out, retval] long* OutParam2 );
becomes
long IWrappedInterface::MyMethod( long* OutParam1 );
If you don't mark it [retval]
the wrapper will contain a method with the original signature:
HRESULT IWrappedInterface::MyMethod( long* OutParam1, long* OutParam2 );
Only the last one [out]
parameter can be marked as [out, retval]
. [in, out]
parameters can't be marked as [retval]
.
这篇关于COM IDL定义中的[in,out]和[out,retval]之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!