From: <ka...@us...> - 2012-06-29 19:37:48
|
Revision: 13210 http://swig.svn.sourceforge.net/swig/?rev=13210&view=rev Author: kabbi Date: 2012-06-29 19:37:42 +0000 (Fri, 29 Jun 2012) Log Message: ----------- Fixed comments parsing, but broken li_boost_shared_ptr_bits test Modified Paths: -------------- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing.i branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_runme.java branches/gsoc2012-doxygen/Examples/test-suite/python/doxygen_parsing_runme.py branches/gsoc2012-doxygen/Source/CParse/parser.y Modified: branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing.i =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing.i 2012-06-29 19:28:21 UTC (rev 13209) +++ branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing.i 2012-06-29 19:37:42 UTC (rev 13210) @@ -16,6 +16,9 @@ //! This is the last type of comment for a var int simpleVarFour=42; +int simpleVarFive=42; +///< This is a post comment + /* We assume that all this comment types are ok, and later we only use the first-type comments. @@ -49,7 +52,8 @@ * Simple method with parameter */ void simpleMethodWithParameter( - int param /**< Some test param */ + int param, /**< Some test param */ + int argument /**< Some test argument */ ) { } Modified: branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_runme.java =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_runme.java 2012-06-29 19:28:21 UTC (rev 13209) +++ branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_runme.java 2012-06-29 19:37:42 UTC (rev 13210) @@ -68,7 +68,9 @@ wantedComments.put("CSimpleClass", " This is simple comment for a class \n"); wantedComments.put("simpleMethod", " Simple method \n"); - wantedComments.put("simpleMethodWithParameter", " Simple method with parameter \n @param\tparam Some test param \n"); + wantedComments.put("simpleMethodWithParameter", " Simple method with parameter \n" + + " @param\tparam Some test param \n" + + " @param\targument Some test argument \n"); wantedComments.put("CTemplateClassInt", " Comment for template class \n"); wantedComments.put("templateMethod", " Template method \n"); @@ -80,6 +82,8 @@ wantedComments.put("getSimpleVarThree", " This is again another type of comment for a var \n"); wantedComments.put("setSimpleVarFour", " This is the last type of comment for a var \n"); wantedComments.put("getSimpleVarFour", " This is the last type of comment for a var \n"); + wantedComments.put("setSimpleVarFive", " This is a post comment \n"); + wantedComments.put("getSimpleVarFive", " This is a post comment \n"); int errorCount=0; Modified: branches/gsoc2012-doxygen/Examples/test-suite/python/doxygen_parsing_runme.py =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/python/doxygen_parsing_runme.py 2012-06-29 19:28:21 UTC (rev 13209) +++ branches/gsoc2012-doxygen/Examples/test-suite/python/doxygen_parsing_runme.py 2012-06-29 19:37:42 UTC (rev 13210) @@ -14,6 +14,7 @@ check(doxygen_parsing.CSimpleClass.simpleMethodWithParameter.__doc__, '' '\s+Simple method with parameter' '\s+Arguments:\s+param \(int\)\s+-- Some test param\s+' +'argument \(int\)\s+-- Some test argument\s+' ) check(doxygen_parsing.CTemplateClassInt.__doc__, '\s+Comment for template class\s+') check(doxygen_parsing.CTemplateClassInt.templateMethod.__doc__, '\s+Template method\s+') \ No newline at end of file Modified: branches/gsoc2012-doxygen/Source/CParse/parser.y =================================================================== --- branches/gsoc2012-doxygen/Source/CParse/parser.y 2012-06-29 19:28:21 UTC (rev 13209) +++ branches/gsoc2012-doxygen/Source/CParse/parser.y 2012-06-29 19:37:42 UTC (rev 13210) @@ -24,6 +24,7 @@ #include "preprocessor.h" #include <ctype.h> + /* We do this for portability */ #undef alloca #define alloca malloc @@ -67,6 +68,7 @@ String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ String *currentCComment; /* Location of the stored C Comment */ static Node *previousNode = NULL; /* Pointer to the previous node (for post comments) */ +static Node *currentNode = NULL; /* Pointer to the current node (for post comments) */ int isStructuralDoxygen(String *s){ char *slashPointer = Strchr(s, '\\'); @@ -106,27 +108,9 @@ set_nodeType(n,tag); Setfile(n,cparse_file); Setline(n,cparse_line); - if(scan_doxygen_comments){ - /* Sets any post comments to the previous node */ - if(previousNode != NULL && currentPostComment != 0){ - String *copyPostComment = Copy(currentPostComment); - if (!Getattr(previousNode, "DoxygenComment")){ - Setattr(previousNode,"DoxygenComment",copyPostComment);} - else { - Append(copyPostComment, Getattr(previousNode, "DoxygenComment")); - Setattr(previousNode,"DoxygenComment",copyPostComment); - } - - currentPostComment = 0; - } - /* Sets Doxygen Comment if a Comment is Availible */ - if(currentComment != 0){ - String *copyComment = Copy(currentComment); - Setattr(n,"DoxygenComment",copyComment); - currentComment = 0; - } - previousNode = n; - } + /* Remember the previous node in case it will need a post-comment */ + previousNode = currentNode; + currentNode = n; return n; } @@ -205,6 +189,25 @@ return nn; } +static void set_comment(Node *n, String *comment) { + Parm *p; + if (!n || !comment) + return; + + if (Getattr(n, "DoxygenComment")) + Append(Getattr(n, "DoxygenComment"), comment); + else { + Setattr(n, "DoxygenComment", comment); + /* This is the first comment, populate it with @params, if any */ + p = Getattr(n, "parms"); + while (p) { + if (Getattr(p, "DoxygenComment")) + Printv(comment, "\n@param ", Getattr(p, "name"), Getattr(p, "DoxygenComment"), NIL); + p=nextSibling(p); + } + } +} + /* ----------------------------------------------------------------------------- * Variables * ----------------------------------------------------------------------------- */ @@ -1496,6 +1499,7 @@ Node *function = n; if (function) { + ParmList *varargs = Getattr(function,"feature:varargs"); if (varargs) { /* Handles the %varargs directive by looking for "feature:varargs" and @@ -1793,6 +1797,7 @@ %type <node> fname stringtype; %type <node> featattr; %type <str> doxygen_comment; +%type <str> doxygen_comment_item; %type <str> c_style_comment; %type <str> doxygen_post_comment; %type <str> doxygen_post_comment_item; @@ -1852,9 +1857,7 @@ declaration : swig_directive { $$ = $1; } | c_declaration { $$ = $1; } | cpp_declaration { $$ = $1; } - | doxygen_comment { $$ = $1; } | c_style_comment { $$ = $1; } - | doxygen_post_comment { $$ = $1; } | SEMI { $$ = 0; } | error { $$ = 0; @@ -1878,6 +1881,14 @@ */ + | doxygen_comment declaration { + $$ = $2; + set_comment($2, $1); + } + | declaration doxygen_post_comment { + $$ = $1; + set_comment($1, $2); + } | error COPERATOR { $$ = 0; skip_decl(); @@ -3442,68 +3453,66 @@ A Doxygen Comment (a string in Doxygen Format) ------------------------------------------------------------ */ -doxygen_comment : DOXYGENSTRING - { - /* while(Strchr($1,'/') == Char($1)) - Replace($1,"/","",DOH_REPLACE_FIRST); */ - DohReplace($1, "/**", "", 0); - DohReplace($1, "/*!", "", 0); - DohReplace($1, "///", "", 0); - DohReplace($1, "*/", "", 0); +doxygen_comment_item : DOXYGENSTRING { + DohReplace($1, "/**", "", 0); + DohReplace($1, "/*!", "", 0); + DohReplace($1, "///", "", 0); + DohReplace($1, "//!", "", 0); + DohReplace($1, "*/", "", 0); - /* isStructuralDoxygen() is disabled, since no comment - appears in such case. Need to fix. (most commands are - not translatable to javadoc anyway) */ - if(0 && isStructuralDoxygen($1)){ - $$ = new_node("doxycomm"); - Setattr($$,"DoxygenComment",$1); - } - else { - if(currentComment != 0){ - Append(currentComment,$1); - } - else - currentComment = $1; - $$ = 0; - } - } - ; + /* isStructuralDoxygen() is disabled, since no comment + appears in such case. Need to fix. (most commands are + not translatable to javadoc anyway) */ + if(0 && isStructuralDoxygen($1)){ + $$ = new_node("doxycomm"); + Setattr($$,"DoxygenComment",$1); + } + else { + $$ = $1; + } + } + ; -doxygen_post_comment_item : DOXYGENPOSTSTRING - { - DohReplace($1, "///<", "", 0); - DohReplace($1, "/**<", "", 0); - DohReplace($1, "/*!<", "", 0); - DohReplace($1, "//!<", "", 0); - DohReplace($1, "*/", "", 0); - - $$ = $1; - } - ; +doxygen_comment : doxygen_comment doxygen_comment_item { + Append($1, $2); + $$ = $1; + } + | doxygen_comment_item { + $$ = $1; + } + ; -doxygen_post_comment : doxygen_post_comment doxygen_post_comment_item - { - Append($1, $2); - $$ = $1; - } - | doxygen_post_comment_item - { - $$ = $1; - } - ; -c_style_comment : C_COMMENT_STRING - { - if(currentCComment != 0){ - Append(currentCComment, $1); - } - else currentCComment = $1; - $$ = 0; - } - ; +doxygen_post_comment_item : DOXYGENPOSTSTRING { + DohReplace($1, "///<", "", 0); + DohReplace($1, "/**<", "", 0); + DohReplace($1, "/*!<", "", 0); + DohReplace($1, "//!<", "", 0); + DohReplace($1, "*/", "", 0); + + $$ = $1; + } + ; +doxygen_post_comment : doxygen_post_comment doxygen_post_comment_item { + Append($1, $2); + $$ = $1; + } + | doxygen_post_comment_item { + $$ = $1; + } + ; +c_style_comment : C_COMMENT_STRING { + if(currentCComment != 0){ + Append(currentCComment, $1); + } + else currentCComment = $1; + $$ = 0; + } + ; + /* ====================================================================== * C++ Support * ====================================================================== */ @@ -4480,9 +4489,7 @@ | storage_class idcolon SEMI { $$ = 0; } | cpp_using_decl { $$ = $1; } | cpp_template_decl { $$ = $1; } - | doxygen_comment{ $$ = $1; } | c_style_comment{ $$ = $1; } - | doxygen_post_comment{ $$ = $1; } | cpp_catch_decl { $$ = 0; } | template_directive { $$ = $1; } | warn_directive { $$ = $1; } @@ -4490,6 +4497,14 @@ | fragment_directive {$$ = $1; } | types_directive {$$ = $1; } | SEMI { $$ = 0; } + | doxygen_comment cpp_member { + $$ = $2; + set_comment($2, $1); + } + | cpp_member doxygen_post_comment { + $$ = $1; + set_comment($1, $2); + } ; /* Possibly a constructor */ @@ -4890,41 +4905,18 @@ set_nextSibling($1,$2); $$ = $1; } - | empty { $$ = 0; } + | empty { $$ = 0; previousNode = currentNode; currentNode=0; } ; ptail : COMMA parm ptail { set_nextSibling($2,$3); $$ = $2; - } - | COMMA doxygen_post_comment parm ptail { - set_nextSibling($3,$4); + } + | COMMA doxygen_post_comment parm ptail { + set_comment(previousNode, $2); + set_nextSibling($3,$4); $$ = $3; - - /** because function parameters are not nodes, - it must be the current function node, which - gets doxy comment set. - */ - - Setattr($3, "postComment", $2); - /* - currentPostComment = $2; - if (previousParmName != 0) { - String *param = NewString("\n@param "); - if (currentComment != 0) { - Append(currentComment, param); - Append(currentComment, previousParmName ); - Append(currentComment, currentPostComment); - } - else { - currentComment = param; - Append(currentComment, Getattr($3, "name") ); - Append(currentComment, currentPostComment); - } - } - currentPostComment = 0; - */ - } + } | empty { $$ = 0; } ; @@ -4932,45 +4924,18 @@ parm : rawtype parameter_declarator { SwigType_push($1,$2.type); $$ = NewParmWithoutFileLineInfo($1,$2.id); + previousNode = currentNode; + currentNode = $$; Setfile($$,cparse_file); Setline($$,cparse_line); if ($2.defarg) { Setattr($$,"value",$2.defarg); } } - | rawtype parameter_declarator doxygen_post_comment { - /** handles the last function parameter, which is not followed by comma */ - /* - String *param = NewString("@param "); - String *name = NewString($2.id); - - if (currentComment != 0) { - Append(currentComment, param); - } - else { - currentComment = param; - } - - Append(currentComment, name); - Append(currentComment, $3); - - if (currentPostComment != 0) { - } - currentPostComment = 0; - */ - - SwigType_push($1,$2.type); - $$ = NewParmWithoutFileLineInfo($1,$2.id); - Setattr($$, "lastParamPostComment", $3); - Setfile($$,cparse_file); - Setline($$,cparse_line); - if ($2.defarg) { - Setattr($$,"value",$2.defarg); - } - } - | TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args { $$ = NewParmWithoutFileLineInfo(NewStringf("template<class> %s %s", $5,$6), 0); + previousNode = currentNode; + currentNode = $$; Setfile($$,cparse_file); Setline($$,cparse_line); if ($7.val) { @@ -4980,9 +4945,19 @@ | PERIOD PERIOD PERIOD { SwigType *t = NewString("v(...)"); $$ = NewParmWithoutFileLineInfo(t, 0); + previousNode = currentNode; + currentNode = $$; Setfile($$,cparse_file); Setline($$,cparse_line); } + | doxygen_comment parm { + $$ = $2; + set_comment($2, $1); + } + | parm doxygen_post_comment { + $$ = $1; + set_comment($1, $2); + } ; valparms : rawvalparms { @@ -5848,66 +5823,15 @@ Setattr($$,"value",$1); Delete(type); } - - | doxygen_comment ID EQUAL etype { - $$ = new_node("enumitem"); - Setattr($$,"name",$2); - Setattr($$,"enumvalue", $4.val); - if ($4.type == T_CHAR) { - SwigType *type = NewSwigType(T_CHAR); - Setattr($$,"value",NewStringf("\'%(escape)s\'", $4.val)); - Setattr($$,"type",type); - Delete(type); - } else { - SwigType *type = NewSwigType(T_INT); - Setattr($$,"value",$2); - Setattr($$,"type",type); - Delete(type); - } - SetFlag($$,"feature:immutable"); - } - - | doxygen_post_comment ID EQUAL etype { - currentPostComment = $1; - $$ = new_node("enumitem"); - Setattr($$,"name",$2); - Setattr($$,"enumvalue", $4.val); - if ($4.type == T_CHAR) { - SwigType *type = NewSwigType(T_CHAR); - Setattr($$,"value",NewStringf("\'%(escape)s\'", $4.val)); - Setattr($$,"type",type); - Delete(type); - } else { - SwigType *type = NewSwigType(T_INT); - Setattr($$,"value",$2); - Setattr($$,"type",type); - Delete(type); - } - SetFlag($$,"feature:immutable"); - } - - | doxygen_comment ID { - SwigType *type = NewSwigType(T_INT); - $$ = new_node("enumitem"); - Setattr($$,"name",$2); - Setattr($$,"type",type); - SetFlag($$,"feature:immutable"); - Delete(type); + | doxygen_comment edecl { + $$ = $2; + set_comment($2, $1); } - | doxygen_post_comment ID { - SwigType *type = NewSwigType(T_INT); - currentPostComment = $1; - $$ = new_node("enumitem"); - Setattr($$,"name",$2); - Setattr($$,"type",type); - SetFlag($$,"feature:immutable"); - Delete(type); + | doxygen_post_comment edecl { + $$ = $2; + set_comment(previousNode, $1); } - | doxygen_post_comment { - currentPostComment = $1; - $$ = $1; - } - | empty { $$ = 0; } + | empty { $$ = 0; previousNode = currentNode; currentNode = 0; } ; etype : expr { @@ -6557,3 +6481,5 @@ } + +struct S; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |