apply doxygen-svndiff.patch from #2763155

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11697 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-10-13 21:27:09 +00:00
commit 45518cd0d1
15 changed files with 467 additions and 170 deletions

View file

@ -427,12 +427,12 @@ int yylook(void) {
scanner_locator(cmt); scanner_locator(cmt);
} }
if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) {
printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
yylval.str = NewString(loc); yylval.str = NewString(loc);
return DOXYGENPOSTSTRING; return DOXYGENPOSTSTRING;
} }
if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { 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); /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
yylval.str = NewString(loc); yylval.str = NewString(loc);
return DOXYGENSTRING; return DOXYGENSTRING;
} }

View file

@ -13,7 +13,7 @@
#define yylex yylex #define yylex yylex
char cvsroot_parser_y[] = "$Id: parser.y 10767 2008-08-16 07:31:05Z cherylfoil $"; char cvsroot_parser_y[] = "$Id$";
#include "swig.h" #include "swig.h"
#include "cparse.h" #include "cparse.h"
@ -1575,6 +1575,7 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
%type <str> doxygen_comment; %type <str> doxygen_comment;
%type <str> c_style_comment; %type <str> c_style_comment;
%type <str> doxygen_post_comment; %type <str> doxygen_post_comment;
%type <str> doxygen_post_comment_item;
%% %%
/* ====================================================================== /* ======================================================================
@ -3213,9 +3214,17 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
doxygen_comment : DOXYGENSTRING doxygen_comment : DOXYGENSTRING
{ {
while(Strchr($1,'/') == Char($1)) /* while(Strchr($1,'/') == Char($1))
Replace($1,"/","",DOH_REPLACE_FIRST); Replace($1,"/","",DOH_REPLACE_FIRST); */
if(isStructuralDoxygen($1)){ 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"); $$ = new_node("doxycomm");
Setattr($$,"DoxygenComment",$1); Setattr($$,"DoxygenComment",$1);
} }
@ -3231,13 +3240,26 @@ doxygen_comment : DOXYGENSTRING
; ;
doxygen_post_comment : DOXYGENPOSTSTRING doxygen_post_comment_item : DOXYGENPOSTSTRING
{ {
if(currentPostComment != 0){ DohReplace($1, "///<", "", 0);
Append(currentPostComment, $1); DohReplace($1, "/**<", "", 0);
} DohReplace($1, "/*!<", "", 0);
else currentPostComment = $1; DohReplace($1, "//!<", "", 0);
$$ = 0; DohReplace($1, "*/", "", 0);
$$ = $1;
}
;
doxygen_post_comment : doxygen_post_comment doxygen_post_comment_item
{
Append($1, $2);
$$ = $1;
}
| doxygen_post_comment_item
{
$$ = $1;
} }
; ;
@ -4541,13 +4563,38 @@ storage_class : EXTERN { $$ = "extern"; }
------------------------------------------------------------------------------ */ ------------------------------------------------------------------------------ */
parms : rawparms { parms : rawparms {
Parm *p; Parm *p, *nextSibling;
$$ = $1; $$ = $1;
p = $1; p = $1;
while (p) { while (p) {
String *postComment = NULL;
nextSibling = nextSibling(p);
if (nextSibling != NULL) {
postComment = Getattr(nextSibling, "postComment");
} else {
/* the last functino parameter has two attributes -
post comment of the previous params and its own post
comment.
*/
postComment = Getattr(p, "lastParamPostComment");
}
if (postComment != NULL) {
String *param = NewString("\n@param ");
if (currentComment != 0) {
Append(currentComment, param);
Append(currentComment, Getattr(p, "name"));
Append(currentComment, postComment);
}
else {
currentComment = param;
Append(currentComment, Getattr(p, "name"));
Append(currentComment, postComment);
}
}
Replace(Getattr(p,"type"),"typename ", "", DOH_REPLACE_ANY); Replace(Getattr(p,"type"),"typename ", "", DOH_REPLACE_ANY);
p = nextSibling(p); p = nextSibling;
} }
} }
; ;
@ -4562,6 +4609,34 @@ ptail : COMMA parm ptail {
set_nextSibling($2,$3); set_nextSibling($2,$3);
$$ = $2; $$ = $2;
} }
| COMMA doxygen_post_comment parm ptail {
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; } | empty { $$ = 0; }
; ;
@ -4575,6 +4650,36 @@ parm : rawtype parameter_declarator {
Setattr($$,"value",$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);
$$ = NewParm($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 { | TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args {
$$ = NewParm(NewStringf("template<class> %s %s", $5,$6), 0); $$ = NewParm(NewStringf("template<class> %s %s", $5,$6), 0);
@ -5462,6 +5567,65 @@ edecl : ID {
} }
SetFlag($$,"feature:immutable"); SetFlag($$,"feature:immutable");
} }
| 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_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 {
currentPostComment = $1;
$$ = $1;
}
| empty { $$ = 0; } | empty { $$ = 0; }
; ;

View file

@ -13,7 +13,7 @@
DoxygenEntity::DoxygenEntity(std::string typeEnt){ DoxygenEntity::DoxygenEntity(std::string typeEnt){
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = ""; data = "";
isLeaf = 1; isLeaf = true;
} }
/* Basic node for commands that have /* Basic node for commands that have
@ -24,7 +24,7 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt){
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = param1; data = param1;
isLeaf = 1; isLeaf = true;
} }
/* Nonterminal node /* Nonterminal node
@ -33,23 +33,35 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList ){ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList ){
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = ""; data = "";
isLeaf = 0; isLeaf = false;
entityList = entList; entityList = entList;
} }
void DoxygenEntity::printEntity(int level){ void DoxygenEntity::printEntity(int level){
int thisLevel = level; int thisLevel = level;
if (isLeaf) { if (isLeaf) {
for (int i = 0; i < thisLevel; i++) {std::cout << "\t";} for (int i = 0; i < thisLevel; i++) {
std::cout << "\t";
}
std::cout << "Node Command: " << typeOfEntity << " "; std::cout << "Node Command: " << typeOfEntity << " ";
if (data.compare("") != 0) std::cout << "Node Data: " << data;
if (data.compare("") != 0) {
std::cout << "Node Data: " << data;
}
std::cout << std::endl; std::cout << std::endl;
} else {
for (int i = 0; i < thisLevel; i++) {
std::cout << "\t";
} }
else{
for (int i = 0; i < thisLevel; i++) {std::cout << "\t";}
std::cout << "Node Command : " << typeOfEntity << std::endl; std::cout << "Node Command : " << typeOfEntity << std::endl;
std::list<DoxygenEntity>::iterator p = entityList.begin(); std::list<DoxygenEntity>::iterator p = entityList.begin();
thisLevel++; thisLevel++;
while (p != entityList.end()){ while (p != entityList.end()){
(*p).printEntity(thisLevel); (*p).printEntity(thisLevel);
p++; p++;
@ -57,7 +69,10 @@ void DoxygenEntity::printEntity(int level){
} }
} }
// not used, completely wrong - currently std lib reports 'invalid operator <'
bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){ bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){
// return first.typeOfEntity < second.typeOfEntity;
if(first.typeOfEntity.compare("brief") == 0) if(first.typeOfEntity.compare("brief") == 0)
return true; return true;
if(second.typeOfEntity.compare("brief") == 0) if(second.typeOfEntity.compare("brief") == 0)
@ -68,7 +83,7 @@ bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& sec
return false; return false;
if(first.typeOfEntity.compare("partofdescription") == 0) if(first.typeOfEntity.compare("partofdescription") == 0)
return true; return true;
if(first.typeOfEntity.compare("partofdescription") == 0) if(second.typeOfEntity.compare("partofdescription") == 0)
return false; return false;
if(first.typeOfEntity.compare("plainstd::string") == 0) if(first.typeOfEntity.compare("plainstd::string") == 0)
return true; return true;

View file

@ -13,18 +13,43 @@
#include <string> #include <string>
#include <list> #include <list>
typedef enum {
SIMPLECOMMAND,
IGNOREDSIMPLECOMMAND,
COMMANDWORD,
IGNOREDCOMMANDWORD,
COMMANDLINE,
IGNOREDCOMMANDLINE,
COMMANDPARAGRAPH,
IGNORECOMMANDPARAGRAPH,
COMMANDENDCOMMAND,
COMMANDWORDPARAGRAPH,
COMMANDWORDLINE,
COMMANDWORDOWORDWORD,
COMMANDOWORD,
COMMANDERRORTHROW,
COMMANDUNIQUE,
END_LINE,
PARAGRAPH_END,
PLAINSTRING,
COMMAND
} DoxyCommandEnum;
/* /*
* Structure to represent a doxygen comment entry * Structure to represent a doxygen comment entry
*/ */
struct DoxygenEntity{ struct DoxygenEntity{
DoxygenEntity(std::string typeEnt);
DoxygenEntity(std::string typeEnt, std::string param1);
DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList );
void printEntity(int level);
std::string typeOfEntity; std::string typeOfEntity;
std::list <DoxygenEntity> entityList; std::list <DoxygenEntity> entityList;
std::string data; std::string data;
int isLeaf; bool isLeaf;
DoxygenEntity(std::string typeEnt);
DoxygenEntity(std::string typeEnt, std::string param1);
DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList );
void printEntity(int level);
}; };
/* /*

View file

@ -1,24 +1,6 @@
#include "DoxygenParser.h" #include "DoxygenParser.h"
#include "TokenList.h" #include "TokenList.h"
#define SIMPLECOMMAND 1
#define IGNOREDSIMPLECOMMAND 2
#define COMMANDWORD 3
#define IGNOREDCOMMANDWORD 4
#define COMMANDLINE 5
#define IGNOREDCOMMANDLINE 6
#define COMMANDPARAGRAPH 7
#define IGNORECOMMANDPARAGRAPH 8
#define COMMANDENDCOMMAND 9
#define COMMANDWORDPARAGRAPH 10
#define COMMANDWORDLINE 11
#define COMMANDWORDOWORDWORD 12
#define COMMANDOWORD 13
#define COMMANDERRORTHROW 14
#define COMMANDUNIQUE 15
#define END_LINE 101
#define PARAGRAPH_END 102
#define PLAINSTRING 103
#define COMMAND 104
DoxygenParser::DoxygenParser() DoxygenParser::DoxygenParser()
{ {
@ -50,14 +32,14 @@ std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "a
"private", "privatesection", "property", "protected", "protectedsection", "protocol", "private", "privatesection", "property", "protected", "protectedsection", "protocol",
"public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval",
"sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage",
"subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until",
"var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem",
"$", "@", "\\","&", "~", "<", ">", "#", "%"}; "$", "@", "\\","&", "~", "<", ">", "#", "%"};
std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details",
"else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param",
"tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo",
"version", "warning", "xrefitem" }; "version", "warning", "xrefitem" };
/* All of the doxygen commands divided up by how they are parsed */ /* All of the doxygen commands divided up by how they are parsed */
@ -73,7 +55,7 @@ std::string commandParagraph[] = {"partofdescription", "return", "remarks", "sin
std::string ignoreCommandParagraphs[] = {"nothing at the moment"}; std::string ignoreCommandParagraphs[] = {"nothing at the moment"};
std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly",
"verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; "verbatim", "xmlonly", "cond", "if", "ifnot", "link"};
std::string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; std::string commandWordParagraphs[] = {"param", "tparam", "throw", "throws", "retval", "exception"};
std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"};
std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"};
std::string commandOWords[] = {"dir", "file", "cond"}; std::string commandOWords[] = {"dir", "file", "cond"};
@ -264,28 +246,33 @@ std::string getStringTilEndCommand(std::string theCommand, TokenList &tokList){
/* Returns the end of a Paragraph as an iterator- /* Returns the end of a Paragraph as an iterator-
* Paragraph is defined in Doxygen to be a paragraph of text * Paragraph is defined in Doxygen to be a paragraph of text
* seperate by either a structural command or a blank line * separated by either a structural command or a blank line
*/ */
std::list<Token>::iterator getEndOfParagraph(TokenList &tokList){ std::list<Token>::iterator getEndOfParagraph(TokenList &tokList){
std::list<Token>::iterator endOfParagraph = tokList.iteratorCopy(); std::list<Token>::iterator endOfParagraph = tokList.iteratorCopy();
while(endOfParagraph != tokList.end()){ while(endOfParagraph != tokList.end()){
if ((* endOfParagraph).tokenType == END_LINE){ if ((* endOfParagraph).tokenType == END_LINE){
endOfParagraph++; endOfParagraph++;
if ((* endOfParagraph).tokenType == END_LINE){ if (endOfParagraph != tokList.end() && (* endOfParagraph).tokenType == END_LINE) {
endOfParagraph++; endOfParagraph++;
//cout << "ENCOUNTERED END OF PARA" << endl; //cout << "ENCOUNTERED END OF PARA" << endl;
return endOfParagraph; return endOfParagraph;
} }
} else if ((*endOfParagraph).tokenType == COMMAND) {
if (isSectionIndicator((* endOfParagraph).tokenString)) {
return endOfParagraph;
} }
else if ((* endOfParagraph).tokenType == COMMAND){
if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph;
else endOfParagraph++; else endOfParagraph++;
}
else if((* endOfParagraph).tokenType == PLAINSTRING) { } else if ((*endOfParagraph).tokenType == PLAINSTRING) {
endOfParagraph++; endOfParagraph++;
} else {
return tokList.end();
} }
else return tokList.end();
} }
return tokList.end(); return tokList.end();
} }
@ -478,7 +465,7 @@ int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list <
/* CommandWordParagraph /* CommandWordParagraph
* Format: @command <word> {paragraph} * Format: @command <word> {paragraph}
* Commands such as param * Commands such as param
* "param", "tparam", "throw", "retval", "exception" * "param", "tparam", "throw", "throws", "retval", "exception"
*/ */
int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) if (noisy)
@ -560,8 +547,10 @@ int addCommandOWord(std::string theCommand, TokenList &tokList, std::list <Doxyg
*/ */
int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
#pragma unused(doxyList) #pragma unused(doxyList)
cout << "Encountered :" << theCommand << endl; if (noisy) {
cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; cout << "Encountered :" << theCommand << endl;
cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl;
}
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
tokList.setIterator(endOfLine); tokList.setIterator(endOfLine);
return 0; return 0;
@ -699,8 +688,6 @@ int addCommandUnique(std::string theCommand, TokenList &tokList, std::list <Doxy
* with my current design- however the skeletal outline is contained in * with my current design- however the skeletal outline is contained in
* the file Skeleton * the file Skeleton
*/ */
int addCommand(std::string commandString, TokenList &tokList,std::list <DoxygenEntity> &doxyList){ int addCommand(std::string commandString, TokenList &tokList,std::list <DoxygenEntity> &doxyList){
std::string theCommand = StringToLower(commandString); std::string theCommand = StringToLower(commandString);
if (theCommand.compare("plainstd::string") == 0){ if (theCommand.compare("plainstd::string") == 0){
@ -790,23 +777,30 @@ std::list<DoxygenEntity> parse(std::list<Token>::iterator endParsingIndex, Token
} }
std::list<DoxygenEntity> parseRoot(std::list<Token>::iterator endParsingIndex, TokenList &tokList){ std::list<DoxygenEntity> parseRoot(std::list<Token>::iterator endParsingIndex, TokenList &tokList){
std::list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
int currCommand; int currCommand;
while (tokList.current() != endParsingIndex){ while (tokList.current() != endParsingIndex){
Token currToken = tokList.peek(); Token currToken = tokList.peek();
if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; if(noisy) {
cout << "Parsing for phrase starting in:" << currToken.toString() << endl;
}
if(currToken.tokenType == END_LINE ){ if(currToken.tokenType == END_LINE ){
tokList.next(); tokList.next();
} }
else if(currToken.tokenType == COMMAND){ else if(currToken.tokenType == COMMAND){
currCommand = findCommand(currToken.tokenString); currCommand = findCommand(currToken.tokenString);
if (currCommand < 0 ){ if (currCommand < 0 ){
if(noisy) if(noisy) {
cout << "Unidentified Command " << currToken.tokenString << endl; cout << "Unidentified Command " << currToken.tokenString << endl;
}
tokList.next();
addCommand(std::string("partofdescription"), tokList, aNewList);
} else {
tokList.next(); tokList.next();
addCommand(std::string("partofdescription"), tokList, aNewList);}
//cout << "Command: " << currWord << " " << currCommand << endl;
else { tokList.next();
addCommand(currToken.tokenString, tokList, aNewList); addCommand(currToken.tokenString, tokList, aNewList);
} }
} }

View file

@ -569,7 +569,7 @@ string getStringTilCommand(int &startInd, string doxygenString){
} }
else{ else{
startIndex = savedIndex; startIndex = savedIndex;
addCommand(string("plainstring"), startIndex, aNewList, doxygenString); addCommand(string("plainstd::string"), startIndex, aNewList, doxygenString);
} }
} }
@ -728,7 +728,7 @@ string getStringTilCommand(int &startInd, string doxygenString){
if(!restOfParagraph.empty()){ if(!restOfParagraph.empty()){
list <DoxygenEntity> aNewList; list <DoxygenEntity> aNewList;
aNewList = parse(placement, restOfParagraph); aNewList = parse(placement, restOfParagraph);
aNewList.push_front(DoxygenEntity("plainstring", name)); aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
@ -752,7 +752,7 @@ string getStringTilCommand(int &startInd, string doxygenString){
if(!restOfLine.empty()){ if(!restOfLine.empty()){
list <DoxygenEntity> aNewList; list <DoxygenEntity> aNewList;
aNewList = parse(placement, restOfLine); aNewList = parse(placement, restOfLine);
aNewList.push_front(DoxygenEntity("plainstring", name)); aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
@ -775,9 +775,9 @@ string getStringTilCommand(int &startInd, string doxygenString){
string headerfile = getNextWord(startInd, doxygenString); string headerfile = getNextWord(startInd, doxygenString);
string headername = getNextWord(startInd, doxygenString); string headername = getNextWord(startInd, doxygenString);
list <DoxygenEntity> aNewList; list <DoxygenEntity> aNewList;
aNewList.push_back(DoxygenEntity("plainstring", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile));
if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
@ -806,10 +806,10 @@ string getStringTilCommand(int &startInd, string doxygenString){
/* @command */ /* @command */
if (theCommand.compare("plainstring") == 0){ if (theCommand.compare("plainstd::string") == 0){
string nextPhrase = getStringTilCommand(startInd, doxygenString); string nextPhrase = getStringTilCommand(startInd, doxygenString);
if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; if (noisy) cout << "Parsing plain string :" << nextPhrase << endl;
doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase ));
return 1; return 1;
} }
int commandNumber = commandBelongs(theCommand); int commandNumber = commandBelongs(theCommand);

View file

@ -15,15 +15,16 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind
lastPosition = i; lastPosition = i;
if (isFirstLine){ if (isFirstLine){
i+=APPROX_LINE_LENGTH; i+=APPROX_LINE_LENGTH;
} else {
i+=APPROX_LINE_LENGTH - indent*TAB_SIZE;
} }
else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE;
i = unformattedLine.find(" ", i); i = unformattedLine.find(" ", i);
if (i > 0 && i + 1 < (int)unformattedLine.length()){ if (i > 0 && i + 1 < (int)unformattedLine.length()){
if (!isFirstLine) for (int j = 0; j < indent; j++) { if (!isFirstLine) for (int j = 0; j < indent; j++) {
formattedLines.append("\t"); formattedLines.append("\t");
} } else {
else {
isFirstLine = 0; isFirstLine = 0;
} }
formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1));
@ -32,7 +33,11 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind
} }
} }
if (lastPosition < (int)unformattedLine.length()){ if (lastPosition < (int)unformattedLine.length()){
if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} if (!isFirstLine) {
for (int j = 0; j < indent; j++) {
formattedLines.append("\t");
}
}
formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition));
} }
@ -46,7 +51,7 @@ std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){
if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){
return doxygenEntity.data; return doxygenEntity.data;
} }
if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){
return doxygenEntity.data; return doxygenEntity.data;
} }
else if (doxygenEntity.typeOfEntity.compare("b") == 0){ else if (doxygenEntity.typeOfEntity.compare("b") == 0){
@ -85,10 +90,12 @@ std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){
std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
std::string returnedString; std::string returnedString;
if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} if (doxygenEntity.isLeaf) {
else { return javaDocFormat(doxygenEntity) + " ";
} else {
returnedString += javaDocFormat(doxygenEntity); returnedString += javaDocFormat(doxygenEntity);
std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin(); std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin();
while (p != doxygenEntity.entityList.end()){ while (p != doxygenEntity.entityList.end()){
returnedString+= translateSubtree(*p); returnedString+= translateSubtree(*p);
p++; p++;
@ -97,38 +104,64 @@ std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
return returnedString; return returnedString;
} }
std::string JavaDocConverter::translateEntity(DoxygenEntity &doxyEntity){ std::string JavaDocConverter::translateEntity(DoxygenEntity &doxyEntity){
if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(std::string(translateSubtree(doxyEntity)), 0); if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) {
if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ return formatCommand(std::string(translateSubtree(doxyEntity)), 0);
return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";}
else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0)
return formatCommand(doxyEntity.data, 0) + "\n * ";
else if(doxyEntity.typeOfEntity.compare("see") == 0){
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2);
} }
else if(doxyEntity.typeOfEntity.compare("return")== 0
if ((doxyEntity.typeOfEntity.compare("brief") == 0) ||
(doxyEntity.typeOfEntity.compare("details") == 0)) {
return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";
} else if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 ||
doxyEntity.typeOfEntity.compare("deprecated")== 0 ||
doxyEntity.typeOfEntity.compare("brief")== 0) {
return formatCommand(doxyEntity.data, 0) + "\n * ";
} else if(doxyEntity.typeOfEntity.compare("see") == 0) {
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" +
translateSubtree(doxyEntity)), 2);
} else if(doxyEntity.typeOfEntity.compare("return")== 0
|| doxyEntity.typeOfEntity.compare("author")== 0 || doxyEntity.typeOfEntity.compare("author")== 0
|| doxyEntity.typeOfEntity.compare("param")== 0 || doxyEntity.typeOfEntity.compare("param")== 0
|| doxyEntity.typeOfEntity.compare("throw")== 0
|| doxyEntity.typeOfEntity.compare("throws")== 0
|| doxyEntity.typeOfEntity.compare("since")== 0 || doxyEntity.typeOfEntity.compare("since")== 0
|| doxyEntity.typeOfEntity.compare("version")== 0 || doxyEntity.typeOfEntity.compare("version")== 0
|| doxyEntity.typeOfEntity.compare("exception") == 0 || doxyEntity.typeOfEntity.compare("exception") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0){ || doxyEntity.typeOfEntity.compare("deprecated") == 0){
// this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing
if (doxyEntity.typeOfEntity.compare("throw")== 0) {
doxyEntity.typeOfEntity = "throws";
}
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2);
}
else if(doxyEntity.typeOfEntity.compare("sa")== 0){ } else if(doxyEntity.typeOfEntity.compare("sa")== 0) {
return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2);
} else {
return formatCommand(javaDocFormat(doxyEntity), 0 );
} }
else return formatCommand(javaDocFormat(doxyEntity), 0 );
return ""; return "";
} }
bool JavaDocConverter::getDocumentation(Node *n, String *&documentation){
documentation = Getattr(n,"DoxygenComment"); bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) {
if(documentation == NULL)
documentation = Getattr(node, "DoxygenComment");
if (documentation == NULL) {
return false; return false;
}
std::list <DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation)); std::list <DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation));
entityList.sort(CompareDoxygenEntities());
// entityList.sort(CompareDoxygenEntities()); sorting currently not used,
// see CompareDoxygenEntities::operator() in DoxygenEntity.cpp
if(debug){ if(debug){
std::cout << "---RESORTED LIST---" << std::endl; std::cout << "---RESORTED LIST---" << std::endl;

View file

@ -18,7 +18,7 @@
class JavaDocConverter : public DoxygenTranslator class JavaDocConverter : public DoxygenTranslator
{ {
public: public:
JavaDocConverter() : debug( true ){} JavaDocConverter() : debug( false ){}
virtual bool getDocumentation(Node *node, String *&documentation); virtual bool getDocumentation(Node *node, String *&documentation);
protected: protected:

View file

@ -94,7 +94,7 @@ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){
||(doxyEntity.typeOfEntity.compare("details") == 0)) ||(doxyEntity.typeOfEntity.compare("details") == 0))
return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n"; return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n";
if(doxyEntity.typeOfEntity.compare("plainstring") == 0 if(doxyEntity.typeOfEntity.compare("plainstd::string") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0 || doxyEntity.typeOfEntity.compare("deprecated") == 0
|| doxyEntity.typeOfEntity.compare("brief") == 0) || doxyEntity.typeOfEntity.compare("brief") == 0)
return justifyString(doxyEntity.data, 0) + "\n"; return justifyString(doxyEntity.data, 0) + "\n";

View file

@ -1,4 +1,5 @@
#include "Token.h" #include "Token.h"
#include "DoxygenEntity.h"
using namespace std; using namespace std;

View file

@ -2,10 +2,6 @@
#define TOKEN_H_ #define TOKEN_H_
#include <string> #include <string>
#define END_LINE 101
#define PARAGRAPH_END 102
#define PLAINSTRING 103
#define COMMAND 104
using namespace std; using namespace std;
class Token class Token
@ -13,6 +9,7 @@ class Token
public: public:
Token(int tType, string tString); Token(int tType, string tString);
~Token(); ~Token();
int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */
string tokenString; /* the data , such as param for @param*/ string tokenString; /* the data , such as param for @param*/
string toString(); string toString();

View file

@ -4,99 +4,162 @@
#include <string> #include <string>
#include <list> #include <list>
#include "Token.h" #include "Token.h"
#include "DoxygenEntity.h"
#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list #define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list
#define END_LINE 101
#define PARAGRAPH_END 102 //not used at the moment
#define PLAINSTRING 103
#define COMMAND 104
using namespace std; using namespace std;
list <Token> tokenList;
list<Token>::iterator tokenListIterator;
int noisy2 = 0; int noisy2 = 0;
/* The tokenizer*/ /* The tokenizer*/
TokenList::TokenList(const std::string &doxygenStringConst){
size_t commentPos;
string doxygenString = doxygenStringConst;
/* Comment start tokens are replaced in parser.y, see doxygen_comment and
doxygen_post_comment_item
do {
commentPos = doxygenString.find("///<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("/**<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("/*!<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("//!<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
break;
} while (true); */
size_t currentIndex = 0;
size_t nextIndex = 0;
TokenList::TokenList(string doxygenString){
int currentIndex = 0;
//Regex whitespace("[ \t]+");
//Regex newLine("[\n]");
//Regex command("[@|\\]{1}[^ \t \n]+"); //the cheap solution
//Regex doxygenFluff("[/*!]+");
int nextIndex = 0;
int isFluff = 0;
string currentWord; string currentWord;
while (currentIndex < doxygenString.length()){ while (currentIndex < doxygenString.length()){
if(doxygenString[currentIndex] == '\n'){ if(doxygenString[currentIndex] == '\n'){
tokenList.push_back(Token(END_LINE, currentWord)); m_tokenList.push_back(Token(END_LINE, currentWord));
currentIndex++; currentIndex++;
} }
// skip WS, except \n
while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' '
|| doxygenString[currentIndex]== '\t')) currentIndex ++; || doxygenString[currentIndex]== '\t')) currentIndex ++;
if (currentIndex == doxygenString.length()) {} //do nothing since end of string was reached
else {nextIndex = currentIndex; if (currentIndex < doxygenString.length()) {
nextIndex = currentIndex;
// skip non WS
while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' '
&& doxygenString[nextIndex]!= '\t' && doxygenString[nextIndex]!= '\n')) nextIndex++; && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex]!= '\n'))
nextIndex++;
// now we have a token
currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex);
if(noisy2) cout << "Current Word: " << currentWord << endl;
if(noisy2)
cout << "Current Word: " << currentWord << endl;
if (currentWord[0] == '@' || currentWord[0] == '\\'){ if (currentWord[0] == '@' || currentWord[0] == '\\'){
// it is doxygen command
currentWord = currentWord.substr(1, currentWord.length()-1); currentWord = currentWord.substr(1, currentWord.length()-1);
tokenList.push_back(Token(COMMAND, currentWord)); m_tokenList.push_back(Token(COMMAND, currentWord));
}
else if (currentWord[0] == '\n'){ } else if (currentWord[0] == '\n'){
//if ((tokenList.back()).tokenType == END_LINE){}
tokenList.push_back(Token(END_LINE, currentWord)); m_tokenList.push_back(Token(END_LINE, currentWord));
} }
else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){ else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){
if (currentWord.length() == 1) {isFluff = 1;}
else { isFluff = 1;
for(int i = 1; i < currentWord.length(); i++){
if (currentWord[0] != '*' && currentWord[0] != '/' && currentWord[0] != '!') isFluff = 0;
}
bool isPlainString = false;
if (currentWord.length() > 1) {
for(size_t i = 1; i < currentWord.length(); i++){
if (currentWord[i] != '*' && currentWord[i] != '/' &&
currentWord[i] != '!') {
isPlainString = true;
break;
}
} }
if(!isFluff) tokenList.push_back(Token(PLAINSTRING, currentWord));
} }
else if (!currentWord.empty())tokenList.push_back(Token(PLAINSTRING, currentWord)); if(isPlainString)
m_tokenList.push_back(Token(PLAINSTRING, currentWord));
} else if (!currentWord.empty()) {
m_tokenList.push_back(Token(PLAINSTRING, currentWord));
}
currentIndex = nextIndex; currentIndex = nextIndex;
} }
} }
tokenListIterator = tokenList.begin();
m_tokenListIter = m_tokenList.begin();
}
TokenList:: ~TokenList(){
} }
Token TokenList::peek(){ Token TokenList::peek(){
if(tokenListIterator!= tokenList.end()){ if(m_tokenListIter!= m_tokenList.end()){
Token returnedToken = (*tokenListIterator); Token returnedToken = (*m_tokenListIter);
return returnedToken; return returnedToken;
} }
else else
return Token(0, ""); return Token(0, "");
} }
Token TokenList::next(){ Token TokenList::next(){
if(tokenListIterator != tokenList.end()){ if(m_tokenListIter != m_tokenList.end()){
Token returnedToken = (*tokenListIterator); Token returnedToken = (*m_tokenListIter);
tokenListIterator++; m_tokenListIter++;
return (returnedToken); return (returnedToken);
} }
else else
return Token(0, ""); return Token(0, "");
} }
list<Token>::iterator TokenList::end(){ list<Token>::iterator TokenList::end(){
return tokenList.end(); return tokenList.end();
} }
list<Token>::iterator TokenList::current(){ list<Token>::iterator TokenList::current(){
return tokenListIterator; return m_tokenListIter;
} }
list<Token>::iterator TokenList::iteratorCopy(){
return m_tokenListIter;
}
void TokenList::setIterator(list<Token>::iterator newPosition){
m_tokenListIter = newPosition;
}
void TokenList::printList(){ void TokenList::printList(){
list<Token>::iterator p = tokenList.begin(); list<Token>::iterator p = m_tokenList.begin();
int i = 1; int i = 1;
int b = 0; int b = 0;
while (p != tokenList.end()){ while (p != m_tokenList.end()){
cout << (*p).toString() << " "; cout << (*p).toString() << " ";
b = i%TOKENSPERLINE; b = i%TOKENSPERLINE;
if (b == 0) cout << endl; if (b == 0) cout << endl;
@ -104,13 +167,3 @@ void TokenList::printList(){
} }
} }
list<Token>::iterator TokenList::iteratorCopy(){
list<Token>::iterator p = tokenListIterator;
return p;
}
void TokenList::setIterator(list<Token>::iterator newPosition){
tokenListIterator = newPosition;
}
TokenList:: ~TokenList(){
tokenList.clear();
}

View file

@ -5,23 +5,30 @@
#include <string> #include <string>
#include <list> #include <list>
#include "Token.h" #include "Token.h"
using namespace std;
/* a small class used to represent the sequence of tokens /* a small class used to represent the sequence of tokens
* that can be derived from a formatted doxygen string * that can be derived from a formatted doxygen string
*/ */
class TokenList{ class TokenList{
private:
std::list<Token> m_tokenList;
std::list<Token>::iterator m_tokenListIter;
public: public:
TokenList(string doxygenString); /* constructor takes a blob of Doxygen comment */ TokenList(const std::string &doxygenString); /* constructor takes a blob of Doxygen comment */
~TokenList(); ~TokenList();
Token peek(); /* returns next token without advancing */ Token peek(); /* returns next token without advancing */
Token next(); /* returns next token and advances */ Token next(); /* returns next token and advances */
list<Token>::iterator end(); /* returns an end iterator */
list<Token>::iterator current(); /* returns the current iterator */ std::list<Token>::iterator end(); /* returns an end iterator */
void printList(); /* prints out the sequence of tokens */ std::list<Token>::iterator current(); /* returns the current iterator */
list<Token>::iterator iteratorCopy(); /* returns a copy of the current iterator */
std::list<Token>::iterator iteratorCopy(); /* returns a copy of the current iterator */
void setIterator(list<Token>::iterator newPosition); /*moves up the iterator*/ void setIterator(list<Token>::iterator newPosition); /*moves up the iterator*/
void printList(); /* prints out the sequence of tokens */
}; };
#endif /*TOKENLIST_H_*/ #endif /*TOKENLIST_H_*/

View file

@ -1304,6 +1304,15 @@ public:
// Note that this is used in enumValue() amongst other places // Note that this is used in enumValue() amongst other places
Setattr(n, "value", tmpValue); Setattr(n, "value", tmpValue);
{
EnumFeature enum_feature = decodeEnumFeature(parentNode(n));
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
// Emit the enum item.
if (!Getattr(n, "_last")) // Only the first enum item has this attribute set
Printf(enum_code, ",\n");
//translate and write javadoc comment if flagged //translate and write javadoc comment if flagged
if (doxygen_javadoc_flag){ if (doxygen_javadoc_flag){
String *doxygen_comments; String *doxygen_comments;
@ -1314,14 +1323,7 @@ public:
Delete(doxygen_comments); Delete(doxygen_comments);
} }
} }
{
EnumFeature enum_feature = decodeEnumFeature(parentNode(n));
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
// Emit the enum item.
if (!Getattr(n, "_last")) // Only the first enum item has this attribute set
Printf(enum_code, ",\n");
Printf(enum_code, " %s", symname); Printf(enum_code, " %s", symname);
if (Getattr(n, "enumvalue")) { if (Getattr(n, "enumvalue")) {
String *value = enumValue(n); String *value = enumValue(n);
@ -1841,7 +1843,6 @@ public:
emitBanner(f_proxy); emitBanner(f_proxy);
if (Len(package) > 0){ if (Len(package) > 0){
Printf(f_proxy, "LETS TEST THIS NAO THX \n\n\n");
Printf(f_proxy, "package %s;\n", package); Printf(f_proxy, "package %s;\n", package);
} }
Clear(proxy_class_def); Clear(proxy_class_def);

View file

@ -7,7 +7,7 @@
* Python language module for SWIG. * Python language module for SWIG.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
char cvsroot_python_cxx[] = "$Id: python.cxx 10453 2008-05-15 21:18:44Z wsfulton $"; char cvsroot_python_cxx[] = "$Id$";
#include "swigmod.h" #include "swigmod.h"
#define ctab2 " " #define ctab2 " "
@ -3124,6 +3124,13 @@ public:
if (!fastproxy || olddefs) { if (!fastproxy || olddefs) {
Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
Printv(f_shadow, " return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); Printv(f_shadow, " return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
if (doxygen) {
String *doxygen_comments;
if (DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)) {
Printf(f_shadow, Char(pythoncode(doxygen_comments, tab8)));
Delete(doxygen_comments);
}
}
} }
} else { } else {
Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL);