Reworking of DoxygenTranslator with the Tokenizer, more Doxygen commands

implemented, beginning of the javaDoc convertor


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10670 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Cheryl Foil 2008-07-16 22:23:45 +00:00
commit cc6db6eab6
7 changed files with 716 additions and 922 deletions

View file

@ -1,3 +1,5 @@
#ifndef DOXYGENENTITY_H_
#define DOXYGENENTITY_H_
#include <cstdlib>
#include <iostream>
@ -12,7 +14,7 @@ public:
DoxygenEntity(string typeEnt);
DoxygenEntity(string typeEnt, string param1);
DoxygenEntity(string typeEnt, list <DoxygenEntity> &entList );
virtual ~DoxygenEntity();
~DoxygenEntity();
void printEntity(int level);
string typeOfEntity;
list <DoxygenEntity> entityList;
@ -21,3 +23,4 @@ public:
};
#endif /*TOKENLIST_H_*/

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,104 @@
#include "JavaDocConverter.h"
#include <cstdlib>
#include <iostream>
#include <string>
#include <list>
int printTree = 1;
JavaDocConverter::JavaDocConverter()
{
}
JavaDocConverter::~JavaDocConverter()
{
}
/* Sorts entities by javaDoc standard order for commands
* NOTE: will not behave entirely properly until "First level" comments
* such as brief descriptions are TAGGED as such
*/
bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){
if(first.typeOfEntity.compare("plainstring") == 0) return true;
if(second.typeOfEntity.compare("plainstring") == 0) return false;
if(first.typeOfEntity.compare("param") == 0){
if(second.typeOfEntity.compare("param")== 0) return true;
if(second.typeOfEntity.compare("return")== 0) return true;
if(second.typeOfEntity.compare("exception")== 0) return true;
if(second.typeOfEntity.compare("author")== 0) return true;
if(second.typeOfEntity.compare("version")== 0)return true;
if(second.typeOfEntity.compare("see")== 0)return true;
if(second.typeOfEntity.compare("since")== 0)return true;
if(second.typeOfEntity.compare("deprecated")== 0)return true;
return false;
}
if(first.typeOfEntity.compare("return")== 0){
if(second.typeOfEntity.compare("return")== 0) return true;
if(second.typeOfEntity.compare("exception")== 0) return true;
if(second.typeOfEntity.compare("author")== 0) return true;
if(second.typeOfEntity.compare("version")== 0)return true;
if(second.typeOfEntity.compare("see")== 0)return true;
if(second.typeOfEntity.compare("since")== 0)return true;
if(second.typeOfEntity.compare("deprecated")== 0)return true;
return false;
}
if(first.typeOfEntity.compare("exception")== 0){
if(second.typeOfEntity.compare("exception")== 0) return true;
if(second.typeOfEntity.compare("author")== 0) return true;
if(second.typeOfEntity.compare("version")== 0)return true;
if(second.typeOfEntity.compare("see")== 0)return true;
if(second.typeOfEntity.compare("since")== 0)return true;
if(second.typeOfEntity.compare("deprecated")== 0)return true;
return false;
}
if(first.typeOfEntity.compare("author")== 0){
if(first.typeOfEntity.compare("author")== 0) return true;
if(first.typeOfEntity.compare("version")== 0)return true;
if(first.typeOfEntity.compare("see")== 0)return true;
if(first.typeOfEntity.compare("since")== 0)return true;
if(first.typeOfEntity.compare("deprecated")== 0)return true;
return false;
}
if(first.typeOfEntity.compare("version")== 0){
if(second.typeOfEntity.compare("version")== 0)return true;
if(second.typeOfEntity.compare("see")== 0)return true;
if(second.typeOfEntity.compare("since")== 0)return true;
if(second.typeOfEntity.compare("deprecated")== 0)return true;
return false;
}
if(first.typeOfEntity.compare("see")== 0){
if(second.typeOfEntity.compare("see")== 0)return true;
if(second.typeOfEntity.compare("since")== 0)return true;
if(second.typeOfEntity.compare("deprecated")== 0)return true;
return false;
}
if(first.typeOfEntity.compare("since")== 0){
if(second.typeOfEntity.compare("since")== 0) return true;
if(second.typeOfEntity.compare("deprecated")== 0)return true;
return false;
}
if(first.typeOfEntity.compare("deprecated")== 0){
if(second.typeOfEntity.compare("deprecated")== 0)return true;
return false;
}
return true;
}
string JavaDocConverter:: convertToJavaDoc(list <DoxygenEntity> entityList){
list<DoxygenEntity>::iterator entityIterator = entityList.begin();
entityList.sort(compare_DoxygenEntities);
cout << "---RESORTED LIST---" << endl;
if (printTree ){
list<DoxygenEntity>::iterator p = entityList.begin();
while (p != entityList.end()){
(*p).printEntity(0);
p++;
}
}
string javaDocString = "/**\n";
javaDocString += "*/\n";
return javaDocString;
}

