コード例 #1
0
ファイル: UmlOperation.cpp プロジェクト: 02JanDal/douml
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();
            }
        }
    }
}
コード例 #2
0
ファイル: UmlRelation.cpp プロジェクト: DoUML/douml
void UmlRelation::change(Context & ctx)
{
    if (ctx.onRelation() && ctx.match_stereotype(stereotype())) {
        if (ctx.cpp()) {
            const QByteArray & c = cppDecl();

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

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

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

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

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

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

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

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

            if (!c.isEmpty() && ctx.match(c)) {
                if (!set_IdlDecl(ctx.replace(c)))
                    ctx.err();
            }
        }
    }
}
コード例 #3
0
void UmlExtraClassMember::generate_decl(QTextStream & f, const Q3CString &,
					Q3CString indent, bool) {
  f << indent << idlDecl();
}
コード例 #4
0
ファイル: UmlRelation.cpp プロジェクト: javrillon/douml
void UmlRelation::generate_inherit(const char *& sep, QTextStream & f,
                                   const WrapperStr & cl_stereotype,
                                   BooL & already)
{
    if ((relationKind() == aGeneralisation) || (relationKind() == aRealization)) {
        UmlClass * role_type = roleType();
        WrapperStr other_stereotype = role_type->idl_stereotype();

        if (other_stereotype == "ignored")
            return;

        if ((cl_stereotype == "union") || (cl_stereotype == "enum")) {
            write_trace_header();
            UmlCom::trace(WrapperStr("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>an <i>")
                          + cl_stereotype + "</i> cannot inherits</b></font><br>");
            incr_warning();
            return;
        }

        if ((other_stereotype == "union") ||
                (other_stereotype == "struct") ||
                (other_stereotype == "enum") ||
                (other_stereotype == "typedef")) {
            write_trace_header();
            UmlCom::trace(WrapperStr("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>cannot inherits an <i>")
                          + other_stereotype + "</i></b></font><br>");
            incr_warning();
            return;
        }

        if (cl_stereotype == "valuetype") {
            if (other_stereotype == "valuetype") {
                if (isIdlTruncatableInheritance())
                    f << sep << "truncatable ";
                else
                    f << sep;
            }
            else {
                // other_stereotype == "interface"
                if (!already) {
                    already = TRUE;
                    f << " supports ";
                }
                else
                    f << sep;
            }
        }
        else
            f << sep;

        const char * p = idlDecl();

        while (*p) {
            if (!strncmp(p, "${type}", 7)) {
                role_type->write(f);
                p += 7;
            }
            else if (*p == '@')
                manage_alias(p, f);
            else
                f << *p++;
        }

        sep = ", ";
    }
}
コード例 #5
0
ファイル: UmlRelation.cpp プロジェクト: javrillon/douml
void UmlRelation::generate_decl(QTextStream & f,
                                const WrapperStr & cl_stereotype,
                                WrapperStr indent, bool)
{
    if ((relationKind() != aGeneralisation) &&
            (relationKind() != aRealization) &&
            (relationKind() != aDependency)) {
        if (cl_stereotype == "enum") {
            write_trace_header();
            UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>");
            incr_warning();
            return;
        }

        if (cl_stereotype == "typedef") {
            write_trace_header();
            UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>");
            incr_warning();
            return;
        }

        if (!idlDecl().isEmpty()) {
            const char * p = idlDecl();
            const char * pp = 0;
            WrapperStr s;

            while ((*p == ' ') || (*p == '\t'))
                indent += *p++;

            if (*p != '#')
                f << indent;

            for (;;) {
                if (*p == 0) {
                    if (pp == 0)
                        break;

                    // comment management done
                    p = pp;
                    pp = 0;

                    if (*p == 0)
                        break;

                    if (*p != '#')
                        f << indent;
                }

                if (*p == '\n') {
                    f << *p++;

                    if (*p && (*p != '#'))
                        f << indent;
                }
                else if (*p == '@')
                    manage_alias(p, f);
                else if (*p != '$')
                    f << *p++;
                else if (!strncmp(p, "${comment}", 10))
                    manage_comment(p, pp);
                else if (!strncmp(p, "${description}", 14))
                    manage_description(p, pp);
                else if (!strncmp(p, "${readonly}", 11)) {
                    p += 11;

                    if (isReadOnly())
                        f << "readonly ";
                }
                else if (!strncmp(p, "${attribut}", 11)) {
                    // old version
                    p += 11;

                    if (cl_stereotype == "interface")
                        f << "attribute ";
                }
                else if (!strncmp(p, "${attribute}", 12)) {
                    p += 12;

                    if (cl_stereotype == "interface")
                        f << "attribute ";
                }
                else if (!strncmp(p, "${visibility}", 13)) {
                    p += 13;

                    if (cl_stereotype == "valuetype") {
                        switch (visibility()) {
                        case PublicVisibility:
                        case PackageVisibility:
                            f << "public ";
                            break;

                        default:
                            f << "private ";
                        }
                    }
                }
                else if (!strncmp(p, "${case}", 7)) {
                    p += 7;

                    WrapperStr idl_case = idlCase();

                    if (idl_case.isEmpty()) {
                        write_trace_header();
                        UmlCom::trace(WrapperStr("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>unspecified <i>case</i> for <i>")
                                      + name() + "</b></font><br>");
                        incr_error();
                    }
                    else
                        f << idlCase();
                }
                else if (!strncmp(p, "${type}", 7)) {
                    p += 7;
                    roleType()->write(f);
                }
                else if (!strncmp(p, "${name}", 7)) {
                    p += 7;
                    f << roleName();
                }
                else if (!strncmp(p, "${inverse_name}", 15)) {
                    p += 15;

                    switch (relationKind()) {
                    case anAssociation:
                    case anAggregation:
                    case anAggregationByValue:
                        f << side(side(TRUE) != this)->roleName();

                    default:
                        break;
                    }
                }
                else if (!strncmp(p, "${stereotype}", 13)) {
                    p += 13;
                    f << IdlSettings::relationAttributeStereotype(stereotype());
                }
                else if (!strncmp(p, "${multiplicity}", 15)) {
                    p += 15;
                    f << multiplicity();
                }
                else if (!strncmp(p, "${association}", 14)) {
                    p += 14;
                    f << IdlSettings::type(association().toString());
                }
                else
                    // strange
                    f << *p++;
            }

            f << '\n';
        }
    }
}
コード例 #6
0
ファイル: UmlOperation.cpp プロジェクト: javrillon/douml
void UmlOperation::generate_decl(QTextStream & f,
                                 const WrapperStr & cl_stereotype,
                                 WrapperStr indent, bool)
{
    if (!idlDecl().isEmpty()) {
        if ((cl_stereotype != "interface") &&
                (cl_stereotype != "valuetype")) {
            write_trace_header();
            UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>cannot have operation</b></font><br>");
            incr_warning();
            return;
        }

        const char * p = idlDecl();
        const char * pp = 0;
        const QList<UmlParameter> & params = this->params();
        const QList<UmlTypeSpec> & exceptions = this->exceptions();
        unsigned rank;

        while ((*p == ' ') || (*p == '\t'))
            indent += *p++;

        if (*p != '#')
            f << indent;

        for (;;) {
            if (*p == 0) {
                if (pp == 0)
                    break;

                // comment management done
                p = pp;
                pp = 0;

                if (*p == 0)
                    break;

                if (*p != '#')
                    f << indent;
            }

            if (*p == '\n') {
                f << *p++;

                if (*p && (*p != '#'))
                    f << indent;
            }
            else if (*p == '@')
                manage_alias(p, f);
            else if (*p != '$')
                f << *p++;
            else if (!strncmp(p, "${comment}", 10))
                manage_comment(p, pp);
            else if (!strncmp(p, "${description}", 14))
                manage_description(p, pp);
            else if (!strncmp(p, "${oneway}", 9)) {
                p += 9;

                if (isIdlOneway())
                    f << "oneway ";
            }
            else if (!strncmp(p, "${type}", 7)) {
                p += 7;
                UmlClass::write(f, returnType());
            }
            else if (!strncmp(p, "${name}", 7)) {
                p += 7;
                f << compute_name();
            }
            else if (!strncmp(p, "${(}", 4)) {
                p += 4;
                f << '(';
            }
            else if (!strncmp(p, "${)}", 4)) {
                p += 4;
                f << ')';
            }
            else if (sscanf(p, "${d%u}", &rank) == 1) {
                if (!generate_dir(params, rank, f))
                    param_error(parent()->name(), name(), rank, "declaration");

                p = strchr(p, '}') + 1;
            }
            else if (sscanf(p, "${t%u}", &rank) == 1) {
                if (!generate_type(params, rank, f))
                    param_error(parent()->name(), name(), rank, "declaration");

                p = strchr(p, '}') + 1;
            }
            else if (sscanf(p, "${p%u}", &rank) == 1) {
                if (!generate_var(params, rank, f))
                    param_error(parent()->name(), name(), rank, "declaration");

                p = strchr(p, '}') + 1;
            }
            else if (!strncmp(p, "${stereotype}", 13)) {
                p += 13;
                f << IdlSettings::relationAttributeStereotype(stereotype());
            }
            else if (!strncmp(p, "${raisesnl}", 11)) {
                if (exceptions.count() != 0) {
                    f << '\n' << indent << "  ";
                }

                p += 11;
            }
            else if (!strncmp(p, "${raises}", 9)) {
                p += 9;

                if (! exceptions.isEmpty()) {
                    const char * sep;
                    QList<UmlTypeSpec>::ConstIterator it;

                    for (it = exceptions.begin(), sep = " raises (";
                            it != exceptions.end();
                            ++it, sep = " ")
                        f << sep << IdlSettings::type((*it).toString());

                    f << ')';
                }
            }
            else if (!strncmp(p, "${association}", 14)) {
                p += 14;

                UmlClassMember * m;

                if (((m = getOf()) != 0) && (m->kind() == aRelation))
                    f << IdlSettings::type(((UmlRelation *) m)->association().toString());
                else if (((m = setOf()) != 0) && (m->kind() == aRelation))
                    f << IdlSettings::type(((UmlRelation *) m)->association().toString());
            }
            else
                // strange
                f << *p++;
        }

        f << '\n';
    }
}
コード例 #7
0
ファイル: UmlOperation.cpp プロジェクト: DoUML/douml
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 = ", ";
    }
}
コード例 #8
0
ファイル: UmlOperation.cpp プロジェクト: DoUML/douml
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();
    }

}