Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Why is papyrus generating separate .cpp and .h files for class methods?
Why is papyrus generating separate .cpp and .h files for class methods? [message #1834931] Fri, 20 November 2020 22:17 Go to next message
Manuel Malagon is currently offline Manuel MalagonFriend
Messages: 81
Registered: December 2011
Member
When I edit a method's code via the UML tab in the Properties view and hit ctrl+s to save, then a folder with the name of the class containing such method is created in the generated CDT project with a .cpp and a .h files whose names are the name of the method.

For example, I have the run() method in the myHelloWorldClass class. I enter some code via the UML tab in the Properties view for run()
index.php/fa/39372/0/

Then hit ctrl+s to save. Immediately after saving I see this:
index.php/fa/39371/0/

Why is this happening? Is this a bug or a feature I need to disable?
  • Attachment: methodFile.jpeg
    (Size: 17.16KB, Downloaded 252 times)
  • Attachment: code.jpeg
    (Size: 68.18KB, Downloaded 283 times)
Re: Why is papyrus generating separate .cpp and .h files for class methods? [message #1835173 is a reply to message #1834931] Thu, 26 November 2020 10:35 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Splitting the code corresponding to a class into a header and body file is a common code generation pattern. The header file contains the declaration, the body the method implementations with the code. The main motivation for this pattern is classes are referenced by others which must therefore know the declarations. If we had single files, the required #includes in the code would also include the implementation which would imply duplicating implementations and thus linkage errors. Another aspect is that implementations often have additional dependencies and the risk of getting circular dependencies would increase the single files are used.
Re: Why is papyrus generating separate .cpp and .h files for class methods? [message #1835193 is a reply to message #1835173] Thu, 26 November 2020 17:32 Go to previous messageGo to next message
Manuel Malagon is currently offline Manuel MalagonFriend
Messages: 81
Registered: December 2011
Member
Wait, that doesn't make sense. The method files (run.h and run.cpp) are generated empty and the method's code is generated in the myHelloWorldClass.cpp.

Additionally, when the myHelloWorldClass class needs to be referenced by others then they will only include myHelloWorldClass.h and then they will have all declarations they need. There are no multiple headers to be included.

There is no implementation code in the header files if that's what you are talking about.

What is happening with this is that every time I save the papyrus project I have to go to the CDT project and delete all the folders with these method files or the code will not compile. Also, they are empty and therefore useless.

Could this please be made configurable?
Re: Why is papyrus generating separate .cpp and .h files for class methods? [message #1835206 is a reply to message #1835193] Fri, 27 November 2020 07:47 Go to previous messageGo to next message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
Hello,
I guess it's a bug. It's fine for a class to split the header and the body but it looks weird for the methods in addition. By the way I don't see that in the case of using some standard transformation chains provided by Papyrus Software Designer (components...).
Regards.
Yoann.
Re: Why is papyrus generating separate .cpp and .h files for class methods? [message #1835224 is a reply to message #1835206] Fri, 27 November 2020 11:28 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
I misunderstood the problem, thanks for clarifying. Yes, likely a bug related to synchronization.
Re: Why is papyrus generating separate .cpp and .h files for class methods? [message #1835296 is a reply to message #1835224] Mon, 30 November 2020 12:12 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
I've created bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=569052 and have submitted a patch for it. The patch captures multiple issues, notably this problem, but also the problem that no editor would pop up if code was not existing yet. The technical reason is that a change listener regenerated code not only for the classes, but also for the behaviors as they inherit from classifier as well. Thus, code was generated as if the owned behaviors were nested classifiers.
Please test with a nightly build - the 2020-06 should be ready in ~20 minutes (2020-12 will be available tomorrow).
Re: Why is papyrus generating separate .cpp and .h files for class methods? [message #1835307 is a reply to message #1835296] Mon, 30 November 2020 14:28 Go to previous message
Manuel Malagon is currently offline Manuel MalagonFriend
Messages: 81
Registered: December 2011
Member
Ansgar Radermacher wrote on Mon, 30 November 2020 07:12

the 2020-06 should be ready in ~20 minutes (2020-12 will be available tomorrow).



Awesome! I'll wait for tomorrow since I'm using 2020-12

[Updated on: Mon, 30 November 2020 14:29]

Report message to a moderator

Previous Topic:How can I hide the stereotypes in the diagrams?
Next Topic:Issues creating my own std library
Goto Forum:
  


Current Time: Wed Apr 24 23:28:44 GMT 2024

Powered by FUDForum. Page generated in 0.02873 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top