From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Me8Ih-0001Ja-45 for qemu-devel@nongnu.org; Thu, 20 Aug 2009 10:07:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Me8Ic-00019l-DF for qemu-devel@nongnu.org; Thu, 20 Aug 2009 10:07:34 -0400 Received: from [199.232.76.173] (port=52742 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Me8Ic-00019Y-9S for qemu-devel@nongnu.org; Thu, 20 Aug 2009 10:07:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39045) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Me8Ib-0002Ur-Nx for qemu-devel@nongnu.org; Thu, 20 Aug 2009 10:07:30 -0400 Message-ID: <4A8D589D.2060208@redhat.com> Date: Thu, 20 Aug 2009 17:07:25 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1250723280-3509-1-git-send-email-lcapitulino@redhat.com> <1250723280-3509-5-git-send-email-lcapitulino@redhat.com> <4A8D0202.7020803@redhat.com> <20090820105756.1bd958c8@doriath> In-Reply-To: <20090820105756.1bd958c8@doriath> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 04/29] Introduce QDict List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org On 08/20/2009 04:57 PM, Luiz Capitulino wrote: > On Thu, 20 Aug 2009 10:57:54 +0300 > Avi Kivity wrote: > > >> On 08/20/2009 02:07 AM, Luiz Capitulino wrote: >> >>> QDict is a high-level dictionary data type that can be used to store a >>> collection of QObjects. A unique key is associated with only one >>> QObject. >>> >>> The following functions are available: >>> >>> - qdict_new() Create a new dictionary >>> - qdict_add() Add a new 'key:object' pair >>> >>> >> qdict_put() is both symmetrical with qdict_get(), and also conveys the >> fact that you can replace an existing key/value. >> > Would it be useful in the current Monitor code? If so, how? > The current code, no, but once we read qdicts from the monitor, you need to be able to handle { a: 1, a: 2 }. >>> + */ >>> +int qdict_get_int(const QDict *qdict, const char *key) >>> +{ >>> + QObject *obj = qdict_get_obj(qdict, key, QTYPE_QINT); >>> + return qint_to_int(qobject_to_qint(obj)); >>> +} >>> >>> >> This assumption does not hold if the dict came from a user. >> > Then the user has to know what he or she is doing. :) > They don't, as a rule. > The problem with high-level functions that receive a QObject > but return a plain int is: what do you return if QObject is > not an QInt? > Pass a default value to return. -- error compiling committee.c: too many arguments to function