On Friday, January 6, 2017 at 10:10:17 PM UTC+3, Jb Evain wrote:
>
> On Thu, Jan 5, 2017 at 4:37 PM, LRN wrote:
>
>> On Thursday, January 5, 2017 at 8:01:17 PM UTC+3, Jb Evain wrote:
>>>
>>> On Thu, Jan 5, 2017 at 5:47 AM, LRN wrote:
>>>
>>>> MethodReturnType has internal Parameter object that it uses to store 
>>>> information about the thing that method returns.
>>>> I need to access that object, because it has Parameter.Name property - 
>>>> the name of return value. Normally return value is nameless, but in COM 
>>>> all 
>>>> interface methods actually return HRESULT, and the "real" result is passed 
>>>> via [output] parameter - which does have a name, and i need to know that 
>>>> name.
>>>>
>>>
>>> For a COM interface method, for a MethodDefinition, you'll have the 
>>> HRESULT (maybe an int?) as the ReturnType.
>>>
>> I think it's established that we agree on this one.
>>  
>>
>>> The [Out] parameter will be in the .Parameters collection of the 
>>> MethodDefinition.
>>>
>>
>> That does not match my observations. For example, 
>> Windows.Foundation.IPropertyValueStatics interface has CreateUInt8() method 
>> with one parameter ([in]System.Byte value). I'm using "foreach 
>> (ParameterDefinition param in method.Parameters)" to look through all 
>> parameters of a method.
>>
>>
> The signature of this method is:
>
> public static object CreateUInt32(uint value)
>
> So it doesn't return an HResult, it returns an object, and takes one 
> parameter. In that case there's simply no out parameter.
>

In IDL the signature of this method is:
            HRESULT CreateUInt8([in] BYTE value, [out] [retval] IInspectable
** propertyValue);
in C++ its signature is:
                    virtual HRESULT STDMETHODCALLTYPE CreateUInt8( 
                        /* [in] */ BYTE value,
                        /* [out][retval] */ __RPC__deref_out_opt 
IInspectable **propertyValue) = 0;

and in C it is:
        HRESULT ( STDMETHODCALLTYPE *CreateUInt8 )( 
            __RPC__in __x_ABI_CWindows_CFoundation_CIPropertyValueStatics * 
This,
            /* [in] */ BYTE value,
            /* [out][retval] */ __RPC__deref_out_opt IInspectable **
propertyValue);
(all of the above is according to Windows SDK).

All COM methods return HRESULT, because it's COM. The actual (useful) 
return value is passed via pointer. Because COM methods return HRESULT.

To turn a ECMA-335 method (what cecil reads from metadata) into COM method 
(what i need), you make it return HRESULT and add an extra argument for the 
real return value (two arguments, if return value is an array). That "real 
return value" is an argument. It has a name. I need to know that name. And 
i can know it, because ECMA-335 encodes method return value as just another 
method parameter, and allows it to have a name. Which i need to know. 
Because in COM return value is an argument. Because COM method itself 
returns HRESULT. Because COM.

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to