X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwrap-json.c;h=6bf6f4fe74d9102ddc5871d96bea0d556dfad2d7;hb=8aac4b82fa18fe6f0feacac86fdde3d78b19cd18;hp=6e604769b236000d5c410f202b713ebde14563b6;hpb=2e2bfa31dc97159b7630c3c2913a49147be818d2;p=src%2Fapp-framework-binder.git diff --git a/src/wrap-json.c b/src/wrap-json.c index 6e604769..6bf6f4fe 100644 --- a/src/wrap-json.c +++ b/src/wrap-json.c @@ -815,7 +815,7 @@ int wrap_json_check(struct json_object *object, const char *desc, ...) va_list args; va_start(args, desc); - rc = vunpack(object, desc, args, 0); + rc = wrap_json_vcheck(object, desc, args); va_end(args); return rc; } @@ -831,9 +831,9 @@ int wrap_json_match(struct json_object *object, const char *desc, ...) va_list args; va_start(args, desc); - rc = vunpack(object, desc, args, 0); + rc = wrap_json_vmatch(object, desc, args); va_end(args); - return !rc; + return rc; } int wrap_json_vunpack(struct json_object *object, const char *desc, va_list args) @@ -992,9 +992,13 @@ struct json_object *wrap_json_clone_depth(struct json_object *item, int depth) } /** - * Clones the 'object': returns a copy of it. But doen't clones + * Clones the 'object': returns a copy of it. But doesn't clones * the content. Synonym of wrap_json_clone_depth(object, 1). * + * Be aware that this implementation doesn't clones content that is deeper + * than 1 but it does link these contents to the original object and + * increments their use count. So, everything deeper that 1 is still available. + * * @param object the object to clone * * @return a copy of the object. @@ -1247,6 +1251,9 @@ int wrap_json_contains(struct json_object *x, struct json_object *y) #if defined(WRAP_JSON_TEST) #include +#if !defined(JSON_C_TO_STRING_NOSLASHESCAPE) +#define JSON_C_TO_STRING_NOSLASHESCAPE 0 +#endif void tclone(struct json_object *object) { @@ -1254,12 +1261,12 @@ void tclone(struct json_object *object) o = wrap_json_clone(object); if (!wrap_json_equal(object, o)) - printf("ERROR in clone or equal: %s VERSUS %s\n", json_object_to_json_string(object), json_object_to_json_string(o)); + printf("ERROR in clone or equal: %s VERSUS %s\n", json_object_to_json_string_ext(object, JSON_C_TO_STRING_NOSLASHESCAPE), json_object_to_json_string_ext(o, JSON_C_TO_STRING_NOSLASHESCAPE)); json_object_put(o); o = wrap_json_clone_deep(object); if (!wrap_json_equal(object, o)) - printf("ERROR in clone_deep or equal: %s VERSUS %s\n", json_object_to_json_string(object), json_object_to_json_string(o)); + printf("ERROR in clone_deep or equal: %s VERSUS %s\n", json_object_to_json_string_ext(object, JSON_C_TO_STRING_NOSLASHESCAPE), json_object_to_json_string_ext(o, JSON_C_TO_STRING_NOSLASHESCAPE)); json_object_put(o); } @@ -1273,7 +1280,7 @@ void p(const char *desc, ...) rc = wrap_json_vpack(&result, desc, args); va_end(args); if (!rc) - printf(" SUCCESS %s\n\n", json_object_to_json_string(result)); + printf(" SUCCESS %s\n\n", json_object_to_json_string_ext(result, JSON_C_TO_STRING_NOSLASHESCAPE)); else printf(" ERROR[char %d err %d] %s\n\n", wrap_json_get_error_position(rc), wrap_json_get_error_code(rc), wrap_json_get_error_string(rc)); tclone(result); @@ -1327,8 +1334,8 @@ void u(const char *value, const char *desc, ...) case 'I': printf(" I:%lld", *va_arg(args, int64_t*)); k = m&1; break; case 'f': printf(" f:%f", *va_arg(args, double*)); k = m&1; break; case 'F': printf(" F:%f", *va_arg(args, double*)); k = m&1; break; - case 'o': printf(" o:%s", json_object_to_json_string(*va_arg(args, struct json_object**))); k = m&1; break; - case 'O': o = *va_arg(args, struct json_object**); printf(" O:%s", json_object_to_json_string(o)); json_object_put(o); k = m&1; break; + case 'o': printf(" o:%s", json_object_to_json_string_ext(*va_arg(args, struct json_object**), JSON_C_TO_STRING_NOSLASHESCAPE)); k = m&1; break; + case 'O': o = *va_arg(args, struct json_object**); printf(" O:%s", json_object_to_json_string_ext(o, JSON_C_TO_STRING_NOSLASHESCAPE)); json_object_put(o); k = m&1; break; case 'y': case 'Y': { uint8_t *p = *va_arg(args, uint8_t**);