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

cgen: fix c struct str method (#8117)

This commit is contained in:
yuyi 2021-01-15 14:51:28 +08:00 committed by GitHub
parent 20c80db426
commit c6099df418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -281,7 +281,7 @@ fn (mut g Gen) gen_str_for_array_fixed(info table.ArrayFixed, styp string, str_f
} else {
g.auto_str_funcs.writeln('\tfor (int i = 0; i < $info.size; ++i) {')
if sym.kind == .struct_ && !sym_has_str_method {
g.auto_str_funcs.writeln('\t\tstrings__Builder_write(&sb, ${elem_str_fn_name}(a[i], indent_count));')
g.auto_str_funcs.writeln('\t\tstrings__Builder_write(&sb, ${elem_str_fn_name}(a[i]));')
} else if sym.kind in [.f32, .f64] {
g.auto_str_funcs.writeln('\t\tstrings__Builder_write(&sb, _STR("%g", 1, a[i]));')
} else if sym.kind == .string {
@ -631,5 +631,5 @@ fn (mut g Gen) gen_str_for_fn_type(info table.FnType, styp string, str_fn_name s
[inline]
fn styp_to_str_fn_name(styp string) string {
return styp.replace_each(['*', '', '.', '__']) + '_str'
return styp.replace_each(['*', '', '.', '__', ' ', '__']) + '_str'
}