poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Updated JSON Schema, pk_mi_val_to_json, pk_mi_json_to_val an


From: Konstantinos Chasialis
Subject: Re: [PATCH] Updated JSON Schema, pk_mi_val_to_json, pk_mi_json_to_val and a test file
Date: Sun, 7 Jun 2020 13:16:58 +0300
User-agent: SquirrelMail/1.4.23 [email.uoa.gr]

Hello, I forgot to capitalize our macros on the previous PATCH.

diff --git a/poke/pk-mi-json.h b/poke/pk-mi-json.h
index b4f33873..ad289bcd 100644
--- a/poke/pk-mi-json.h
+++ b/poke/pk-mi-json.h
@@ -24,17 +24,17 @@
 #include "pk-mi-msg.h"
 #include "libpoke.h"

-#define pk_mi_set_errmsg(errmsg, M, ...)  \
+#define PK_MI_SET_ERRMSG(errmsg, M, ...)  \
    sprintf(*errmsg, "[ERROR] " M "\n",\
         ##__VA_ARGS__)

-#define pk_mi_check(errmsg, A, M, ...) \
+#define PK_MI_CHECK(errmsg, A, M, ...) \
    if(!(A)) {                  \
      if (errmsg == NULL) goto error; \
      *errmsg = (char *) pk_alloc (1024);    \
-     pk_mi_set_errmsg(errmsg, M, ##__VA_ARGS__); goto error;}
+     PK_MI_SET_ERRMSG(errmsg, M, ##__VA_ARGS__); goto error;}

-#define pk_mi_debug(M, ...)                  \
+#define PK_MI_DEBUG(M, ...)                  \
       fprintf(stderr, "DEBUG %s:%d: " M "\n",\
         __FILE__, __LINE__, ##__VA_ARGS__)




diff --git a/poke/pk-mi-json.c b/poke/pk-mi-json.c
index cb499aef..517d5bea 100644
--- a/poke/pk-mi-json.c
+++ b/poke/pk-mi-json.c
@@ -491,28 +491,28 @@ _pk_mi_make_json_int (pk_val integer, char **errmsg)

   pk_assert (pk_type_code (pk_typeof (integer)) == PK_INT);

-  pk_mi_check (errmsg, (int_object = json_object_new_object ()) != NULL,
"json_object_new_object() failed");
+  PK_MI_CHECK (errmsg, (int_object = json_object_new_object ()) != NULL,
"json_object_new_object() failed");

   if  (! (pk_uint_value (pk_integral_type_signed_p (pk_typeof
(integer))))) {
-    pk_mi_check (errmsg, (value_object = json_object_new_uint64
(pk_uint_value (integer))) != NULL, "json_object_new_object() failed");
+    PK_MI_CHECK (errmsg, (value_object = json_object_new_uint64
(pk_uint_value (integer))) != NULL, "json_object_new_object() failed");
     size = pk_uint_size (integer);
     type = "UnsignedInteger";
   }
   else {
-    pk_mi_check (errmsg,  (value_object = json_object_new_int64
(pk_int_value (integer))) != NULL, "json_object_new_object() failed");
+    PK_MI_CHECK (errmsg,  (value_object = json_object_new_int64
(pk_int_value (integer))) != NULL, "json_object_new_object() failed");
     size = pk_int_size (integer);
     type = "Integer";
   }

   pk_assert (size <= 64);

-  pk_mi_check (errmsg, (size_object = json_object_new_int (size)) !=
NULL, "json_object_new_object() failed");
-  pk_mi_check (errmsg, (type_object = json_object_new_string (type)) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg, (size_object = json_object_new_int (size)) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg, (type_object = json_object_new_string (type)) !=
NULL, "json_object_new_object() failed");

   /*OK, fill the properties of our object*/
-  pk_mi_check (errmsg, json_object_object_add (int_object, "type",
type_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (int_object, "value",
value_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (int_object, "size",
size_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (int_object, "type",
type_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (int_object, "value",
value_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (int_object, "size",
size_object) != -1, "json_object_object_add() failed");

   return int_object;

@@ -527,14 +527,14 @@ _pk_mi_make_json_string (pk_val str, char **errmsg)

   pk_assert (pk_type_code (pk_typeof (str)) == PK_STRING);

-  pk_mi_check (errmsg, (string_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg, (string_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");

-  pk_mi_check (errmsg, (string_type_object = json_object_new_string
("String")) != NULL, "json_object_new_object() failed");
-  pk_mi_check (errmsg, (string_value_object = json_object_new_string
(pk_string_str (str))) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg, (string_type_object = json_object_new_string
("String")) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg, (string_value_object = json_object_new_string
(pk_string_str (str))) != NULL, "json_object_new_object() failed");

   /*OK, fill the properties of our object*/
-  pk_mi_check (errmsg, json_object_object_add (string_object, "type",
string_type_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (string_object, "value",
string_value_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (string_object, "type",
string_type_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (string_object, "value",
string_value_object) != -1, "json_object_object_add() failed");

   return string_object;

@@ -551,26 +551,26 @@ _pk_mi_make_json_offset (pk_val offset, char **errmsg)

   pk_assert (pk_type_code (pk_typeof (offset)) == PK_OFFSET);

-  pk_mi_check (errmsg,  (offset_type_object = json_object_new_string
("Offset")) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (offset_type_object = json_object_new_string
("Offset")) != NULL, "json_object_new_object() failed");

   magnitude_object = _pk_mi_make_json_int (pk_offset_magnitude (offset),
errmsg);

-  pk_mi_check (errmsg,  (unit_type_object = json_object_new_string
("UnsignedInteger")) != NULL, "json_object_new_object() failed");
-  pk_mi_check (errmsg,  (unit_size_object = json_object_new_int (64)) !=
NULL, "json_object_new_object() failed");
-  pk_mi_check (errmsg,  (unit_value_object = json_object_new_uint64
(pk_uint_value (pk_offset_unit (offset)))) != NULL,
"json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (unit_type_object = json_object_new_string
("UnsignedInteger")) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (unit_size_object = json_object_new_int (64)) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (unit_value_object = json_object_new_uint64
(pk_uint_value (pk_offset_unit (offset)))) != NULL,
"json_object_new_object() failed");

-  pk_mi_check (errmsg,  (unit_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (unit_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");

-  pk_mi_check (errmsg, json_object_object_add (unit_object, "type",
unit_type_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (unit_object, "value",
unit_value_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (unit_object, "size",
unit_size_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (unit_object, "type",
unit_type_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (unit_object, "value",
unit_value_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (unit_object, "size",
unit_size_object) != -1, "json_object_object_add() failed");

-  pk_mi_check (errmsg,  (offset_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (offset_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");

   /*Built sub-objects, add them to our offset_object*/
-  pk_mi_check (errmsg, json_object_object_add (offset_object, "type",
offset_type_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (offset_object,
"magnitude", magnitude_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (offset_object, "unit",
unit_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (offset_object, "type",
offset_type_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (offset_object,
"magnitude", magnitude_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (offset_object, "unit",
unit_object) != -1, "json_object_object_add() failed");

   return offset_object;

@@ -585,12 +585,12 @@ _pk_mi_make_json_mapping (pk_val val, char **errmsg)

   offset_object = _pk_mi_make_json_offset (pk_val_offset (val), errmsg);

-  pk_mi_check (errmsg, (ios_object = json_object_new_int64 (pk_int_value
(pk_val_ios (val)))) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg, (ios_object = json_object_new_int64 (pk_int_value
(pk_val_ios (val)))) != NULL, "json_object_new_object() failed");

-  pk_mi_check (errmsg, (mapping_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg, (mapping_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");

-  pk_mi_check (errmsg, json_object_object_add (mapping_object, "IOS",
ios_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (mapping_object, "offset",
offset_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (mapping_object, "IOS",
ios_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (mapping_object, "offset",
offset_object) != -1, "json_object_object_add() failed");

   return mapping_object;

@@ -606,9 +606,9 @@ _pk_mi_make_json_struct (pk_val sct, char **errmsg)

   pk_assert (pk_type_code (pk_typeof (sct)) == PK_STRUCT);

-  pk_mi_check (errmsg,  (pk_struct_type_object = json_object_new_string
("Struct")) != NULL, "json_object_new_object() failed");
-  pk_mi_check (errmsg,  (pk_struct_fields_object = json_object_new_array
()) != NULL, "json_object_new_object() failed");
-  pk_mi_check (errmsg,  (pk_struct_name_object = _pk_mi_make_json_string
(pk_struct_type_name (pk_struct_type (sct)), errmsg)) != NULL,
"json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (pk_struct_type_object = json_object_new_string
("Struct")) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (pk_struct_fields_object = json_object_new_array
()) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (pk_struct_name_object = _pk_mi_make_json_string
(pk_struct_type_name (pk_struct_type (sct)), errmsg)) != NULL,
"json_object_new_object() failed");

   /*Fill the array of struct fields*/
   for  (ssize_t i = 0 ; i < pk_uint_value (pk_struct_nfields (sct)) ; i++) {
@@ -625,18 +625,18 @@ _pk_mi_make_json_struct (pk_val sct, char **errmsg)
     json_object_object_add (pk_struct_field_object, "value",
pk_struct_field_value_object);
     json_object_object_add (pk_struct_field_object, "offset",
pk_struct_field_offset_object);

-    pk_mi_check (errmsg, json_object_array_add (pk_struct_fields_object,
pk_struct_field_object) != -1, "failed to add name object to struct
field");
+    PK_MI_CHECK (errmsg, json_object_array_add (pk_struct_fields_object,
pk_struct_field_object) != -1, "failed to add name object to struct
field");
   }

   /*Optionally, add a mapping*/
   pk_struct_mapping_object = pk_val_mapped_p  (sct) ?
_pk_mi_make_json_mapping (sct, errmsg) : _pk_mi_make_json_null
(errmsg);

-  pk_mi_check (errmsg,  (pk_struct_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (pk_struct_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");

-  pk_mi_check (errmsg, json_object_object_add (pk_struct_object, "type",
pk_struct_type_object) != -1, "failed to add type object to struct");
-  pk_mi_check (errmsg, json_object_object_add (pk_struct_object, "name",
pk_struct_name_object) != -1, "failed to add type object to struct");
-  pk_mi_check (errmsg, json_object_object_add (pk_struct_object,
"fields", pk_struct_fields_object) != -1, "failed to add fields object to
struct");
-  pk_mi_check (errmsg, json_object_object_add (pk_struct_object,
"mapping", pk_struct_mapping_object) != -1, "failed to add mapping object
to struct");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_struct_object, "type",
pk_struct_type_object) != -1, "failed to add type object to struct");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_struct_object, "name",
pk_struct_name_object) != -1, "failed to add type object to struct");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_struct_object,
"fields", pk_struct_fields_object) != -1, "failed to add fields object to
struct");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_struct_object,
"mapping", pk_struct_mapping_object) != -1, "failed to add mapping object
to struct");

   return pk_struct_object;

@@ -652,13 +652,13 @@ _pk_mi_make_json_array (pk_val array, char **errmsg)

   pk_assert (pk_type_code (pk_typeof (array)) == PK_ARRAY);

-  pk_mi_check (errmsg,  (pk_array_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (pk_array_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");

   const char *type = "Array";
-  pk_mi_check (errmsg,  (pk_array_type_object = json_object_new_string
(type)) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (pk_array_type_object = json_object_new_string
(type)) != NULL, "json_object_new_object() failed");

   /*Initialize our array*/
-  pk_mi_check (errmsg,  (pk_array_elements_object = json_object_new_array
()) != NULL, "json_object_new_object() failed");
+  PK_MI_CHECK (errmsg,  (pk_array_elements_object = json_object_new_array
()) != NULL, "json_object_new_object() failed");

   /*Fill elements object*/
   for  (size_t i = 0 ; i < pk_uint_value (pk_array_nelem (array)) ; i++) {
@@ -669,7 +669,7 @@ _pk_mi_make_json_array (pk_val array, char **errmsg)
     json_object_object_add (pk_array_element_object, "value",
pk_array_element_value_object);
     json_object_object_add (pk_array_element_object, "offset",
pk_array_element_offset_object);

-    pk_mi_check (errmsg, json_object_array_add (pk_array_elements_object,
pk_array_element_object) != -1, "failed to add element to array");
+    PK_MI_CHECK (errmsg, json_object_array_add (pk_array_elements_object,
pk_array_element_object) != -1, "failed to add element to array");
   }

   pk_array_mapping_object = pk_val_mapped_p (array) ?
_pk_mi_make_json_mapping (array, errmsg) : _pk_mi_make_json_null
(errmsg);
@@ -678,9 +678,9 @@ _pk_mi_make_json_array (pk_val array, char **errmsg)
   }

   /*OK, fill the properties of the array object*/
-  pk_mi_check (errmsg, json_object_object_add (pk_array_object, "type",
pk_array_type_object) != -1, "json_object_object_add() failed");
-  pk_mi_check (errmsg, json_object_object_add (pk_array_object,
"elements", pk_array_elements_object) != -1, "json_object_object_add()
failed");
-  pk_mi_check (errmsg, json_object_object_add (pk_array_object,
"mapping", pk_array_mapping_object) != -1, "json_object_object_add()
failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_array_object, "type",
pk_array_type_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_array_object,
"elements", pk_array_elements_object) != -1, "json_object_object_add()
failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_array_object,
"mapping", pk_array_mapping_object) != -1, "json_object_object_add()
failed");

   return pk_array_object;

@@ -693,10 +693,10 @@ static json_object* _pk_mi_make_json_null (char
**errmsg)
   struct json_object *pk_null_object;

   pk_null_object = json_object_new_object();
-  pk_mi_check (errmsg, pk_null_object != NULL, "json_object_new_object()
failed");
+  PK_MI_CHECK (errmsg, pk_null_object != NULL, "json_object_new_object()
failed");

-  pk_mi_check (errmsg, json_object_object_add (pk_null_object, "type",
json_object_new_string ("Null")) != -1, "json_object_object_add()
failed");
-  pk_mi_check (errmsg, json_object_object_add (pk_null_object, "value",
json_object_new_null ()) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_null_object, "type",
json_object_new_string ("Null")) != -1, "json_object_object_add()
failed");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_null_object, "value",
json_object_new_null ()) != -1, "json_object_object_add() failed");

   return pk_null_object;

@@ -712,8 +712,8 @@ pk_mi_val_to_json (pk_val val, char **errmsg)
   pk_val_object = _pk_mi_val_to_json (val, errmsg);

   pk_object = json_object_new_object ();
-  pk_mi_check (errmsg, pk_object != NULL, "failed to create new
json_object");
-  pk_mi_check (errmsg, json_object_object_add (pk_object, "PokeValue",
pk_val_object) != -1, "json_object_object_add() failed");
+  PK_MI_CHECK (errmsg, pk_object != NULL, "failed to create new
json_object");
+  PK_MI_CHECK (errmsg, json_object_object_add (pk_object, "PokeValue",
pk_val_object) != -1, "json_object_object_add() failed");

   return pk_object != NULL ? json_object_to_json_string_ext (pk_object,
JSON_C_TO_STRING_PRETTY) : NULL;

@@ -749,14 +749,14 @@ _pk_mi_make_pk_int (pk_val *pk_int, struct
json_object *int_obj, char **errmsg)
   int64_t value;
   int size;

-  pk_mi_check (errmsg, json_object_object_get_ex (int_obj, "value",
&value_object) != 0, "json type %s does not contain key \"value\"",
_pk_mi_get_json_poke_value_type (int_obj));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (int_obj, "value",
&value_object) != 0, "json type %s does not contain key \"value\"",
_pk_mi_get_json_poke_value_type (int_obj));
   value = json_object_get_int64 (value_object);

-  pk_mi_check (errmsg, json_object_object_get_ex (int_obj, "size",
&size_object) != 0, "json type %s does not contain key \"size\"",
_pk_mi_get_json_poke_value_type (int_obj));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (int_obj, "size",
&size_object) != 0, "json type %s does not contain key \"size\"",
_pk_mi_get_json_poke_value_type (int_obj));
   size = json_object_get_int (size_object);

   *pk_int = pk_make_int (value, size);
-  pk_mi_check (errmsg, *pk_int != PK_NULL, "pk_make_int failed");
+  PK_MI_CHECK (errmsg, *pk_int != PK_NULL, "pk_make_int failed");

   return 0;

@@ -771,14 +771,14 @@ _pk_mi_make_pk_uint (pk_val *pk_uint, struct
json_object *uint_obj, char **errms
   uint64_t value;
   int size;

-  pk_mi_check (errmsg, json_object_object_get_ex (uint_obj, "value",
&value_object) != 0, "json type %s does not contain key \"value\"",
_pk_mi_get_json_poke_value_type (uint_obj));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (uint_obj, "value",
&value_object) != 0, "json type %s does not contain key \"value\"",
_pk_mi_get_json_poke_value_type (uint_obj));
   value = json_object_get_uint64 (value_object);

-  pk_mi_check (errmsg, json_object_object_get_ex (uint_obj, "size",
&size_object) != 0, "json type %s does not contain key \"size\"",
_pk_mi_get_json_poke_value_type (uint_obj));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (uint_obj, "size",
&size_object) != 0, "json type %s does not contain key \"size\"",
_pk_mi_get_json_poke_value_type (uint_obj));
   size = json_object_get_int (size_object);

   *pk_uint = pk_make_uint (value, size);
-  pk_mi_check (errmsg, *pk_uint != PK_NULL, "pk_make_uint failed");
+  PK_MI_CHECK (errmsg, *pk_uint != PK_NULL, "pk_make_uint failed");

   return 0;

@@ -792,11 +792,11 @@ _pk_mi_make_pk_string (pk_val *pk_string, struct
json_object *str_obj, char **er
   struct json_object *value_object;
   const char *value_str;

-  pk_mi_check (errmsg, json_object_object_get_ex (str_obj, "value",
&value_object) != 0, "json type %s does not contain key \"value\"",
_pk_mi_get_json_poke_value_type (str_obj));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (str_obj, "value",
&value_object) != 0, "json type %s does not contain key \"value\"",
_pk_mi_get_json_poke_value_type (str_obj));
   value_str = json_object_get_string (value_object);

   *pk_string = pk_make_string (value_str);
-  pk_mi_check (errmsg, *pk_string != PK_NULL, "pk_make_string failed");
+  PK_MI_CHECK (errmsg, *pk_string != PK_NULL, "pk_make_string failed");

   return 0;

@@ -811,18 +811,18 @@ _pk_mi_make_pk_offset (pk_val *pk_offset, struct
json_object *offset_obj, char *
   pk_val magnitude, unit;
   struct json_object *magnitude_object, *unit_object;

-  pk_mi_check (errmsg, json_object_object_get_ex (offset_obj,
"magnitude", &magnitude_object) != 0, "json type %s does not contain key
\"magnitude\"", _pk_mi_get_json_poke_value_type (offset_obj));
-  pk_mi_check (errmsg, _pk_mi_make_pk_uint (&magnitude, magnitude_object,
errmsg) != -1, "_pk_mi_make_pk_uint failed");
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (offset_obj,
"magnitude", &magnitude_object) != 0, "json type %s does not contain key
\"magnitude\"", _pk_mi_get_json_poke_value_type (offset_obj));
+  PK_MI_CHECK (errmsg, _pk_mi_make_pk_uint (&magnitude, magnitude_object,
errmsg) != -1, "_pk_mi_make_pk_uint failed");

-  pk_mi_check (errmsg, json_object_object_get_ex (offset_obj, "unit",
&unit_object) != 0, "json type %s does not contain key \"unit\"",
_pk_mi_get_json_poke_value_type (offset_obj));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (offset_obj, "unit",
&unit_object) != 0, "json type %s does not contain key \"unit\"",
_pk_mi_get_json_poke_value_type (offset_obj));

   pk_assert (json_object_get_type (unit_object) == json_type_object);

-  pk_mi_check (errmsg, _pk_mi_make_pk_uint (&unit, unit_object, errmsg)
!= -1, "unable to conver offset unit to pk_uint");
+  PK_MI_CHECK (errmsg, _pk_mi_make_pk_uint (&unit, unit_object, errmsg)
!= -1, "unable to conver offset unit to pk_uint");
   pk_assert (pk_uint_size (unit) == 64);

   *pk_offset = pk_make_offset (magnitude, unit);
-  pk_mi_check(errmsg, *pk_offset != PK_NULL, "pk_make_offset failed");
+  PK_MI_CHECK(errmsg, *pk_offset != PK_NULL, "pk_make_offset failed");

   return 0;

@@ -845,7 +845,7 @@ _pk_mi_make_pk_struct (pk_val *pk_struct, struct
json_object *sct_obj, char **er
   pk_val mapping, sct_type, sct_field_name, sct_field_value,
sct_field_offset, sct, *fnames, *ftypes, nfields, name;
   size_t fields_len;

-  pk_mi_check (errmsg, json_object_object_get_ex (sct_obj, "fields",
&search_object) != 0, "json type %s does does not contain key \"fields\"",
_pk_mi_get_json_poke_value_type (sct_obj));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (sct_obj, "fields",
&search_object) != 0, "json type %s does does not contain key \"fields\"",
_pk_mi_get_json_poke_value_type (sct_obj));

   fields_object = search_object;
   pk_assert (json_object_get_type (fields_object) == json_type_array);
@@ -853,7 +853,7 @@ _pk_mi_make_pk_struct (pk_val *pk_struct, struct
json_object *sct_obj, char **er
   fields_len = json_object_array_length (fields_object);

   if (fields_len > 0) {
-    pk_mi_check (errmsg, json_object_object_get_ex (sct_obj, "name",
&search_object) != 0, "json type %s does does not contain key \"name\"",
_pk_mi_get_json_poke_value_type (sct_obj));
+    PK_MI_CHECK (errmsg, json_object_object_get_ex (sct_obj, "name",
&search_object) != 0, "json type %s does does not contain key \"name\"",
_pk_mi_get_json_poke_value_type (sct_obj));
     nfields = pk_make_uint (fields_len, 64);
     name = _pk_mi_json_to_val (search_object, errmsg);
     fnames = pk_alloc (sizeof (pk_val) * fields_len);
@@ -862,13 +862,13 @@ _pk_mi_make_pk_struct (pk_val *pk_struct, struct
json_object *sct_obj, char **er
     sct_type = pk_make_struct_type (nfields, name, fnames, ftypes);
     sct = pk_make_struct (nfields, sct_type);
     for (size_t i = 0 ; i < fields_len ; i++) {
-      pk_mi_check (errmsg, json_object_object_get_ex
(json_object_array_get_idx (fields_object, i), "name", &search_object) !=
0, "json type %s does not contain key \"name\"",
_pk_mi_get_json_poke_value_type (json_object_array_get_idx (fields_object,
i)));
+      PK_MI_CHECK (errmsg, json_object_object_get_ex
(json_object_array_get_idx (fields_object, i), "name", &search_object) !=
0, "json type %s does not contain key \"name\"",
_pk_mi_get_json_poke_value_type (json_object_array_get_idx (fields_object,
i)));
       sct_field_name = _pk_mi_json_to_val (search_object, errmsg);

-      pk_mi_check (errmsg, json_object_object_get_ex
(json_object_array_get_idx (fields_object, i), "value", &search_object) !=
0, "json type %s does not contain key \"value\"",
_pk_mi_get_json_poke_value_type (json_object_array_get_idx (fields_object,
i)));
+      PK_MI_CHECK (errmsg, json_object_object_get_ex
(json_object_array_get_idx (fields_object, i), "value", &search_object) !=
0, "json type %s does not contain key \"value\"",
_pk_mi_get_json_poke_value_type (json_object_array_get_idx (fields_object,
i)));
       sct_field_value = _pk_mi_json_to_val (search_object, errmsg);

-      pk_mi_check (errmsg, json_object_object_get_ex
(json_object_array_get_idx (fields_object, i), "offset", &search_object)
!= 0, "json type %s does not contain key \"offset\"",
_pk_mi_get_json_poke_value_type (json_object_array_get_idx (fields_object,
i)));
+      PK_MI_CHECK (errmsg, json_object_object_get_ex
(json_object_array_get_idx (fields_object, i), "offset", &search_object)
!= 0, "json type %s does not contain key \"offset\"",
_pk_mi_get_json_poke_value_type (json_object_array_get_idx (fields_object,
i)));
       sct_field_offset = _pk_mi_json_to_val (search_object, errmsg);

       pk_assert (pk_type_code (pk_typeof (sct_field_name)) == PK_STRING);
@@ -881,7 +881,7 @@ _pk_mi_make_pk_struct (pk_val *pk_struct, struct
json_object *sct_obj, char **er
       pk_struct_set_field_value (sct, i, sct_field_value);
     }

-    pk_mi_check (errmsg, json_object_object_get_ex (sct_obj, "mapping",
&search_object) != 0, "json type %s does not contain key \"mapping\"",
_pk_mi_get_json_poke_value_type (sct_obj));
+    PK_MI_CHECK (errmsg, json_object_object_get_ex (sct_obj, "mapping",
&search_object) != 0, "json type %s does not contain key \"mapping\"",
_pk_mi_get_json_poke_value_type (sct_obj));
     mapping = pk_mi_make_pk_mapping (search_object, errmsg);
   }
   else {
@@ -905,10 +905,10 @@ _pk_mi_json_array_element_pair (struct json_object
*elements_object, size_t idx,

   element_object = json_object_array_get_idx (elements_object, idx);

-  pk_mi_check (errmsg, json_object_object_get_ex (element_object,
"value", &search_object) != 0, "json type %s does not contain key
\"value\"", _pk_mi_get_json_poke_value_type (element_object));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (element_object,
"value", &search_object) != 0, "json type %s does not contain key
\"value\"", _pk_mi_get_json_poke_value_type (element_object));
   pair[0] =  _pk_mi_json_to_val (search_object, errmsg);

-  pk_mi_check (errmsg, json_object_object_get_ex (element_object,
"offset", &search_object) != 0, "json type %s does not contain key
\"offset\"", _pk_mi_get_json_poke_value_type (element_object));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (element_object,
"offset", &search_object) != 0, "json type %s does not contain key
\"offset\"", _pk_mi_get_json_poke_value_type (element_object));
   pair[1] = _pk_mi_json_to_val (search_object, errmsg);

   return pair;
@@ -925,7 +925,7 @@ _pk_mi_make_pk_array (pk_val *pk_array, struct
json_object *array_obj, char **er
   pk_val mapping, array_etype, array, *element_pair;
   size_t elements_len;

-  pk_mi_check (errmsg, json_object_object_get_ex (array_obj, "elements",
&search_object) != 0, "json type %s does not contain key \"elements\"",
_pk_mi_get_json_poke_value_type (array_obj));
+  PK_MI_CHECK (errmsg, json_object_object_get_ex (array_obj, "elements",
&search_object) != 0, "json type %s does not contain key \"elements\"",
_pk_mi_get_json_poke_value_type (array_obj));

   elements_object = search_object;
   pk_assert (json_object_get_type (elements_object) == json_type_array);
@@ -955,7 +955,7 @@ _pk_mi_make_pk_array (pk_val *pk_array, struct
json_object *array_obj, char **er
       pk_array_set_elem_boffset (array, i, element_pair[1]);
     }

-    pk_mi_check (errmsg, json_object_object_get_ex (array_obj, "mapping",
&search_object) != 0, "json type %s does not contain key \"mapping\"",
_pk_mi_get_json_poke_value_type (array_obj));
+    PK_MI_CHECK (errmsg, json_object_object_get_ex (array_obj, "mapping",
&search_object) != 0, "json type %s does not contain key \"mapping\"",
_pk_mi_get_json_poke_value_type (array_obj));

     mapping = pk_mi_make_pk_mapping (search_object);
   }
@@ -1016,7 +1016,7 @@ _pk_mi_json_to_val (struct json_object *obj, char
**errmsg)
     poke_value = PK_NULL;
   }
   else {
-    pk_mi_set_errmsg (errmsg, "An error happened, this is a bug.");
+    PK_MI_SET_ERRMSG (errmsg, "An error happened, this is a bug.");
     return PK_NULL;
   }

@@ -1039,10 +1039,10 @@ pk_mi_json_to_val (const char *poke_object_str,
char **errmsg)
     poke_object = json_tokener_parse_ex (tok, poke_object_str, strlen
(poke_object_str));
   } while ((jerr = json_tokener_get_error (tok)) == json_tokener_continue);

-  pk_mi_check(errmsg, jerr == json_tokener_success, "%s",
json_tokener_error_desc (jerr));
+  PK_MI_CHECK(errmsg, jerr == json_tokener_success, "%s",
json_tokener_error_desc (jerr));

   search_object = json_object_object_get (poke_object, "PokeValue");
-  pk_mi_check(errmsg, search_object != NULL, "Not a valid PokeValue
object");
+  PK_MI_CHECK(errmsg, search_object != NULL, "Not a valid PokeValue
object");




reply via email to

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