[foreign-jextract] RFR: 8252634: jextract should generate type annotations for C types
Jorn Vernee
jvernee at openjdk.java.net
Wed Sep 2 08:56:57 UTC 2020
On Wed, 2 Sep 2020 04:27:30 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:
> @C annotation generated for C types
src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/AnnotationWriter.java line 51:
> 50: * questions.
> 51: */
> 52:
There are 2 copyright headers here!
src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/AnnotationWriter.java line 73:
> 72: if (t.type() instanceof Type.Function) {
> 73: return typeStr.replace("(", "(*)(");
> 74: } else {
This might be problematic for multiple nested function types, e.g.
void (int, void (*)(void)) -> void (*)(int, void (*)(*)(*)(void))
The return type could also be a function pointer, so it's not always the first occurrence that needs to be replaced
either.
src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/StructBuilder.java line 166:
> 165: String param = MemorySegment.class.getSimpleName() + " seg";
> 166: append(PUB_MODS + "void " + javaName + "$set(" + this.anno + " " + param + ", " + anno + " " +
> type.getSimpleName() + " x) {\n"); 167: incrAlign();
Maybe rename `this.anno` to `parentAnno` to avoid the name conflict.
test/jdk/tools/jextract/Test8252634.java line 78:
> 77: Method allocate = findMethod(pointClass, "allocate");
> 78: checkAnnotation(allocate.getAnnotatedReturnType(), "struct Point");
> 79: } finally {
What about scoped allocate, allocate array, and indexed setters?
test/jdk/tools/jextract/test8252634.h line 35:
> 34: void func(int (*callback)(int));
> 35:
> 36: #ifdef __cplusplus
typedef is missing as well I guess.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/300
More information about the panama-dev
mailing list