qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH v1 0/8] qapi: add generator for Golang interface


From: Markus Armbruster
Subject: Re: [RFC PATCH v1 0/8] qapi: add generator for Golang interface
Date: Thu, 28 Apr 2022 15:50:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Andrea Bolognani <abologna@redhat.com> writes:

> On Sat, Apr 02, 2022 at 12:40:56AM +0200, Victor Toso wrote:
>> Thanks for taking a look, let me know if you have questions, ideas
>> or suggestions.
>
> Full disclosure: I have only given the actual implementation a very
> cursory look so far, and I've focused on the generated Go API
> instead.
>
> Overall things look pretty good.
>
> One concern that I have is about naming struct members: things like
> SpiceInfo.MouseMode and most others are translated from the QAPI
> schema exactly the way you'd expect them, but for example
> ChardevCommon.Logappend doesn't look quite right.

It doesn't look quite right in the QAPI schema, either: @logappend.  If
it was @log-append, as it should, then it would get translated to
LogAppend, I guess.

Fixing up style isn't a code generator's job.

>                                                   Of course there's
> no way to programmatically figure out what to capitalize,

Some case conversions are straightforward enough.  For instance, the C
code generator generates qapi_event_send_some_event() for event
SOME_EVENT, and inclusion guard macro FILE_NAME_H for module file name
file-name.json.  No magic involved.

Conversion from lower-case-with-dashes to CamelCase doesn't have to be
magic, either.  You just have to accept garbage-in (like missing dashes)
will give you garbage-out.  I wouldn't care too much;
CamelCaseIsAnIllegibleMessAnyway.

Conversion from CamelCase is always trouble, though.  There is one
instance so far: generating C enumeration constants.  We want TYPE_NAME
+ '_' + MEMBER_NAME, where TYPE_NAME is the enumeration type's name
converted from CamelCase to UPPER_CASE_WITH_UNDERSCORES, and MEMBER_NAME
is the member name converted from lower-case-with-dashes to
UPPER_CASE_WITH_UNDERSCORES.

camel_to_upper() tries, but the result is often unappealing, surprising,
or both.

>                                                           but maybe
> there's room for adding this kind of information in the form of
> additional annotations or something like that?

We did for enumeration types: 'prefix' overrides the TYPE_NAME prefix.
I fear this was a mistake.

>                                                Same for the various
> structs or members that have unexpectedly-capitalized "Tls" or "Vnc"
> in them.

Examples?

> To be clear, I don't think the above is a blocker - just something to
> be aware of, and think about.

Yup.

[...]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]