[nicl] RFR: Undefined struct and void*

Henry Jen henry.jen at oracle.com
Thu May 24 15:10:48 UTC 2018


On May 24, 2018, at 5:27 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> 
> 
> On 24/05/18 13:12, Maurizio Cimadamore wrote:
>> 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. 
> To summarize - I view an undefined struct in an header as a fancy way of doing a typedef over a void*. For typedefs, we currently generate annotations, so I think we should be consistent here?
> 
> Maurizio
> 

I understand the perspective of Pointer, but it’s really not that different to a incomplete array, the descriptor currently generated is '*c’. The benefit of the new approach is that the type safety is better as the struct type is preserved and enforced.

In the jclang case, the CXTranslationUnit annotation still there for the Pointer<>, what changed is the CXTranslationUnitImpl was an type annotation for the Void, but now it’s an empty interface.

Therefore, the consistency is actually better as struct will be interface and typedef be alias.

Cheers,
Henry




More information about the panama-dev mailing list