Commit 9dbc282c authored by Ralf Habacker's avatar Ralf Habacker

Fix 'c++ Import does not recognize destructor'.

BUG:377593
FIXED-IN:2.21.80 (KDE Applications 17.03.80)
parent d669b9c3
......@@ -560,7 +560,7 @@ bool AdaImport::parseStmt()
isAbstract = true;
if (klass != 0 && op != 0)
Import_Utils::insertMethod(klass, op, m_currentAccess, returnType,
false, isAbstract, false, false, m_comment);
false, isAbstract, false, false, false, m_comment);
skipStmt();
return true;
}
......
......@@ -415,7 +415,7 @@ bool CSharpImport::parseStmt()
}
Import_Utils::insertMethod(m_klass, op, m_currentAccess, typeName,
m_isStatic, m_isAbstract, false /*isFriend*/,
false /*isConstructor*/, m_comment);
false /*isConstructor*/, false, m_comment);
m_isAbstract = m_isStatic = false;
// reset the default visibility
m_currentAccess = m_defaultCurrentAccess;
......
......@@ -438,7 +438,7 @@ bool IDLImport::parseStmt()
m_srcIndex++;
}
Import_Utils::insertMethod(m_klass, op, Uml::Visibility::Public, typeName,
false, false, false, false, m_comment);
false, false, false, false, false, m_comment);
if (m_isOneway) {
op->setStereotype(QLatin1String("oneway"));
m_isOneway = false;
......
......@@ -422,13 +422,14 @@ UMLObject* insertAttribute(UMLClassifier *owner, Uml::Visibility::Enum scope,
* @param isAbstract boolean switch to decide if method is abstract
* @param isFriend true boolean switch to decide if methods is a friend function
* @param isConstructor boolean switch to decide if methods is a constructor
* @param isDestructor boolean switch to decide if methods is a destructor
* @param comment The Documentation for this method
*/
void insertMethod(UMLClassifier *klass, UMLOperation* &op,
Uml::Visibility::Enum scope, const QString& type,
bool isStatic, bool isAbstract,
bool isFriend, bool isConstructor,
const QString& comment)
bool isDestructor, const QString& comment)
{
op->setVisibilityCmd(scope);
if (!type.isEmpty() // return type may be missing (constructor/destructor)
......@@ -457,6 +458,8 @@ void insertMethod(UMLClassifier *klass, UMLOperation* &op,
// if the operation is a constructor, add it as a stereotype
if (isConstructor)
op->setStereotype(QLatin1String("constructor"));
if (isDestructor)
op->setStereotype(QLatin1String("destructor"));
QString strippedComment = formatComment(comment);
if (! strippedComment.isEmpty()) {
......
......@@ -65,7 +65,7 @@ namespace Import_Utils {
void insertMethod(UMLClassifier *klass, UMLOperation* &op,
Uml::Visibility::Enum scope, const QString& type,
bool isStatic, bool isAbstract,
bool isFriend = false, bool isConstructor = false,
bool isFriend = false, bool isConstructor = false, bool isDestructor = false,
const QString& comment = QString());
UMLAttribute* addMethodParameter(UMLOperation *method,
......
......@@ -567,7 +567,7 @@ bool JavaImport::parseStmt()
}
Import_Utils::insertMethod(m_klass, op, m_currentAccess, typeName,
m_isStatic, m_isAbstract, false /*isFriend*/,
false /*isConstructor*/, m_comment);
false /*isConstructor*/, false, m_comment);
m_isAbstract = m_isStatic = false;
// reset the default visibility
m_currentAccess = m_defaultCurrentAccess;
......
......@@ -277,6 +277,7 @@ void CppTree2Uml::parseFunctionDefinition(FunctionDefinitionAST* ast)
bool isStatic = false;
//:unused: bool isInline = false;
bool isConstructor = false;
bool isDestructor = false;
bool isConstExpression = false;
......@@ -319,12 +320,17 @@ void CppTree2Uml::parseFunctionDefinition(FunctionDefinitionAST* ast)
// if a class has no return type, it could be a constructor or
// a destructor
if (d && returnType.isEmpty() && id.indexOf(QLatin1Char('~')) == -1)
isConstructor = true;
if (d && returnType.isEmpty()) {
if (id.indexOf(QLatin1Char('~')) == -1)
isConstructor = true;
else
isDestructor = true;
}
parseFunctionArguments(d, m);
Import_Utils::insertMethod(c, m, m_currentAccess, returnType,
isStatic, false /*isAbstract*/, isFriend, isConstructor, m_comment);
isStatic, false /*isAbstract*/, isFriend, isConstructor,
isDestructor, m_comment);
m_comment = QString();
/* For reference, Kdevelop does some more:
......@@ -552,6 +558,7 @@ void CppTree2Uml::parseFunctionDeclaration(GroupAST* funSpec, GroupAST* storageS
bool isPure = decl->initializer() != 0;
bool isConstructor = false;
bool isConstExpression = false;
bool isDestructor = false;
if (funSpec){
//:unused: QList<AST*> l = funSpec->nodeList();
......@@ -588,12 +595,16 @@ void CppTree2Uml::parseFunctionDeclaration(GroupAST* funSpec, GroupAST* storageS
m->setStereotype(QLatin1String("constexpr"));
// if a class has no return type, it could de a constructor or
// a destructor
if (d && returnType.isEmpty() && id.indexOf(QLatin1Char('~')) == -1)
isConstructor = true;
if (d && returnType.isEmpty()) {
if (id.indexOf(QLatin1Char('~')) == -1)
isConstructor = true;
else
isDestructor = true;
}
parseFunctionArguments(d, m);
Import_Utils::insertMethod(c, m, m_currentAccess, returnType,
isStatic, isPure, isFriend, isConstructor, m_comment);
isStatic, isPure, isFriend, isConstructor, isDestructor, m_comment);
if (isPure)
c->setAbstract(true);
m_comment = QString();
......
......@@ -288,6 +288,8 @@ bool PascalImport::parseStmt()
break;
}
}
bool isConstructor = false;
bool isDestructor = false;
QString returnType;
if (keyword == QLatin1String("function")) {
if (advance() != QLatin1String(":")) {
......@@ -296,15 +298,18 @@ bool PascalImport::parseStmt()
return false;
}
returnType = advance();
} else if (keyword == QLatin1String("constructor") || keyword == QLatin1String("destructor")) {
op->setStereotype(keyword);
} else if (keyword == QLatin1String("constructor")) {
isConstructor = true;
} else if (keyword == QLatin1String("destructor")) {
isDestructor = true;
}
skipStmt();
bool isVirtual = false;
bool isAbstract = false;
checkModifiers(isVirtual, isAbstract);
Import_Utils::insertMethod(m_klass, op, m_currentAccess, returnType,
!isVirtual, isAbstract, false, false, m_comment);
!isVirtual, isAbstract, false, isConstructor,
isDestructor, m_comment);
return true;
}
if (m_section != sect_TYPE) {
......
......@@ -345,7 +345,7 @@ bool PythonImport::parseStmt()
}
Import_Utils::insertMethod(m_klass, op, visibility, QLatin1String("string"),
m_isStatic, false /*isAbstract*/, false /*isFriend*/,
false /*isConstructor*/, m_comment);
false /*isConstructor*/, false, m_comment);
m_isStatic = false;
int srcIndex = m_srcIndex;
op->setSourceCode(skipBody());
......
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