[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 9/9] docs: update the documentation about schema configuratio
From: |
Marc-André Lureau |
Subject: |
Re: [PATCH 9/9] docs: update the documentation about schema configuration |
Date: |
Thu, 15 Oct 2020 21:02:58 +0400 |
On Thu, Oct 15, 2020 at 8:54 PM <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> docs/devel/qapi-code-gen.txt | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
> index 3d22a7ae21..517bc29507 100644
> --- a/docs/devel/qapi-code-gen.txt
> +++ b/docs/devel/qapi-code-gen.txt
> @@ -772,26 +772,30 @@ downstream command __com.redhat_drive-mirror.
> === Configuring the schema ===
>
> Syntax:
> - COND = STRING
> - | [ STRING, ... ]
> + COND = CFG-ID
> + | [ CFG-ID, ... ]
> + | { 'all: [ CFG-ID, ... ] }
> + | { 'any: [ CFG-ID, ... ] }
> + | { 'not': COND }
Btw, I realized while writing that, the doc is actually quite
faithfull with the currently limited supported expressions, but I will
probably improve on that in v2 (unless it's considered a feature :)
>
> -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 = 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 shorthand for a
> +'all'-member object. The C code generated for the definition will then be
> guarded
> +by an #if precessor expression.
>
> 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
> --
> 2.28.0
>
- [PATCH 0/9] qapi: untie 'if' conditions from C preprocessor, marcandre . lureau, 2020/10/15
- [PATCH 1/9] qapi: replace List[str] by IfCond, marcandre . lureau, 2020/10/15
- [PATCH 2/9] qapi: move gen_if/gen_endif to IfCond, marcandre . lureau, 2020/10/15
- [PATCH 3/9] qapi: start building an 'if' predicate tree, marcandre . lureau, 2020/10/15
- [PATCH 4/9] qapi: introduce IfPredicateList and IfAny, marcandre . lureau, 2020/10/15
- [PATCH 5/9] qapi: add IfNot, marcandre . lureau, 2020/10/15
- [PATCH 6/9] qapi: normalize 'if' condition to IfPredicate, marcandre . lureau, 2020/10/15
- [PATCH 7/9] qapi: convert 'if' C expressions to literal form, marcandre . lureau, 2020/10/15
- [PATCH 9/9] docs: update the documentation about schema configuration, marcandre . lureau, 2020/10/15
- Re: [PATCH 9/9] docs: update the documentation about schema configuration,
Marc-André Lureau <=
- [PATCH 8/9] qapi: make 'if' condition strings simple identifiers, marcandre . lureau, 2020/10/15