Re: ANSI-C-model and dealing with redundant references [message #640992] |
Tue, 23 November 2010 19:00 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Tom,
comments below.
Tom Brandenburg wrote:
> Hello all,
>
> In my current project I want to create some C code out of an UML
> model. For this I want to use the ANSI-C-Model from the ViPER project.
> But I think it's a more general topic apart from that.
>
> Please look at the following extract from the ANSI-C-Model:
>
>
> Here you can see some type of hierarchy where TranslationElement and
> ASTElement are abstract and all children of TranslationElement inherit
> the composition association to itself. Now for complying with the
> ANSI-C-Standard and for better browsability there is also a
> composition between DeclSpecifier and FunctionDefinition. So somehow
> the composition is redundant.
Sounds like UML details best discussed on the UML2 newsgroup...
>
>
> During the model-2-model-transformation a DeclSpecifier is added to
> the FunctionDefinition explicitly as a DeclSpecifier and not as a
> nestedElement. The result is that the reference from a DeclSpecifier
> to a FunctionDefinition is set and not from the nestedElement to the
> nestingElement. The latter evolves to a problem when the model-2-text
> transformation want to browse through the model with the following
> code (found in the ViPER project):
>
> ansic::TranslationUnit getTranslationUnit(ansic::ASTElement element) :
> element.translationUnit != null ? element.translationUnit :
> element.nestingElement.getTranslationUnit()
> ;
>
> It returns null when translationUnit is null and the nestingElement
> reference is missing.
This model-2-model stuff is using what technology?
>
> So my question is, how it might be possible to add a DeclSpecifier to
> a FunctionDefinition and the reference is also added automatically to
> the nestedElements relation (because it is a nested element but also a
> DeclSpecifier for the Function Definition). Otherwise I might have to
> change the code at many location because this problem is not the only
> one of that kind in the ANSI-C-model. On the other hand I wonder why
> it does not work with me, whereas the ViPER project is tested and
> released. Even without the complex m2m and m2t transformations I can
> simulate that behaviour (which is somehow understandable) with the
> small sample above and a dynamic instance of it. But I don't to change
> the implementation of the ViPER plugin.
>
> Btw, the following code adds a DeclSpecifier to a FunctionDefinition:
>
> create ansic::FunctionDefinition d
> createFunctionDefinition(ansic::DeclSpecifier declSpecifier,
> ansic::FunctionDeclarator declarator) :
> //let d = new ansic::FunctionDefinition :
> d.setDeclSpecifier(declSpecifier) ->
> d.setFunctionDeclarator(declarator) ->
> d
>
> Where do the set-Functions come from? Is it a feature of EMF to have
> them automatically as soon as there are references with a
> 1-to-1-association?
Definitely best asked on the UML2 newsgroup. I've added it to the "to"
list of the reply, so no need to repost.
>
> Many thanks in advance and best regards,
> Tom
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
Re: ANSI-C-model and dealing with redundant references [message #646372 is a reply to message #646285] |
Thu, 23 December 2010 14:39 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Tom,
It helps to boil your question down to just the relevant details. When
you say things like "I want to create some C code out of an UML model"
it sure sounds like you have a UML model. If you don't, it's a
confusing way to start your question.
Tom Brandenburg wrote:
> Hey Rafael,
>
> I posted the same in the EMF newsgroup. Hopefully they don't want to
> shift me to somewhere else :)
>
> Bye Tom
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03527 seconds