View file

@ -0,0 +1,17 @@
#include <list>
#include <string>
#include "DoxygenEntity.h"
#ifndef JAVADOCCONVERTER_H_
#define JAVADOCCONVERTER_H_
class JavaDocConverter
{
public:
JavaDocConverter();
string convertToJavaDoc(list <DoxygenEntity> entityList);
~JavaDocConverter();
};
#endif /*JAVADOCCONVERTER_H_*/

View file

@ -13,8 +13,8 @@ class Token
public:
Token(int tType, string tString);
~Token();
int tokenType;
string tokenString;
int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */
string tokenString; /* the data , such as param for @param*/
string toString();
};

View file

@ -67,11 +67,8 @@ TokenList::TokenList(string doxygenString){
}
Token TokenList::peek(){
list<Token>::iterator p = tokenList.begin();
if(p != tokenList.end()){
p++;
Token returnedToken = (*p);
p--;
if(tokenListIterator!= tokenList.end()){
Token returnedToken = (*tokenListIterator);
return returnedToken;
}
else
@ -79,15 +76,22 @@ Token TokenList::peek(){
}
Token TokenList::next(){
list<Token>::iterator p = tokenList.begin();
if(p != tokenList.end()){
p++;
return (*p);
if(tokenListIterator != tokenList.end()){
Token returnedToken = (*tokenListIterator);
tokenListIterator++;
return (returnedToken);
}
else
return Token(0, "");
}
list<Token>::iterator TokenList::end(){
return tokenList.end();
}
list<Token>::iterator TokenList::current(){
return tokenListIterator;
}
void TokenList::printList(){
list<Token>::iterator p = tokenList.begin();
int i = 1;
@ -100,4 +104,11 @@ void TokenList::printList(){
}
}
TokenList:: ~TokenList(){}
list<Token>::iterator TokenList::iteratorCopy(){
list<Token>::iterator p = tokenListIterator;
return p;
}
void TokenList::setIterator(list<Token>::iterator newPosition){
tokenListIterator = newPosition;
}
TokenList:: ~TokenList(){}

View file

@ -13,12 +13,15 @@ using namespace std;
class TokenList{
public:
/* constructor takes a blob of Doxygen comment */
TokenList(string doxygenString);
TokenList(string doxygenString); /* constructor takes a blob of Doxygen comment */
~TokenList();
Token peek(); /* returns next token without advancing */
Token next(); /* returns next token and advances */
list<Token>::iterator end(); /* returns an end iterator */
list<Token>::iterator current(); /* returns the current iterator */
void printList(); /* prints out the sequence of tokens */
list<Token>::iterator iteratorCopy(); /* returns a copy of the current iterator */
void setIterator(list<Token>::iterator newPosition); /*moves up the iterator*/
};
#endif /*TOKENLIST_H_*/