poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] MI: Make JSON msg field consistent with C counterpart


From: Jose E. Marchesi
Subject: Re: [PATCH] MI: Make JSON msg field consistent with C counterpart
Date: Wed, 01 Sep 2021 15:38:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Mohammad.

> C code uses "kind" to distinguish messages in `poke/pk-mi-msg.h`,
> but JSON messages use "type". This commit change the name "type"
> to "kind".

I'm not sure if you already applied this.  OK for both master and
maint/poke-1 (if applicable there).

Thanks!

>
> 2021-08-19  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>
>       * poke/pk-mi-json.c (MI Messages): Use "kind" instead of "type" for
>       messages.
>       (pk_mi_msg_to_json_object): Likewise.
>       (pk_mi_json_object_to_msg): Likewise.
> ---
>  ChangeLog         |  7 +++++++
>  poke/pk-mi-json.c | 10 +++++-----
>  2 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index abf23c2b..d7e9dc95 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,10 @@
> +2021-08-19  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
> +
> +     * poke/pk-mi-json.c (MI Messages): Use "kind" instead of "type" for
> +     messages.
> +     (pk_mi_msg_to_json_object): Likewise.
> +     (pk_mi_json_object_to_msg): Likewise.
> +
>  2021-08-19  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>  
>       * poke/pk-mi-msg.h (pk_mi_seqnum): Replaced by `pk_mi_id`.
> diff --git a/poke/pk-mi-json.c b/poke/pk-mi-json.c
> index 8ffea7f0..6e5fae87 100644
> --- a/poke/pk-mi-json.c
> +++ b/poke/pk-mi-json.c
> @@ -133,11 +133,11 @@ jerror (int ok, char **out, const char *fmt, ...)
>  /* Message::
>     {
>       "id"   : uint64
> -     "type" : MessageType
> +     "kind" : MessageKind
>       "data" : Request | Response | Event
>     }
>  
> -   MessageType:: ( 0 => request | 1 => response | 2 => event )
> +   MessageKind:: ( 0 => request | 1 => response | 2 => event )
>  
>     Request::
>     {
> @@ -1127,7 +1127,7 @@ pk_mi_msg_to_json_object (pk_mi_msg msg)
>  
>      if (!integer)
>        goto out_of_memory;
> -    json_object_object_add (json, "type", integer);
> +    json_object_object_add (json, "kind", integer);
>    }
>  
>    /* Add the data.  */
> @@ -1247,8 +1247,8 @@ pk_mi_json_object_to_msg (json_object *json, char** 
> errmsg)
>      msg_id = json_object_get_int (number);
>    }
>  
> -  /* Get the message type.  */
> -  GOTO_ON_JERR (jexpect (json, "type", json_type_int, &obj, errmsg), failed,
> +  /* Get the message kind.  */
> +  GOTO_ON_JERR (jexpect (json, "kind", json_type_int, &obj, errmsg), failed,
>                  errmsg, "invalid message");
>    msg_kind = json_object_get_int (obj);



reply via email to

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