New warning when the smartptr feature is missing in some classes in an inheritance chain. Errors test-suite now uses Python instead of Tcl as testing language

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12395 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-01-17 21:12:35 +00:00
commit 3d7799fe0d
8 changed files with 107 additions and 16 deletions

View file

@ -1802,20 +1802,6 @@ struct DerivedIntValue : IntValue {
</pre>
</div>
<p>
Note that if the <tt>%shared_ptr</tt> macro is omitted for any class in the inheritance hierarchy, it will
result in a C++ compiler error.
For example if the above <tt>%shared_ptr(DerivedIntValue)</tt> is omitted, the following is typical of the compiler error that will result:
</p>
<div class="shell">
<pre>
example_wrap.cxx: In function 'void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*,
_jclass*, jlong)':
example_wrap.cxx:3169: error: 'smartarg1' was not declared in this scope
</pre>
</div>
<p>
A shared_ptr of the derived class can now be passed to a method where the base is expected in the target language, just as it can in C++:
</p>
@ -1828,6 +1814,59 @@ int val4 = example.extractValueSmart(div);
</pre>
</div>
<p>
If the <tt>%shared_ptr</tt> macro is omitted for any class in the inheritance hierarchy, SWIG will warn about this and the generated code may or may not result in a C++ compilation error.
For example, the following input:
</p>
<div class="code">
<pre>
%include "boost_shared_ptr.i"
%shared_ptr(Parent);
%inline %{
#include &lt;boost/shared_ptr.hpp&gt;
struct GrandParent {
virtual ~GrandParent() {}
};
struct Parent : GrandParent {
virtual ~Parent() {}
};
struct Child : Parent {
virtual ~Child() {}
};
%}
</pre>
</div>
<p>
warns about the missing smart pointer information:
</p>
<div class="shell">
<pre>
example.i:12: Warning 520: Base class 'GrandParent' of 'Parent' is not similarly marked as a smart pointer.
example.i:16: Warning 520: Derived class 'Child' of 'Parent' is not similarly marked as a smart pointer.
</pre>
</div>
<p>
Adding the missing <tt>%shared_ptr</tt> macros will fix this:
</p>
<div class="code">
<pre>
%include "boost_shared_ptr.i"
%shared_ptr(GrandParent);
%shared_ptr(Parent);
%shared_ptr(Child);
... as before ...
</pre>
</div>
<H2><a name="Library_nn16"></a>8.5 Utility Libraries</H2>

View file

@ -513,6 +513,7 @@ example.i(4) : Syntax error in input.
<li>517.
<li>518. Portability warning: File <em>file1</em> will be overwritten by <em>file2</em> on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
<li>519. %template() contains no name. Template method ignored: <em>declaration</em>
<li>520. <em>Base/Derived</em> class '<em>classname1</em>' of '<em>classname2</em>' is not similarly marked as a smart pointer.
</ul>
<H3><a name="Warnings_nn15"></a>14.9.6 Language module specific (700-899) </H3>