From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5zJF-00081e-4V for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:38:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5zJB-0001y1-31 for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:38:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5zJA-0001xs-Tw for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:38:25 -0400 Message-ID: <5584457A.4030903@redhat.com> Date: Fri, 19 Jun 2015 10:38:18 -0600 From: Eric Blake MIME-Version: 1.0 References: <1432739276-10452-1-git-send-email-berrange@redhat.com> <1432739276-10452-8-git-send-email-berrange@redhat.com> In-Reply-To: <1432739276-10452-8-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tsdqgCj01qmKUlq6D07iJ48T91LLc7QUc" 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: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --tsdqgCj01qmKUlq6D07iJ48T91LLc7QUc Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 >=20 > typedef struct { > Object parent; > MyDevType devtype; > ...other fields... > } MyDev; >=20 > The property can then be registered as follows: >=20 > static int mydev_prop_get_devtype(Object *obj, > Error **errp G_GNUC_UNUSED) > { > MyDev *dev =3D MYDEV(obj); >=20 > return dev->devtype; > } >=20 > static void mydev_prop_set_devtype(Object *obj, > int value, > Error **errp G_GNUC_UNUSED) > { > MyDev *dev =3D MYDEV(obj); >=20 > dev->endpoint =3D value; s/endpoint/devtype/ > Signed-off-by: Daniel P. Berrange > --- --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --tsdqgCj01qmKUlq6D07iJ48T91LLc7QUc 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVhEV6AAoJEKeha0olJ0NqAyoH/2oj5PoFpa7/GsNfAuC8PcbZ lVsIa/861vfNhgq1UdwTxG1Ghi7UAMGf9ULyvIjRFg5E801SrhoCJW7uTrTF4UuL xUrhdbc0AxMj8CZLH0fKt6hnBXOepJJr3fEJjakMsIOtuxsbjs5MzbQU6PaF0BBx s28RPmHUMlF1TQlTSRrn57z532ibLxH42KXRhUD0rBNCn3Ze+tmntf1eqDiP26+2 IArlo/ZnztMKbkfdIa9Wf6g/ktoZfj78tKtikmUZKVCwRzeFk8jamig/sbM9Xywi ObD8hphcNkpllOZ3wEqSHNroQwjshJjWpSPUl3d0GhH7oh+uduGekA4KJoefkhU= =yUmE -----END PGP SIGNATURE----- --tsdqgCj01qmKUlq6D07iJ48T91LLc7QUc--