Improve documentation for multi-argument typemaps and overloading

This commit is contained in:
William S Fulton 2016-04-02 13:44:44 +01:00
commit 355f2623c7
2 changed files with 55 additions and 5 deletions

View file

@ -3444,7 +3444,7 @@ list of strings like this:
<div class="targetlang">
<pre>
&gt;&gt;&gt; foo(["ale","lager","stout"])
&gt;&gt;&gt; foo(["ale", "lager", "stout"])
</pre>
</div>
@ -3487,6 +3487,11 @@ maps perform the conversion described for the above example:
%typemap(freearg) (int argc, char *argv[]) {
if ($2) free($2);
}
/* Required for C++ method overloading */
%typecheck(SWIG_TYPECHECK_STRING_ARRAY) (int argc, char *argv[]) {
$1 = PyList_Check($input) ? 1 : 0;
}
</pre>
</div>
@ -3554,6 +3559,11 @@ Other directives such as <tt>%apply</tt> and <tt>%clear</tt> also work with mult
</pre>
</div>
<p>
Don't forget to also provide a suitable <a href="#Typemaps_overloading">typemap for overloaded functions</a>, such as <tt>%typecheck</tt> shown for foo above.
This is only required if the function is overloaded in C++.
</p>
<p>
Although multi-argument typemaps may seem like an exotic, little used feature, there
are several situations where they make sense. First, suppose you wanted to wrap