Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » C99 codegen for Papyrus-RT
C99 codegen for Papyrus-RT [message #1790707] Thu, 14 June 2018 17:31 Go to next message
Mateusz Jemielity is currently offline Mateusz JemielityFriend
Messages: 1
Registered: June 2018
Junior Member

Are there any plans to include C99 code generation to Papyrus-RT?

Alternatively, if I wanted to implement this feature myself, where should I start?
Re: C99 codegen for Papyrus-RT [message #1790822 is a reply to message #1790707] Mon, 18 June 2018 15:06 Go to previous message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 416
Registered: March 2011
Senior Member
Hi. For the time being there are no plans for a C99 generator.

To create your own generator you could start by creating a plugin that provides a (context) menu item that provides the entry point to call your own generator. This would be needed because the current generator doesn't allow you to "hook up" third-party generators. You can use the org.eclipse.papyrusrt.codegen.papyrus plugin as an example to base your own plugin on it.

Then you would need to create another plugin with the actual generator itself. It could be in the same plugin as above, but in general it is better design to separate UI plugins from non-UI plugins. We implemented the Papyrus-RT generator as a combination of Java and Xtend code. You can use any JVM language for that, and it helps having some familiarity with EMF. The input to the generator is a UML model with the UML-RT profile. This is an instance of UML elements from org.eclipse.uml2.uml, but we provide a convenient façade, an API on top of UML that allows you to interact with these objects as UML-RT elements. This is defined in the org.eclipse.papyrusrt.umlrt.uml plugin., in particular in the org.eclipse.papyrusrt.umlrt.uml package (in the src-facade folder), where you will find classes for each UMLRT element, e.g. UMLRTCapsule, UMLRTCapsulePart, UMLRTStateMachine, etc. So your generator would normally need to provide a method that has a UMLRT element (most likely a UMLRTModel) as input, traverse it and generate code accordingly. If Papyrus is correctly setup and the org.eclipse.papyrusrt.umlrt.uml plugin was loaded and activated, then all necessary registrations are in place and you don't need to do anything to convert a "plain" UML element into a façade UML-RT element; you can just assume that the element selected from the context menu (when clicking it in the Model Explorer) is an instance of one of these UMLRT* classes.

You could take a look at the current C++ generator, but it's likely it won't be very suitable to generate C99. And it may be more complex than it needs to be. It uses two intermediate representations. One called XtUML-RT, which is a UML-RT meta-model, removing all the additional complexity from UML, and then another representation which is a meta-model of a subset of C++. Finally there is a model-to-text translation from the later model. Maybe C99 is a subset of this meta-model, but there may be cases that are not covered.

In any case, you would have to setup the development environment manually, installing all dependencies by yourself. We have an Oomph setup model that automates the process of creating the development environment, cloning the git repo, installing dependencies, setting the target platform and preferences, etc., but unfortunately it is broken (as is the build of Papyrus-RT itself) due to a problem related to the Papyrus build upstream.

[Updated on: Mon, 18 June 2018 15:09]

Report message to a moderator

Previous Topic:Code Generation
Next Topic:Run without code generation
Goto Forum:

Current Time: Wed Dec 07 01:15:38 GMT 2022

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

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

Back to the top