[foreign-jextract] [Rev 01] RFR: 8239809: Need API to access attributes
Henry Jen
henryjen at openjdk.java.net
Tue Feb 25 20:57:04 UTC 2020
On Tue, 25 Feb 2020 18:12:36 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> The pull request has been updated with 1 additional commit.
>
> src/jdk.incubator.jextract/share/classes/jdk/incubator/jextract/Declaration.java line 295:
>
>> 294: */
>> 295: static Declaration.Variable globalVariable(Position pos, String name, Type type, Map<String, List<ConstantDesc>> attrs) {
>> 296: return new DeclarationImpl.VariableImpl(type, Declaration.Variable.Kind.GLOBAL, name, pos, attrs);
>
> Uhmmm. I think I'd prefer not to have a Map accepting factory, but to have a `Declaration::withAttribute(String, ConstantDesc)` method. This makes the API a lot tidier (and is similar to what we did for layouts).
I removed changes to factory methods, they are from parsing internally, so this is fine.
I agree withAttributes is preferred, but not certain about take single attribute/value. While this maybe the use case most of time, there are situations I need to do multiple modifications or copy and that leads to unnecessary rounds of object creation.
We can leave that out for now, since attributes are populated via parsing, and we don't have a use case where user should be adding attributes.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/33
More information about the panama-dev
mailing list