title: %rename and %inline in swig, error checking
body: <p>I use SWIG and Numpy. I define a C function called <code>inplace()</code> to process data array fast, and I want to make some error checking (if two arrays have the same dimentions). </p>
  
  <p>I use <code>%rename</code> and <code>%inline</code> in the <code>.i</code> file. As I understand, rename should map the function names', so every time someone uses <code>inplace</code>, <code>safe_inplace</code> is run and the errors are checked.</p>
  
  <p>But it does not work :( . As far I notice, safe_inplace is not executed, python runs directly <code>inplace</code> without touching the safe version of the function.</p>
  
  <pre><code># .i
  
  %include "inplace.h"
  %rename (inplace) safe_inplace;
  
  %inline %{
      void safe_inplace(int* datain, int in_dx, int in_dy, int in_dz,
                        int* dataout, int out_dx, int out_dy)
      {
          if ((in_dx != out_dx) || (in_dy != out_dy)) { 
              PyErr_Format(PyExc_ValueError, /*... messgage*/) 
              return;
          } 
  
          inplace( /* .. pass the arguments to original function*/ );
      }
  </code></pre>
  
  <p>header file:</p>
  
  <pre><code># .h 
  
  void inplace(int* datain, int in_dx, int in_dy, int in_dz, int* dataout, int out_dx, int out_dy);
  </code></pre>
  
  <p>Python:</p>
  
  <pre><code>#.py
  inplace.inplace(a,b)
  </code></pre>
  
  <p>The original example that I modify can be found <a href="http://www.scipy.org/Cookbook/SWIG_NumPy_examples" rel="nofollow">here</a></p>