On Thu, 2025-09-04 at 10:20 +0200, Nam Cao wrote:
> On Thu, Aug 14, 2025 at 05:08:08PM +0200, Gabriele Monaco wrote:
> > +    def fill_per_obj_definitions(self) -> list:
> > +        if self.monitor_type == "per_obj":
> > +            return ["""
> > +/*
> > + * da_get_id - Get the id from a target
> > + */
> > +static inline da_id_type da_get_id(monitor_target target)
> > +{
> > +   return /* XXX: define how to get an id from the target */;
> > +}
> > +"""]
> > +        return []
> > +
> 
> I know this is the existing style that we have. But I think this is
> not something we should keep. How about something like:
> 
> import textwrap
> 
> def fill_per_obj_definitions(self) -> list:
>     if self.monitor_type == "per_obj":
>         return [textwrap.dedent("""
>             /*
>              * da_get_id - Get the id from a target
>              */
>             static inline da_id_type da_get_id(monitor_target target)
>             {
>               return /* XXX: define how to get an id from the
> target */;
>             }
>             """)]
>     return []

Mmh, I see what you mean.
I wasn't aware of this textwrap, but what immediately comes to mind is
that we'd end up mixing spaces (python indentation) and tabs (C
indentation).
While textwrap may handle the case, it doesn't look too readable to me.

I'd say we can (slowly) transition to using textwrap here but mandate
having \t for tabs to make them explicit (didn't test).

What do you think?

Thanks,
Gabriele


Reply via email to