rebase onto master
Move some more stuff from capi.cpp to capi/

I guess our goal should be to eventually get rid of this directory -- this stuff
should mostly be just taken from CPython, and we could/should use their directory
names for that.  But for now it feels better than putting it all into a single file.