Refactor the ndarray adaptor and expose the array flags

This uses a cleaner pattern in the C implementation, instead of computing all pointers by hand.
I'm not sure what keeping the original layout would bring, apart making it harder to emulate in C.