Can we do template based generation using only Xtend2

226 views Asked by At

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?

0

There are 0 answers