From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23709 invoked by alias); 15 Aug 2011 12:58:08 -0000 Received: (qmail 23699 invoked by uid 22791); 15 Aug 2011 12:58:07 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Aug 2011 12:57:54 +0000 Received: (qmail 16470 invoked from network); 15 Aug 2011 12:57:53 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 15 Aug 2011 12:57:53 -0000 From: Pedro Alves To: gdb@sourceware.org Subject: Re: Python API - nested pretty printers MI implications Date: Mon, 15 Aug 2011 12:58:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-10-generic; KDE/4.7.0; x86_64; ; ) Cc: Andrew Oakley References: <20110814171023.19db4f49@ado-gentoo> In-Reply-To: <20110814171023.19db4f49@ado-gentoo> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201108151357.50298.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-08/txt/msg00042.txt.bz2 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