From: petr000 Date: Thu, 5 May 2011 15:40:44 +0000 (+0200) Subject: Add some commentaries to file. X-Git-Url: https://rtime.felk.cvut.cz/gitweb/boost-statechart-viewer.git/commitdiff_plain/136b9c892da1a4277d12c9a88bb78e39e4d15e74 Add some commentaries to file. --- diff --git a/src/iooper.h b/src/iooper.h index 6a28b41..4807773 100644 --- a/src/iooper.h +++ b/src/iooper.h @@ -41,14 +41,14 @@ class IO_operations { if(type == 1) { - for(unsigned i = 3;i transitions; list cReactions; list events; @@ -110,7 +111,6 @@ class FindStates : public ASTConsumer string name_of_machine; string name_of_start; FullSourceLoc *fsloc; - public: list getStates() @@ -145,6 +145,9 @@ class FindStates : public ASTConsumer name_of_machine = ""; } +/* + Traverse global decls using DeclGroupRef for handling all global decls. +*/ virtual void HandleTopLevelDecl(DeclGroupRef DGR)// traverse all top level declarations { SourceLocation loc; @@ -179,6 +182,10 @@ class FindStates : public ASTConsumer output = ""; } } + +/* + It is used to recursive traverse decls in namespaces. +*/ void recursive_visit(const DeclContext *declCont) //recursively visit all decls hidden inside namespaces { string line, output, event; @@ -213,6 +220,10 @@ class FindStates : public ASTConsumer } } +/* + This function works with class or struct. It splits the decl into 3 interesting parts. + The state machine decl, state decl and event decl. +*/ void struct_class(const Decl *decl) // works with struct or class decl { string output, line, ret, trans, event; @@ -245,7 +256,7 @@ class FindStates : public ASTConsumer } else { - ret = find_states(cRecDecl, line); + ret = find_states(cRecDecl, line); if(!ret.empty()) { cout << "New state: " << namedDecl->getNameAsString() << "\n"; @@ -256,19 +267,21 @@ class FindStates : public ASTConsumer } } - void methods_in_class(const Decl *decl, const string state) +/* + This function provides traversing all methods and other context indide class. If + typedef or classic method decl is found. Transitions inside it are beiing founded. +*/ + void methods_in_class(const Decl *decl, const string state) // traverse context inside one class { string output, line, ret, trans, event; llvm::raw_string_ostream x(output); int pos, num; const TagDecl *tagDecl = dyn_cast(decl); - const DeclContext *declCont = tagDecl->castToDeclContext(tagDecl); - //states.push_back(namedDecl->getNameAsString()); - + const DeclContext *declCont = tagDecl->castToDeclContext(tagDecl); output=""; for (DeclContext::decl_iterator i = declCont->decls_begin(), e = declCont->decls_end(); i != e; ++i) { - if (i->getKind()==26) + if (i->getKind()==26) // typedefs { i->print(x); output = x.str(); @@ -293,17 +306,16 @@ class FindStates : public ASTConsumer if(pos==-1) transitions.push_back(ret); else transitions.push_back(ret.substr(0,pos)); } - //cout<getKind()==35) method_decl(decl); + if(i->getKind()==35) method_decl(decl);// C++ method } } - void method_decl(const Decl *decl) + void method_decl(const Decl *decl) // method decl traverse. Using Stmt { string output, line, event; llvm::raw_string_ostream x(output); @@ -324,7 +336,7 @@ class FindStates : public ASTConsumer line.append(","); line.append(event); find_return_stmt(decl->getBody(),line); - for(list::iterator i = cReactions.begin();i!=cReactions.end();i++) + for(list::iterator i = cReactions.begin();i!=cReactions.end();i++) // erase info about it from list of custom reactions { event = *i; if(line.compare(event)==0) @@ -337,7 +349,7 @@ class FindStates : public ASTConsumer } } - void find_return_stmt(Stmt *statemt,string event) + void find_return_stmt(Stmt *statemt,string event) // traverse all statements in function for finding return Statement { if(statemt->getStmtClass() == 99) test_stmt(dyn_cast(statemt)->getSubStmt(), event); else @@ -349,7 +361,7 @@ class FindStates : public ASTConsumer } } - void test_stmt(Stmt *stmt, string event) + void test_stmt(Stmt *stmt, string event) // test statement { const SourceManager &sman = fsloc->getManager(); int type;