From 9057e9f1dd594c4da2ffad8765a0525a08d2932c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 22 Jan 2022 23:08:30 +0200 Subject: [PATCH] ci: fix vls compilation --- vlib/v/gen/c/json.v | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/vlib/v/gen/c/json.v b/vlib/v/gen/c/json.v index 626caff2c7..40619accbe 100644 --- a/vlib/v/gen/c/json.v +++ b/vlib/v/gen/c/json.v @@ -47,14 +47,29 @@ fn (mut g Gen) gen_jsons() { dec_fn_name := js_dec_name(styp) dec_fn_dec := 'Option_$styp ${dec_fn_name}(cJSON* root)' - init_styp := g.expr_string(ast.Expr(ast.StructInit{ - typ: utyp - typ_str: styp - })) + mut init_styp := '$styp res' + if sym.kind == .struct_ { + mut skips := 0 + info := sym.info as ast.Struct + for field in info.fields { + for attr in field.attrs { + if attr.name == 'skip' { + skips++ + } + } + } + if skips > 0 { + init_styp += ' = ' + init_styp += g.expr_string(ast.Expr(ast.StructInit{ + typ: utyp + typ_str: styp + })) + } + } dec.writeln(' $dec_fn_dec { - $styp res = $init_styp; + $init_styp; if (!root) { const char *error_ptr = cJSON_GetErrorPtr(); if (error_ptr != NULL) {