Improved C++0x rvalue reference implementation differentiating lvalue and rvalue references. The previous implementation treated rvalue references as lvalue references which leads to a number of different wrapping issues.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12160 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c3b48505e2
commit
d8cc75946b
13 changed files with 399 additions and 32 deletions
|
|
@ -3968,15 +3968,19 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para
|
|||
Delete(Namespaceprefix);
|
||||
Namespaceprefix = Swig_symbol_qualifiedscopename(0);
|
||||
if (error) $$ = 0;
|
||||
}
|
||||
| TEMPLATE cpptype idcolon { /* Explicit template instantiation */
|
||||
}
|
||||
|
||||
/* Explicit template instantiation */
|
||||
| TEMPLATE cpptype idcolon {
|
||||
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
|
||||
$$ = 0;
|
||||
}
|
||||
| EXTERN TEMPLATE cpptype idcolon { /* Explicit template instantiation without the translation unit */
|
||||
$$ = 0;
|
||||
}
|
||||
|
||||
/* Explicit template instantiation without the translation unit */
|
||||
| EXTERN TEMPLATE cpptype idcolon {
|
||||
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
|
||||
$$ = 0;
|
||||
}
|
||||
$$ = 0;
|
||||
}
|
||||
;
|
||||
|
||||
cpp_temp_possible: c_decl {
|
||||
|
|
@ -4395,6 +4399,23 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
|
|||
Setattr($$,"conversion_operator","1");
|
||||
add_symbols($$);
|
||||
}
|
||||
| storage_class COPERATOR type LAND LPAREN parms RPAREN cpp_vend {
|
||||
SwigType *decl;
|
||||
$$ = new_node("cdecl");
|
||||
Setattr($$,"type",$3);
|
||||
Setattr($$,"name",$2);
|
||||
Setattr($$,"storage",$1);
|
||||
decl = NewStringEmpty();
|
||||
SwigType_add_rvalue_reference(decl);
|
||||
SwigType_add_function(decl,$6);
|
||||
if ($8.qualifier) {
|
||||
SwigType_push(decl,$8.qualifier);
|
||||
}
|
||||
Setattr($$,"decl",decl);
|
||||
Setattr($$,"parms",$6);
|
||||
Setattr($$,"conversion_operator","1");
|
||||
add_symbols($$);
|
||||
}
|
||||
|
||||
| storage_class COPERATOR type LPAREN parms RPAREN cpp_vend {
|
||||
String *t = NewStringEmpty();
|
||||
|
|
@ -4902,6 +4923,15 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| pointer LAND notso_direct_declarator {
|
||||
$$ = $3;
|
||||
SwigType_add_rvalue_reference($1);
|
||||
if ($$.type) {
|
||||
SwigType_push($1,$$.type);
|
||||
Delete($$.type);
|
||||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| direct_declarator {
|
||||
$$ = $1;
|
||||
if (!$$.type) $$.type = NewStringEmpty();
|
||||
|
|
@ -4920,7 +4950,7 @@ declarator : pointer notso_direct_declarator {
|
|||
/* Adds one S/R conflict */
|
||||
$$ = $2;
|
||||
$$.type = NewStringEmpty();
|
||||
SwigType_add_reference($$.type);
|
||||
SwigType_add_rvalue_reference($$.type);
|
||||
if ($2.type) {
|
||||
SwigType_push($$.type,$2.type);
|
||||
Delete($2.type);
|
||||
|
|
@ -4990,6 +5020,15 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| pointer LAND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
$$ = $6;
|
||||
SwigType_add_rvalue_reference($1);
|
||||
if ($$.type) {
|
||||
SwigType_push($1,$$.type);
|
||||
Delete($$.type);
|
||||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| PERIOD PERIOD PERIOD direct_declarator {
|
||||
$$ = $4;
|
||||
if (!$$.type) $$.type = NewStringEmpty();
|
||||
|
|
@ -5008,7 +5047,7 @@ declarator : pointer notso_direct_declarator {
|
|||
/* Adds one S/R conflict */
|
||||
$$ = $5;
|
||||
$$.type = NewStringEmpty();
|
||||
SwigType_add_reference($$.type);
|
||||
SwigType_add_rvalue_reference($$.type);
|
||||
if ($5.type) {
|
||||
SwigType_push($$.type,$5.type);
|
||||
Delete($5.type);
|
||||
|
|
@ -5047,6 +5086,16 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| pointer idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
$$ = $8;
|
||||
SwigType_add_memberpointer($1,$2);
|
||||
SwigType_add_rvalue_reference($1);
|
||||
if ($$.type) {
|
||||
SwigType_push($1,$$.type);
|
||||
Delete($$.type);
|
||||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
SwigType *t = NewStringEmpty();
|
||||
$$ = $7;
|
||||
|
|
@ -5058,6 +5107,17 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = t;
|
||||
}
|
||||
| idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
SwigType *t = NewStringEmpty();
|
||||
$$ = $7;
|
||||
SwigType_add_memberpointer(t,$1);
|
||||
SwigType_add_rvalue_reference(t);
|
||||
if ($$.type) {
|
||||
SwigType_push(t,$$.type);
|
||||
Delete($$.type);
|
||||
}
|
||||
$$.type = t;
|
||||
}
|
||||
;
|
||||
|
||||
notso_direct_declarator : idcolon {
|
||||
|
|
@ -5191,6 +5251,13 @@ direct_declarator : idcolon {
|
|||
}
|
||||
SwigType_add_reference($$.type);
|
||||
}
|
||||
| LPAREN LAND direct_declarator RPAREN {
|
||||
$$ = $3;
|
||||
if (!$$.type) {
|
||||
$$.type = NewStringEmpty();
|
||||
}
|
||||
SwigType_add_rvalue_reference($$.type);
|
||||
}
|
||||
| LPAREN idcolon DSTAR direct_declarator RPAREN {
|
||||
SwigType *t;
|
||||
$$ = $4;
|
||||
|
|
@ -5283,6 +5350,13 @@ abstract_declarator : pointer {
|
|||
$$.parms = 0;
|
||||
$$.have_parms = 0;
|
||||
}
|
||||
| pointer LAND {
|
||||
$$.type = $1;
|
||||
SwigType_add_rvalue_reference($$.type);
|
||||
$$.id = 0;
|
||||
$$.parms = 0;
|
||||
$$.have_parms = 0;
|
||||
}
|
||||
| pointer AND direct_abstract_declarator {
|
||||
$$ = $3;
|
||||
SwigType_add_reference($1);
|
||||
|
|
@ -5292,6 +5366,15 @@ abstract_declarator : pointer {
|
|||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| pointer LAND direct_abstract_declarator {
|
||||
$$ = $3;
|
||||
SwigType_add_rvalue_reference($1);
|
||||
if ($$.type) {
|
||||
SwigType_push($1,$$.type);
|
||||
Delete($$.type);
|
||||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| direct_abstract_declarator {
|
||||
$$ = $1;
|
||||
}
|
||||
|
|
@ -5304,6 +5387,15 @@ abstract_declarator : pointer {
|
|||
Delete($2.type);
|
||||
}
|
||||
}
|
||||
| LAND direct_abstract_declarator {
|
||||
$$ = $2;
|
||||
$$.type = NewStringEmpty();
|
||||
SwigType_add_rvalue_reference($$.type);
|
||||
if ($2.type) {
|
||||
SwigType_push($$.type,$2.type);
|
||||
Delete($2.type);
|
||||
}
|
||||
}
|
||||
| AND {
|
||||
$$.id = 0;
|
||||
$$.parms = 0;
|
||||
|
|
@ -5311,6 +5403,13 @@ abstract_declarator : pointer {
|
|||
$$.type = NewStringEmpty();
|
||||
SwigType_add_reference($$.type);
|
||||
}
|
||||
| LAND {
|
||||
$$.id = 0;
|
||||
$$.parms = 0;
|
||||
$$.have_parms = 0;
|
||||
$$.type = NewStringEmpty();
|
||||
SwigType_add_rvalue_reference($$.type);
|
||||
}
|
||||
| idcolon DSTAR {
|
||||
$$.type = NewStringEmpty();
|
||||
SwigType_add_memberpointer($$.type,$1);
|
||||
|
|
@ -5821,6 +5920,13 @@ valexpr : exprnum { $$ = $1; }
|
|||
$$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $5.val);
|
||||
}
|
||||
}
|
||||
| LPAREN expr LAND RPAREN expr %prec CAST {
|
||||
$$ = $5;
|
||||
if ($5.type != T_STRING) {
|
||||
SwigType_add_rvalue_reference($2.val);
|
||||
$$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $5.val);
|
||||
}
|
||||
}
|
||||
| LPAREN expr pointer AND RPAREN expr %prec CAST {
|
||||
$$ = $6;
|
||||
if ($6.type != T_STRING) {
|
||||
|
|
@ -5829,10 +5935,22 @@ valexpr : exprnum { $$ = $1; }
|
|||
$$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $6.val);
|
||||
}
|
||||
}
|
||||
| LPAREN expr pointer LAND RPAREN expr %prec CAST {
|
||||
$$ = $6;
|
||||
if ($6.type != T_STRING) {
|
||||
SwigType_push($2.val,$3);
|
||||
SwigType_add_rvalue_reference($2.val);
|
||||
$$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $6.val);
|
||||
}
|
||||
}
|
||||
| AND expr {
|
||||
$$ = $2;
|
||||
$$.val = NewStringf("&%s",$2.val);
|
||||
}
|
||||
| LAND expr {
|
||||
$$ = $2;
|
||||
$$.val = NewStringf("&&%s",$2.val);
|
||||
}
|
||||
| STAR expr {
|
||||
$$ = $2;
|
||||
$$.val = NewStringf("*%s",$2.val);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue