コード例 #1
0
// returns the actuals forms associated to inheritence of 'parent'
QString ClassData::get_actuals(BrowserClass * parent) {
  QList<ActualParamData> l;
  
  get_actuals(l, parent);
  
  QList<BrowserNode> parents = parent->parents();

  for (parent = (BrowserClass *) parents.first();
       parent != 0;
       parent = (BrowserClass *) parents.next())
    get_actuals(l, parent);
  
  QString s;  
  const char * sep = "<";
  ActualParamData * actual;
  QString arrow = "->";
  
  for (actual = l.first(); actual != 0; actual = l.next()) {
    QString v = actual->get_value().get_type();
    
    if (!v.isEmpty()) {
      s += sep + actual->get_name(FALSE) + arrow + v;
      sep = ", ";
    }
  }

  return (s.isEmpty()) ? s : s + ">";
}
コード例 #2
0
void ClassData::get_actuals(QList<ActualParamData> & l, BrowserClass * parent) {
  if (((BrowserNode *) parent->parent())->get_type() == UmlClass)
    get_actuals(l, (BrowserClass * ) parent->parent());
  
  ActualParamData * actual;
  int n = ((ClassData *) parent->get_data())->nformals;
  
  if (n != 0) {
    // search the first associated actual
    for (actual = actuals.first(); actual != 0; actual = actuals.next()) {
      if ((actual->get_class() == parent) &&
	  (l.findRef(actual) == -1))
	// find;
	break;
    }
    
    int nth = 0;
    
    // progress on still present formals
    while (actual && (nth < n) && (actual->get_class() == parent)) {
      // actual ok
      l.append(actual);
      
      actual = actuals.next();
      nth += 1;
    }
  }
}
コード例 #3
0
ファイル: ClassData.cpp プロジェクト: lollisoft/douml
ClassData::ClassData(const ClassData * model, BrowserNode * bn)
    : BasicData(model), constraint(model->constraint)
{
    browser_node = bn;

    if ((nformals = model->nformals) == 0)
        formals = 0;
    else {
        FormalParamData * mformals = model->formals;
        formals = new FormalParamData[nformals];

        for (int index = 0; index != nformals; index += 1)
            formals[index] = mformals[index];
    }

    Q3PtrListIterator<ActualParamData> it(model->actuals);
    BrowserClass * cl = 0;

    for (; it.current(); ++it) {
        ActualParamData * actual = new ActualParamData(*(it.current()));

        if (actual->get_class() != cl) {
            cl = actual->get_class();
            connect(cl->get_data(), SIGNAL(changed()),
                    this, SLOT(update_actuals()));
            connect(cl->get_data(), SIGNAL(deleted()),
                    this, SLOT(update_actuals()));
        }

        actuals.append(actual);
    }

    set_base_type(model->base_type);
    is_deleted = FALSE;
    bodies_read = FALSE;
    bodies_modified = FALSE;
    is_abstract = model->is_abstract;
    is_active = model->is_active;
    cpp_external = model->cpp_external;
    java_external = model->java_external;
    java_final = model->java_final;
    php_external = model->php_external;
    php_final = model->php_final;
    python_2_2 = model->python_2_2;
    python_external = model->python_external;
    idl_external = model->idl_external;
    idl_local = model->idl_local;
    idl_custom = model->idl_custom;
    uml_visibility = model->uml_visibility;
    cpp_visibility = model->cpp_visibility;
    cpp_decl = model->cpp_decl;
    java_decl = model->java_decl;
    java_annotation = model->java_annotation;
    php_decl = model->php_decl;
    python_decl = model->python_decl;
    set_switch_type(model->switch_type);
    idl_decl = model->idl_decl;

    connect(this, SIGNAL(changed()), this, SLOT(update_actuals()));
}
コード例 #4
0
ファイル: ClassData.cpp プロジェクト: lollisoft/douml
void ClassData::update_actuals(BrowserClass * parent,
                               Q3PtrList<ActualParamData> & new_actuals,
                               Q3PtrList<ActualParamData> & managed)
{
    if (((BrowserNode *) parent->parent())->get_type() == UmlClass)
        update_actuals((BrowserClass *) parent->parent(), new_actuals, managed);

    ActualParamData * actual;
    int n = ((ClassData *) parent->get_data())->nformals;

    if (n != 0) {
        // search the first associated actual
        for (actual = actuals.first(); actual != 0; actual = actuals.next()) {
            if ((actual->get_class() == parent) &&
                (managed.findRef(actual) == -1))
                // find;
                break;
        }

        int nth = 0;

        // progress on still present formals
        while (actual && (nth < n) && (actual->get_class() == parent)) {
            // actual ok
            new_actuals.append(actual);
            managed.append(actual);

            actual = actuals.next();
            nth += 1;
        }

        if (nth < n) {
            // adds necessary actuals
            if (nth == 0) {
                // new inheritance
                connect(parent->get_data(), SIGNAL(deleted()),
                        this, SLOT(update_actuals()));
                connect(parent->get_data(), SIGNAL(changed()),
                        this, SLOT(update_actuals()));
            }

            do {
                new_actuals.append(new ActualParamData(parent, nth));
                nth += 1;
            }
            while (nth != n);
        }
    }
}
コード例 #5
0
void ClassData::read(char * & st, char * & k) {
  if (!strcmp(k, "abstract")) {
    is_abstract = TRUE;
    k = read_keyword(st);
  }
  else
    is_abstract = FALSE;
  
  if (!strcmp(k, "active")) {
    is_active = TRUE;
    k = read_keyword(st);
  }
  else
    is_active = FALSE;
  
  if (!strcmp(k, "visibility")) {
    uml_visibility = ::visibility(read_keyword(st));  
    k = read_keyword(st);
  }
  else {
    // old non nested class
    uml_visibility = UmlPackageVisibility;
  }
  
  if (!strcmp(k, "stereotype")) {
    set_stereotype(read_string(st));
    
    if (!strcmp(stereotype, "typedef")) {
      AType t;
      
      t.read(st, "base_type", "explicit_base_type");
      set_base_type(t);
    }
    
    k = read_keyword(st);
  }
  
  unsigned n, i;
  
  if (!strcmp(k, "nformals")) {
    n = read_unsigned(st);
    set_n_formalparams(n);
    
    for (i = 0; i != n; i += 1)
      formals[i].read(st);
    
    k = read_keyword(st);
  }
  else
    set_n_formalparams(0);

  if (!strcmp(k, "nactuals")) {
    n = read_unsigned(st);
    
    BrowserClass * cl = 0;

    for (i = 0; i != n; i += 1) {
      ActualParamData * actual = ActualParamData::read(st);

      actuals.append(actual);
      
      if (actual->get_class() != cl) {
	cl = actual->get_class();
	connect(cl->get_data(), SIGNAL(deleted()),
		this, SLOT(update_actuals()));
	connect(cl->get_data(), SIGNAL(changed()),
		this, SLOT(update_actuals()));
      }
    }

    k = read_keyword(st);
  }
  else {
    n = 0;
    actuals.clear();
  }
  
  if (!strcmp(k, "constraint")) {
    constraint = read_string(st);
    k = read_keyword(st);
  }
  else
    constraint = QString::null;
  
  if (!strcmp(k, "cpp_external")) {
    cpp_external = TRUE;
    k = read_keyword(st);
  }
  else
    cpp_external = FALSE;
  
  if (!strcmp(k, "cpp_visibility")) {
    cpp_visibility = ::visibility(read_keyword(st));
    k = read_keyword(st);
  }
  else
    cpp_visibility = UmlDefaultVisibility;

  if (!strcmp(k, "cpp_decl")) {
    cpp_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "cpp_decl");
  
  if (!strcmp(k, "java_external")) {
    java_external = TRUE;
    k = read_keyword(st);
  }
  else
    java_external = FALSE;
  
  if (read_file_format() <= 33) {
    // old file
    if ((cpp_visibility == UmlDefaultVisibility) &&
	(uml_visibility != UmlPublic) && 
	(uml_visibility != UmlPackageVisibility))
      cpp_visibility = uml_visibility;
    
    if (!strcmp(k, "public")) {
      uml_visibility = UmlPublic;
      k = read_keyword(st);
    }
    else
      uml_visibility = UmlPackageVisibility;
  }
  
  if (!strcmp(k, "final")) {
    java_final = TRUE;
    k = read_keyword(st);
  }
  else
    java_final = FALSE;
  
  if (!strcmp(k, "java_decl")) {
    java_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "java_decl");
  
  if (!strcmp(k, "java_annotation")) {
    java_annotation = read_string(st);
    k = read_keyword(st);
  }
  else
    java_annotation = QString::null;
  
  if (!strcmp(k, "php_external")) {
    php_external = TRUE;
    k = read_keyword(st);
  }
  else
    php_external = FALSE;
  
  if (!strcmp(k, "php_final")) {
    php_final = TRUE;
    k = read_keyword(st);
  }
  else
    php_final = FALSE;
  
  if (!strcmp(k, "php_decl")) {
    php_decl = read_string(st);
    k = read_keyword(st);
  }
  else if (read_file_format() >= 44)
    wrong_keyword(k, "php_decl");
  else
    php_decl = "";
  
  if (!strcmp(k, "python_external")) {
    python_external = TRUE;
    k = read_keyword(st);
  }
  else
    python_external = FALSE;
  
  if (!strcmp(k, "python_2_2")) {
    python_2_2 = TRUE;
    k = read_keyword(st);
  }
  else
    python_2_2 = (read_file_format() < 51);
  
  if (!strcmp(k, "python_decl")) {
    python_decl = read_string(st);
    k = read_keyword(st);
  }
  else if (read_file_format() >= 51)
    wrong_keyword(k, "python_decl");
  else
    python_decl = "";
  
  if (!strcmp(k, "idl_external")) {
    idl_external = TRUE;
    k = read_keyword(st);
  }
  else
    idl_external = FALSE;
  
  if (!strcmp(k, "local")) {
    idl_local = TRUE;
    k = read_keyword(st);
  }
  else
    idl_local = FALSE;
  
  if (!strcmp(k, "custom")) {
    idl_custom = TRUE;
    k = read_keyword(st);
  }
  else
    idl_custom = FALSE;
  
  if (!strcmp(k, "idl_decl")) {
    idl_decl = read_string(st);
    k = read_keyword(st);
  }
  else
    wrong_keyword(k, "idl_decl");
  
  AType t;
  
  t.read(st, "switch_type", "explicit_switch_type", k);
  set_switch_type(t);
  
  k = read_keyword(st);
}
コード例 #6
0
bool ClassData::tool_cmd(ToolCom * com, const char * args,
			 BrowserNode * bn,
			 const QString & comment) {
  if (((unsigned char) args[-1]) >= firstSetCmd) {
    if (!bn->is_writable() && !root_permission())
      com->write_ack(FALSE);
    else {
      switch ((unsigned char) args[-1]) {
      case setIsAbstractCmd:
	if ((*args == 0) && 
	    strcmp(browser_node->get_stereotype(), "enum") &&
	    ((BrowserClass *) browser_node)->have_abstract_operation()) {
	  com->write_ack(FALSE);
	  return TRUE;
	}
	else
	  is_abstract = (*args != 0);
	break;
      case setActiveCmd:
	is_active = (*args != 0);
	break;
      case setVisibilityCmd:
	{
	  UmlVisibility v;
	  
	  if (! com->get_visibility(v, args)) {
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	  else
	    uml_visibility = v;
	}
	break;
      case setBaseTypeCmd:
	if (stereotype != "typedef") {
	  com->write_ack(FALSE);
	  return TRUE;
	}
	else {
	  AType t;
	  
	  com->get_type(t, args);
	  set_base_type(t);	  
	}
	break;
      case setConstraintCmd:
	constraint = args;
	break;
      case setIsCppExternalCmd:
	cpp_external = (*args != 0);
	break;
      case setCppVisibilityCmd:
	{
	  UmlVisibility v;
	  
	  if (! com->get_extended_visibility(v, args)) {
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	  else
	    cpp_visibility = v;
	}
	break;
      case setCppDeclCmd:
	cpp_decl = args;
	break;
      case setIsJavaExternalCmd:
	java_external = (*args != 0);
	break;
      case setJavaDeclCmd:
	java_decl = args;
	break;
      case setJavaAnnotationCmd:
	{
	  QCString s = args;
	  
	  s = s.stripWhiteSpace();
	  if (! s.isEmpty())
	    s += '\n';
	  java_annotation = s;
	}
	break;
      case setIsJavaPublicCmd:
	{
	  UmlVisibility v = (*args != 0) ? UmlPublic : UmlPackageVisibility;
	  
	  if ((cpp_visibility == UmlDefaultVisibility) &&
	      (uml_visibility != UmlPublic) &&
	      (uml_visibility != UmlPackageVisibility))
	    cpp_visibility = uml_visibility;
	  uml_visibility = v;
	}
	break;
      case setIsJavaFinalCmd:
	java_final = (*args != 0);
	break;
      case setIsPhpExternalCmd:
	php_external = (*args != 0);
	break;
      case setPhpDeclCmd:
	php_decl = args;
	break;
      case setIsPhpFinalCmd:
	php_final = (*args != 0);
	break;
      case setIsPythonExternalCmd:
	python_external = (*args != 0);
	break;
      case setPythonDeclCmd:
	python_decl = args;
	break;
      case setIsPython2_2Cmd:
	python_2_2 = (*args != 0);
	break;
      case setIdlDeclCmd:
	idl_decl = args;
	break;
      case setSwitchTypeCmd:
	if (GenerationSettings::idl_class_stereotype(stereotype) != "union") {
	  com->write_ack(FALSE);
	  return TRUE;
	}
	else {
	  AType t;
	  
	  com->get_type(t, args);
	  set_switch_type(t);
	}
	break;
      case setIsIdlExternalCmd:
	idl_external = (*args != 0);
	break;
      case setIsIdlLocalCmd:
	idl_local = (*args != 0);
	break;
      case setIsIdlCustomCmd:
	idl_custom = (*args != 0);
	break;
      case setIsClassMemberCmd:
      case setIsVolatileCmd:
	com->write_ack(FALSE);
	return TRUE;
      case removeFormalCmd:
	{
	  unsigned rank = com->get_unsigned(args);
	  
	  if (rank < nformals) {
	    if (nformals == 1) {
	      delete [] formals;
	      formals = 0;
	    }
	    else
	      while (++rank != nformals)
		formals[rank - 1] = formals[rank];
	    nformals -= 1;
	    DontUpdateActuals = FALSE;
	  }
	  else {
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	}
	break;
      case addFormalCmd:
	{
	  unsigned rank = com->get_unsigned(args);
	  
	  if (rank <= nformals) {
	    FormalParamData * new_formals = new FormalParamData[++nformals];
	    unsigned index;
	    
	    for (index = 0; index != rank; index += 1)
	      new_formals[index] = formals[index];
	    
	    new_formals[index].read(com, args);
	    
	    while (++index != nformals)
	      new_formals[index] = formals[index - 1];
	    
	    delete [] formals;
	    formals = new_formals;
	    DontUpdateActuals = FALSE;
	  }
	  else {
	    FormalParamData::skip(com, args);
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	}
	break;
      case replaceFormalCmd:
	{
	  unsigned rank = com->get_unsigned(args);
	  
	  if (rank < nformals) {
	    formals[rank].read(com, args);
	    DontUpdateActuals = FALSE;
	  }
	  else {
	    FormalParamData::skip(com, args);
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	}
	break;
      case replaceActualCmd:
	{
	  unsigned rank = com->get_unsigned(args);
	  
	  if (rank < actuals.count()) {
	    AType t;
	    
	    com->get_type(t, args);
	    actuals.at(rank)->set_value(t);
	  }
	  else {
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	}
	break;
      default:
	return BasicData::tool_cmd(com, args, bn, comment);
      }
  
      // ok case
      bn->modified();	// call modified
      bn->package_modified();
      com->write_ack(TRUE);
    }
  }
  else {
    // get only !
    switch ((unsigned char) args[-1]) {
    case formalsCmd:
      {
	com->write_unsigned((unsigned) nformals);
	for (int index = 0; index != nformals; index += 1)
	  formals[index].send_uml_def(com);
      }
      break;
    case actualsCmd:
      {
	com->write_unsigned((unsigned) actuals.count());
	for (ActualParamData * a = actuals.first(); a != 0; a = actuals.next())
	  a->send_uml_def(com);
      }
      break;
    default:
      return BasicData::tool_cmd(com, args, bn, comment);
    }
  }
  
  return TRUE;
}