Book a Demo

Author Topic: LIST MACRO element order  (Read 2883 times)

ferran

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
LIST MACRO element order
« on: November 14, 2019, 07:47:16 pm »
Dear Sparx admin,

I realized that with the CTF templates I have now, the #define statements are generated at the end after other inner classes like enumerations or struct in C.
See the following code:


/****************************************************
 *  SPIDefinitions.h                                         
 *  Created on: 13-Nov-2019 5:23:12 PM                     
 *  Implementation of the Class SPIDefinitions       
 *  Original author: ferran.casanovas                     
 ****************************************************/

#ifndef SPIDEFINITIONS_H_
#define SPIDEFINITIONS_H_


#ifdef __cplusplus
extern "C" {
#endif

#include "TypeDefinitions.h"

/**
 * @brief SPI DATASIZE  Enum of SPI available sData Size
 */
typedef enum SPI_DATASIZE_t
{
   SPI_DATASIZE_1       /*< Data size equals to 1 bit*/,
   SPI_DATASIZE_2       /*< Data size equals to 2 bits*/,
   SPI_DATASIZE_3       /*< Data size equals to 3 bits*/,
   SPI_DATASIZE_4       /*< Data size equals to 4 bits*/,
   SPI_DATASIZE_5       /*< Data size equals to 5 bits*/,
   SPI_DATASIZE_6       /*< Data size equals to 6 bits*/,
   SPI_DATASIZE_7       /*< Data size equals to 7 bits*/,
   SPI_DATASIZE_8       /*< Data size equals to 8 bits*/,
   SPI_DATASIZE_9       /*< Data size equals to 9 bits*/,
   SPI_DATASIZE_10       /*< Data size equals to 10 bits*/,
   SPI_DATASIZE_11       /*< Data size equals to 11 bits*/,
   SPI_DATASIZE_12       /*< Data size equals to 12 bits*/,
   SPI_DATASIZE_13       /*< Data size equals to 13 bits*/,
   SPI_DATASIZE_14       /*< Data size equals to 14 bits*/,
   SPI_DATASIZE_15       /*< Data size equals to 15 bits*/,
   SPI_DATASIZE_16       /*< Data size equals to 16 bits*/
} SPI_DATASIZE_t;

typedef enum SPI_MODE_t
{
   SPI_MODE_0       /*clock polarity =  0      clock phase = 0*/,
   SPI_MODE_1       /*clock polarity =  0      clock phase = 1*/,
   SPI_MODE_2       /*clock polarity =  1      clock phase = 0*/,
   SPI_MODE_3       /*clock polarity =  1      clock phase = 1*/
} SPI_MODE_t;

#define SPI1SLAVESNUM 4       
#define SPICHANNELSNUM 5       


#ifdef __cplusplus
}
#endif


#endif /* SPIDEFINITIONS_H_ */


I guess that this is controlled by a LIST MACRO. Is it possible to alter the generated order, so I can have the #define statements generated at the beginning of the .h file?


Kind regards,

Ferran.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: LIST MACRO element order
« Reply #1 on: November 15, 2019, 09:26:49 am »
Not easily.

The #define statements are generated by a %list="Attribute". The order is specified in the Class Body template from line 28 on. $pubFeatures2 contains the enums and is added to $classFeatures there. The attributes including defines is added to $nonClassFeatures on line 38.

The complexity is separating the defines from variables.

You may need a new custom template that processes only defines, then list over that earlier.

New custom template Attribute__Defines
Code: [Select]
%if attTag:"define" != "true"%
%endTemplate%

%PI=""%
#define %attName%
%attInitial ? value%

Add to top of Attribute
Code: [Select]
%if attTag:"define" == "true"%
%endTemplate%

Add to Class Body
Code: [Select]
%list="Attribute__Defines" @separator="\n"%If you put it before the %PI=""% you'll automatically get a newline after it.

ferran

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: LIST MACRO element order
« Reply #2 on: November 15, 2019, 08:25:40 pm »
Dear Eve,

Thank you very much. That defintely solved my problem.

I am not sure now where to add to new empty lines after the defines?

Regards,

Ferran.

ferran

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: LIST MACRO element order
« Reply #3 on: November 15, 2019, 08:31:07 pm »
OK found!

thanks!