title: How to apply SWIG OUTPUT typemaps for class types in Python?
body: <p>I am having some trouble generating a Python wrapper around a C++ library using SWIG (version 3.0.6).</p>
  
  <p>My issue relates to applying the OUTPUT typemap, specifically in the case of pointers/references to class types.</p>
  
  <p>To illustrate, this is what I want for standard types, and it works:</p>
  
  <pre><code>// .h
  int add(const long arg1,const long arg2,long&amp; resultLong);
  
  // interface.i
  %apply long&amp; OUTPUT { long&amp; resultLong };
  int add(const long arg1,const long arg2,long&amp; resultLong);
  
  // projectWrapper.py
  def add(arg1, arg2):
      return _projectWrapper.add(arg1, arg2)
  addTerm = _projectWrapper.add
  
  // usage
  &gt;&gt;&gt; result = projectWrapper.add(2, 4)
  &gt;&gt;&gt; print result
  [0, 6L]
  </code></pre>
  
  <p>You don't have to pass in "resultLong", but it is appended to the result automatically. Great!</p>
  
  <p>However, this doesn't seem to be working as I expect when the output type is some pointer to a class type:</p>
  
  <pre><code>// .h
  int GetClassType(const char* name, exportedClassType*&amp; resultPointer);
  
  class exportedClassType
  {...}
  
  // interface.i
  %apply exportedClassType*&amp; OUTPUT { exportedClassType*&amp; resultPointer };    
  int GetClassType(const char* name, exportedClassType*&amp; resultPointer);
  
  // projectWrapper.py
  def GetClassType(name, resultPointer):
      return _projectWrapper.GetClassType(name, resultPointer)
  GetClassType = _projectWrapper.GetClassType
  </code></pre>
  
  <p>The problem seems to be that SWIG has not processed it in the same way as the simple type. It still appears as an "input" parameter in the wrapped function signature.</p>
  
  <pre><code>// attempted usage
  &gt;&gt;&gt; classType = projectWrapper.GetClassType("name")
  TypeError: GetClassType() takes exactly 2 arguments (1 given)
  
  &gt;&gt;&gt; result = 0
  &gt;&gt;&gt; projectWrapper.GetClassType("name", result)
  Traceback (most recent call last):
  File "&lt;input&gt;", line 1, in &lt;module&gt;
  TypeError: in method 'GetClassType', argument 2 of type 'exportedClassType *&amp;'
  </code></pre>
  
  <p>Can somebody please tell me what I'm doing wrong or point me in the right direction? Any help gratefully received! Thanks</p>