From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5zPe-0004yF-18 for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5zPY-0005JZ-HR for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:45:05 -0400 Received: from cantor2.suse.de ([195.135.220.15]:56428 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5zPY-0005JV-B8 for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:45:00 -0400 Message-ID: <5584470B.8030809@suse.de> Date: Fri, 19 Jun 2015 18:44:59 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1432739276-10452-1-git-send-email-berrange@redhat.com> <1432739276-10452-8-git-send-email-berrange@redhat.com> <5584457A.4030903@redhat.com> In-Reply-To: <5584457A.4030903@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Ip12tHIQHtS43Dvgkxhi8JbRfsAN97TIw" Subject: Re: [Qemu-devel] [PATCH v5 7/8] qom: add a object_property_add_enum helper method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Ip12tHIQHtS43Dvgkxhi8JbRfsAN97TIw Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Am 19.06.2015 um 18:38 schrieb Eric Blake: > On 05/27/2015 09:07 AM, Daniel P. Berrange wrote: >> A QOM property can be parsed as enum using the visit_type_enum() >> helper method, but this forces callers to use the more complex >> generic object_property_add() method when registering it. It >> also requires that users of that object have access to the >> string map when they want to read the property value. >> >=20 >> Assuming an object struct of >> >> typedef struct { >> Object parent; >> MyDevType devtype; >> ...other fields... >> } MyDev; >> >> The property can then be registered as follows: >> >> static int mydev_prop_get_devtype(Object *obj, >> Error **errp G_GNUC_UNUSED) >> { >> MyDev *dev =3D MYDEV(obj); >> >> return dev->devtype; >> } >> >> static void mydev_prop_set_devtype(Object *obj, >> int value, >> Error **errp G_GNUC_UNUSED) >> { >> MyDev *dev =3D MYDEV(obj); >> >> dev->endpoint =3D value; >=20 > s/endpoint/devtype/ Fixed, and s/parent/parent_obj/ while at it. Andreas >=20 >> Signed-off-by: Daniel P. Berrange >> --- >=20 --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Felix Imend=C3=B6rffer, Jane Smithard, Dilip Upmanyu, Graham Norton; = HRB 21284 (AG N=C3=BCrnberg) --Ip12tHIQHtS43Dvgkxhi8JbRfsAN97TIw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJVhEcLAAoJEPou0S0+fgE/Tp4P/1MroIQ4lnE08+7hXKAxvsfc IJUgajlog2hn61xCj3TcxZVbfOam1Ev8/Lm8I4BrxytkdZ5LvVq+vMOKfaC+9sob meyUc4+OanNyRyrVqgjWmVwGLMTxL5d4m7J/IF7KvQ4b5NCmTeNhxc89FB8M4WZ3 VQZAsvIop+QZSQBoJaEIySDlnOzwKLPlaetZkXY82NT1Pj0vQQGbDNr37aOxc1im upVypmBM7cgg28yiQ05Wh9ezFZ8p5okFsvIRAwg1G+r955rVa09HCXWe6jmB3Yp9 kg3P/7i2MjSyxjLL7lSkCWG2CGuaVnJRLlxViThBt0oQWD5bJ9iIrRB+LzyRuxis EVNwipQuIPAIJzDFedmXw/Ype7UBQCRJmoMkwOLyD58gIzD43dlHdMoSel01rXLr uwQqLG8Z6vTFcTcvmdWYXMiA5i7QtwyyY8CfSaK0eAFpPD+VNZLQdG/y474iEXNE ztgVSZKMH1b+VIgKB5kvT4ct2onsR4JxhOC7mnuA+Bq1d2uMrLMIATe+2Ih/Tyu6 Qhzo9CGSCFUppro3Eknb57JhVnkQoX44WFuwa+eOH6n2g58zuw3bDHubg+E27unq S+kd3U3N73VPmo2ljMGLofjQT1Vot2DGEYAc16AT/LyUBY0z/Kjp1DvfJcFCM7dB FsAvD7wDW1pR9QhEsQHv =eJYE -----END PGP SIGNATURE----- --Ip12tHIQHtS43Dvgkxhi8JbRfsAN97TIw--