From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6EBC433ED for ; Fri, 21 May 2021 12:33:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 26F53613BF for ; Fri, 21 May 2021 12:33:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26F53613BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lk4Lc-0004kh-4X for qemu-devel@archiver.kernel.org; Fri, 21 May 2021 08:33:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lk4HS-0000t6-7O for qemu-devel@nongnu.org; Fri, 21 May 2021 08:29:31 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]:44864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lk4HO-0003xF-Fq for qemu-devel@nongnu.org; Fri, 21 May 2021 08:29:29 -0400 Received: by mail-ej1-x635.google.com with SMTP id lz27so30183799ejb.11 for ; Fri, 21 May 2021 05:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HapzqVMRP5PWh6aTG7JXULNQ0mXnItBWh8lkLDbgo50=; b=r/5SnnhzwP++be5z9x7uoiD9brZLVFdiJ7XtvNfRkFMkeS5VRM/uT1xf0+/x5V0Mx8 2S/aTJqlsGCZHCySMLGRKZFDl4fWfLUUXpyEbTIYDzZvGzrv+ZVOsRw9C7J8U16XIJM8 9FOaCzGxl1RIVzvcdQOpAy57jwpO6T+AIM/GM1+71zC+TC4uoBKYIK7xkeIDPyVGDMNi Ac42Nb5MD8c0Bo21Cc2+nE06UmIBwtqz44NpFXEWOSDhGXi2vfXXbevw4NOO3DpUscKj Bap1WWsVFkfPw0EDUJpFGwwef78t4xk683el32WD0hCAR0LsDGnlc56wruAr4EspKwBL 6tKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HapzqVMRP5PWh6aTG7JXULNQ0mXnItBWh8lkLDbgo50=; b=VqdSHkfcVFSESvT7xZNB+2TXg2TIh1zIbIRrxO26ZUz5dT/loyydTAxaGkq1WYmfab +EvmtamKpOIO7SaZD5YDUX7hcCKMM/YIbhYhOGk0OizJEInlOEZRC0FpdjgPU+UJD/4S lRD5WsantAI5Ynzphd3ZjnQLikEAJegHMEEfdVr6xzNmHp137OkTKa6GmvXxb4c/y+Fa EqoMAEBjQEG+XFbaQ2QBesWhDp7kwFY9C2fewnZmXMmdCiiEMS2CqQKuejFoWdMQjq6P ayH4SAT45Hbtaem86Q8PY/UHLvHdUKeJajMMx/U+cYajGqq53VtGi8zTItAZ6ze4EstT q82g== X-Gm-Message-State: AOAM533fcPqS+FmumEXt14s0UvewGODRTxcgjbtIvxxB62F1TlHu2+dw aMmi/QWmlJYYBM5ptJftn9SfJmlhs8Hwm/qozmUb+9/WWnc= X-Google-Smtp-Source: ABdhPJyc7GmajYh02aqU0H95rYNTqLu6qfbfOujms5ip6cjpSh2+ORjzbyn8+BTdoZd1tacgYRFwel0ea/VHX99QnuE= X-Received: by 2002:a17:906:2655:: with SMTP id i21mr10118384ejc.389.1621600164969; Fri, 21 May 2021 05:29:24 -0700 (PDT) MIME-Version: 1.0 References: <20210517163040.2308926-1-marcandre.lureau@redhat.com> <20210517163040.2308926-10-marcandre.lureau@redhat.com> <878s485mh5.fsf@dusky.pond.sub.org> In-Reply-To: <878s485mh5.fsf@dusky.pond.sub.org> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Fri, 21 May 2021 16:29:11 +0400 Message-ID: Subject: Re: [PATCH v4 9/9] docs: update the documentation about schema configuration To: Markus Armbruster Content-Type: multipart/alternative; boundary="000000000000cd015505c2d6353a" Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=marcandre.lureau@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , QEMU , Stefan Hajnoczi Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000cd015505c2d6353a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi On Fri, May 21, 2021 at 3:58 PM Markus Armbruster wrote= : > marcandre.lureau@redhat.com writes: > > > From: Marc-Andr=C3=A9 Lureau > > > > Signed-off-by: Marc-Andr=C3=A9 Lureau > > Reviewed-by: Stefan Hajnoczi > > Tested-by: John Snow > > --- > > docs/devel/qapi-code-gen.txt | 27 ++++++++++++++++----------- > > 1 file changed, 16 insertions(+), 11 deletions(-) > > > > diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.tx= t > > index edaaf7ec40..4a3fd02723 100644 > > --- a/docs/devel/qapi-code-gen.txt > > +++ b/docs/devel/qapi-code-gen.txt > > @@ -780,26 +780,31 @@ downstream command __com.redhat_drive-mirror. > > =3D=3D=3D Configuring the schema =3D=3D=3D > > > > Syntax: > > - COND =3D STRING > > - | [ STRING, ... ] > > + COND =3D CFG-ID > > + | [ COND, ... ] > > + | { 'all: [ COND, ... ] } > > + | { 'any: [ COND, ... ] } > > + | { 'not': COND } > > > > -All definitions take an optional 'if' member. Its value must be a > > -string or a list of strings. A string is shorthand for a list > > -containing just that string. The code generated for the definition > > -will then be guarded by #if STRING for each STRING in the COND list. > > + CFG-ID =3D STRING > > + > > +All definitions take an optional 'if' member. Its value must be a > string, a list > > +of strings or an object with a single member 'all', 'any' or 'not'. A > string is > > +shorthand for a list containing just that string. A list is a shorthan= d > for a > > +'all'-member object. The C code generated for the definition will then > be guarded > > Please try to make your changes blend into the existing text: limit line > length to 70 characters, and put two spaces between sentences. > ok > I doubt the CFG-ID non-terminal is useful. Elsewhere, we do without, > e.g. ENUM-VALUE, ALTERNATIVE, FEATURE. > > Sure the [ COND, ... ] sugar is worth the bother? > Maybe not > Perhaps > > COND =3D STRING > | { 'all: [ COND, ... ] } > | { 'any: [ COND, ... ] } > | { 'not': COND } > > All definitions take an optional 'if' member. The form STRING is > shorthand for { 'any': [ STRING ] }. The C code generated ... > ok > > +by an #if precessor expression generated from that condition: 'all': > [COND, ...] > > +will generate '(COND && ...)', 'any': [COND, ...] '(COND || ...)', > 'not': COND '!COND'. > > The technical term is "#if preprocessing directive". Let's use it. > ok > I find the last part unnecessarily hard to read. What about: > > ... generated from that condition: > > * { 'all': [COND, ...] } will generate #if (COND && ...) > * { 'any': [COND, ...] } will generate #if (COND || ...) > * { 'not': COND } will generate #if !COND > > Yes! > > > Example: a conditional struct > > > > { 'struct': 'IfStruct', 'data': { 'foo': 'int' }, > > - 'if': ['CONFIG_FOO', 'HAVE_BAR'] } > > + 'if': { 'all': [ 'CONFIG_FOO', 'HAVE_BAR' ] } } > > > > gets its generated code guarded like this: > > > > - #if defined(CONFIG_FOO) > > - #if defined(HAVE_BAR) > > + #if defined(CONFIG_FOO) && defined(HAVE_BAR) > > ... generated code ... > > - #endif /* defined(HAVE_BAR) */ > > - #endif /* defined(CONFIG_FOO) */ > > + #endif /* defined(HAVE_BAR) && defined(CONFIG_FOO) */ > > > > Individual members of complex types, commands arguments, and > > event-specific data can also be made conditional. This requires the > > > thanks --=20 Marc-Andr=C3=A9 Lureau --000000000000cd015505c2d6353a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

