0

I've been trying to do some template based C code generation with Xpand/Xtend. Using Template.xpt which uses some xtend code like Utils.ext to do some processing. My problem is that instead of writing methods like this:

cached getCanIfCtrlsSort(AUTOSAR::EcucDefs::CanIf CanIf):
CanIf.CanIfCtrlDrvCfgs.CanIfCtrlCfgs.sortBy(e|e.CanIfCtrlId.value);

or calling a Java method like this:

cached String int2hex(Integer value) :
    JAVA extensions.ExtensionHelper.toHex( java.lang.Integer );

Is there a way where we can still use the Template.xpt and use something like Utils.xtend to do the same? Can we do that using Xtend2? I've seen that Xtend2 is supposed to be the successor of Xpand. It's very hard to find tutorials on this. I meant, like calling Java methods can we call xtend methods in Xpand template?

Sujju
  • 97
  • 8
  • xtend is a successor and not a companion. what is the reason you want to keep the old .xpt file (the only one besides effort i know are dynamic metamodels) since xtend is translated to java you case use xtend code in java extensions as well. the trick part may be to leverage the guice stuff. you may have a look at https://kthoms.wordpress.com/2011/08/17/using-xtext-injected-types-in-xpand/ – Christian Dietrich Nov 20 '14 at 10:59
  • The reason being I can go with the flow of the output file to be generated if I use .xpt files... Is there a way to do that using Xtend? Please do enlighten – Sujju Nov 21 '14 at 09:44
  • what do you mean by 'flow of the output file' - please elaborate – Christian Dietrich Nov 21 '14 at 09:53

0 Answers0