|
Re: C99 codegen for Papyrus-RT [message #1790822 is a reply to message #1790707] |
Mon, 18 June 2018 15:06 |
Ernesto Posse Messages: 438 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
|
|
|
Powered by
FUDForum. Page generated in 0.03600 seconds