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:
parent
da4e3cd374
commit
cc6db6eab6
7 changed files with 716 additions and 922 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifndef DOXYGENENTITY_H_
|
||||||
|
#define DOXYGENENTITY_H_
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -12,7 +14,7 @@ public:
|
||||||
DoxygenEntity(string typeEnt);
|
DoxygenEntity(string typeEnt);
|
||||||
DoxygenEntity(string typeEnt, string param1);
|
DoxygenEntity(string typeEnt, string param1);
|
||||||
DoxygenEntity(string typeEnt, list <DoxygenEntity> &entList );
|
DoxygenEntity(string typeEnt, list <DoxygenEntity> &entList );
|
||||||
virtual ~DoxygenEntity();
|
~DoxygenEntity();
|
||||||
void printEntity(int level);
|
void printEntity(int level);
|
||||||
string typeOfEntity;
|
string typeOfEntity;
|
||||||
list <DoxygenEntity> entityList;
|
list <DoxygenEntity> entityList;
|
||||||
|
|
@ -21,3 +23,4 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*TOKENLIST_H_*/
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
104
Source/DoxygenTranslator/JavaDocConverter.cpp
Normal file
104
Source/DoxygenTranslator/JavaDocConverter.cpp
Normal 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;
|
||||||
|
}
|
||||||
17
Source/DoxygenTranslator/JavaDocConverter.h
Normal file
17
Source/DoxygenTranslator/JavaDocConverter.h
Normal 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_*/
|
||||||
|
|
@ -13,8 +13,8 @@ class Token
|
||||||
public:
|
public:
|
||||||
Token(int tType, string tString);
|
Token(int tType, string tString);
|
||||||
~Token();
|
~Token();
|
||||||
int tokenType;
|
int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */
|
||||||
string tokenString;
|
string tokenString; /* the data , such as param for @param*/
|
||||||
string toString();
|
string toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,11 +67,8 @@ TokenList::TokenList(string doxygenString){
|
||||||
}
|
}
|
||||||
|
|
||||||
Token TokenList::peek(){
|
Token TokenList::peek(){
|
||||||
list<Token>::iterator p = tokenList.begin();
|
if(tokenListIterator!= tokenList.end()){
|
||||||
if(p != tokenList.end()){
|
Token returnedToken = (*tokenListIterator);
|
||||||
p++;
|
|
||||||
Token returnedToken = (*p);
|
|
||||||
p--;
|
|
||||||
return returnedToken;
|
return returnedToken;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -79,15 +76,22 @@ Token TokenList::peek(){
|
||||||
}
|
}
|
||||||
|
|
||||||
Token TokenList::next(){
|
Token TokenList::next(){
|
||||||
list<Token>::iterator p = tokenList.begin();
|
if(tokenListIterator != tokenList.end()){
|
||||||
if(p != tokenList.end()){
|
Token returnedToken = (*tokenListIterator);
|
||||||
p++;
|
tokenListIterator++;
|
||||||
return (*p);
|
return (returnedToken);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Token(0, "");
|
return Token(0, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list<Token>::iterator TokenList::end(){
|
||||||
|
return tokenList.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
list<Token>::iterator TokenList::current(){
|
||||||
|
return tokenListIterator;
|
||||||
|
}
|
||||||
void TokenList::printList(){
|
void TokenList::printList(){
|
||||||
list<Token>::iterator p = tokenList.begin();
|
list<Token>::iterator p = tokenList.begin();
|
||||||
int i = 1;
|
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(){}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,15 @@ using namespace std;
|
||||||
|
|
||||||
class TokenList{
|
class TokenList{
|
||||||
public:
|
public:
|
||||||
/* constructor takes a blob of Doxygen comment */
|
TokenList(string doxygenString); /* constructor takes a blob of Doxygen comment */
|
||||||
TokenList(string doxygenString);
|
|
||||||
~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 */
|
||||||
void printList(); /* prints out the sequence of tokens */
|
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_*/
|
#endif /*TOKENLIST_H_*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue