[foreign-jextract] RFR: 8240300: jextract produces non compilable code with repeated declarations
Henry Jen
henryjen at openjdk.java.net
Mon Mar 2 19:27:35 UTC 2020
On Mon, 2 Mar 2020 18:03:42 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:
> Filtering repeated global variables and functions in code generator (added necessary hashCode, equals for decls, types)
src/jdk.incubator.jextract/share/classes/jdk/incubator/jextract/tool/StaticWrapperSourceFactory.java line 102:
> 101: public Void visitVariable(Declaration.Variable tree, Declaration parent) {
> 102: if (parent == null && !(variables.add(tree))) {
> 103: return null;
Why check parent == null? Isn't that the case for global variable or you have top-level for header file as parent?
src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/DeclarationImpl.java line 198:
> 197: if (this == o) return true;
> 198: if (o == null || getClass() != o.getClass()) return false;
> 199: FunctionImpl function = (FunctionImpl) o;
I am not sure if we should force same class or check at the interface level by only using interface APIs. Although we only have one implementation class now and perhaps will remain so in foreseeable future. Same applies to other classes.
src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/DeclarationImpl.java line 200:
> 199: FunctionImpl function = (FunctionImpl) o;
> 200: return params.equals(function.params) &&
> 201: type.equals(function.type);
Type would have covered both parameter type and return type. Compare params depends on how Variable implements equals and may cause same type declaration with different argument name to fail(not the case here).
src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/TypeImpl.java line 271:
> 270: argtypes.equals(function.argtypes) &&
> 271: restype.equals(function.restype);
> 272: }
Function with typedef and raw type will not be equal?
typedef int* intptr;
void intConsumer(int *ptr);
void intConsumer(intptr);
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/37
More information about the panama-dev
mailing list