Ejemplo n.º 1
0
void UmlOperation::defaultDef()
{
    if (cppDecl().isEmpty())
        set_CppDecl(CppSettings::operationDecl());

    if (isAbstract())
        set_CppDef("");
    else if (cppDef().isEmpty())
        set_CppDef(CppSettings::operationDef());

    setUsed();
}
Ejemplo n.º 2
0
void UmlOperation::change(Context & ctx)
{
    if (ctx.onOperation() && ctx.match_stereotype(stereotype())) {
        if (ctx.cpp()) {
            const Q3CString & c = cppDecl();

            if (!c.isEmpty() && ctx.match(c)) {
                if (!set_CppDecl(ctx.replace(c)))
                    ctx.err();
            }

            const Q3CString & f = cppDef();

            if (!f.isEmpty() && ctx.match(f)) {
                if (!set_CppDef(ctx.replace(f)))
                    ctx.err();
            }
        }

        if (ctx.java()) {
            const Q3CString & c = javaDecl();

            if (!c.isEmpty() && ctx.match(c)) {
                if (!set_JavaDecl(ctx.replace(c)))
                    ctx.err();
            }
        }

        if (ctx.php()) {
            const Q3CString & c = phpDecl();

            if (!c.isEmpty() && ctx.match(c)) {
                if (!set_PhpDecl(ctx.replace(c)))
                    ctx.err();
            }
        }

        if (ctx.python()) {
            const Q3CString & c = pythonDecl();

            if (!c.isEmpty() && ctx.match(c)) {
                if (!set_PythonDecl(ctx.replace(c)))
                    ctx.err();
            }
        }

        if (ctx.idl()) {
            const Q3CString & c = idlDecl();

            if (!c.isEmpty() && ctx.match(c)) {
                if (!set_IdlDecl(ctx.replace(c)))
                    ctx.err();
            }
        }
    }
}
Ejemplo n.º 3
0
void UmlOperation::setParams(const char * s)
{
    QByteArray d;
    int index;

    d = cppDecl();

    if (((index = d.indexOf("${(}")) != -1) &&
        (d.mid(index + 4, 4) == "${)}")) {
        d.insert(d.indexOf("${(}") + 4, s);
        set_CppDecl(d);
    }

    d = cppDef();

    if (((index = d.indexOf("${(}")) != -1) &&
        (d.mid(index + 4, 4) == "${)}")) {
        d.insert(d.indexOf("${(}") + 4, s);
        set_CppDef(d);
    }
}
Ejemplo n.º 4
0
void UmlOperation::rename_jdk5() {
  QCString s;
  bool changed = FALSE;
  bool javasettings = (parent()->name() == "JavaSettings");
  
  s = cppDecl();
  if (rename(s, FALSE, javasettings)) {
    changed = TRUE;
    set_CppDecl(s);
  }
  
  s = cppDef();
  if (rename(s, FALSE, javasettings)) {
    changed = TRUE;
    set_CppDef(s);
  }
  
  s = cppBody();
  if (rename(s, FALSE, javasettings)) {
    changed = TRUE;
    set_CppBody(s);
  }
  
  s = javaDef();
  if (rename(s, TRUE, javasettings)) {
    changed = TRUE;
    set_JavaDef(s);
  }
  
  s = javaBody();
  if (rename(s, TRUE, javasettings)) {
    changed = TRUE;
    set_JavaBody(s);
  }
  
  if (changed)
    UmlCom::trace(parent()->name() + "::" + name() +
		  " upgraded to take into account the rename of 'enum' to 'enum pattern'<br>\n");
  
}
Ejemplo n.º 5
0
void UmlOperation::setType(UmlClass * type, const char * s)
{
    UmlTypeSpec t;

    t.type = type;
    set_ReturnType(t);

    static const QByteArray sep = " \t\n\r";
    QByteArray d;
    int typeindex;
    int nameindex;

    d = cppDecl();

    if (((typeindex = d.indexOf("${type}")) != -1) &&
        ((nameindex = d.indexOf("${name}", typeindex + 7)) != -1)) {
        while (sep.indexOf(d[nameindex - 1]) != -1)
            nameindex -= 1;

        d.replace(typeindex, nameindex - typeindex, s);
        set_CppDecl(d);
    }

    if (! isAbstract()) {
        d = cppDef();

        if (((typeindex = d.indexOf("${type}")) != -1) &&
            ((nameindex = d.indexOf("${class}", typeindex + 7)) != -1)) {
            while (sep.indexOf(d[nameindex - 1]) != -1)
                nameindex -= 1;

            d.replace(typeindex, nameindex - typeindex, s);
            set_CppDef(d);
        }
    }
}
Ejemplo n.º 6
0
void UmlOperation::cplusplus(QHash<QByteArray, QByteArray*> &)
{
    set_CppDecl(CppSettings::operationDecl());
    set_CppDef(CppSettings::operationDef());
}
Ejemplo n.º 7
0
void UmlOperation::importParameters(File & f)
{
    QByteArray s;
    unsigned rank = 0;
    const char * sep = "";
    QByteArray doc = description();

    for (;;) {
        switch (f.read(s)) {
        case ')':
            if (doc != description())
                set_Description(doc);

            return;

        case '(':
            // a parameter
            break;

        default:
            f.syntaxError(s);
        }

        f.read("object");
        f.read("Parameter");

        UmlParameter p;
        QByteArray ti;

        ti = QString("${t%1}").arg(rank).toLatin1();

        if (f.read(p.name) != STRING)
            f.syntaxError(s, "parameter's name");

        QByteArray id;
        QByteArray ste;
        QByteArray p_doc;
        QHash<QByteArray, QByteArray*> prop;
        int k;

        for (;;) {
            k = f.readDefinitionBeginning(s, id, ste, p_doc, prop);

            if (k == ')')
                break;

            if (s == "type") {
                if (f.read(s) != STRING)
                    f.syntaxError(s, "parameter type");

                switch (((UmlClass *) parent())->language()) {
                case Corba:
                    if (strncmp(s,  "in ", 3) == 0) {
                        p.dir = InputDirection;
                        s = s.mid(3);
                    }
                    else if (strncmp(s,  "out ", 4) == 0) {
                        p.dir = OutputDirection;
                        s = s.mid(4);
                    }
                    else if (strncmp(s,  "inout ", 6) == 0) {
                        p.dir = InputOutputDirection;
                        s = s.mid(6);
                    }
                    else {
                        QByteArray err =
                            "<br>'" + s + "' : wrong parameter direction, in " + f.context();

                        UmlCom::trace(err);
                        p.dir = InputOutputDirection;
                    }

                    break;

                default:
                    // !!!!!!!!!!!!!
                    p.dir = InputOutputDirection;
                }

                p.type.explicit_type = s;
            }
            else if (s == "quidu") {
                if (f.read(s) != STRING)
                    f.syntaxError(s, "wrong quidu");

                if (UmlClass::replaceType(p.type, s, ti))
                    ti = s;
            }
            else
                f.skipNextForm();
        }

        QByteArray d;
        int index;

        switch (((UmlClass *) parent())->language()) {
        case Cplusplus:
        case AnsiCplusplus:
        case VCplusplus:
            s= QString("%1%2 ${p%3}").arg(sep).arg((const char *) ti).arg(rank).toLatin1();

            if ((index = (d = cppDecl()).indexOf("${)}")) != -1)
                //set_CppDecl(d.insert(index, s));//[jasa] original line
                set_CppDecl(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call

            if ((index = (d = cppDef()).indexOf("${)}")) != -1)
                set_CppDef(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call

            break;

        case Oracle8:
            break;

        case Corba:
            if ((index = (d = idlDecl()).indexOf("${)}")) != -1) {
                s = QString("%1${d%2} %3 ${p%4}").arg(
                          sep).arg(rank).arg((const char *) ti).arg(rank).toLatin1();
                set_IdlDecl(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call
            }

            break;

        case Java:
            if ((index = (d = javaDecl()).indexOf("${)}")) != -1) {
                s = QString("%s%s ${p%u}").arg( sep).arg( (const char *) ti).arg( rank).toLatin1();
                set_JavaDecl(d.insert(index, (const char *)s)); //[jasa]
            }

            break;

        default:
            break;
        }

        addParameter(rank++, p);
        sep = ", ";
    }
}
Ejemplo n.º 8
0
void UmlOperation::import(File & f)
{
    if (scanning) {
        f.skipBlock();
        return;
    }

    QByteArray s;
    UmlTypeSpec t;

    for (;;) {
        switch (f.read(s)) {
        case -1:
            f.eof();
            throw 0;

        case ')':
            set_ReturnType(t);
            return;

        case ATOM:
            break;

        default:
            f.syntaxError(s);
        }

        // atom
        if (s == "parameters") {
            f.read("(");
            f.read("list");
            f.read("Parameters");
            importParameters(f);
        }
        else if (s == "result") {
            if (f.read(s) != STRING)
                f.syntaxError(s, "return type");

            t.explicit_type = s;
        }
        else if (s == "quidu") {
            if (f.read(s) != STRING)
                f.syntaxError(s, "wrong quidu");

            if (UmlClass::replaceType(t, s, "${type}")) {
                switch (((UmlClass *) parent())->language()) {
                case Cplusplus:
                case AnsiCplusplus:
                case VCplusplus:
                    set_CppDecl(replace(cppDecl(), "${type}", s));
                    set_CppDef(replace(cppDef(), "${type}", s));
                    break;

                case Oracle8:
                    break;

                case Corba:
                    set_IdlDecl(replace(idlDecl(), "${type}", s));
                    break;

                case Java:
                    set_JavaDecl(replace(javaDecl(), "${type}", s));
                    break;

                default:
                    break;
                }
            }
        }
        else if (s == "exceptions")
            importExceptions(f);
        else if (s == "opExportControl")
            set_Visibility(f.readVisibility());
        else
            f.skipNextForm();
    }

}
Ejemplo n.º 9
0
void UmlOperation::set_cpp(const char * return_form_or_inherit,
			   const char * params, QCString body,
			   bool inlinep, const char * if_def,
			   const char * end_if) {
  if (*return_form_or_inherit == ':') {
    // inherit
    if (inlinep) {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${)}");
      
      s.resize(index + 5);
      s.insert(index, params);
      s.append(" ");
      s.append(return_form_or_inherit);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      set_CppDef("");
    }
    else {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${)}");
      
      s.resize(index + 5);
      s.insert(index, params);
      s.append(";");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      s = remove_throw(CppSettings::operationDef());
      index = s.find("${)}");
      s.resize(index + 5);
      s.insert(index, params);
      s.append(" ");
      s.append(return_form_or_inherit);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDef(s);
    }
  }
  else {
    // return
    if (inlinep) {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${type}");
      
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      s.resize(s.findRev(";") + 1);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      set_CppDef("");
    }
    else {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${type}");
      
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      s = remove_throw(CppSettings::operationDef());
      index = s.find("${type}");
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      conditional(s, if_def, end_if);
      set_CppDef(s);
      
      set_CppBody(body);
    }
  }
}
Ejemplo n.º 10
0
void UmlOperation::remove_cpp_throw() {
  set_CppDecl(remove_throw(CppSettings::operationDecl()));
  set_CppDef(remove_throw(CppSettings::operationDef()));
}