Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
void UmlClass::addAssign(bool cte)
{
    TRACE_FUNCTION;
    UmlOperation * op = UmlOperation::create(this, "operator=");

    if (op == 0)
        UmlCom::trace("can't add assignment contructor");
    else {
        // add 'source' parameter

        UmlParameter param;

        param.name = "source";
        param.dir = (cte) ? InputDirection : InputOutputDirection;
        param.type.type = this;

        op->addParameter(0, param);

        // set return type, add the parameter profile

        UmlTypeSpec t;

        t.type = this;

        op->set_ReturnType(t);

        QByteArray p = (cte) ? "const ${t0} & ${p0}" : "${t0} & ${p0}";
        QByteArray s;
        int index;

        s = op->cppDecl();

        if (s.isEmpty())
            s = CppSettings::operationDecl();

        if ((index = s.indexOf("${(}")) != -1)
            s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray

        if ((index = s.indexOf("${type}")) != -1)
            s.insert(index + 7, " &");

        op->set_CppDecl(s);

        s = op->cppDef();

        if (s.isEmpty())
            s = CppSettings::operationDef();

        if ((index = s.indexOf("${(}")) != -1)
            s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray

        if ((index = s.indexOf("${type}")) != -1)
            s.insert(index + 7, " &");

        op->set_CppDef(s);
    }
}
Ejemplo n.º 3
0
void UmlClass::addCopy(bool cte)
{
    TRACE_FUNCTION;
    UmlOperation * op = UmlOperation::create(this, name());

    if (op == 0)
        UmlCom::trace("can't add copy contructor");
    else {
        // to see that it is a copy constructor
        op->set_Stereotype("copy");

        // add 'source' parameter

        UmlParameter param;

        param.name = "source";
        param.dir = (cte) ? InputDirection : InputOutputDirection;
        param.type.type = this;

        op->addParameter(0, param);

        // add the parameter profile, and
        // remove the useless "${type} " mainly to remove the space

        QByteArray p = (cte) ? "const ${t0} & ${p0}" : "${t0} & ${p0}";
        QByteArray s;
        int index;

        s = op->cppDecl();

        if (s.isEmpty())
            s = CppSettings::operationDecl();

        if ((index = s.indexOf("${(}")) != -1)
            s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray

        if ((index = s.indexOf("${type} ")) != -1)
            s.remove(index, 8);

        op->set_CppDecl(s);

        s = op->cppDef();

        if (s.isEmpty())
            s = CppSettings::operationDef();

        if ((index = s.indexOf("${(}")) != -1)
            s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray

        if ((index = s.indexOf("${type} ")) != -1)
            s.remove(index, 8);

        op->set_CppDef(s);
    }
}
Ejemplo n.º 4
0
void UmlClass::addContructor(bool expl)
{
    TRACE_FUNCTION;
    QLOG_INFO() << "1.1.1";
    UmlOperation * op = UmlOperation::create(this, name());
    QLOG_INFO() << "1.1.2";
    if (op == 0)
        UmlCom::trace("can't add contructor");
    else {
        QLOG_INFO() << "1.1.3";
        QByteArray s;
        int index;

        // remove the useless "${type} " mainly to remove the space

        s = op->cppDecl();
        QLOG_INFO() << s;
        QLOG_INFO() << "1.1.4";
        if (s.isEmpty())
            s = CppSettings::operationDecl();
        QLOG_INFO() << s;
        QLOG_INFO() << "1.1.5";
        if ((index = s.indexOf("${type} ")) != -1)
            s.remove(index, 8);
        QLOG_INFO() << s;
        QLOG_INFO() << "1.1.6";
        if (expl && ((index = s.indexOf("${name}")) != -1))
            s.insert(index, "explicit ");
        QLOG_INFO() << s;
        QLOG_INFO() << "1.1.7";
        op->set_CppDecl(s);
        QLOG_INFO() << s;
        QLOG_INFO() << "1.1.8";
        s = op->cppDef();
        QLOG_INFO() << s;
        QLOG_INFO() << "1.1.81";
        if (s.isEmpty())
            s = CppSettings::operationDef();
        QLOG_INFO() << "1.1.9";
        if ((index = s.indexOf("${type} ")) != -1)
            s.remove(index, 8);
        QLOG_INFO() << "1.1.10";
        op->set_CppDef(s);
    }
}
Ejemplo n.º 5
0
void UmlClass::addDestructor(bool virt)
{
    TRACE_FUNCTION;
    UmlOperation * op = UmlOperation::create(this, "~" + name());

    if (op == 0)
        UmlCom::trace("can't add destructor");
    else {
        if (virt)
            op->set_isCppVirtual(TRUE);

        QByteArray s;
        int index;

        // remove the useless "${type} " mainly to remove the space

        s = op->cppDecl();

        if (s.isEmpty())
            s = CppSettings::operationDecl();

        if ((index = s.indexOf("${type} ")) != -1) {
            s.remove(index, 8);
            op->set_CppDecl(s);
        }

        s = op->cppDef();

        if (s.isEmpty())
            s = CppSettings::operationDef();

        if ((index = s.indexOf("${type} ")) != -1) {
            s.remove(index, 8);
            op->set_CppDef(s);
        }
    }
}