Re: [PATCH v4 3/9] add target method delegation

Tom Tromey
2013-12-16T21:21:16Z

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> 3. de_fault will be completely eliminated. INHERIT will be limited to
>> the smallest possible list of fields, like to_shortname. Nearly
>> every current_target method will simply delegate.

Pedro> Sounds like the squashed target will end up mostly unused? It sounds
Pedro> to me that even for those (data fields) we wouldn't need INHERIT. As
Pedro> all targets have a name, e.g., target_shortname could be made a method
Pedro> that returns the name of the currently topmost target in the stack
Pedro> (not the squashed target).

Yeah. The squashed target may still need to exist, or the debug target
would have to be recast as a new stratum.

>> 5. Any given to_* method implementation will be guaranteed to be called
>> with the target_ops with which it was registered. (This rule is
>> handy on multi-target, where I split out the target_ops vtable from
>> the object itself.)

FWIW I wrote a script to add all the missing "this" arguments -- not
just to target.h but to every method implementation in the tree.

This yields 103 patches -- one per converted method. (I may zap a few
of these, the bulk of them seem to make sense...) I'm not quite sure
how to submit it. I mean, email is doable, but it seems a bit large.

>> This is a bit difficult since I don't have access to many targets. I'm
>> not sure what to do about this aspect.

Pedro> What I've done in that past for this sort of thing is just go ahead
Pedro> and do the almost mechanical adjustment across the board, and don't
Pedro> fret about it if something breaks. Publish git test branches, IOW,
Pedro> make it very easy for people to test, report issues and hopefully
Pedro> help with targets they care about should help drive this through
Pedro> faster.

Yeah. It doesn't quite sit right but it does seem like the best way.

The nice thing about these refactorings is that the needed changes are
usually trivial anyhow.

Tom