simple-binary-encoding
simple-binary-encoding copied to clipboard
Adding configurable attributes to methods
Adding configurable attributes to methods
Can you provide an example for reference?
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
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.
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.