Add docs about missing precedence levels for typecheck typemaps

This commit is contained in:
William S Fulton 2015-04-13 20:28:32 +01:00
commit 073bb244e4

View file

@ -4429,7 +4429,7 @@ before arrays, and so forth.
<p> <p>
Using the above table as a guide, each target language defines a collection of "typecheck" typemaps. Using the above table as a guide, each target language defines a collection of "typecheck" typemaps.
The follow excerpt from the Python module illustrates this: The following excerpt from the Python module illustrates this:
</p> </p>
<div class="code"> <div class="code">
@ -4542,11 +4542,31 @@ Here is an example,
<p> <p>
The bottom line: If you are writing new typemaps and you are using overloaded methods, you will probably The bottom line: If you are writing new typemaps and you are using overloaded methods, you will probably
have to write typecheck code or copy existing code. Since this is a relatively new SWIG feature, there are have to write new typecheck code or copy and modify existing typecheck code.
few examples to work with. However, you might look at some of the existing library files likes 'typemaps.i' for
a guide.
</p> </p>
<p>
If you write a typecheck typemap and omit the precedence level, for example commenting it out as shown below:
</p>
<div class="code">
<pre>
%typemap(typecheck /*,precedence=SWIG_TYPECHECK_INTEGER*/) int {
$1 = PyInt_Check($input) ? 1 : 0;
}
</pre>
</div>
<p>
then the type is given a precedence higher than any other known precedence level and a <a href="Warnings.html#Warnings">warning</a> is issued:
</p>
<div class="shell">
<pre>
example.i:18: Warning 467: Overloaded method foo(int) not supported (no type checking rule for 'int').
</pre>
</div>
<p> <p>
<b>Notes:</b> <b>Notes:</b>
</p> </p>