Implement toggling comment parsing feature on and off
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13182 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e3f41f32a6
commit
b0f8e594c9
3 changed files with 16 additions and 11 deletions
|
|
@ -26,6 +26,7 @@ extern "C" {
|
||||||
extern int cparse_line;
|
extern int cparse_line;
|
||||||
extern int cparse_cplusplus;
|
extern int cparse_cplusplus;
|
||||||
extern int cparse_start_line;
|
extern int cparse_start_line;
|
||||||
|
extern int scan_doxygen_comments;
|
||||||
|
|
||||||
extern void Swig_cparse_cplusplus(int);
|
extern void Swig_cparse_cplusplus(int);
|
||||||
extern void scanner_file(File *);
|
extern void scanner_file(File *);
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@ static int last_brace = 0;
|
||||||
static int last_id = 0;
|
static int last_id = 0;
|
||||||
static int rename_active = 0;
|
static int rename_active = 0;
|
||||||
|
|
||||||
|
/* Doxygen comments scanning */
|
||||||
|
int scan_doxygen_comments = 1;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_cparse_cplusplus()
|
* Swig_cparse_cplusplus()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
@ -337,15 +340,17 @@ static int yylook(void) {
|
||||||
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
|
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
|
||||||
Scanner_locator(scan, cmt);
|
Scanner_locator(scan, cmt);
|
||||||
}
|
}
|
||||||
if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) {
|
if (scan_doxygen_comments) { /* else just skip this node, to avoid crashes in parser module*/
|
||||||
/* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
|
if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) {
|
||||||
yylval.str = NewString(loc);
|
/* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
|
||||||
return DOXYGENPOSTSTRING;
|
yylval.str = NewString(loc);
|
||||||
}
|
return DOXYGENPOSTSTRING;
|
||||||
if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) {
|
}
|
||||||
/* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
|
if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) {
|
||||||
yylval.str = NewString(loc);
|
/* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
|
||||||
return DOXYGENSTRING;
|
yylval.str = NewString(loc);
|
||||||
|
return DOXYGENSTRING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ static Node **class_decl = NULL;
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Doxygen Comment Globals and Assist Functions
|
* Doxygen Comment Globals and Assist Functions
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
int parseComments = 1; /* set this to activate Doxygen uptake into the parse tree */
|
|
||||||
String *currentComment; /* Location of the stored Doxygen Comment */
|
String *currentComment; /* Location of the stored Doxygen Comment */
|
||||||
String *currentPostComment; /* Location of the stored Doxygen Post-Comment */
|
String *currentPostComment; /* Location of the stored Doxygen Post-Comment */
|
||||||
String *currentCComment; /* Location of the stored C Comment */
|
String *currentCComment; /* Location of the stored C Comment */
|
||||||
|
|
@ -107,7 +106,7 @@ static Node *new_node(const_String_or_char_ptr tag) {
|
||||||
set_nodeType(n,tag);
|
set_nodeType(n,tag);
|
||||||
Setfile(n,cparse_file);
|
Setfile(n,cparse_file);
|
||||||
Setline(n,cparse_line);
|
Setline(n,cparse_line);
|
||||||
if(parseComments){
|
if(scan_doxygen_comments){
|
||||||
/* Sets any post comments to the previous node */
|
/* Sets any post comments to the previous node */
|
||||||
if(previousNode != NULL && currentPostComment != 0){
|
if(previousNode != NULL && currentPostComment != 0){
|
||||||
String *copyPostComment = Copy(currentPostComment);
|
String *copyPostComment = Copy(currentPostComment);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue