コード例 #1
0
void UmlJunctionPseudoState::generate(UmlClass * machine, UmlClass * anystate, UmlState * state) {
  // create an operation because a priori shared
  if (_oper.isEmpty())
    _oper.sprintf("_junction%d", ++_rank);

  UmlClass * cl = state->assocClass();
  UmlOperation * junction;
  
  if (((junction = (UmlOperation *) cl->getChild(anOperation, _oper)) == 0) &&
      ((junction = UmlBaseOperation::create(cl, _oper)) == 0)) {
    UmlCom::trace("Error : cannot create operation '" + _oper 
		  + "' in class '" + cl->name() + "'<br>");
    throw 0;
  }

  junction->defaultDef();
  junction->setComment("implement a junction, through an operation because shared, internal");
  junction->setType("void", "${type}");
  junction->addParam(0, InputOutputDirection, "stm", machine);
  junction->setParams("${t0} & ${p0}");
  
  Q3CString body;
  const Q3PtrVector<UmlItem> ch = children();
  Q3PtrList<UmlTransition> trs;
  unsigned index;
  
  for (index = 0; index != ch.count(); index += 1)
    if (ch[index]->kind() == aTransition)
      // theo mandatory
      trs.append((UmlTransition *) ch[index]);
    
  UmlTransition::generate(trs, machine, anystate, state, body, "  ", FALSE);
  
  junction->set_CppBody(body);
}
コード例 #2
0
UmlOperation * UmlOperation::cpp2Python(UmlClass * python, UmlClass * cpp,
					 const char * cppname,
					 const char * pythonname)
{
  if (pythonname == 0)
    pythonname = cppname;
  
  UmlOperation * from = cpp->get_operation(cppname);
  
  if (from == 0) {
    QCString err = QCString("cannot find operation '") + 
      cppname + QCString("' in class '") + cpp->name()
	+ QCString("'<br>\n");
    UmlCom::trace(err);
    throw 0;
  }
  
  UmlOperation * to = UmlBaseOperation::create(python, pythonname);
  
  if (to == 0) {
    QCString err = QCString("cannot create operation '") + 
      pythonname + QCString("' in class '") + python->name()
	+ QCString("'<br>\n");
    UmlCom::trace(err);
    throw 0;
  }
  
  UmlCom::trace("add operation " + python->name() + "::" + pythonname + "<br>\n");

  to->set_Description(::cpp2Python(from->description()));
  to->set_ReturnType(from->returnType());
  to->set_isClassMember(from->isClassMember());
  to->set_Visibility(from->visibility());
  to->set_CppVisibility(from->cppVisibility());
  
  const QValueList<UmlParameter> params = from->params();
  unsigned index;
  
  for (index = 0; index != params.count(); index += 1)
    to->addParameter(index, params[index]);
  
  const QValueList<UmlTypeSpec> exceptions = from->exceptions();
  
  for (index = 0; index != exceptions.count(); index += 1)
    to->addException(index, exceptions[index]);
  
  to->set_isCppVirtual(from->isCppVirtual());
  to->set_isCppConst(from->isCppConst());
  to->set_isCppInline(from->isCppInline());
  to->set_CppDecl(::cpp2Python(from->cppDecl()));
  to->set_CppDef(::cpp2Python(from->cppDef()));
  to->set_CppBody(::cpp2Python(from->cppBody()));
  
  to->set_isJavaFinal(from->isJavaFinal());
  to->set_JavaDef(from->javaDef());
  to->set_JavaBody(::cpp2Python(from->javaBody()));
  
  return to;
}
コード例 #3
0
ファイル: UmlTransition.cpp プロジェクト: bleakxanadu/douml
void UmlTransition::generate(UmlClass * machine, UmlClass * anystate, UmlState * state)
{
    if (_already_managed)
        return;

    Q3CString s = triggerName();

    // group transitions having the same trigger
    const Q3PtrVector<UmlItem> ch = parent()->children();
    unsigned index = ch.findRef(this);
    Q3PtrList<UmlTransition> trs;
    UmlTransition * tr_no_guard = 0;

    if (cppGuard().isEmpty())
        tr_no_guard = this;
    else
        trs.append(this);

    while (++index != ch.count()) {
        if ((ch[index]->kind() == aTransition) &&
            (((UmlTransition *) ch[index])->triggerName() == s)) {
            if (!((UmlTransition *) ch[index])->cppGuard().isEmpty())
                trs.append((UmlTransition *) ch[index]);
            else if (tr_no_guard != 0) {
                UmlCom::trace("Error : several transitions from '" + parent()->name()
                              + "' don't have guard");
                throw 0;
            }
            else
                tr_no_guard = (UmlTransition *) ch[index];

            ((UmlTransition *) ch[index])->_already_managed = TRUE;
        }
    }

    if (tr_no_guard != 0)
        // place it at end
        trs.append(tr_no_guard);

    // made the trigger

    UmlOperation * trg = state->assocClass()->trigger(s, machine, anystate);
    Q3CString body;

    if (s == "create") {
        // manage entry
        if (!state->cppEntryBehavior().isEmpty())
            body = "  _doentry(stm);\n";
    }

    if (!state->cppDoActivity().isEmpty())
        // state do activity before each event except create
        body += "  _do(stm);\n";

    bool completion = (s == "_completion");

    if (!completion && state->isLeaf() && state->hasCompletion())
        // manage completion
        body += "  if (_completion(stm)) return;\n";

    UmlTransition::generate(trs, machine, anystate, state,
                            body, "  ", completion);

    trg->set_CppBody(body);
}