Commit bd1f2fd4 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Merge remote-tracking branch 'origin/Applications/16.12'

# Conflicts:
#	CMakeLists.txt
#	umbrello/uml1model/umlobject.cpp
parents d092ff0f 9144401c
......@@ -23,6 +23,10 @@ include(Macros)
set(CMAKE_AUTORCC ON)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-delete-null-pointer-checks")
endif()
if(NOT BUILD_KF5)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
......
......@@ -21,7 +21,6 @@
#include "ast.h"
#include "debug_utils.h"
#include "macro.h"
#include <qpair.h>
#include <QStringList>
......@@ -110,7 +109,6 @@ public:
TranslationUnitAST* operator -> () const
{
uCheckPointerAndReturnIfZero(this);
return (TranslationUnitAST*)m_translationUnit.data();
}
......
......@@ -208,8 +208,11 @@ bool AssocRules::allowAssociation(Uml::AssociationType::Enum assocType,
return true; // doesn't matter what's already connected to widget
break;
case Uml::AssociationType::Composition: // can't have mutual composition
case Uml::AssociationType::Containment: // can't have mutual containment
case Uml::AssociationType::Composition:
case Uml::AssociationType::Containment:
return true;
break;
case Uml::AssociationType::Generalization://can have many sub/super types but can't sup/sub each
foreach (AssociationWidget * assoc, list) {
if((widgetA == assoc->widgetForRole(Uml::RoleType::A) ||
......
......@@ -329,8 +329,11 @@ bool AdaImport::parseStmt()
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
UMLEnum *enumType = ns->asUMLEnum();
if (enumType == 0)
enumType = Import_Utils::remapUMLEnum(ns, enumType);
while ((next = advance()) != QLatin1String(")")) {
Import_Utils::addEnumLiteral(enumType, next, m_comment);
if (enumType != 0)
Import_Utils::addEnumLiteral(enumType, next, m_comment);
m_comment.clear();
if (advance() != QLatin1String(","))
break;
......
......@@ -626,12 +626,15 @@ bool CSharpImport::parseEnumDeclaration()
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
UMLEnum *enumType = ns->asUMLEnum();
if (enumType == 0)
enumType = Import_Utils::remapUMLEnum(ns, currentScope());
skipStmt(QLatin1String("{"));
while (m_srcIndex < m_source.count() - 1 && advance() != QLatin1String("}")) {
QString next = advance();
if (next == QLatin1String("=")) {
next = advance();
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex - 2], QString(), m_source[m_srcIndex]);
if (enumType != 0)
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex - 2], QString(), m_source[m_srcIndex]);
next = advance();
} else {
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex - 1]);
......
......@@ -306,9 +306,12 @@ bool IDLImport::parseStmt()
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
UMLEnum *enumType = ns->asUMLEnum();
if (enumType == 0)
enumType = Import_Utils::remapUMLEnum(ns, enumType);
m_srcIndex++; // skip name
while (++m_srcIndex < srcLength && m_source[m_srcIndex] != QLatin1String("}")) {
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
if (enumType != 0)
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
if (advance() != QLatin1String(","))
break;
}
......
......@@ -587,6 +587,35 @@ void createGeneralization(UMLClassifier *child, const QString &parentName)
createGeneralization(child, parent);
}
/**
* Remap UMLObject instance in case it does not have the correct type.
*
* @param ns uml object instance with incorrect class
* @param currentScope parent uml object
* @return newly created UMLEnum instance or zero in case of error
*/
UMLEnum *remapUMLEnum(UMLObject *ns, UMLPackage *currentScope)
{
if (ns) {
QString comment = ns->doc();
QString name = ns->name();
QString stereotype = ns->stereotype();
Uml::Visibility::Enum visibility = ns->visibility();
UMLApp::app()->document()->removeUMLObject(ns, true);
if (currentScope == 0)
currentScope = UMLApp::app()->document()->rootFolder(Uml::ModelType::Logical);
UMLObject *o = Object_Factory::createNewUMLObject(UMLObject::ot_Enum, name, currentScope, false);
o->setDoc(comment);
o->setStereotypeCmd(stereotype.isEmpty() ? QLatin1String("enum") : stereotype);
o->setVisibilityCmd(visibility);
// add to parents child list
if (!currentScope->containedObjects().contains(o))
currentScope->containedObjects().append(o);
return o->asUMLEnum();
}
return 0;
}
/**
* Return the list of paths set by previous calls to addIncludePath()
* and the environment variable UMBRELLO_INCPATH.
......
......@@ -79,6 +79,8 @@ namespace Import_Utils {
void createGeneralization(UMLClassifier *child, UMLClassifier *parent);
void createGeneralization(UMLClassifier *child, const QString &parentName);
UMLEnum *remapUMLEnum(UMLObject *ns, UMLPackage *currentScope);
QString formatComment(const QString &comment);
QStringList includePathList();
......
......@@ -307,6 +307,14 @@ bool JavaImport::parseStmt()
log(keyword + QLatin1Char(' ') + name);
UMLObject *ns = Import_Utils::createUMLObject(ot, name, currentScope(), m_comment);
m_klass = ns->asUMLClassifier();
// The name is already used but is package
if (ns && ns->isUMLPackage() && !m_klass) {
ns = Object_Factory::createNewUMLObject(ot, name, ns->asUMLPackage());
ns->setDoc(m_comment);
m_klass = ns->asUMLClassifier();
m_klass->setUMLPackage(currentScope());
currentScope()->containedObjects().append(m_klass);
}
pushScope(m_klass);
m_klass->setStatic(m_isStatic);
m_klass->setVisibilityCmd(m_currentAccess);
......@@ -394,25 +402,12 @@ bool JavaImport::parseStmt()
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
UMLEnum *enumType = ns->asUMLEnum();
// handle type mismatch
if (ns && enumType == 0) {
QString comment = ns->doc();
QString stereotype = ns->stereotype();
Uml::Visibility::Enum visibility = ns->visibility();
UMLApp::app()->document()->removeUMLObject(ns, true);
ns = Object_Factory::createNewUMLObject(UMLObject::ot_Enum, name, currentScope(), false);
ns->setDoc(comment);
ns->setStereotypeCmd(stereotype.isEmpty() ? QLatin1String("enum") : stereotype);
ns->setVisibilityCmd(visibility);
// add to parents child list
if (!currentScope()->containedObjects().contains(ns))
currentScope()->containedObjects().append(ns);
enumType = ns->asUMLEnum();
}
if (enumType == 0)
enumType = Import_Utils::remapUMLEnum(ns, currentScope());
skipStmt(QLatin1String("{"));
while (m_srcIndex < srcLength - 1 && advance() != QLatin1String("}")) {
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
if (enumType != 0)
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
QString next = advance();
if (next == QLatin1String("{") || next == QLatin1String("(")) {
if (! skipToClosing(next[0]))
......
......@@ -324,8 +324,11 @@ bool PascalImport::parseStmt()
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
UMLEnum *enumType = ns->asUMLEnum();
if (enumType == 0)
enumType = Import_Utils::remapUMLEnum(ns, enumType);
while (++m_srcIndex < srcLength && m_source[m_srcIndex] != QLatin1String(")")) {
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
if (enumType != 0)
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
if (advance() != QLatin1String(","))
break;
}
......
......@@ -853,6 +853,8 @@ UMLObject *SQLImport::addDatatype(const QStringList &type)
QString name = Model_Utils::uniqObjectName(UMLObject::ot_Enum, parent, type.at(0));
datatype = Import_Utils::createUMLObject(UMLObject::ot_Enum, name, parent);
UMLEnum *enumType = datatype->asUMLEnum();
if (enumType == 0)
enumType = Import_Utils::remapUMLEnum(datatype, enumType);
if (enumType) {
for (int i = 2; i < type.size(); i++) {
Import_Utils::addEnumLiteral(enumType, type.at(i));
......
......@@ -131,25 +131,6 @@ private:
#define uIgnoreZeroPointer(a) if (!a) { uDebug() << "zero pointer detected" << __FILE__ << __LINE__; continue; }
/**
Check a pointer and return 0 if it is zero.
This macros is implemented as asm code to prevent
removing by gcc optimizer for example in class methods
where 'this' pointer is attributed as "nonnull".
@param p pointer to check
@return returns 0 is pointer is zero
*/
#define uCheckPointerAndReturnIfZero(p) \
asm goto ("test %0,%0; jne %l[next]" \
: /* No outputs. */ \
: "r"(p) \
: \
: next); \
return 0; \
next:
/**
* In a Q_OBJECT class define any enum as Q_ENUMS.
......
......@@ -669,7 +669,6 @@ void UMLObject::setUMLParent(UMLObject *parent)
*/
UMLObject *UMLObject::umlParent() const
{
uCheckPointerAndReturnIfZero(this);
return dynamic_cast<UMLObject *>(parent());
}
......@@ -1236,34 +1235,34 @@ QDebug operator<<(QDebug out, const UMLObject& obj)
#include "usecase.h"
UMLActor* UMLObject::asUMLActor() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLActor*>(this); }
UMLArtifact* UMLObject::asUMLArtifact() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLArtifact*>(this); }
UMLAssociation* UMLObject::asUMLAssociation() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLAssociation*>(this); }
UMLAttribute* UMLObject::asUMLAttribute() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLAttribute*>(this); }
UMLCanvasObject* UMLObject::asUMLCanvasObject() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLCanvasObject*>(this); }
UMLCategory* UMLObject::asUMLCategory() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLCategory*>(this); }
UMLCheckConstraint* UMLObject::asUMLCheckConstraint() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLCheckConstraint*>(this); }
UMLClassifier* UMLObject::asUMLClassifier() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLClassifier*>(this); }
UMLClassifierListItem *UMLObject::asUMLClassifierListItem() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLClassifierListItem*>(this); }
UMLComponent* UMLObject::asUMLComponent() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLComponent*>(this); }
UMLDatatype *UMLObject::asUMLDatatype() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLDatatype*>(this); }
UMLEntity* UMLObject::asUMLEntity() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLEntity*>(this); }
UMLEntityAttribute* UMLObject::asUMLEntityAttribute() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLEntityAttribute*>(this); }
UMLEntityConstraint* UMLObject::asUMLEntityConstraint() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLEntityConstraint*>(this); }
UMLEnum* UMLObject::asUMLEnum() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLEnum*>(this); }
UMLEnumLiteral* UMLObject::asUMLEnumLiteral() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLEnumLiteral*>(this); }
UMLFolder* UMLObject::asUMLFolder() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLFolder*>(this); }
UMLForeignKeyConstraint* UMLObject::asUMLForeignKeyConstraint() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLForeignKeyConstraint*>(this); }
UMLInstance *UMLObject::asUMLInstance() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLInstance*>(this); }
UMLInstanceAttribute *UMLObject::asUMLInstanceAttribute() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLInstanceAttribute*>(this); }
UMLNode* UMLObject::asUMLNode() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLNode*>(this); }
UMLObject* UMLObject::asUMLObject() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLObject*>(this); }
UMLOperation* UMLObject::asUMLOperation() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLOperation*>(this); }
UMLPackage* UMLObject::asUMLPackage() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLPackage*>(this); }
UMLPort* UMLObject::asUMLPort() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLPort*>(this); }
UMLRole* UMLObject::asUMLRole() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLRole*>(this); }
UMLStereotype* UMLObject::asUMLStereotype() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLStereotype*>(this); }
UMLTemplate* UMLObject::asUMLTemplate() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLTemplate*>(this); }
UMLUniqueConstraint* UMLObject::asUMLUniqueConstraint() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLUniqueConstraint*>(this); }
UMLUseCase* UMLObject::asUMLUseCase() { uCheckPointerAndReturnIfZero(this); return dynamic_cast<UMLUseCase*>(this); }
UMLActor* UMLObject::asUMLActor() { return dynamic_cast<UMLActor*>(this); }
UMLArtifact* UMLObject::asUMLArtifact() { return dynamic_cast<UMLArtifact*>(this); }
UMLAssociation* UMLObject::asUMLAssociation() { return dynamic_cast<UMLAssociation*>(this); }
UMLAttribute* UMLObject::asUMLAttribute() { return dynamic_cast<UMLAttribute*>(this); }
UMLCanvasObject* UMLObject::asUMLCanvasObject() { return dynamic_cast<UMLCanvasObject*>(this); }
UMLCategory* UMLObject::asUMLCategory() { return dynamic_cast<UMLCategory*>(this); }
UMLCheckConstraint* UMLObject::asUMLCheckConstraint() { return dynamic_cast<UMLCheckConstraint*>(this); }
UMLClassifier* UMLObject::asUMLClassifier() { return dynamic_cast<UMLClassifier*>(this); }
UMLClassifierListItem *UMLObject::asUMLClassifierListItem() { return dynamic_cast<UMLClassifierListItem*>(this); }
UMLComponent* UMLObject::asUMLComponent() { return dynamic_cast<UMLComponent*>(this); }
UMLDatatype *UMLObject::asUMLDatatype() { return dynamic_cast<UMLDatatype*>(this); }
UMLEntity* UMLObject::asUMLEntity() { return dynamic_cast<UMLEntity*>(this); }
UMLEntityAttribute* UMLObject::asUMLEntityAttribute() { return dynamic_cast<UMLEntityAttribute*>(this); }
UMLEntityConstraint* UMLObject::asUMLEntityConstraint() { return dynamic_cast<UMLEntityConstraint*>(this); }
UMLEnum* UMLObject::asUMLEnum() { return dynamic_cast<UMLEnum*>(this); }
UMLEnumLiteral* UMLObject::asUMLEnumLiteral() { return dynamic_cast<UMLEnumLiteral*>(this); }
UMLFolder* UMLObject::asUMLFolder() { return dynamic_cast<UMLFolder*>(this); }
UMLForeignKeyConstraint* UMLObject::asUMLForeignKeyConstraint() { return dynamic_cast<UMLForeignKeyConstraint*>(this); }
UMLInstance *UMLObject::asUMLInstance() { return dynamic_cast<UMLInstance*>(this); }
UMLInstanceAttribute *UMLObject::asUMLInstanceAttribute() { return dynamic_cast<UMLInstanceAttribute*>(this); }
UMLNode* UMLObject::asUMLNode() { return dynamic_cast<UMLNode*>(this); }
UMLObject* UMLObject::asUMLObject() { return dynamic_cast<UMLObject*>(this); }
UMLOperation* UMLObject::asUMLOperation() { return dynamic_cast<UMLOperation*>(this); }
UMLPackage* UMLObject::asUMLPackage() { return dynamic_cast<UMLPackage*>(this); }
UMLPort* UMLObject::asUMLPort() { return dynamic_cast<UMLPort*>(this); }
UMLRole* UMLObject::asUMLRole() { return dynamic_cast<UMLRole*>(this); }
UMLStereotype* UMLObject::asUMLStereotype() { return dynamic_cast<UMLStereotype*>(this); }
UMLTemplate* UMLObject::asUMLTemplate() { return dynamic_cast<UMLTemplate*>(this); }
UMLUniqueConstraint* UMLObject::asUMLUniqueConstraint() { return dynamic_cast<UMLUniqueConstraint*>(this); }
UMLUseCase* UMLObject::asUMLUseCase() { return dynamic_cast<UMLUseCase*>(this); }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment