[nicl] RFR: Undefined struct and void*

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu May 24 12:12:48 UTC 2018


I agree with the wildcards changes; these seem like nice little 
usability improvements.

I'm a bit more skeptical over mapping undefined structs over to empty 
interface types. I think there is some value in trying to keep the lid 
over the kind of pointers that do not have an associated layout.

Looking at your test rewrite, it really does seem that something like:

Pointer<CXTranslationUnitImpl>

Is a real pointer, and you could do things with it, just as with other 
pointers (dereference, arithmetic), but it's all fake, as there's no 
layout under the hood.

So I think I'm slightly biased towards Pointer<Void> or Pointer<?> (plus 
annotation) in this case, as that models more accurately what is known 
about that pointer at that point in time (which is, nothing).

In terms of the new implementation in the foreign branch - these 
pointers do not have any LayoutType associated with them - so they're 
much more similar to void* than the C syntax would suggest. I agree that 
many C API do use this style in what Sundar calls poor-man OO style 
(:-)), and that having a 'real' interfaace name improves readability 
somewhat - but I also think that _not_ using real interface names seems 
a more honest approach which more accurately reflects what's under the hood.

Maurizio



On 24/05/18 09:36, Henry Jen wrote:
> Hi,
>
> Please review the webrev[1], in which we have a couple modification for jextract,
>
> - Generate empty interface for undefined struct instead of use Void. This actually improve readability and works better than type annotation.
>
> - When void* on the left side of assignment, Pointer<?> works way better than Pointer<Void> as it’s much more convenient. Thus this webrev make jextract emit Pointer<?> for void* for argument in function or a field setter. However, Pointer<?> on the right-hand side doesn’t give much value as it require cast just like Pointer<Void>, additionally Pointer<Pointer<Void>> is much usable then Pointer<Pointer<?>> in case of void**.
>
> - Fix a Array descriptor bug in toString
>
> - StructTest.java and struct.h to test mentioned changes. This also include test for C++ mode which should have gone in with last push, but I missed them. :(
>
> Thoughts?
>
> Cheers,
> Henry
>
> [1] http://cr.openjdk.java.net/~henryjen/panama/wildcardPointer/webrev/



More information about the panama-dev mailing list