RFR: 7903257: jextract should generate javadoc comments [v3]

Athijegannathan Sundararajan sundar at openjdk.org
Wed Oct 12 12:38:21 UTC 2022


On Wed, 12 Oct 2022 12:16:25 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   defensive code to avoid possible crashes in doc generation
>
> src/main/java/org/openjdk/jextract/impl/CDeclarationPrinter.java line 149:
> 
>> 147:         indent();
>> 148:         builder.append("typedef ");
>> 149:         builder.append(nameAndType(d.type(), d.name()));
> 
> This use of `nameAndType` also leaves me a bit doubtful. There's var declarations, and there's just types + name. What's acceptable in both cases is different - e.g. `int a[3]` is not a valid type for a typedef. So, in cases where we just want a type, and the type should not have a name, we should have a way to say so in the code.

Example:

typedef int (*handler)(int x);

The type signature has buried name here ("handler")

> src/main/java/org/openjdk/jextract/impl/CDeclarationPrinter.java line 231:
> 
>> 229:             }
>> 230:             String res = t.returnType().accept(this, "").typeStr();
>> 231:             return new TypeVisitorResult(true, res + " (" + context + ")" + argsStr);
> 
> Is there always a name attached to a function pointer? I'd say no (e.g. typedef).

You're asking about parameter names? That's not present always. Hence the conditional code above.

> src/main/java/org/openjdk/jextract/impl/CDeclarationPrinter.java line 244:
> 
>> 242:             String brackets = String.format(" %s[%s]", context,
>> 243:                 t.elementCount().isPresent() ? t.elementCount().getAsLong() : "");
>> 244:             return new TypeVisitorResult(true, t.elementType().accept(this, "").typeStr() + brackets);
> 
> Is there always a name attached to an array type? I would say no? (e.g. in a typedef)

context is either empty string or has a name.

-------------

PR: https://git.openjdk.org/jextract/pull/85


More information about the jextract-dev mailing list