[PATCH 5/5] widl: Generate helper macros for WinRT implementation.

Rémi Bernon rbernon at codeweavers.com
Thu Feb 25 07:56:30 CST 2021


On 2/25/21 2:47 PM, Jacek Caban wrote:
> On 19.02.2021 20:43, Rémi Bernon wrote:
>> On 2/19/21 8:12 PM, Jacek Caban wrote:
>>> On 19.02.2021 18:18, Rémi Bernon wrote:
>>>> Hi Jacek!
>>>>
>>>> On 2/19/21 5:48 PM, Jacek Caban wrote:
>>>>> Hi Rémi,
>>>>>
>>>>>
>>>>> On 19.02.2021 12:04, Rémi Bernon wrote:
>>>>>> This generates additional macros to help keeping implementation 
>>>>>> simple,
>>>>>> guarded with WIDL_USING ifdefs, like this:
>>>>>>
>>>>>>      #ifdef WIDL_USING_WINDOWS_FOO_IFOO
>>>>>
>>>>>
>>>>> I would find it more readable if we didn't follow all-uppercase for 
>>>>> macro rule here, something like:
>>>>>
>>>>> #define WIDL_using_Windows_Foo_IFoo
>>>>>
>>>>> But it's a matter of taste, so I'm mentioning it just for 
>>>>> consideration.
>>>>>
>>>>
>>>> Yeah I don't really like it much, but I can see one reason to make 
>>>> something like that, which would also possibly solve the [1] below:
>>>>
>>>> For making things simpler to type, it could just be the type C name 
>>>> prefixed by WIDL_USING_, like in:
>>>>
>>>> #define WIDL_USING_CWindows_CGaming_CInput_CIRawGameController
>>>>
>>>> The generation of the guard macros would just have to remove the 
>>>> __x_ABI_ prefix, and developers just need to copy paste the type 
>>>> names they want without having to remove the C prefixes or mess with 
>>>> the name case.
>>>
>>>
>>> I hope that we can save developers from dealing with details about 
>>> name mangling, at least in non-templated cases. Ideally they would be 
>>> able to type it manually.
>>>
>>
>> Well, in that case all upper case could also save some effort trying 
>> to guess how the words are supposed to be capitalized :) 
> 
> 
> The other way to look at this is that now you have to take the original 
> spelling and do an additional step to upper case it :) My original 
> comment also applied to the other part of the patch, which required 
> developer to know when and how to use _F instead of _C. It may be less 
> of a deal for namespaces, but if we ever want to apply it to per-type as 
> well, I find IRAWGAMECONTROLLER much less readable than IRawGameController.
> 
> 
> widl already generates a number of macros that include type names in 
> their original casing. Upper casing only selected extension macros feels 
> inconsistent to me.
> 
> 
> Thanks,
> 
> Jacek
> 

In my opinion this differs from the convenience macros that WIDL 
generates, as they are supposed to be used in the code, as a replacement 
to the vtable methods and types accesses. So having them consistent with 
the original method and types names is relevant.

In this case, I think it is instead some preprocessor control mechanism, 
in the same way as COBJMACROS / INITGUID / WIN32_NO_STATUS, but specific 
to WIDL, and to some extent to the WinRT namespaces. They won't be used 
in the code, but should only be defined once before including the WinRT 
headers. So to me it would be more natural for them to follow the 
"standard" preprocessor macro naming scheme.

In any case I can probably live with the camelcase style, even if 
WIDL_using_Windows_Foundation still feels a bit awkward :)

I'll send an update with the other things addressed once the other 
patches are upstream.
-- 
Rémi Bernon <rbernon at codeweavers.com>



More information about the wine-devel mailing list