Bug 413519 - C++ interface class is not generated with pure virtual methods
Summary: C++ interface class is not generated with pure virtual methods
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: exporter (show other bugs)
Version: 2.29.0 (KDE Applications 19.08.0)
Platform: unspecified All
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-27 14:17 UTC by Carsten Behling
Modified: 2019-10-29 18:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.29.3 (KDE Applications 19.08.03)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carsten Behling 2019-10-27 14:17:28 UTC
SUMMARY

Though <<interface>> stereotype is given

1. '= 0' declaration is not is not used
2. an implementation file *.cpp is created
3. 'virtual' and 'abstract' are optional though the class is an interface istead of always 'abstract' and 'virtual'
4.  choice between 'private', 'protected' and 'public' is possible instead of always 'public'

STEPS TO REPRODUCE
1. create an interface
2. add a method 'void test()'
3. generate code from the interface

OBSERVED RESULT

1. *.cpp file is generated
2. 'void test()' is not pure virtual and has an implementation
3. method options 'abstract' and 'virtual' are optional in the dialog
4. 'public', 'protected' and 'private' are selectable

EXPECTED RESULT

1. Only a header  is generated.
2. Only public pure virtual functions are available and no more options are available.


SOFTWARE/OS VERSIONS
Windows: 2.29.0
macOS: -
Linux/KDE Plasma: -
(available in About System)
KDE Plasma Version: -
KDE Frameworks Version: - 
Qt Version: -

ADDITIONAL INFORMATION
Comment 1 Ralf Habacker 2019-10-28 15:35:45 UTC
Git commit 869268b5edc00f96075d5304e84ec14ed867974a by Ralf Habacker.
Committed on 28/10/2019 at 15:35.
Pushed by habacker into branch 'Applications/19.08'.

Disable unrelated checkboxes in operation property dialog for interfaces

Methods on interfaces are always abstract, virtual, non inline, public and can
not override.

M  +6    -0    umbrello/dialogs/umloperationdialog.cpp

https://commits.kde.org/umbrello/869268b5edc00f96075d5304e84ec14ed867974a
Comment 2 Ralf Habacker 2019-10-28 15:35:45 UTC
Git commit ef47ab7b242aa87b5cd4d8e5abeb841e2b00d663 by Ralf Habacker.
Committed on 28/10/2019 at 15:10.
Pushed by habacker into branch 'Applications/19.08'.

cppwriter: Add support for writing abstract methods

M  +4    -1    umbrello/codegenerators/cpp/cppwriter.cpp

https://commits.kde.org/umbrello/ef47ab7b242aa87b5cd4d8e5abeb841e2b00d663
Comment 3 Ralf Habacker 2019-10-28 15:35:45 UTC
Git commit 0333988fc16e0a403cdd306e3e213f0b7a5c6dcb by Ralf Habacker.
Committed on 28/10/2019 at 15:35.
Pushed by habacker into branch 'Applications/19.08'.

Fixes missing initialisation of members m_inline and m_abstract of class UMLOperation

M  +6    -2    umbrello/uml1model/operation.cpp

https://commits.kde.org/umbrello/0333988fc16e0a403cdd306e3e213f0b7a5c6dcb
Comment 4 Ralf Habacker 2019-10-28 15:35:45 UTC
Git commit c3afcda6559537dfff238f6783d8f9a782b294e0 by Ralf Habacker.
Committed on 28/10/2019 at 15:35.
Pushed by habacker into branch 'Applications/19.08'.

When creating class methods for an interface through the user interface set abstract and virtual attributes
FIXED-IN:2.29.3 (KDE Applications 19.08.03)

M  +5    -0    umbrello/uml1model/classifier.cpp

https://commits.kde.org/umbrello/c3afcda6559537dfff238f6783d8f9a782b294e0
Comment 5 Ralf Habacker 2019-10-28 15:45:31 UTC
Git commit aa52c15a8ff69434950abdbf220ddbf2113604d5 by Ralf Habacker.
Committed on 28/10/2019 at 15:45.
Pushed by habacker into branch 'Applications/19.08'.

cppwriter: In case of interfaces, do not write a superfluous .cpp file

M  +1    -1    umbrello/codegenerators/cpp/cppwriter.cpp

https://commits.kde.org/umbrello/aa52c15a8ff69434950abdbf220ddbf2113604d5
Comment 6 Carsten Behling 2019-10-28 20:37:11 UTC
Verified with aa52c15a8ff69434950abdbf220ddbf2113604d5 on Applications/19.08.


Works basically. Just one issue:

The generated code still contains sections and Doxygen comments indicating accessor methods like this:

// Protected attribute accessor methods

Since interfaces doesn't have attributes accessor method sections wouldn't make sense.
Comment 7 Ralf Habacker 2019-10-28 22:29:03 UTC
This depends on code generator settings. See settings->Umbrello-Settings->Code generation->formatting. There are two checkboxes, which are related to comments in source code. I unchecked these boxes and those comments are not included on code generating.
Comment 8 Ralf Habacker 2019-10-28 23:37:15 UTC
BTW: I cleaned up partially the generated c++ code, see bug 413574.
Comment 9 Carsten Behling 2019-10-29 05:54:46 UTC
(In reply to Ralf Habacker from comment #8)
> BTW: I cleaned up partially the generated c++ code, see bug 413574.

I unchecked

- "Write documentationcomments even if empty"
- "Write comments for sections even if section i empty"

there a lot of empty 'public:'/'private:' sections remaining:

--- cut here ---
#ifndef ISOMETHING_H
#define ISOMETHING_H

#include <string>
class ISomething
{
public:



  /**
   */
  virtual void doSomething () = 0;

protected:

public:

protected:

public:

protected:


private:

public:

private:

public:

private:



};

#endif // ISOMETHING_H
--- cut here ---

It seems to belong into bug 413574 but it`s closed.
Comment 10 Ralf Habacker 2019-10-29 06:26:48 UTC
(In reply to Carsten Behling from comment #9)
> (In reply to Ralf Habacker from comment #8)
> 
> there a lot of empty 'public:'/'private:' sections remaining:
...
> It seems to belong into bug 413574 but it`s closed.
Because this issue has been fixed with the mentioned ticket :-)
Comment 11 Carsten Behling 2019-10-29 18:16:57 UTC
(In reply to Ralf Habacker from comment #10)
> (In reply to Carsten Behling from comment #9)
> > (In reply to Ralf Habacker from comment #8)
> > 
> > there a lot of empty 'public:'/'private:' sections remaining:
> ...
> > It seems to belong into bug 413574 but it`s closed.
> Because this issue has been fixed with the mentioned ticket :-)

My real question is:

Should I report another Bug for that?
Comment 12 Carsten Behling 2019-10-29 18:42:50 UTC
(In reply to Carsten Behling from comment #11)
> (In reply to Ralf Habacker from comment #10)
> > (In reply to Carsten Behling from comment #9)
> > > (In reply to Ralf Habacker from comment #8)
> > > 
> > > there a lot of empty 'public:'/'private:' sections remaining:
> > ...
> > > It seems to belong into bug 413574 but it`s closed.
> > Because this issue has been fixed with the mentioned ticket :-)
> 
> My real question is:
> 
> Should I report another Bug for that?

I see it's gone with a6f00ce109f8b834eaa8aaefc7a9408a86ef6f33 on Applications/19.08.