RFR 8200452: Jextract failed to produce enum constants for anonymous enums
Henry Jen
henry.jen at oracle.com
Thu Apr 5 03:00:51 UTC 2018
OK, please review a follow up patch on top of this one, in which
- isAnonymousEnum() is strictly as enum {} without name, doesn’t matter if it’s typedefed
- lift all enum constants into the main header file. So instead of having the constants in the annotation enum type class, they are now at the head file file interface.
- Generate type annotation interface for named enum and typedefs. For example, #typedef enum color { r, g, b } color_t, both color and color_t will be annotations.
The webrev can be found at [1]. Combined webrev can be found at [2].
Cheers,
Henry
[1] http://cr.openjdk.java.net/~henryjen/panama/unscope_enum/webrev/
[2] http://cr.openjdk.java.net/~henryjen/panama/8200452.1/webrev/
Cheers,
Henry
> On Apr 2, 2018, at 11:30 PM, Sundararajan Athijegannathan <sundararajan.athijegannathan at oracle.com> wrote:
>
> The name "enum (anonymous" looks as if it is generated for debugging. libclang may change that between releases. I suggested Java identifier (as proxy for C identifier) check so that we can avoid brittleness in our code.
>
> -Sundar
>
> On 03/04/18, 10:54 AM, Henry Jen wrote:
>> On Apr 2, 2018, at 9:23 PM, Sundararajan Athijegannathan<sundararajan.athijegannathan at oracle.com> wrote:
>>>
>>> + public boolean isAnonymousEnum() {
>>>
>>> + // libclang::clang_Cursor_isAnonymous only applies to struct, not enum
>>> + if (type().kind() == TypeKind.Enum) {
>>> + return spelling().isEmpty()&&
>>> + type().spelling().startsWith("enum (anonymous");
>>> + }
>>> + return false;
>>> + }
>>> +
>>>
>>>
>>> Is it possible for check something else that is more stable than implementation aspect ("enum (anonymous")? How about Java non-identifier character presence or something like that?
>>>
>> I don’t get it, this is based on values from libclang implementation, so I have no idea how that related to Java non-identifie character.
>> Unfortunately, I cannot find anything we can use in libclang, the isAnonymous() only applies to record type, not enum. I am open to suggestions on how can it be more reliable.
>>
>> Cheers,
>> Henry
>>
>>> -Sundar
>>>
>>> On 03/04/18, 9:40 AM, Henry Jen wrote:
>>>> Hi,
>>>>
>>>> Please review the webrev[1] for 8200452[2]. The patch add constant int into the main interface is the enum is complete anonymous, otherwise, it was created as an type annotation of int with all enum constants in it.
>>>>
>>>> Cheers,
>>>> Henry
>>>>
>>>> [1]
>>>> http://cr.openjdk.java.net/~henryjen/panama/8200452/webrev/
>>>>
>>>> [2]
>>>> https://bugs.openjdk.java.net/browse/JDK-8200452
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> On Mar 29, 2018, at 12:11 PM, Henry Jen<henry.jen at oracle.com>
>>>>> wrote:
>>>>>
>>>>> Thanks, this fix part of the issue we encountered with anonymous enum.
>>>>>
>>>>> I filed a bug JDK-8200452[1] for various cases, we need to have a better strategy for naming anonymous enum, particularly when without typedef.
>>>>>
>>>>> Cheers,
>>>>> Henry
>>>>>
>>>>>
>>>>> [1]
>>>>> https://bugs.openjdk.java.net/browse/JDK-8200452
>>>>>
>>>>>
>>>>>
>>>>>> On Mar 27, 2018, at 10:00 PM, Sundararajan Athijegannathan<sundararajan.athijegannathan at oracle.com>
>>>>>> wrote:
>>>>>>
>>>>>> Please review.
>>>>>>
>>>>>> Webrev:
>>>>>> http://cr.openjdk.java.net/~sundar/jextract_anonymous_enum/webrev.00/
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> -Sundar
>>>>>>
More information about the panama-dev
mailing list