bneradt commented on code in PR #12719: URL: https://github.com/apache/trafficserver/pull/12719#discussion_r2590761990
########## src/api/InkAPI.cc: ########## @@ -7202,6 +7203,27 @@ _memberp_to_generic(MgmtFloat *ptr, MgmtConverter const *&conv) -> typename std: return ptr; } +// Converter dispatch macros for the X-macro expansion. +// clang-format off +#define _CONF_CASE_GENERIC(KEY, MEMBER) \ + case TS_CONFIG_##KEY: ret = _memberp_to_generic(&overridableHttpConfig->MEMBER, conv); break; +#define _CONF_CASE_NONE(KEY, MEMBER) \ + case TS_CONFIG_##KEY: break; +#define _CONF_CASE_HttpDownServerCacheTimeConv(KEY, MEMBER) \ + case TS_CONFIG_##KEY: conv = &HttpDownServerCacheTimeConv; ret = &overridableHttpConfig->MEMBER; break; +#define _CONF_CASE_HttpStatusCodeList_Conv(KEY, MEMBER) \ + case TS_CONFIG_##KEY: ret = &overridableHttpConfig->MEMBER; conv = &HttpStatusCodeList::Conv; break; +#define _CONF_CASE_ConnectionTracker_MIN_SERVER_CONV(KEY, MEMBER) \ + case TS_CONFIG_##KEY: ret = &overridableHttpConfig->MEMBER; conv = &ConnectionTracker::MIN_SERVER_CONV; break; +#define _CONF_CASE_ConnectionTracker_MAX_SERVER_CONV(KEY, MEMBER) \ + case TS_CONFIG_##KEY: ret = &overridableHttpConfig->MEMBER; conv = &ConnectionTracker::MAX_SERVER_CONV; break; +#define _CONF_CASE_ConnectionTracker_SERVER_MATCH_CONV(KEY, MEMBER) \ + case TS_CONFIG_##KEY: ret = &overridableHttpConfig->MEMBER; conv = &ConnectionTracker::SERVER_MATCH_CONV; break; +#define _CONF_CASE_HttpTransact_HOST_RES_CONV(KEY, MEMBER) \ + case TS_CONFIG_##KEY: ret = &overridableHttpConfig->MEMBER; conv = &HttpTransact::HOST_RES_CONV; break; +#define _CONF_CASE_DISPATCH(KEY, MEMBER, RECORD_NAME, DATA_TYPE, CONV) _CONF_CASE_##CONV(KEY, MEMBER) Review Comment: I agree this is complicated. :) I took a crack at using a map, but I think I wound up making it more complicated. https://github.com/bneradt/trafficserver/tree/streamline_overridable_map How about this: I beefed up the documentation quite a bit on this. Does that help? Note that the great majority of people won't have to deal with custom converters and this macro will just take care of things for them automatically. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
