// p0 is the beginning of the operation's def // p point to ${body} // indent is the one of the operation const char * UmlOperation::generate_body(QTextStream & f, WrapperStr indent, const char * p) { if(isAbstract()) return p + 7; const char * body = 0; WrapperStr modeler_body; bool no_indent; char s_id[9]; if (preserve() && !isBodyGenerationForced()) { unsigned id = get_id(); sprintf(s_id, "%08X", id); body = bodies.find((long) id); } if (body == 0) { no_indent = !javaContextualBodyIndent(); modeler_body = javaBody(); // to not free the string body = modeler_body; } else // body from file, respect its indent no_indent = TRUE; // get keyword indent WrapperStr bindent = indent; while (*p != '$') bindent += *p++; if (preserve() && !isBodyGenerationForced()) f << bindent << BodyPrefix << s_id << '\n'; if ((body != 0) && (*body != 0)) { // output body if (bindent.isEmpty() || no_indent) { f << body; body += strlen(body); } else { f << bindent; while (*body) { f << *body; if (*body++ == '\n') { if (*body == 0) break; f << bindent; } } } if (body[-1] != '\n') f << '\n'; } if (preserve() && !isBodyGenerationForced()) f << bindent << BodyPostfix << s_id << '\n'; f << indent; // for the } return p + 7; }
// p point to ${body} const char * UmlOperation::generate_body(QTextStream & f, WrapperStr indent, BooL & indent_needed, const char * p) { if(isAbstract()) return p + 7; const char * body = 0; WrapperStr modeler_body; WrapperStr body_indent; char s_id[9]; if (preserve() && !isBodyGenerationForced()) { unsigned id = get_id(); sprintf(s_id, "%08X", id); body = bodies.value((long) id); } if (body == 0) { modeler_body = pythonBody(); // to not free the string body = modeler_body; if (pythonContextualBodyIndent()) body_indent = indent; } if (name() == "__init__") { const QList<UmlParameter> & params = this->params(); if (params.count() != 0) ((UmlClass *) parent())->generate_instance_att_rel(f, indent, indent_needed, params[0].name + "."); else { WrapperStr err = " <font color=\"red\"><b><i>" + parent()->name() + ".__init__()</i> doesn't have parameter, instance variables not generated </b></font><br>"; write_trace_header(); UmlCom::trace(err); incr_warning(); } } if (preserve() && !isBodyGenerationForced()) { if (indent_needed) f << indent; f << BodyPrefix << s_id << '\n' << body_indent; } else if (indent_needed) f << body_indent; if ((body != 0) && (*body != 0)) { // output body while (*body) { f << *body; if (*body++ == '\n') { if (*body == 0) break; f << body_indent; } } if (body[-1] != '\n') f << '\n'; } else f << "pass\n"; if (preserve() && !isBodyGenerationForced()) f << indent << BodyPostfix << s_id << '\n'; indent_needed = TRUE; return p + 7; }