Fix #1538522 and #1338527, forward templated class declarations without a name for the templated class parameters, such as: template <typename, class> class X;

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9645 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2007-01-25 23:50:04 +00:00
parent 93496ba199
commit 71c5f58bb3
3 changed files with 54 additions and 8 deletions

View File

@ -1,6 +1,12 @@
Version 1.3.32 (in progress)
============================
01/25/2007: wsfulton
Fix #1538522 and #1338527, forward templated class declarations without a
name for the templated class parameters, such as:
template <typename, class> class X;
01/23/2007: mgossage
[Lua] Patch #1640862: <malloc.h> replaced by <stdlib.h>
Patch #1598063 Typo in typemaps.i

View File

@ -58,3 +58,14 @@ namespace foo {
%template (LinearOpBase_int) LinearOpBase<int,int>;
%template (VectorBase_int) VectorBase<int>;
// Template forward class declarations mixing class and typename without always naming the templated parameter name
%inline %{
template <class> class TClass1;
template <typename> class TClass2;
template <class, typename> class TClass3;
template <class, class, class> class TClass4;
template <typename, typename> class TClass5;
template <typename, class K = double> class TClass6;
template<typename, class K, class C = K> class TClass7;
%}

View File

@ -1459,9 +1459,11 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
%type <dtype> initializer cpp_const ;
%type <id> storage_class;
%type <pl> parms ptail rawparms varargs_parms;
%type <pl> templateparameters templateparameterstail;
%type <p> parm valparm rawvalparms valparms valptail ;
%type <p> typemap_parm tm_list tm_tail ;
%type <id> cpptype access_specifier;
%type <p> templateparameter ;
%type <id> templcpptype cpptype access_specifier;
%type <node> base_specifier
%type <type> type rawtype type_right ;
%type <bases> base_list inherit raw_inherit;
@ -3769,7 +3771,7 @@ cpp_temp_possible: c_decl {
}
;
template_parms : rawparms {
template_parms : templateparameters {
/* Rip out the parameter names */
Parm *p = $1;
$$ = $1;
@ -3797,7 +3799,29 @@ template_parms : rawparms {
p = nextSibling(p);
}
}
;
;
templateparameters : templateparameter templateparameterstail {
set_nextSibling($1,$2);
$$ = $1;
}
| empty { $$ = 0; }
;
templateparameter : templcpptype {
$$ = NewParm(NewString($1), 0);
}
| parm {
$$ = $1;
}
;
templateparameterstail : COMMA templateparameter templateparameterstail {
set_nextSibling($2,$3);
$$ = $2;
}
| empty { $$ = 0; }
;
/* Namespace support */
@ -5594,10 +5618,19 @@ access_specifier : PUBLIC { $$ = (char*)"public"; }
;
cpptype : CLASS {
templcpptype : CLASS {
$$ = (char*)"class";
if (!inherit_list) last_cpptype = $$;
}
| TYPENAME {
$$ = (char *)"typename";
if (!inherit_list) last_cpptype = $$;
}
;
cpptype : templcpptype {
$$ = $1;
}
| STRUCT {
$$ = (char*)"struct";
if (!inherit_list) last_cpptype = $$;
@ -5606,10 +5639,6 @@ cpptype : CLASS {
$$ = (char*)"union";
if (!inherit_list) last_cpptype = $$;
}
| TYPENAME {
$$ = (char *)"typename";
if (!inherit_list) last_cpptype = $$;
}
;
opt_virtual : VIRTUAL