This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Python API - nested pretty printers MI implications


On Sunday 14 August 2011 17:10:23, Andrew Oakley wrote:
>         def children(self):
>                 yield ("normal variable", "some value")
>                 yield ("phony group 1", inner_pretty_printer(...))
>                 yield ("phony group 2", inner_pretty_printer(...))
> 
> This seems to work well but I'm not quite sure how to handle the for MI.
> 
> As far as I can tell I need to create "fake" varobj structures with no
> underlying value or type (because I don't have one). 

I'm not very familiar with the pretty printing stuff, but,
doesn't something like this work nowadays?

class phony_value:
       ...
       /* extend Value */

class phony_value_pretty_printer:
        def __init__(self, ...):
                ...

def new_phony(outer, whatnot):
       /* return new phony value for outer */
       ...

class outer_pretty_printer:
        def __init__(self, val):
                ...

        def to_string(self):
                ...

        def children(self):
                yield ("normal variable", "some value")
                yield ("phony group 1", new_phony(1))
                yield ("phony group 2", new_phony(2))


That is, create a specialized Value class and install the pretty
printer for that _value_.

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]