list<string> defferedEvents;
public:
const string name;
- explicit State(string name) : name(name) {}
+ bool noTypedef;
+ explicit State(string name) : name(name), noTypedef(false) {}
void setInitialInnerState(string name) { initialInnerState = name; }
void addDeferredEvent(const string &name) { defferedEvents.push_back(name); }
+ void setNoTypedef() { noTypedef = true;}
friend ostream& operator<<(ostream& os, const State& s);
};
string label = s.name;
for (list<string>::const_iterator i = s.defferedEvents.begin(), e = s.defferedEvents.end(); i != e; ++i)
label.append("<br />").append(*i).append(" / defer");
- os << indent << s.name << " [label=<" << label << ">]\n";
+ if(s.noTypedef) os << indent << s.name << " [label=<" << label << ">, color=\"red\"]\n";
+ else os << indent << s.name << " [label=<" << label << ">]\n";
if (s.size()) {
os << indent << s.name << " -> " << s.initialInnerState << " [style = dashed]\n";
os << indent << "subgraph cluster_" << s.name << " {\n" << indent_inc;
if (TST->getNumArgs() >= ArgNum+1) {
return TST->getArgLoc(ArgNum);
} else
- Diag(TST->getBeginLoc(), diag_warning) << TST->getType()->getTypeClassName() << "has not enough arguments" << TST->getSourceRange();
+ if(ArgNum!=2)
+ Diag(TST->getBeginLoc(), diag_warning) << TST->getType()->getTypeClassName() << "has not enough arguments" << TST->getSourceRange();
} else
Diag(T.getBeginLoc(), diag_warning) << T.getType()->getTypeClassName() << "type as template argument is not supported" << T.getSourceRange();
return TemplateArgumentLoc();
}
TemplateArgumentLoc getTemplateArgLocOfBase(const CXXBaseSpecifier *Base, unsigned ArgNum) {
- return getTemplateArgLoc(Base->getTypeSourceInfo()->getTypeLoc(), 1);
+ return getTemplateArgLoc(Base->getTypeSourceInfo()->getTypeLoc(), ArgNum);
}
CXXRecordDecl *getTemplateArgDeclOfBase(const CXXBaseSpecifier *Base, unsigned ArgNum, TemplateArgumentLoc &Loc) {
- Loc = getTemplateArgLocOfBase(Base, 1);
+ Loc = getTemplateArgLocOfBase(Base, ArgNum);
switch (Loc.getArgument().getKind()) {
case TemplateArgument::Type:
return Loc.getTypeSourceInfo()->getType()->getAsCXXRecordDecl();
void handleSimpleState(CXXRecordDecl *RecordDecl, const CXXBaseSpecifier *Base)
{
+ int typedef_num = 0;
string name(RecordDecl->getName()); //getQualifiedNameAsString());
+ printf("stav %s\n", RecordDecl->getName());
Diag(RecordDecl->getLocStart(), diag_found_state) << name;
Model::State *state;
}
c->add(state);
}
-
+ //TODO support more innitial states
TemplateArgumentLoc Loc;
if (MyCXXRecordDecl *InnerInitialState =
static_cast<MyCXXRecordDecl*>(getTemplateArgDeclOfBase(Base, 2, Loc))) {
- if (InnerInitialState->isDerivedFrom("boost::statechart::simple_state") ||
- InnerInitialState->isDerivedFrom("boost::statechart::state_machine"))
- state->setInitialInnerState(InnerInitialState->getName());
+ if (InnerInitialState->isDerivedFrom("boost::statechart::simple_state") ||
+ InnerInitialState->isDerivedFrom("boost::statechart::state_machine")) {
+ state->setInitialInnerState(InnerInitialState->getName());
+ }
else
Diag(Loc.getTypeSourceInfo()->getTypeLoc().getLocStart(), diag_warning)
<< InnerInitialState->getName() << " as inner initial state is not supported" << Loc.getSourceRange();
IdentifierInfo& II = ASTCtx->Idents.get("reactions");
// TODO: Lookup for reactions even in base classes - probably by using Sema::LookupQualifiedName()
- // TODO: Find when state has no reactions
for (DeclContext::lookup_result Reactions = RecordDecl->lookup(DeclarationName(&II));
- Reactions.first != Reactions.second; ++Reactions.first)
+ Reactions.first != Reactions.second; ++Reactions.first, typedef_num++)
HandleReaction(*Reactions.first, RecordDecl);
+ if(typedef_num == 0) {
+ Diag(RecordDecl->getLocStart(), diag_warning)
+ << " missing typedef for reactions in state : " << RecordDecl->getName();
+ state->setNoTypedef();
+ }
}
void handleStateMachine(CXXRecordDecl *RecordDecl, const CXXBaseSpecifier *Base)
{
if (!Declaration->isCompleteDefinition())
return true;
- if (Declaration->getQualifiedNameAsString() == "boost::statechart::state")
+ if (Declaration->getQualifiedNameAsString() == "boost::statechart::state" ||
+ Declaration->getQualifiedNameAsString() == "TimedState" ||
+ Declaration->getQualifiedNameAsString() == "TimedSimpleState")
return true; // This is an "abstract class" not a real state
- if (Declaration->getQualifiedNameAsString() == "TimedState")
- return true; // This is an "abstract class" not a real state
- if (Declaration->getQualifiedNameAsString() == "TimedSimpleState")
- return true; // This is an "abstract class" not a real state
-
MyCXXRecordDecl *RecordDecl = static_cast<MyCXXRecordDecl*>(Declaration);
const CXXBaseSpecifier *Base;