[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 12/18] qapi: Add qobject_to_json_pretty_prefi
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v3 12/18] qapi: Add qobject_to_json_pretty_prefix() |
Date: |
Mon, 02 May 2016 15:56:52 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> writes:
> The next patch will add pretty indentation to the JSON visitor.
> But in order to support pretty output in the type_any() callback,
> we need to prefix every line of the QObject visitor by the current
> indentation in the JSON visitor. Hence, a new function
> qobject_to_json_pretty_indent(), and the old function becomes a
> thin wrapper to the expanded behavior.
>
> While at it, change 'pretty' to be a bool, to match its usage.
>
> Note that the new simple_pretty() test is a bit sensitive to our
> current notion of prettiness, as well as to the hash ordering in
> QDict (most of the tests in check-qobject-json intentionally do
> not compare the original string to the round-trip string, because
> we liberally accept more input forms than the canonical form that
> we output).
>
> Signed-off-by: Eric Blake <address@hidden>
>
> ---
> v3: no change
> v2: no change
> ---
> include/qapi/qmp/qobject-json.h | 1 +
> qobject/qobject-json.c | 40 ++++++++++++++++++-------
> tests/check-qobject-json.c | 65
> +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 95 insertions(+), 11 deletions(-)
>
> diff --git a/include/qapi/qmp/qobject-json.h b/include/qapi/qmp/qobject-json.h
> index 02b1f2c..d420c71 100644
> --- a/include/qapi/qmp/qobject-json.h
> +++ b/include/qapi/qmp/qobject-json.h
> @@ -23,5 +23,6 @@ QObject *qobject_from_jsonv(const char *string, va_list
> *ap) GCC_FMT_ATTR(1, 0);
>
> QString *qobject_to_json(const QObject *obj);
> QString *qobject_to_json_pretty(const QObject *obj);
> +QString *qobject_to_json_pretty_prefix(const QObject *obj, const char
> *prefix);
Why a string prefix, and not indentation?
>
> #endif /* QJSON_H */
[...]
- Re: [Qemu-devel] [PATCH v3 12/18] qapi: Add qobject_to_json_pretty_prefix(),
Markus Armbruster <=