Fixed problem with doxygen comments at the end of a file or in a file without declarations.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13485 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marko Klopcic 2012-08-02 20:48:28 +00:00
parent c72a56c6f1
commit 174e203180
3 changed files with 29 additions and 8 deletions

View File

@ -0,0 +1,5 @@
/**
* This file contains only doxygen comment without a declaration -
* it should be ignored by SWIG and must not trigger syntax error.
*/

View File

@ -1,5 +1,7 @@
%module doxygen_basic_translate
%include "doxygen_basic_translate.h"
%inline %{
/**
@ -59,12 +61,21 @@ int function4()
{
}
int function5(int a)
{
}
/**< This is a post comment. */
/**
* Test for default args
* @param a Some parameter, default is 42
*/
int function5(int a=42)
int function6(int a=42)
{
}
/**
* Comment at the end of file should be ignored.
*/
%}

View File

@ -66,7 +66,7 @@ static Node **class_decl = NULL;
* ----------------------------------------------------------------------------- */
String *currentComment; /* Location of the stored Doxygen Comment */
String *currentPostComment; /* Location of the stored Doxygen Post-Comment */
String *currentCComment; /* Location of the stored C Comment */
static String *currentDeclComment = NULL; /* Comment of C/C++ declaration. */
static Node *previousNode = NULL; /* Pointer to the previous node (for post comments) */
static Node *currentNode = NULL; /* Pointer to the current node (for post comments) */
@ -1852,17 +1852,22 @@ program : interface {
interface : interface declaration {
/* add declaration to end of linked list (the declaration isn't always a single declaration, sometimes it is a linked list itself) */
if (currentDeclComment != NULL) {
set_comment($2, currentDeclComment);
currentDeclComment = NULL;
}
appendChild($1,$2);
$$ = $1;
}
| interface doxygen_comment declaration {
set_comment($3, $2);
appendChild($1, $3);
| interface doxygen_comment {
currentDeclComment = $2;
$$ = $1;
}
| interface declaration doxygen_post_comment {
set_comment($2, $3);
appendChild($1, $2);
| interface doxygen_post_comment {
Node *node = lastChild($1);
if (node) {
set_comment(node, $2);
}
$$ = $1;
}
| empty {