jextract C++ support

Rel enatai at proton.me
Wed Sep 6 00:34:29 UTC 2023


Short updates from me.

I continue working on generating layout for std::string and found that it is failing on cxx branch:

Scoped: TOPLEVEL <toplevel>
Scoped: STRUCT __mbstate_t layout = [i32(__count)[i32(__wch)|[4:b8](__wchb)](__value)](__mbstate_t)
Attr: LINK -> []
Variable: FIELD __count type = Int(layout = i32)
Variable: FIELD __value type = Declared([i32(__wch)|[4:b8](__wchb)](union (unnamed at enum.h:28:3)))

java.lang.IllegalArgumentException: Invalid member name: union (unnamed at enum.h:28:3)
at java.base/java.lang.constant.ConstantUtils.validateMemberName(ConstantUtils.java:152)
at java.base/java.lang.constant.ClassDesc.of(ClassDesc.java:129)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.ClassSourceBuilder.<init>(ClassSourceBuilder.java:70)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.StructBuilder.<init>(StructBuilder.java:67)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.StructBuilder.<init>(StructBuilder.java:62)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.StructBuilder.addStruct(StructBuilder.java:136)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.OutputFactory.visitScoped(OutputFactory.java:187)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.OutputFactory.visitScoped(OutputFactory.java:54)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.DeclarationImpl$ScopedImpl.accept(DeclarationImpl.java:333)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.OutputFactory.visitVariable(OutputFactory.java:354)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.OutputFactory.visitVariable(OutputFactory.java:54)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.DeclarationImpl$VariableImpl.accept(DeclarationImpl.java:172)
at org.openjdk.jextract at 21/org.openjdk.jextract.impl.OutputFactory.lambda$visitScoped$0(OutputFactory.java:201)

But same worked with latest changes in panama branch.

In order to update cxx branch to panama branch I decided to use rebase instead of merge (I see Maurizio was merging them instead). The reason why I did rebase is that way our cpp changes will be always on top of whatever changes were done in panama branch (and not spread across the branch) so it will be easy to track them.

Initially we had following branch:
cxx - Maurizio initial cpp support

Now I added cxx2 branch which is rebase on latest panama branch with Maurizio changes.

Now, if you remember previously we did mangle only for member functions, and for ordinary functions we had define wrapper manually like:

https://github.com/enatai/panamaexperiments/blob/ec76f9c2d25734a8c9f93f6b4200161b353c81f0/cppexperiments/src/main/java/libcppexperiments/CalcDistance.java

I fixed it so jextract mangles, in case of C++, non member functions too:

https://github.com/enatai/jextractcpp/commit/f1f64e31702b06aa9325546013758ce912f36363

I plan to continue to do my changes in cxx2 branch and keep rebasing it to panama branch once in a while
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jextract-dev/attachments/20230906/d2d4a6ae/attachment.htm>


More information about the jextract-dev mailing list