simple-binary-encoding icon indicating copy to clipboard operation
simple-binary-encoding copied to clipboard

Adding configurable attributes to methods

Open kdoherty2 opened this issue 7 years ago • 4 comments

Adding configurable attributes to methods

kdoherty2 avatar Oct 12 '18 19:10 kdoherty2

Can you provide an example for reference?

mjpt777 avatar Oct 12 '18 19:10 mjpt777

Time to time it's very beneficial to mark methods with attributes. E.g. [[gnu::always_inline]]. This can be done via macros (empty by default).

Would be really nice to categorize the functions to be able giving them different attributes:

  • getters
    • getters for constant fields (in some cases we need them to be static constexpr)
  • setters

VSol-ll avatar Oct 15 '18 11:10 VSol-ll

For ease of use, it might be easiest to configure a String to be prepended to getters and setters. The fields that can be static const already have a String (macro). These strings can be macros or direct values. This might be also nice for Java as these could be annotations.

tmontgomery avatar Oct 15 '18 17:10 tmontgomery

You know, in case of C++ it can be basically a set of hardcoded macros:

#ifndef SBE_CFG_METHOD_PREFIX
#  define SBE_CFG_METHOD_PREFIX
#endif 
#ifndef SBE_CFG_GETTER_PREFIX
#  define SBE_CFG_GETTER_PREFIX SBE_CFG_METHOD_PREFIX
#endif 
#ifndef SBE_CFG_CONST_FLD_GETTER_PREFIX
#  define SBE_CFG_CONST_FLD_GETTER_PREFIX SBE_CFG_GETTER_PREFIX
#endif 
#ifndef SBE_CFG_SETTER_PREFIX
#  define SBE_CFG_SETTER_PREFIX SBE_CFG_METHOD_PREFIX
#endif 
....
  SBE_CFG_GETTER_PREFIX int getField(){...}

But if it's beneficial for other langs too it's better to go SbeTool parameters.

VSol-ll avatar Oct 16 '18 06:10 VSol-ll