[swig] Define attribute(ref) instead of accessing swig internals.
As of SWIG 4.0, swig_getmethods and swig_setmethods are no
longer defined. The solution is to stop using these internal swig
dictionaries and use %attribute and %attributeref instead. I plan on
doing this incrementally, with this differential serving as an example.
Differential revision: https://reviews.llvm.org/D63530