xo-facet: facetgen bugfixes

This commit is contained in:
Roland Conybeare 2026-01-13 16:42:11 -05:00
commit 0d79236814
3 changed files with 26 additions and 6 deletions

View file

@ -67,12 +67,18 @@ def format_args_routing(args):
names = [p['name'] for p in args]
return ', '.join([f"O::data()"] + names[1:])
def format_args_impl(args, drepr):
def format_args_impl_const(args, drepr):
""" Format argument names, for implementation (IFoo_DRepr)
"""
names = [f"{p['type']} {p['name']}" for p in args]
return ', '.join([f"const {drepr} & self"] + names[1:])
def format_args_impl_nonconst(args, drepr):
""" Format argument names, for implementation (IFoo_DRepr)
"""
names = [f"{p['type']} {p['name']}" for p in args]
return ', '.join([f"{drepr} & self"] + names[1:])
def gen_facet(env,
idl_fname,
@ -480,7 +486,8 @@ def main():
env.filters['argnamesnodata'] = format_arg_names_nodata
env.filters['argsnodata'] = format_args_nodata
env.filters['argrouting'] = format_args_routing
env.filters['argimpl'] = format_args_impl
env.filters['argimplconst'] = format_args_impl_const
env.filters['argimplnonconst'] = format_args_impl_nonconst
if idl['mode'] == 'facet':
gen_facet(env=env,

View file

@ -17,7 +17,7 @@ namespace {{repr_ns1}} {
namespace {{repr_ns2}} {
{% for md in const_methods %}
auto
{{iface_facet_repr}}::{{md.name}}({{md.args | argimpl(data_repr)}}){{md | staticqual}} -> {{md.return_type}}
{{iface_facet_repr}}::{{md.name}}({{md.args | argimplconst(data_repr)}}){{md | staticqual}} -> {{md.return_type}}
{
{% if md.return_type == "void" %}
self.{{md.name}}({{md.args | argnamesnodata}});
@ -27,6 +27,17 @@ namespace {{repr_ns1}} {
}
{% endfor %}
{% for md in nonconst_methods %}
auto
{{iface_facet_repr}}::{{md.name}}({{md.args | argimplnonconst(data_repr)}}){{md | staticqual}} -> {{md.return_type}}
{
{% if md.return_type == "void" %}
self.{{md.name}}({{md.args | argnamesnodata}});
{% else %}
return self.{{md.name}}({{md.args | argnamesnodata}});
{% endif %}
}
{% endfor %}
} /*namespace {{repr_ns2}}*/
} /*namespace {{repr_ns1}}*/

View file

@ -51,14 +51,16 @@ namespace {{repr_ns1}} {
/** @defgroup {{repr_ns2}}-{{facet_name_lc}}-{{data_repr_lc}}-methods **/
///@{
{% endif %}
// const methods
{% for md in const_methods %}
/** {{md.doc}} **/
static {{md.return_type}} {{md.name}}({{md.args | argimpl(data_repr)}}){{md | staticqual}};
static {{md.return_type}} {{md.name}}({{md.args | argimplconst(data_repr)}}){{md | staticqual}};
{% endfor %}
{% for md in methods %}
// non-const methods
{% for md in nonconst_methods %}
/** {{md.doc}} **/
static {{md.return_type}} {{md.name}}({{md.args | argimpl(data_repr)}}){{md | staticqual}};
static {{md.return_type}} {{md.name}}({{md.args | argimplnonconst(data_repr)}}){{md | staticqual}};
{% endfor %}
{% if using_dox %}
///@}