From: Pieter Lexis Date: Thu, 13 Nov 2025 12:55:27 +0000 (+0100) Subject: chore(dnsdist): stop boost::optional to std::optional conversions in generated code X-Git-Tag: rec-5.4.0-alpha1~33^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a6d81d48c450693b7ba6e9052189f7cf404d7ef;p=thirdparty%2Fpdns.git chore(dnsdist): stop boost::optional to std::optional conversions in generated code --- diff --git a/pdns/dnsdistdist/dnsdist-actions-definitions.yml b/pdns/dnsdistdist/dnsdist-actions-definitions.yml index 055dac87ef..a9ea1c3ca6 100644 --- a/pdns/dnsdistdist/dnsdist-actions-definitions.yml +++ b/pdns/dnsdistdist/dnsdist-actions-definitions.yml @@ -118,32 +118,32 @@ Subsequent rules are processed after this action" - name: "file_name" type: "String" default: "" - cpp-optional: false + optional: false description: "File to log to. Set to an empty string to log to the normal stdout log, this only works when ``-v`` is set on the command line" - name: "binary" type: "bool" default: "true" - cpp-optional: false + optional: false description: "Whether to do binary logging" - name: "append" type: "bool" default: "false" - cpp-optional: false + optional: false description: "Whether to append to an existing file" - name: "buffered" type: "bool" default: "false" - cpp-optional: false + optional: false description: "Whether to use buffered I/O" - name: "verbose_only" type: "bool" default: "true" - cpp-optional: false + optional: false description: "Whether to log only in verbose mode when logging to stdout" - name: "include_timestamp" type: "bool" default: "false" - cpp-optional: false + optional: false description: "Whether to include a timestamp for every entry" - name: "lua" description: "Invoke a Lua function that accepts a :class:`DNSQuestion`. The function should return a :ref:`DNSAction`. If the Lua code fails, ``ServFail`` is returned" @@ -230,7 +230,7 @@ The function will be invoked in a per-thread Lua state, without access to the gl - name: "stop_processing" type: "bool" default: "true" - cpp-optional: false + optional: false description: "Whether subsequent rules should be executed after this one" - name: "QPS" description: "Drop a packet if it does exceed the ``limit`` queries per second limit. Letting the subsequent rules apply otherwise" @@ -250,7 +250,7 @@ The function will be invoked in a per-thread Lua state, without access to the gl - name: "stop_processing" type: "bool" default: "true" - cpp-optional: false + optional: false description: "Whether subsequent rules should be executed after this one" - name: "RCode" description: "Reply immediately by turning the query into a response with the specified rcode" @@ -332,7 +332,7 @@ are processed after this action" type: "String" default: "" description: "The IPv6 netmask, if any" - cpp-optional: false + optional: false - name: "SetECSOverride" description: "Whether an existing EDNS Client Subnet value should be overridden (true) or not (false). Subsequent rules are processed after this action" parameters: @@ -357,7 +357,7 @@ are processed after this action" - name: "extra_text" type: "String" default: "" - cpp-optional: false + optional: false description: "The optional EDNS Extended DNS Error extra text" - name: "SetMacAddr" description: "Add the source MAC address to the query as an EDNS0 option. This action is currently only supported on Linux. Subsequent rules are processed after this action" @@ -420,7 +420,7 @@ are processed after this action" - name: "reason" type: "String" default: "" - cpp-optional: false + optional: false description: "The SNMP trap reason" - name: "Spoof" description: "Forge a response with the specified IPv4 (for an A query) or IPv6 (for an AAAA) addresses. If you specify multiple addresses, all that match the query type (A, AAAA or ANY) will get spoofed in" diff --git a/pdns/dnsdistdist/dnsdist-lua-actions.cc b/pdns/dnsdistdist/dnsdist-lua-actions.cc index f79ec1b480..73a2ed4d23 100644 --- a/pdns/dnsdistdist/dnsdist-lua-actions.cc +++ b/pdns/dnsdistdist/dnsdist-lua-actions.cc @@ -54,12 +54,6 @@ static std::vector convertLuaArrayToRegular(const LuaArray& luaArray) return out; } -template -std::optional boostToStandardOptional(const std::optional& boostOpt) -{ - return boostOpt ? *boostOpt : std::optional(); -} - // NOLINTNEXTLINE(readability-function-cognitive-complexity): this function declares Lua bindings, even with a good refactoring it will likely blow up the threshold void setupLuaActions(LuaContext& luaCtx) { diff --git a/pdns/dnsdistdist/dnsdist-lua-rules.cc b/pdns/dnsdistdist/dnsdist-lua-rules.cc index 30d5f0db82..23144e7529 100644 --- a/pdns/dnsdistdist/dnsdist-lua-rules.cc +++ b/pdns/dnsdistdist/dnsdist-lua-rules.cc @@ -360,12 +360,6 @@ std::shared_ptr qnameSuffixRule(const boost::variant(&names); return std::shared_ptr(new SuffixMatchNodeRule(smn, quiet ? *quiet : false)); } - -template -std::optional boostToStandardOptional(const std::optional& boostOpt) -{ - return boostOpt ? *boostOpt : std::optional(); -} } void setupLuaRuleChainsManagement(LuaContext& luaCtx) diff --git a/pdns/dnsdistdist/dnsdist-response-actions-definitions.yml b/pdns/dnsdistdist/dnsdist-response-actions-definitions.yml index f9959dfe08..ff07440188 100644 --- a/pdns/dnsdistdist/dnsdist-response-actions-definitions.yml +++ b/pdns/dnsdistdist/dnsdist-response-actions-definitions.yml @@ -65,27 +65,27 @@ Subsequent rules are processed after this action" - name: "file_name" type: "String" default: "" - cpp-optional: false + optional: false description: "File to log to. Set to an empty string to log to the normal stdout log, this only works when ``-v`` is set on the command line" - name: "append" type: "bool" default: "false" - cpp-optional: false + optional: false description: "Whether to append to an existing file" - name: "buffered" type: "bool" default: "false" - cpp-optional: false + optional: false description: "Whether to use buffered I/O" - name: "verbose_only" type: "bool" default: "true" - cpp-optional: false + optional: false description: "Whether to log only in verbose mode when logging to stdout" - name: "include_timestamp" type: "bool" default: "false" - cpp-optional: false + optional: false description: "Whether to include a timestamp for every entry" - name: "lua" description: "Invoke a Lua function that accepts a :class:`DNSResponse`. The function should return a :ref:`DNSResponseAction`. If the Lua code fails, ``ServFail`` is returned" @@ -201,7 +201,7 @@ The function will be invoked in a per-thread Lua state, without access to the gl - name: "extra_text" type: "String" default: "" - cpp-optional: false + optional: false description: "The optional EDNS Extended DNS Error extra text" - name: "SetMaxReturnedTTL" description: "Cap the TTLs of the response to the given maximum, but only after inserting the response into the packet cache with the initial TTL values" @@ -249,7 +249,7 @@ The function will be invoked in a per-thread Lua state, without access to the gl - name: "reason" type: "String" default: "" - cpp-optional: false + optional: false description: "The SNMP trap reason" - name: "TC" description: "Truncate an existing answer, to force the client to TCP. Only applied to answers that will be sent to the client over TCP. In addition to the TC bit being set, all records are removed from the answer, authority and additional sections" diff --git a/pdns/dnsdistdist/dnsdist-rules-generator.py b/pdns/dnsdistdist/dnsdist-rules-generator.py index 885ad23205..be46a33858 100644 --- a/pdns/dnsdistdist/dnsdist-rules-generator.py +++ b/pdns/dnsdistdist/dnsdist-rules-generator.py @@ -97,8 +97,8 @@ def get_cpp_parameters_definition(parameters, lua_interface): if 'default' in parameter: if lua_interface: ptype = type_to_cpp(parameter['type'], lua_interface, True) - ptype = f'boost::optional<{ptype}>' - elif not 'cpp-optional' in parameter or parameter['cpp-optional']: + ptype = f'std::optional<{ptype}>' + elif not 'optional' in parameter or parameter['optional']: ptype = type_to_cpp(parameter['type'], lua_interface, True) ptype = f'std::optional<{ptype}>' if len(output) > 0: @@ -117,17 +117,12 @@ def get_cpp_parameters(parameters, lua_interface): output += f'{pname}' continue - cpp_optional = not 'cpp-optional' in parameter or parameter['cpp-optional'] - if lua_interface and not cpp_optional: + optional = not 'optional' in parameter or parameter['optional'] + if lua_interface and not optional: # We are the Lua binding, and the factory does not handle optional values # -> pass the value if any, and the default otherwise default = parameter['default'] - elif lua_interface and cpp_optional: - # we are the Lua binding, the factory does handle optional values, - # -> boost::optional to std::optional - output += f'boostToStandardOptional({pname})' - continue - elif not lua_interface and cpp_optional: + elif not lua_interface and optional: # We are the C++ factory and we do handle optional values # -> pass the value if any, and the default otherwise default = parameter['default']