diff options
Diffstat (limited to 'src/options/mkoptions.py')
-rw-r--r-- | src/options/mkoptions.py | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/options/mkoptions.py b/src/options/mkoptions.py index 91a5c32e0..c355ff436 100644 --- a/src/options/mkoptions.py +++ b/src/options/mkoptions.py @@ -129,16 +129,6 @@ TPL_OPTION_STRUCT_RW = \ type operator()() const; }} thread_local {name};""" -TPL_DECL_OP_BRACKET = \ -"""template <> const options::{name}__option_t::type& Options::operator[]( - options::{name}__option_t) const;""" - -TPL_IMPL_OP_BRACKET = TPL_DECL_OP_BRACKET[:-1] + \ -""" -{{ - return {module}.{name}; -}}""" - TPL_DECL_WAS_SET_BY_USER = \ """template <> bool Options::wasSetByUser(options::{name}__option_t) const;""" @@ -151,10 +141,8 @@ TPL_IMPL_WAS_SET_BY_USER = TPL_DECL_WAS_SET_BY_USER[:-1] + \ # Option specific methods TPL_IMPL_OP_PAR = \ -"""inline {name}__option_t::type {name}__option_t::operator()() const -{{ - return Options::current()[*this]; -}}""" +"""inline {type} {name}__option_t::operator()() const +{{ return Options::current().{module}.{name}; }}""" # Mode templates TPL_DECL_MODE_ENUM = \ @@ -591,7 +579,6 @@ def codegen_module(module, dst_dir, tpl_module_h, tpl_module_cpp): # Generate module specialization default_decl.append(TPL_DECL_SET_DEFAULT.format(module=module.id, name=option.name, funcname=capoptionname, type=option.type)) - specs.append(TPL_DECL_OP_BRACKET.format(name=option.name)) specs.append(TPL_DECL_WAS_SET_BY_USER.format(name=option.name)) if option.long and option.type not in ['bool', 'void'] and \ @@ -606,14 +593,13 @@ def codegen_module(module, dst_dir, tpl_module_h, tpl_module_cpp): module.id, option.long, option.type)) # Generate module inlines - inls.append(TPL_IMPL_OP_PAR.format(name=option.name)) + inls.append(TPL_IMPL_OP_PAR.format(module=module.id, name=option.name, type=option.type)) ### Generate code for {module.name}_options.cpp # Accessors default_impl.append(TPL_IMPL_SET_DEFAULT.format(module=module.id, name=option.name, funcname=capoptionname, type=option.type)) - accs.append(TPL_IMPL_OP_BRACKET.format(module=module.id, name=option.name)) accs.append(TPL_IMPL_WAS_SET_BY_USER.format(module=module.id, name=option.name)) # Global definitions @@ -872,17 +858,17 @@ def codegen_all_modules(modules, build_dir, dst_dir, tpl_options_h, tpl_options_ 'if ({}) {{'.format(cond)) if option.type == 'bool': getoption_handlers.append( - 'return (*this)[options::{}] ? "true" : "false";'.format(option.name)) + 'return options.{}.{} ? "true" : "false";'.format(module.id, option.name)) elif option.type == 'std::string': getoption_handlers.append( - 'return (*this)[options::{}];'.format(option.name)) + 'return options.{}.{};'.format(module.id, option.name)) elif is_numeric_cpp_type(option.type): getoption_handlers.append( - 'return std::to_string((*this)[options::{}]);'.format(option.name)) + 'return std::to_string(options.{}.{});'.format(module.id, option.name)) else: getoption_handlers.append('std::stringstream ss;') getoption_handlers.append( - 'ss << (*this)[options::{}];'.format(option.name)) + 'ss << options.{}.{};'.format(module.id, option.name)) getoption_handlers.append('return ss.str();') getoption_handlers.append('}') |