From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwXu4-0002vN-0e for qemu-devel@nongnu.org; Wed, 11 Nov 2015 11:06:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwXt3-0006Mi-PZ for qemu-devel@nongnu.org; Wed, 11 Nov 2015 11:05:43 -0500 References: <1447224690-9743-1-git-send-email-eblake@redhat.com> <1447224690-9743-20-git-send-email-eblake@redhat.com> <87egfwbnfc.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <564366CB.6000804@redhat.com> Date: Wed, 11 Nov 2015 09:03:23 -0700 MIME-Version: 1.0 In-Reply-To: <87egfwbnfc.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="I710KiQNsKqT2CpC9oOpP5pSJV06wKRsT" Subject: Re: [Qemu-devel] [PATCH v11 19/28] qapi: Change munging of CamelCase enum values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , Peter Maydell , "open list:Block layer core" , "Michael S. Tsirkin" , Jason Wang , qemu-devel@nongnu.org, Michael Roth , Gerd Hoffmann , Amit Shah , Luiz Capitulino , =?UTF-8?Q?Andreas_F=c3=a4rber?= This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --I710KiQNsKqT2CpC9oOpP5pSJV06wKRsT Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [hmm, wonder why scripts/get-maintainer.pl didn't loop in Gerd to the patch itself] On 11/11/2015 07:50 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> When munging enum values, the fact that we were passing the entire >> prefix + value through camel_to_upper() meant that enum values >> spelled with CamelCase could be turned into CAMEL_CASE. However, >> this provides a potential collision (both OneTwo and One-Two would >> munge into ONE_TWO). By changing the generation of enum constants >> to always be prefix + '_' + c_name(value).upper(), we can avoid >> any risk of collisions (if we can also ensure no case collisions, >> in the next patch) without having to think about what the >> heuristics in camel_to_upper() will actually do to the value. >=20 > This is the good part: the rules for clashes become much simpler. >=20 > Bonus: the implementation for detecting them will be simple, too. >=20 >> Thankfully, only two enums are affected: ErrorClass and InputButton. Visiting just InputButton in this email. >=20 > By convention (see CODING_STYLE), we use CamelCase for type names, and > nothing else. >=20 > Only enums violating this naming convention can be affected. The bad > part: they exist. >=20 > InputButton has two camels: WheelUp and WheelDown. The C enumeration > constants change from INPUT_BUTTON_WHEEL_UP/WHEEL_DOWN to > INPUT_BUTTON_WHEELUP/WHEELDOWN. Not exactly an improvement, but one, > there are just 21 occurences in 11 files, and two, I think we can still= > fix the enumeration to "lower case with dash", as it's only used by > x-input-send-event. The InputButton type has existed since 2.0; which is then part of the 'InputBtnEvent' struct, then the 'InputEvent' union, also since 2.0. I can't easily tell if it was only used internally at that point, or if we exposed it through the command line (even if we didn't expose it through QMP); but I concur with your reading that in QMP it is only used via 'x-input-send-event' (since 2.2, but the x- prefix gives us freedom). [Oh, and I just spotted a typo; 'InputAxis' has a copy-and-paste doc typo calling it 'InputButton'] If desired, I can prepare an alternate patch that adds the dash to the qapi enum definition, to see what we think. But meanwhile, look at some of the lines in the patch: > diff --git a/ui/sdl.c b/ui/sdl.c > index 570cb99..2678611 100644 > --- a/ui/sdl.c > +++ b/ui/sdl.c > @@ -469,8 +469,8 @@ static void sdl_send_mouse_event(int dx, int dy, in= t x, int y, int state) > [INPUT_BUTTON_LEFT] =3D SDL_BUTTON(SDL_BUTTON_LEFT), > [INPUT_BUTTON_MIDDLE] =3D SDL_BUTTON(SDL_BUTTON_MIDDLE), > [INPUT_BUTTON_RIGHT] =3D SDL_BUTTON(SDL_BUTTON_RIGHT), > - [INPUT_BUTTON_WHEEL_UP] =3D SDL_BUTTON(SDL_BUTTON_WHEELUP), > - [INPUT_BUTTON_WHEEL_DOWN] =3D SDL_BUTTON(SDL_BUTTON_WHEELDOWN)= , > + [INPUT_BUTTON_WHEELUP] =3D SDL_BUTTON(SDL_BUTTON_WHEELUP), > + [INPUT_BUTTON_WHEELDOWN] =3D SDL_BUTTON(SDL_BUTTON_WHEELDOWN),= Since SDL already spells the names without space, it's not the end of the world if we do likewise. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --I710KiQNsKqT2CpC9oOpP5pSJV06wKRsT 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/ iQEcBAEBCAAGBQJWQ2bLAAoJEKeha0olJ0NqyJEIAJct3vS9YjHVgZsh8j1UqZ7m PdtiAd8xKsAQtwPLNTsiQpwwvCWAjCiqPoKDgsnqQTqt2abOFSQmIIm2GhvgHyug qkEyUFIULU5UiWTd9zQ7xwCzCoC3BooO0tOqdAuerrige3ngZqOtaaUEkNLPiGC5 bXt7/fXKqBudQedhXTFk5F6CoO1G4+fPMO7LbOBmGmaF9pqNqfV7weC3rtOslEZF 6cRTBb/5Ytep7o5JQFlrfWFZlQODDH12VbCottuTp96rcKaQsVU97xeZiCb8rXWl KxS+npp4AHpVKCcTQsn6unkdn1exOfJO4wfENmPEMoSZcKPeY2eMfJCid1d32tw= =ygOo -----END PGP SIGNATURE----- --I710KiQNsKqT2CpC9oOpP5pSJV06wKRsT--