add docs for new -nodefault, -nodefaultdtor and -oldnodefault
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8023 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e5482f9e08
commit
c2073866b3
5 changed files with 182 additions and 43 deletions
|
|
@ -2222,13 +2222,13 @@ differently.
|
|||
</p>
|
||||
|
||||
<p>
|
||||
If you don't want SWIG to generate constructors and destructors, you
|
||||
can use the <tt>%nodefault</tt> directive or the <tt>-no_default</tt>
|
||||
command line option. For example:
|
||||
If you don't want SWIG to generate default constructors when processing C++
|
||||
interfaces, you can use the <tt>%nodefault</tt> directive or the
|
||||
<tt>-nodefault</tt> command line option. For example:
|
||||
</p>
|
||||
|
||||
<div class="shell"><pre>
|
||||
swig -no_default example.i
|
||||
swig -nodefault example.i
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -2238,9 +2238,9 @@ or
|
|||
<div class="code"><pre>
|
||||
%module foo
|
||||
...
|
||||
%nodefault; // Don't create default constructors/destructors
|
||||
%nodefault; // Don't create default constructors
|
||||
... declarations ...
|
||||
%makedefault; // Reenable default constructors/destructors
|
||||
%makedefault; // Reenable default constructors
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -2250,16 +2250,38 @@ definitions. For example:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%nodefault Foo; // No default constructor/destructors for Foo
|
||||
%nodefault Foo; // No default constructor for Foo
|
||||
...
|
||||
struct Foo { // No default generated.
|
||||
struct Foo { // No default constructor generated.
|
||||
};
|
||||
|
||||
struct Bar { // Default constructor/destructor generated.
|
||||
struct Bar { // Default constructor generated.
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
Since ignoring the implicit or default destructors most of the times
|
||||
produce memory leaks, SWIG will always try to generate them. If
|
||||
needed, however, you can selectively disable the generation of the
|
||||
default/implicit destructor by using <tt>%nodefaultdestructor </tt>
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%nodefaultdestructor Foo; // No default/implicit destructor for Foo
|
||||
...
|
||||
struct Foo { // No default destructor is generated.
|
||||
};
|
||||
|
||||
struct Bar { // Default destructor generated.
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
<b>Compatibility note:</b> Prior to SWIG-1.3.7, SWIG did not generate default constructors
|
||||
or destructors unless you explicitly turned them on using <tt>-make_default</tt>.
|
||||
|
|
@ -2267,6 +2289,17 @@ However, it appears that most users want to have constructor and destructor func
|
|||
has now been enabled as the default behavior.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Compatibility note:</b> Prior to SWIG-1.3.28, the
|
||||
<tt>-nodefault</tt> option and <tt>%nodefault</tt> directive also
|
||||
disable the default or implicit destructor generation. This had the
|
||||
major side effect of generating memory leaks, and is now disabled. If
|
||||
your interface needs the old behavior, use the
|
||||
<tt>-oldnodefault</tt> option.
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<H3><a name="SWIG_adding_member_functions"></a>5.5.6 Adding member functions to C structures</H3>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue