diff --git a/SWIG/Source/CParse/parser.y b/SWIG/Source/CParse/parser.y index c811273ca..5eac869fd 100644 --- a/SWIG/Source/CParse/parser.y +++ b/SWIG/Source/CParse/parser.y @@ -3543,7 +3543,6 @@ notso_direct_declarator : idcolon { $$.parms = 0; $$.have_parms = 0; } - | NOT idcolon { $$.id = Char(NewStringf("~%s",$2)); $$.type = 0; @@ -3559,6 +3558,14 @@ notso_direct_declarator : idcolon { $$.have_parms = 0; } +/* + | LPAREN AND idcolon RPAREN { + $$.id = Char($3); + $$.type = 0; + $$.parms = 0; + $$.have_parms = 0; + } +*/ /* Technically, this should be LPAREN declarator RPAREN, but we get reduce/reduce conflicts */ | LPAREN pointer notso_direct_declarator RPAREN { $$ = $3; @@ -3653,6 +3660,13 @@ direct_declarator : idcolon { } $$.type = $2; } + | LPAREN AND direct_declarator RPAREN { + $$ = $3; + if (!$$.type) { + $$.type = NewString(""); + } + SwigType_add_reference($$.type); + } | LPAREN idcolon DSTAR direct_declarator RPAREN { SwigType *t; $$ = $4; diff --git a/SWIG/Source/Swig/stype.c b/SWIG/Source/Swig/stype.c index bb9b27ddf..85588d523 100644 --- a/SWIG/Source/Swig/stype.c +++ b/SWIG/Source/Swig/stype.c @@ -1176,6 +1176,10 @@ SwigType_str(SwigType *s, const String_or_char *id) } else if (SwigType_isreference(element)) { Insert(result,0,"&"); + if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) { + Insert(result,0,"("); + Append(result,")"); + } } else if (SwigType_isarray(element)) { DOH *size; Append(result,"["); @@ -1380,11 +1384,15 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) { } firstarray = 0; } else if (SwigType_isreference(element)) { - Insert(result,0,"&"); - isreference = 1; + Insert(result,0,"&"); + if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) { + Insert(result,0,"("); + Append(result,")"); + } + isreference = 1; } else if (SwigType_isarray(element)) { DOH *size; - if (firstarray) { + if (firstarray && !isreference) { Append(result,"(*)"); firstarray = 0; } else {