summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-12-22 18:32:02 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-12-22 21:23:44 +0000
commitf648e58cb1062984b77946d0ebf9ea2778c933d2 (patch)
tree0d5ca46924b18c142feb7c5417377b464d01d300
parent67c4c2186cd7e7d47bb7e372f9dc07ec8c4af3e6 (diff)
downloadswig-f648e58cb1062984b77946d0ebf9ea2778c933d2.tar.gz
Extend variadic template support to various type combinations
-rw-r--r--Examples/test-suite/cpp11_variadic_templates.i17
-rw-r--r--Source/CParse/parser.y16
2 files changed, 28 insertions, 5 deletions
diff --git a/Examples/test-suite/cpp11_variadic_templates.i b/Examples/test-suite/cpp11_variadic_templates.i
index e561ad805..9ea11368e 100644
--- a/Examples/test-suite/cpp11_variadic_templates.i
+++ b/Examples/test-suite/cpp11_variadic_templates.i
@@ -138,3 +138,20 @@ public:
%template (LotsInherit2) LotsInherit<A,B>;
%template (LotsInherit3) LotsInherit<A,B,C>;
%template (LotsInherit4) LotsInherit<A,B,C,D>;
+
+
+%inline %{
+template <typename... V> struct VariadicParms {
+public:
+ void ParmsPtr(V*... vparms_p) {}
+ void ParmsPtrRef(V*&... vparms_pr) {}
+ void ParmsPtrRValueRef(V*&&... vparms_rvr) {}
+ void ParmsVal(V... vparms_v) {}
+ void ParmsRef(V&... vparms_r) {}
+ void ParmsConstRef(const V&... vparms_cr) {}
+};
+%}
+
+%template(VariadicParms1) VariadicParms<A>;
+%template(VariadicParms2) VariadicParms<A,B>;
+%template(VariadicParms3) VariadicParms<A,B,C>;
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 31b1f92ea..af15f43ec 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -4434,7 +4434,6 @@ templateparameter : templcpptype def_args {
const char *t = Strchr(type, ' ');
Setattr(p, "name", t + 1);
Setattr(p, "type", NewStringWithSize(type, t - Char(type)));
- SetFlag(p, "variadic");
}
}
}
@@ -5513,6 +5512,7 @@ declarator : pointer notso_direct_declarator {
Delete($$.type);
}
$$.type = $1;
+ SwigType_add_variadic($$.type);
}
| pointer AND ELLIPSIS notso_direct_declarator {
$$ = $4;
@@ -5522,6 +5522,7 @@ declarator : pointer notso_direct_declarator {
Delete($$.type);
}
$$.type = $1;
+ SwigType_add_variadic($$.type);
}
| pointer LAND ELLIPSIS notso_direct_declarator {
$$ = $4;
@@ -5531,17 +5532,18 @@ declarator : pointer notso_direct_declarator {
Delete($$.type);
}
$$.type = $1;
+ SwigType_add_variadic($$.type);
}
| ELLIPSIS direct_declarator {
$$ = $2;
if (!$$.type) $$.type = NewStringEmpty();
+ SwigType_add_variadic($$.type);
}
| AND ELLIPSIS notso_direct_declarator {
$$ = $3;
$$.type = NewStringEmpty();
SwigType_add_reference($$.type);
SwigType_add_variadic($$.type);
-/* TODO: add other SwigType_add_variadic */
if ($3.type) {
SwigType_push($$.type,$3.type);
Delete($3.type);
@@ -5553,6 +5555,7 @@ declarator : pointer notso_direct_declarator {
$$ = $3;
$$.type = NewStringEmpty();
SwigType_add_rvalue_reference($$.type);
+ SwigType_add_variadic($$.type);
if ($3.type) {
SwigType_push($$.type,$3.type);
Delete($3.type);
@@ -5563,6 +5566,7 @@ declarator : pointer notso_direct_declarator {
$$ = $4;
SwigType_add_memberpointer(t,$1);
+ SwigType_add_variadic(t);
if ($$.type) {
SwigType_push(t,$$.type);
Delete($$.type);
@@ -5573,6 +5577,7 @@ declarator : pointer notso_direct_declarator {
SwigType *t = NewStringEmpty();
$$ = $5;
SwigType_add_memberpointer(t,$2);
+ SwigType_add_variadic(t);
SwigType_push($1,t);
if ($$.type) {
SwigType_push($1,$$.type);
@@ -5585,6 +5590,7 @@ declarator : pointer notso_direct_declarator {
$$ = $6;
SwigType_add_memberpointer($1,$2);
SwigType_add_reference($1);
+ SwigType_add_variadic($1);
if ($$.type) {
SwigType_push($1,$$.type);
Delete($$.type);
@@ -5595,6 +5601,7 @@ declarator : pointer notso_direct_declarator {
$$ = $6;
SwigType_add_memberpointer($1,$2);
SwigType_add_rvalue_reference($1);
+ SwigType_add_variadic($1);
if ($$.type) {
SwigType_push($1,$$.type);
Delete($$.type);
@@ -5606,6 +5613,7 @@ declarator : pointer notso_direct_declarator {
$$ = $5;
SwigType_add_memberpointer(t,$1);
SwigType_add_reference(t);
+ SwigType_add_variadic(t);
if ($$.type) {
SwigType_push(t,$$.type);
Delete($$.type);
@@ -5617,6 +5625,7 @@ declarator : pointer notso_direct_declarator {
$$ = $5;
SwigType_add_memberpointer(t,$1);
SwigType_add_rvalue_reference(t);
+ SwigType_add_variadic(t);
if ($$.type) {
SwigType_push(t,$$.type);
Delete($$.type);
@@ -6926,8 +6935,6 @@ base_specifier : opt_virtual {
Setattr($$,"access","public");
}
if ($4) {
-/*TODO: remove "variadic" flag */
- SetFlag($$, "variadic");
SwigType_add_variadic(Getattr($$, "name"));
}
}
@@ -6945,7 +6952,6 @@ base_specifier : opt_virtual {
Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5));
}
if ($6) {
- SetFlag($$, "variadic");
SwigType_add_variadic(Getattr($$, "name"));
}
}