Documented default typemaps that can now be mixed together
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6554 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
66d92bb3f4
commit
8d36ce73d6
1 changed files with 44 additions and 0 deletions
|
|
@ -1180,6 +1180,50 @@ definitions are usually found in the SWIG library in a file such as
|
|||
<tt>python.swg</tt>, <tt>tcl8.swg</tt>, etc.
|
||||
</p>
|
||||
|
||||
<H3>Mixed default typemaps</H3>
|
||||
The default typemaps described above can be mixed with <tt>const</tt> and with each other.
|
||||
For example the <tt>SWIGTYPE *</tt> typemap is for default pointer handling, but if a <tt>const SWIGTYPE *</tt> typemap
|
||||
is defined it will be used instead for constant pointers. Some further examples follow:
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
%typemap(in) enum SWIGTYPE & { ... enum references ... }
|
||||
%typemap(in) const enum SWIGTYPE & { ... const enum references ... }
|
||||
%typemap(in) SWIGTYPE *& { ... pointers passed by reference ... }
|
||||
%typemap(in) SWIGTYPE * const & { ... constant pointers passed by reference ... }
|
||||
%typemap(in) SWIGTYPE[ANY][ANY] { ... 2D arrays ... }
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
<p>
|
||||
Note that the the typedef reduction described earlier is also used with these mixed default typemaps.
|
||||
For example, say the following typemaps are defined and SWIG is looking for the best match for the enum shown below:
|
||||
</p>
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
%typemap(in) const Hello & { ... }
|
||||
%typemap(in) const enum SWIGTYPE & { ... }
|
||||
%typemap(in) enum SWIGTYPE & { ... }
|
||||
%typemap(in) SWIGTYPE & { ... }
|
||||
%typemap(in) SWIGTYPE { ... }
|
||||
|
||||
enum Hello {};
|
||||
const Hello &hi;
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
<p>
|
||||
The typemap at the top of the list will be chosen, not because it is defined first, but because it is the closest match for the type being wrapped.
|
||||
If any of the typemaps in the above list were not defined, then the next one on the list would have precedence.
|
||||
In other words the typemap chosen is the closest explicit match.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Compatibility note: </b> The mixed default typemaps were introduced in SWIG-1.3.23, but were not used much in this version.
|
||||
Expect to see them being used more and more within the various libraries in later versions of SWIG.
|
||||
</p>
|
||||
|
||||
|
||||
<H3><a name="Typemaps_nn20"></a>10.3.4 Multi-arguments typemaps</H3>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue