Polymorphism for shared_ptr declared templated classes which use typedef does not work.
If a templated shared_ptr class hiearchy is declared which uses a typedef for the templated class, SWIG does not correctly resolve the correct class hierchy.
This is illustrated by the minimal example attached, which fails when run. I am not sure it is related but in the generated wrapper code are shared_ptr types generated correctly for the typedefed template class Base<INT> and Derived<INT>
#define SWIGTYPE_p_boost__shared_ptrT_BaseT_INT_t_t swig_types[2]
#define SWIGTYPE_p_boost__shared_ptrT_DerivedT_INT_t_t swig_types[3]
But only the corresponding none shared_ptr type is defined with the typedef resolved:
#define SWIGTYPE_p_boost__shared_ptrT_BaseT_INT_t_t swig_types[2]
#define SWIGTYPE_p_boost__shared_ptrT_DerivedT_INT_t_t swig_types[3]
Johan
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
The handed test has been checked failing for SWIG version 2.0.4 on a Linux box
The bug can be reproduced by downloading the files and type
make
Johan
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
The last two #defines in the description should be
#define SWIGTYPE_p_BaseT_int_t swig_types[0]
#define SWIGTYPE_p_DerivedT_int_t swig_types[1]
Note the *int* instead of *INT*
Johan
In cplus_inherit_types_impl() in typepass.cxx,
smart = SwigType_typedef_resolve_all(spt);
is failing to resolve spt == "boost::shared_ptr<(Derived<(INTT)>)>"
You can move the typedef to above the %shared_ptr statements so that the type information is fully available. However, I've fixed your example for swig-2.0.5 so that it works as you'd hope it to.
The fix has been reverted for swig-2.0.5 (svn revision 12953) as it introduces other %shared_ptr regressions. To be looked at later...
Also note rev 12982 when coming back to this bug.
This particular case has been fixed for swig-3.0.11.