fix template + typedef issue reported by Bo Peng
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8733 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2764016815
commit
511e4895b1
2 changed files with 38 additions and 8 deletions
|
|
@ -2,16 +2,15 @@
|
||||||
|
|
||||||
%include "std_vector.i"
|
%include "std_vector.i"
|
||||||
|
|
||||||
%inline
|
%inline {
|
||||||
{
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace simuPOP
|
namespace simuPOP
|
||||||
{
|
{
|
||||||
// some simple pop class
|
// some simple pop class
|
||||||
struct pop {
|
template <class Type>
|
||||||
|
struct Population {
|
||||||
int m_a;
|
int m_a;
|
||||||
pop(int a):m_a(a){}
|
Population(int a):m_a(a){}
|
||||||
};
|
};
|
||||||
|
|
||||||
// base operator, output pop.m_a
|
// base operator, output pop.m_a
|
||||||
|
|
@ -32,9 +31,40 @@ namespace simuPOP
|
||||||
virtual int func() const
|
virtual int func() const
|
||||||
{ return 2*this->m_pop.m_a; }
|
{ return 2*this->m_pop.m_a; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
namespace simuPOP
|
||||||
|
{
|
||||||
|
%template(population) Population< std::pair<unsigned long,unsigned long> >;
|
||||||
|
}
|
||||||
|
|
||||||
|
%inline
|
||||||
|
{
|
||||||
|
namespace simuPOP
|
||||||
|
{
|
||||||
|
typedef Population< std::pair<unsigned long,unsigned long> > pop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
%inline
|
||||||
|
{
|
||||||
|
namespace simuPOP
|
||||||
|
{
|
||||||
|
// %template(population) Population< std::pair<unsigned long,unsigned long> >;
|
||||||
|
|
||||||
|
struct pop {
|
||||||
|
int m_a;
|
||||||
|
pop(int a):m_a(a){}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace simuPOP
|
namespace simuPOP
|
||||||
{
|
{
|
||||||
%template(baseOperator) Operator< pop >;
|
%template(baseOperator) Operator< pop >;
|
||||||
|
|
|
||||||
|
|
@ -353,9 +353,9 @@ class TypePass : private Dispatcher {
|
||||||
// We need to fully resolve the name to make templates work correctly */
|
// We need to fully resolve the name to make templates work correctly */
|
||||||
Node *cn;
|
Node *cn;
|
||||||
fname = SwigType_typedef_resolve_all(name);
|
fname = SwigType_typedef_resolve_all(name);
|
||||||
if (Strcmp(fname,name) != 0) {
|
if (Strcmp(fname,name) != 0 && (cn = Swig_symbol_clookup_local(fname,0))) {
|
||||||
cn = Swig_symbol_clookup_local(fname,0);
|
if ((n == cn)
|
||||||
if ((!cn) || (Strcmp(nodeType(cn),"template") == 0)
|
|| (Strcmp(nodeType(cn),"template") == 0)
|
||||||
|| (Getattr(cn,"feature:onlychildren") != 0)
|
|| (Getattr(cn,"feature:onlychildren") != 0)
|
||||||
|| (Getattr(n,"feature:onlychildren") != 0)) {
|
|| (Getattr(n,"feature:onlychildren") != 0)) {
|
||||||
Swig_symbol_cadd(fname,n);
|
Swig_symbol_cadd(fname,n);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue