poke-devel
[Top][All Lists]
Advanced

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

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


From: Mohammad-Reza Nabipoor
Subject: [PATCH] MI: Make JSON msg field consistent with C counterpart
Date: Thu, 19 Aug 2021 13:51:03 +0430

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".

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);
 
-- 
2.32.0




reply via email to

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