On Fri, May 21, 2021 at 3:58 P= M Markus Armbruster <armbru@redhat.= com> wrote:
marcand= re.lureau@redhat.com writes:

> From: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com> > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Tested-by: John Snow <jsnow@redhat.com>
> ---
>=C2=A0 docs/devel/qapi-code-gen.txt | 27 ++++++++++++++++----------- >=C2=A0 1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.t= xt
> index edaaf7ec40..4a3fd02723 100644
> --- a/docs/devel/qapi-code-gen.txt
> +++ b/docs/devel/qapi-code-gen.txt
> @@ -780,26 +780,31 @@ downstream command __com.redhat_drive-mirror. >=C2=A0 =3D=3D=3D Configuring the schema =3D=3D=3D
>=C2=A0
>=C2=A0 Syntax:
> -=C2=A0 =C2=A0 COND =3D STRING
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| [ STRING, ... ]
> +=C2=A0 =C2=A0 COND =3D CFG-ID
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| [ COND, ... ]
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| { 'all: [ COND, ... ] }
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| { 'any: [ COND, ... ] }
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| { 'not': COND }
>=C2=A0
> -All definitions take an optional 'if' member.=C2=A0 Its value= must be a
> -string or a list of strings.=C2=A0 A string is shorthand for a list > -containing just that string.=C2=A0 The code generated for the definit= ion
> -will then be guarded by #if STRING for each STRING in the COND list.<= br> > +=C2=A0 =C2=A0 CFG-ID =3D STRING
> +
> +All definitions take an optional 'if' member. Its value must = be a string, a list
> +of strings or an object with a single member 'all', 'any&= #39; or 'not'. A string is
> +shorthand for a list containing just that string. A list is a shortha= nd for a
> +'all'-member object. The C code generated for the definition = will then be guarded

Please try to make your changes blend into the existing text: limit line length to 70 characters, and put two spaces between sentences.

ok


I doubt the CFG-ID non-terminal is useful.=C2=A0 Elsewhere, we do without,<= br> e.g. ENUM-VALUE, ALTERNATIVE, FEATURE.

Sure the [ COND, ... ] sugar is worth the bother?

=
Maybe not


Perhaps

=C2=A0 =C2=A0 =C2=A0 =C2=A0COND =3D STRING
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | { 'all: [ COND, ... ] }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | { 'any: [ COND, ... ] }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | { 'not': COND }

=C2=A0 =C2=A0All definitions take an optional 'if' member.=C2=A0 Th= e form STRING is
=C2=A0 =C2=A0shorthand for { 'any': [ STRING ] }.=C2=A0 The C code = generated ...

ok

<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">
> +by an #if precessor expression generated from that condition: 'al= l': [COND, ...]
> +will generate '(COND && ...)', 'any': [COND, = ...] '(COND || ...)', 'not': COND '!COND'.

The technical term is "#if preprocessing directive".=C2=A0 Let= 9;s use it.

ok


I find the last part unnecessarily hard to read.=C2=A0 What about:

=C2=A0 =C2=A0... generated from that condition:

=C2=A0 =C2=A0* { 'all': [COND, ...] } will generate #if (COND &= & ...)
=C2=A0 =C2=A0* { 'any': [COND, ...] } will generate #if (COND || ..= .)
=C2=A0 =C2=A0* { 'not': COND } will generate #if !COND


Yes!

>=C2=A0
>=C2=A0 Example: a conditional struct
>=C2=A0
>=C2=A0 =C2=A0{ 'struct': 'IfStruct', 'data': { = 'foo': 'int' },
> -=C2=A0 =C2=A0'if': ['CONFIG_FOO', 'HAVE_BAR']= }
> +=C2=A0 =C2=A0'if': { 'all': [ 'CONFIG_FOO', &= #39;HAVE_BAR' ] } }
>=C2=A0
>=C2=A0 gets its generated code guarded like this:
>=C2=A0
> - #if defined(CONFIG_FOO)
> - #if defined(HAVE_BAR)
> + #if defined(CONFIG_FOO) && defined(HAVE_BAR)
>=C2=A0 =C2=A0... generated code ...
> - #endif /* defined(HAVE_BAR) */
> - #endif /* defined(CONFIG_FOO) */
> + #endif /* defined(HAVE_BAR) && defined(CONFIG_FOO) */
>=C2=A0
>=C2=A0 Individual members of complex types, commands arguments, and
>=C2=A0 event-specific data can also be made conditional.=C2=A0 This req= uires the



thanks

=
--
Marc-Andr=C3=A9 Lure= au
--000000000000cd015505c2d6353a--