GML Rotate,Flip,Shift Ds Grid or 2d Array

How do you rotate (90 degree increments) or flip (xflip, yflip) the contents of a ds grid or 2d array without manually rewriting the whole thing? I might also need to x shift and y shift the contents afterward as well.
 
Top