Book a Demo

Author Topic: Generating delegate classes with code, list macro  (Read 3501 times)

GBeutler

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Generating delegate classes with code, list macro
« on: February 29, 2008, 03:34:52 am »
Hi all,

I try to write a transformation for creating a delegate class from an interface. The default code should be generated too like:

Quote
int testMethod(int arg)
{
   return ref.testMethod(arg);
}

My problem is how to get the dynamic list of attributes? I tried:

Quote
Operation
{
  %TRANSFORM_CURRENT()%
  %list="Parameter" @separator="\n" @indent="  "%
$attr=%list="Parameter" @separator="\n" @indent="  "%
  code=%qt%return ref.%opName%($attr);%qt%
}

This is not working. How can I create a String which contains the name of all parameters of the operation? Thanks in advance and

best regards,

Guido
« Last Edit: February 29, 2008, 03:47:48 am by GBeutler »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Generating delegate classes with code, list ma
« Reply #1 on: February 29, 2008, 08:28:56 am »
You need to create a custom template.  Select the type 'Parameter' and give a name such as 'Name'.

Edit that template to just give the parameter name.

Parameter__Name
Code: [Select]
%opName%The list in the calling template would then use the custom template you chose.  (Note. Two underscores)

Code: [Select]
$attr=%list="Parameter__Name" @separator=", " @indent="  "%

GBeutler

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Generating delegate classes with code, list ma
« Reply #2 on: February 29, 2008, 08:29:12 pm »
Hi,

ok, working now. To be complete here the working version:

At Operation template:
Code: [Select]
Operation
{
  %TRANSFORM_CURRENT()%
  %list="Parameter" @separator="\n" @indent="  "%
  $attr=%list="Parameter__Name" @separator="," @indent="  "%
  code=%qt%return ref.%opName%($attr);%qt%
}

and the Parameter__Name (2 underscore!) template:

Code: [Select]
%paramName%


Thanks! and best regards,

Guido