From: <bh...@us...> - 2008-08-11 10:21:43
|
Revision: 10750 http://swig.svn.sourceforge.net/swig/?rev=10750&view=rev Author: bhy Date: 2008-08-11 10:21:39 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Patch the parser and scanner so %feature can be applied on C++ conversion operator, eg. operator bool. For example, the following code has no effect without this patch: %feature("shadow") *::operator bool %{ ... %} Modified Paths: -------------- branches/gsoc2008-bhy/Source/CParse/cscanner.c branches/gsoc2008-bhy/Source/CParse/parser.y Modified: branches/gsoc2008-bhy/Source/CParse/cscanner.c =================================================================== --- branches/gsoc2008-bhy/Source/CParse/cscanner.c 2008-08-09 23:57:55 UTC (rev 10749) +++ branches/gsoc2008-bhy/Source/CParse/cscanner.c 2008-08-11 10:21:39 UTC (rev 10750) @@ -690,7 +690,15 @@ termtoken = SWIG_TOKEN_LPAREN; termvalue = "("; break; - } else if (nexttok == SWIG_TOKEN_SEMI) { + } else if (nexttok == SWIG_TOKEN_CODEBLOCK) { + termtoken = SWIG_TOKEN_CODEBLOCK; + termvalue = Scanner_text(scan); + break; + } else if (nexttok == SWIG_TOKEN_LBRACE) { + termtoken = SWIG_TOKEN_LBRACE; + termvalue = "{"; + break; + } else if (nexttok == SWIG_TOKEN_SEMI) { termtoken = SWIG_TOKEN_SEMI; termvalue = ";"; break; @@ -859,8 +867,14 @@ return (INLINE); if (strcmp(yytext, "%typemap") == 0) return (TYPEMAP); - if (strcmp(yytext, "%feature") == 0) + if (strcmp(yytext, "%feature") == 0) { + /* The rename_active indicates we don't need the information of the + * following function's return type. This applied for %rename, so do + * %feature. + */ + rename_active = 1; return (FEATURE); + } if (strcmp(yytext, "%except") == 0) return (EXCEPT); if (strcmp(yytext, "%importfile") == 0) Modified: branches/gsoc2008-bhy/Source/CParse/parser.y =================================================================== --- branches/gsoc2008-bhy/Source/CParse/parser.y 2008-08-09 23:57:55 UTC (rev 10749) +++ branches/gsoc2008-bhy/Source/CParse/parser.y 2008-08-11 10:21:39 UTC (rev 10750) @@ -2290,21 +2290,25 @@ String *val = $7 ? NewString($7) : NewString("1"); new_feature($3, val, 0, $5.id, $5.type, $5.parms, $6.qualifier); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum RPAREN declarator cpp_const SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, 0, $7.id, $7.type, $7.parms, $8.qualifier); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring featattr RPAREN declarator cpp_const stringbracesemi { String *val = $8 ? NewString($8) : NewString("1"); new_feature($3, val, $4, $6.id, $6.type, $6.parms, $7.qualifier); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum featattr RPAREN declarator cpp_const SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, $6, $8.id, $8.type, $8.parms, $9.qualifier); $$ = 0; + scanner_clear_rename(); } /* Global feature */ @@ -2312,21 +2316,25 @@ String *val = $5 ? NewString($5) : NewString("1"); new_feature($3, val, 0, 0, 0, 0, 0); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum RPAREN SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, 0, 0, 0, 0, 0); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring featattr RPAREN stringbracesemi { String *val = $6 ? NewString($6) : NewString("1"); new_feature($3, val, $4, 0, 0, 0, 0); $$ = 0; + scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum featattr RPAREN SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, $6, 0, 0, 0, 0); $$ = 0; + scanner_clear_rename(); } ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |