CNES / ccsdsmo-malc-stubgenerator

Stub Generator for CCSDS MAL C API
https://cnes.github.io/ccsdsmo-malc
MIT License
3 stars 2 forks source link

Generate field accessors for abstract attribute composite fields #15

Closed georgeslabreche closed 3 years ago

georgeslabreche commented 3 years ago

Is there are reason why only attribute tag accessors for abstract attribute composite fields are being generated? See here: https://github.com/tanagraspace/ccsdsmo-malc-stubgenerator/blob/1aa0dd51dd7c852261998a8c8702e4b1d1f8a5d7/generator/src/main/java/fr/cnes/mo/stubgen/c/GeneratorC.java#L1456-L1457

For instance, for unsigned char f_rawvalue_attribute_tag and union mal_attribute_t in the following structure definition:

struct _mc_parameter_parametervalue_t {
  mal_uoctet_t f_validitystate;
  bool f_rawvalue_is_present;
  unsigned char f_rawvalue_attribute_tag;
  union mal_attribute_t f_rawvalue;
  bool f_convertedvalue_is_present;
  unsigned char f_convertedvalue_attribute_tag;
  union mal_attribute_t f_convertedvalue;
};

Only accessors for unsigned char f_rawvalue_attribute_tag will be generated:

unsigned char mc_parameter_parametervalue_rawvalue_get_attribute_tag(mc_parameter_parametervalue_t * self)
{
  return self->f_rawvalue_attribute_tag;
}
void mc_parameter_parametervalue_rawvalue_set_attribute_tag(mc_parameter_parametervalue_t * self, unsigned char attribute_tag)
{
  self->f_rawvalue_attribute_tag = attribute_tag;
}

We also want accessors for union mal_attribute_t f_rawvalue.

I resolved this in a forked version of this repo, here: https://github.com/tanagraspace/ccsdsmo-malc-stubgenerator/pull/2/commits/ac1e0e6bf48cd4c5bf198424e25d66b2576c53a0

Where I just added the following function call:

addCompFieldAccessors(compositeH, compCStructAccess, compCtxt.mapCompNameL, "union mal_attribute_t", cfDetails.fieldName);
lacourte commented 3 years ago

I agree with you, there is some code missing here. I will fix it with the call to addCompFieldAccessors at the end of the addAttributeFieldAccessors function.