Book a Demo

Author Topic: Code Generation  (Read 3149 times)

Graham_Labdon

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Code Generation
« on: March 04, 2009, 09:57:36 pm »
Hello everybody
Can anybody give some advice on code generation.
In the header file for a class I would like to have a comment simmilar to
// <Operation Name>
// <Operation Notes>
// <parameter1>
//    <parameter1 type>
//    <parameter1 direction>
//    <parameter1 notes>
For example for the operation
CalcualteArea(const int width, const int height, int &result)
The comment would be
// CalculateArea
// Calcualtes the area
// in width - the width
// in height - the height
// out result - the area

Thanks in advance

Graham

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code Generation
« Reply #1 on: March 07, 2009, 01:03:13 am »
Hi Graham,


I've constructed a couple of templates that might help. These are for C++ and generate comments according to the schema you listed in the top of your post, not like in the example you gave - but hey, it's not the first time any of us has seen conflicting requirements, right? ;)

OK, on with the show. Modify your File template, adding the following just before the "do not modify template below" line:
Code: [Select]
%if elemType == "Class"%
%Class__OperationHeaders%
%endIf%
Create a custom Class template called OperationHeaders, containing
Code: [Select]
%list="Operation__HeaderInfo" @separator="\n"%Create a custom Operation header called HeaderInfo, containing
Code: [Select]
// %opName%
%WRAP_COMMENT(opNotes, "60", "", "// ")%
%list="Parameter__HeaderInfo" @separator="\n"%
Create a custom Parameter template called HeaderInfo, containing
Code: [Select]
// %paramName%
//   %paramType%
//   %paramKind%
%WRAP_COMMENT(paramNotes, "58", "", "//   ")%

Et voilà!


/Uffe
My theories are always correct, just apply them to the right reality.

Graham_Labdon

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Code Generation
« Reply #2 on: March 07, 2009, 01:04:50 am »
Thanks Uffe - you're a wizz at this stuff ;D

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code Generation
« Reply #3 on: March 07, 2009, 01:23:03 am »
Aw shucks.... ::)
My theories are always correct, just apply them to the right reality.