jaylib
jaylib copied to clipboard
better arrays
Javacpp accesses C arrays via pointers, e.g.
model.materials().position(1).maps().position(2)
This is weird for a Java programmer because it isn't just an accessor; it modifies the position field of the object, and is obviously highly unsafe. It would be better if we could convert the C arrays into Java arrays, or at least wrap a List interface around them.
We could perhaps make a class like ArrayWrapper<T>(Pointer p, int size) with methods such as get(index) and set(index) which will handle the requests carefully using the C style pointers, but the user would not need to be aware of it.