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 would prefer keeping the original layout.  The `parent` field is only needed as a hack to support returning array object passed in as argument.  It is not used outside of the call wrapper.  Even better is that we remove parent and support return-array-from-argument using static analysis and bake it into the call wrapper.