Imported a29647cdf48806876a3bdb6173e3c0df8dda15ce from upstream for swig templating