ci: fix vls compilation

pull/13261/head
Delyan Angelov 2022-01-22 23:08:30 +02:00
parent 62c3ad4953
commit 9057e9f1dd
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 20 additions and 5 deletions

View File

@ -47,14 +47,29 @@ fn (mut g Gen) gen_jsons() {
dec_fn_name := js_dec_name(styp) dec_fn_name := js_dec_name(styp)
dec_fn_dec := 'Option_$styp ${dec_fn_name}(cJSON* root)' dec_fn_dec := 'Option_$styp ${dec_fn_name}(cJSON* root)'
init_styp := g.expr_string(ast.Expr(ast.StructInit{ mut init_styp := '$styp res'
typ: utyp if sym.kind == .struct_ {
typ_str: styp 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.writeln('
$dec_fn_dec { $dec_fn_dec {
$styp res = $init_styp; $init_styp;
if (!root) { if (!root) {
const char *error_ptr = cJSON_GetErrorPtr(); const char *error_ptr = cJSON_GetErrorPtr();
if (error_ptr != NULL) { if (error_ptr != NULL) {