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

run vfmt on http, net, sync, strconv

This commit is contained in:
Alexander Medvednikov
2019-12-22 01:41:42 +03:00
parent 28ecfb231d
commit 848cd3cb3e
18 changed files with 523 additions and 404 deletions

View File

@@ -1,13 +1,11 @@
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module json
#flag -I @VROOT/thirdparty/cJSON
#flag @VROOT/thirdparty/cJSON/cJSON.o
#include "cJSON.h"
struct C.cJSON {
valueint int
valuedouble f32
@@ -39,7 +37,7 @@ fn jsdecode_i64(root &C.cJSON) i64 {
if isnil(root) {
return i64(0)
}
return i64(root.valuedouble) //i64 is double in C
return i64(root.valuedouble) // i64 is double in C
}
fn jsdecode_byte(root &C.cJSON) byte {
@@ -84,7 +82,6 @@ fn jsdecode_f64(root &C.cJSON) f64 {
return f64(root.valuedouble)
}
fn jsdecode_string(root &C.cJSON) string {
if isnil(root) {
return ''
@@ -94,16 +91,27 @@ fn jsdecode_string(root &C.cJSON) string {
}
// println('jsdecode string valuestring="$root.valuestring"')
// return tos(root.valuestring, _strlen(root.valuestring))
return tos_clone(root.valuestring)// , _strlen(root.valuestring))
return tos_clone(root.valuestring) // , _strlen(root.valuestring))
}
fn C.cJSON_IsTrue() bool
fn C.cJSON_CreateNumber() &C.cJSON
fn C.cJSON_CreateBool() &C.cJSON
fn C.cJSON_CreateString() &C.cJSON
fn C.cJSON_Parse() &C.cJSON
fn C.cJSON_PrintUnformatted() byteptr
fn jsdecode_bool(root &C.cJSON) bool {
if isnil(root) {
return false
@@ -161,7 +169,6 @@ fn jsencode_string(val string) &C.cJSON {
return C.cJSON_CreateString(clone.str)
// return C.cJSON_CreateString2(val.str, val.len)
}
// ///////////////////////
// user := decode_User(json_parse(js_string_var))
fn json_parse(s string) &C.cJSON {
@@ -178,3 +185,4 @@ fn json_print(json &C.cJSON) string {
// fn json_array_for_each(val, root &C.cJSON) {
// #cJSON_ArrayForEach (val ,root)
// }