Pointer/Scope API questions

Samuel Audet samuel.audet at gmail.com
Wed Jan 8 10:12:02 UTC 2020


On 1/8/20 12:47 AM, Ty Young wrote:
> Likewise I think the enum situation can and should be handled better 
> regardless of the way it can be abused in C. An idea that comes to mind 
> is to take that int that represents the corresponding C enum and wrap it 
> in a Java enum (since you know the C enum name from the header) and have 
> it implement an interface generated from the header to lock it to the 
> specific methods it is used in(to prevent the current generic int type 
> method calls whenever enums are used).

BTW, I'm already doing that in JavaCPP. If you're curious, give it a try 
here with, for example, TensorRT:
https://github.com/bytedeco/javacpp-presets/tree/master/tensorrt#sample-usage

IMO, it works well enough, but I had to add an "intern()" method that 
works a bit like String.intern() to convert any random enum object to 
the right singleton object... If you have any better ideas than that, 
please let me know!

Samuel


More information about the panama-dev mailing list