1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: fix failing -Werror steps for code generated by json.encode(map{'a': []string{}})

This commit is contained in:
Delyan Angelov
2021-03-18 11:58:32 +02:00
parent f7a8a460f6
commit 7bbcf02134
2 changed files with 26 additions and 26 deletions

View File

@@ -11,9 +11,23 @@ module json
struct C.cJSON {
valueint int
valuedouble f32
valuestring byteptr
valuestring charptr
}
fn C.cJSON_IsTrue(&C.cJSON) bool
fn C.cJSON_CreateNumber(int) &C.cJSON
fn C.cJSON_CreateBool(bool) &C.cJSON
fn C.cJSON_CreateString(charptr) &C.cJSON
fn C.cJSON_Parse(charptr) &C.cJSON
fn C.cJSON_PrintUnformatted(&C.cJSON) charptr
fn C.cJSON_Print(&C.cJSON) charptr
pub fn decode(typ voidptr, s string) ?voidptr {
// compiler implementation
return 0
@@ -108,23 +122,9 @@ fn decode_string(root &C.cJSON) string {
}
// println('decode string valuestring="$root.valuestring"')
// return tos(root.valuestring, _strlen(root.valuestring))
return unsafe { tos_clone(root.valuestring) } // , _strlen(root.valuestring))
return unsafe { tos_clone(byteptr(root.valuestring)) } // , _strlen(root.valuestring))
}
fn C.cJSON_IsTrue(voidptr) bool
fn C.cJSON_CreateNumber(int) &C.cJSON
fn C.cJSON_CreateBool(bool) &C.cJSON
fn C.cJSON_CreateString(charptr) &C.cJSON
fn C.cJSON_Parse(charptr) &C.cJSON
fn C.cJSON_PrintUnformatted(voidptr) byteptr
fn C.cJSON_Print(voidptr) byteptr
fn decode_bool(root &C.cJSON) bool {
if isnil(root) {
return false
@@ -178,24 +178,24 @@ fn encode_bool(val bool) &C.cJSON {
}
fn encode_string(val string) &C.cJSON {
return C.cJSON_CreateString(val.str)
return C.cJSON_CreateString(charptr(val.str))
}
// ///////////////////////
// user := decode_User(json_parse(js_string_var))
fn json_parse(s string) &C.cJSON {
return C.cJSON_Parse(s.str)
return C.cJSON_Parse(charptr(s.str))
}
// json_string := json_print(encode_User(user))
fn json_print(json &C.cJSON) string {
s := C.cJSON_PrintUnformatted(json)
return unsafe { tos(s, C.strlen(s)) }
return unsafe { tos(byteptr(s), C.strlen(s)) }
}
fn json_print_pretty(json &C.cJSON) string {
s := C.cJSON_Print(json)
return unsafe { tos(s, C.strlen(s)) }
return unsafe { tos(byteptr(s), C.strlen(s)) }
}
// / cjson wrappers