Fix template template parameters with default arguments
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10179 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e024efafce
commit
8f09d00bb0
5 changed files with 76 additions and 1 deletions
|
|
@ -1,6 +1,12 @@
|
|||
Version 1.3.34 (in progress)
|
||||
============================
|
||||
|
||||
12/06/2007: wsfulton
|
||||
Fix #1734415 - template template parameters with default arguments such as:
|
||||
|
||||
template<typename t_item, template<typename> class t_alloc = pfc::alloc_fast >
|
||||
class list_t : public list_impl_t<t_item,pfc::array_t<t_item,t_alloc> > { ... };
|
||||
|
||||
12/04/2007: mgossage
|
||||
[lua] Fix a bug in the class hierachy code, where the methods were not propagated,
|
||||
if the name ordering was in a certain order.
|
||||
|
|
|
|||
|
|
@ -299,6 +299,7 @@ CPP_TEST_CASES += \
|
|||
template_specialization_enum \
|
||||
template_static \
|
||||
template_tbase_template \
|
||||
template_template_parameters \
|
||||
template_typedef \
|
||||
template_typedef_cplx \
|
||||
template_typedef_cplx2 \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
|
||||
import template_template_parameters.*;
|
||||
|
||||
public class template_template_parameters_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_template_parameters");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
ListFastBool listBool = new ListFastBool();
|
||||
listBool.setItem(true);
|
||||
if (listBool.getItem() != true)
|
||||
throw new RuntimeException("Failed");
|
||||
|
||||
ListDefaultDouble listDouble = new ListDefaultDouble();
|
||||
listDouble.setItem(10.2);
|
||||
if (listDouble.getItem() != 10.2)
|
||||
throw new RuntimeException("Failed");
|
||||
}
|
||||
}
|
||||
|
||||
37
Examples/test-suite/template_template_parameters.i
Normal file
37
Examples/test-suite/template_template_parameters.i
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
%module template_template_parameters
|
||||
|
||||
|
||||
%inline %{
|
||||
namespace pfc {
|
||||
template<typename t_item, template <typename> class t_alloc> class array_t {};
|
||||
template<typename t_item> class alloc_fast {
|
||||
public:
|
||||
typedef t_item alloc_type;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename t_item, typename t2> class list_impl_t {};
|
||||
|
||||
template<typename t_item, template<typename> class t_alloc = pfc::alloc_fast >
|
||||
class list_t : public list_impl_t<t_item,pfc::array_t<t_item,t_alloc> > {
|
||||
public:
|
||||
t_item item;
|
||||
// typename t_alloc<t_item>::alloc_type allotype; // SWIG can't handle this yet
|
||||
void xx() {
|
||||
typename t_alloc<t_item>::alloc_type atype; // this type is the same as t_item type
|
||||
atype = 10;
|
||||
}
|
||||
};
|
||||
|
||||
void TestInstantiations() {
|
||||
pfc::array_t<int, pfc::alloc_fast> myArrayInt;
|
||||
list_impl_t<int, pfc::array_t<int, pfc::alloc_fast> > myListImplInt;
|
||||
}
|
||||
%}
|
||||
|
||||
%template(ListImplFastBool) list_impl_t<bool, pfc::array_t<bool, pfc::alloc_fast> >;
|
||||
%template(ListFastBool) list_t<bool, pfc::alloc_fast>;
|
||||
|
||||
%template(ListImplFastDouble) list_impl_t<double, pfc::array_t<double, pfc::alloc_fast> >;
|
||||
%template(ListDefaultDouble) list_t<double>;
|
||||
|
||||
|
|
@ -4432,10 +4432,13 @@ parm : rawtype parameter_declarator {
|
|||
}
|
||||
}
|
||||
|
||||
| TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon {
|
||||
| TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args {
|
||||
$$ = NewParm(NewStringf("template<class> %s %s", $5,$6), 0);
|
||||
Setfile($$,cparse_file);
|
||||
Setline($$,cparse_line);
|
||||
if ($7.val) {
|
||||
Setattr($$,"value",$7.val);
|
||||
}
|
||||
}
|
||||
| PERIOD PERIOD PERIOD {
|
||||
SwigType *t = NewString("v(...)");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue