summaryrefslogtreecommitdiff
path: root/src/options/mkoptions.py
diff options
context:
space:
mode:
authorGereon Kremer <nafur42@gmail.com>2021-10-22 15:32:33 -0700
committerGitHub <noreply@github.com>2021-10-22 22:32:33 +0000
commitc6c2cb9d3cc911526266e517460b3e8ae2dab9c0 (patch)
tree69ddf30843d1ff26f3c5e604987d3d9325132d61 /src/options/mkoptions.py
parent76c6a103fb68f75e65201da5bab572f4630cd207 (diff)
Remove options::X__name (#7414)
This PR removes the static strings options::module::X__name that hold the primary long option name. We used them to figure out which option an handler function was called on for certain handler functions. This was always a weird way, and the past refactorings have eliminated all these cases. This also removes the need to the two arguments option and flag to all option handlers.
Diffstat (limited to 'src/options/mkoptions.py')
-rw-r--r--src/options/mkoptions.py31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/options/mkoptions.py b/src/options/mkoptions.py
index 57f8b64e6..badfd59f0 100644
--- a/src/options/mkoptions.py
+++ b/src/options/mkoptions.py
@@ -295,15 +295,12 @@ def _set_handlers(option):
optname = option.long_name if option.long else ""
if option.handler:
if option.type == 'void':
- return 'opts.handler().{}("{}", name)'.format(
- option.handler, optname)
+ return 'opts.handler().{}(name)'.format(option.handler)
else:
- return 'opts.handler().{}("{}", name, optionarg)'.format(
- option.handler, optname)
+ return 'opts.handler().{}(name, optionarg)'.format(option.handler)
elif option.mode:
return 'stringTo{}(optionarg)'.format(option.type)
- return 'handlers::handleOption<{}>("{}", name, optionarg)'.format(
- option.type, optname)
+ return 'handlers::handleOption<{}>(name, optionarg)'.format(option.type)
def _set_predicates(option):
@@ -315,14 +312,14 @@ def _set_predicates(option):
res = []
if option.minimum:
res.append(
- 'opts.handler().checkMinimum("{}", name, value, static_cast<{}>({}));'
- .format(optname, option.type, option.minimum))
+ 'opts.handler().checkMinimum(name, value, static_cast<{}>({}));'
+ .format(option.type, option.minimum))
if option.maximum:
res.append(
- 'opts.handler().checkMaximum("{}", name, value, static_cast<{}>({}));'
- .format(optname, option.type, option.maximum))
+ 'opts.handler().checkMaximum(name, value, static_cast<{}>({}));'
+ .format(option.type, option.maximum))
res += [
- 'opts.handler().{}("{}", name, value);'.format(x, optname)
+ 'opts.handler().{}(name, value);'.format(x)
for x in option.predicates
]
return res
@@ -361,7 +358,7 @@ def generate_set_impl(modules):
name=option.name,
handler=_set_handlers(option)))
elif option.handler:
- h = ' opts.handler().{handler}("{smtname}", name'
+ h = ' opts.handler().{handler}(name'
if option.type not in ['bool', 'void']:
h += ', optionarg'
h += ');'
@@ -471,15 +468,6 @@ def generate_module_wrapper_functions(module):
return '\n'.join(res)
-def generate_module_option_names(module):
- relevant = [
- o for o in module.options
- if not (o.name is None or o.long_name is None)
- ]
- return concat_format(
- 'static constexpr const char* {name}__name = "{long_name}";', relevant)
-
-
################################################################################
# for options/<module>.cpp
@@ -842,7 +830,6 @@ def codegen_module(module, dst_dir, tpls):
'modes_decl': generate_module_mode_decl(module),
'holder_decl': generate_module_holder_decl(module),
'wrapper_functions': generate_module_wrapper_functions(module),
- 'option_names': generate_module_option_names(module),
# module source
'header': module.header,
'modes_impl': generate_module_mode_impl(module),
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback