[foreign-jextract] [Rev 01] RFR: 8241925: jextract should generate simple allocation, access API for C primitive types
Jorn Vernee
jvernee at openjdk.java.net
Wed Apr 1 10:42:55 UTC 2020
On Wed, 1 Apr 2020 02:55:42 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:
>> added static method helper classes to handle allocation, access ot C primitive types and C strings.
>
> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last
> revision:
> * added static modifier to Cstring.toString method. Added tests for Cstring methods
> * added length accepting allocateArray overloadeds and using the same in samples.
> * using bulk copy for array copy
> * fixed samples to use Cstring method instead of methods from Foreign.
Looks good! I had some suggestions but they can be addressed separately as well
src/jdk.incubator.jextract/share/classes/jdk/incubator/jextract/tool/resources/C-X.java.template line 40:
> 39: arrayHandle.set(addr, index, value);
> 40: }
> 41:
Could maybe name these `getArray` and `setArray`. We also have `allocateArray`, and it would make them a little easier
to tell apart from the normal `get` and `set` when reading the code that uses them.
src/jdk.incubator.jextract/share/classes/jdk/incubator/jextract/tool/resources/Cstring.java.template line 22:
> 21: .varHandle(elemCarrier, MemoryLayout.PathElement.sequenceElement());
> 22: }
> 23: private final static VarHandle byteArrHandle = arrayHandle(C_CHAR, byte.class);
Could this be moved to a common file (seems to be the same every time)? Maybe you could put it in RuntimeHelper, and
have an `import static ${RUNTIME_HELPER}` where you plugin in the generated class name?
-------------
Marked as reviewed by jvernee (Committer).
PR: https://git.openjdk.java.net/panama-foreign/pull/78
More information about the panama-dev
mailing list