Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » redefining types in an Xpand project
redefining types in an Xpand project [message #517132] Fri, 26 February 2010 11:16 Go to next message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
I want to make a simple test, that would generate

		Typedef int Cap;
		class Plane {
				Cap cap;	
		}

Everything works but for one thing.

In my model.xmi, I created a Datatype Cap, which I'd like to be an Integer, just renamed.
Looking at the documentation, it seems to be called a parameterized type, but I just don't understand how to create/make/use it.

Regards
Maxime

PS : I'm sorry for having been asking what are basic ans dumb questions for the last few days, I just hope there won't be many more.


One day I shall master M2T, but that day has yet to come...

[Updated on: Fri, 26 February 2010 11:17]

Report message to a moderator

Re: redefining types in an Xpand project [message #517136 is a reply to message #517132] Fri, 26 February 2010 11:26 Go to previous messageGo to next message
Darius Jockel is currently offline Darius JockelFriend
Messages: 63
Registered: July 2009
Member
Hallo Maxime,

I have not enought information for an answer.
What metamodeling framework do you use:
EMF, UML2 ?

Is a 'parameterized type' part of your (meta-)metamodell,
or a type of your DSL?

Can you provide a more detailled example?

Regards
Darius
Re: redefining types in an Xpand project [message #517156 is a reply to message #517136] Fri, 26 February 2010 12:19 Go to previous messageGo to next message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
>I have not enought information for an answer.
>What metamodeling framework do you use:
>EMF, UML2 ?

I am using M2T, ecore, and I created an Xpand Project, with a sample (the my.generator.project that is used as an example).

>Is a 'parameterized type' part of your (meta-)metamodell,
>or a type of your DSL?

It's a type for my DSL. Right now I'm trying to create a Cap Type, that is just an alias for Integer (documentation seems to be calling that a 'parameterized type').

>Can you provide a more detailled example?

Not really, i'm trying to keep things simple now, before I go to more difficult things.
My model has a Datatype Cap, a Datatype Integer (never used), and an Entity Plane that has a Feature cap (which type I want to be of type Cap)

Thanks

Regards
Maxime


One day I shall master M2T, but that day has yet to come...
Re: redefining types in an Xpand project [message #517203 is a reply to message #517156] Fri, 26 February 2010 15:21 Go to previous messageGo to next message
Darius Jockel is currently offline Darius JockelFriend
Messages: 63
Registered: July 2009
Member
Hello,

hm, do you want somethng like this:

Adding concept 'ParameterizedType' to 'metamodel.ecore' (your DSL).
<eClassifiers xsi:type="ecore:EClass" name="ParameterizedType" eSuperTypes="#//Type">
    <eStructuralFeatures xsi:type="ecore:EReference" name="alias" eType="#//Datatype"/>
  </eClassifiers>

Using the new concept in the model like this:
<?xml version="1.0" encoding="ASCII"?>
<metamodel:Model ...">
  <types xsi:type="metamodel:Datatype" name="int"/>
  <types xsi:type="metamodel:Entity" name="Plane">
    <features name="cap" type="//@types.2"/>
  </types>
  <types xsi:type="metamodel:ParameterizedType" name="Cap" alias="//@types.0"/>
</metamodel:Model>

And Template like this:
«DEFINE javaClass FOR Entity»
	«FILE name+".java"-»
		«FOREACH features.type.typeSelect(ParameterizedType) AS f»
Typedef «f.alias.name» «f.name»;
		«ENDFOREACH-»
class «name» {
		«FOREACH features AS f-»
	«f.type.name»  «f.name»;
		«ENDFOREACH-»
}
	«ENDFILE»
«ENDDEFINE»

will result in:
Typedef int Cap;
class Plane {
	Cap  cap;
}

Regards
Darius
Re: redefining types in an Xpand project [message #517245 is a reply to message #517132] Fri, 26 February 2010 16:36 Go to previous message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
Yes, it's exactly that.

I thought my tutor didn't want me to add concepts at all, so I couldn't find how to do it he told me I could, and so I solved the problem.

Thank you

Regards
Maxime


One day I shall master M2T, but that day has yet to come...
Previous Topic:References between projects in Xpand
Next Topic:how to import an xpand file from an xpand file?
Goto Forum:
  


Current Time: Tue Oct 15 03:28:32 GMT 2024

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

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

Back to the top