From 7f93f9adb968b9487cc556f89d97036cbe288e51 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 27 Jan 2026 12:01:14 +0200 Subject: [PATCH] ci: revert the part of f665055 that affected vlib/v/, to fix the failing jobs asap --- vlib/v/gen/c/auto_str_methods.v | 19 +++---------------- vlib/v/gen/c/str_intp.v | 5 ++--- vlib/v/tests/printing_c_structs/cstruct.h | 13 ------------- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/vlib/v/gen/c/auto_str_methods.v b/vlib/v/gen/c/auto_str_methods.v index 168a4780a..6fd1585d5 100644 --- a/vlib/v/gen/c/auto_str_methods.v +++ b/vlib/v/gen/c/auto_str_methods.v @@ -1034,15 +1034,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin if base_typ.has_flag(.shared_f) { base_typ = base_typ.clear_flag(.shared_f).deref() } - // For C structs, voidptr/byteptr fields in V may have different actual types in C headers, - // so we use string format instead of pointer format to avoid invalid casts. - // charptr fields are excluded as they are properly handled by builtin__tos4. - mut base_fmt := g.type_to_fmt(base_typ) - is_c_voidptr_field := is_c_struct && field.typ in ast.cptr_types - && field.typ !in ast.charptr_types - if is_c_voidptr_field { - base_fmt = .si_s - } + base_fmt := g.type_to_fmt(base_typ) is_opt_field := field.typ.has_flag(.option) // manage prefix and quote symbol for the filed @@ -1104,11 +1096,6 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin it_field_name := 'it${op}${field_name}' if ftyp_nr_muls > 1 || field.typ in ast.cptr_types { if is_opt_field { - } else if is_c_voidptr_field { - // For C structs, the actual type may differ from V's declaration, - // so we just output a placeholder instead of trying to cast - func = '_S("")' - caller_should_free = false } else { func = '(voidptr) ${it_field_name}' caller_should_free = false @@ -1149,8 +1136,8 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin fn_body.write_string('${funcprefix}_S("")') } } else { - // manage C charptr (but not our placeholder for C struct voidptr fields) - if field.typ in ast.charptr_types && !is_c_voidptr_field { + // manage C charptr + if field.typ in ast.charptr_types { fn_body.write_string('builtin__tos4((byteptr)${func})') } else { if field.typ.is_ptr() && sym.kind in [.struct, .interface] { diff --git a/vlib/v/gen/c/str_intp.v b/vlib/v/gen/c/str_intp.v index 4db5a32d5..a1045195c 100644 --- a/vlib/v/gen/c/str_intp.v +++ b/vlib/v/gen/c/str_intp.v @@ -165,9 +165,8 @@ fn (mut g Gen) str_format(node ast.StringInterLiteral, i int, fmts []u8) (u64, s } } } else { - // For unknown types (like C structs), use string format - // so that their str() method will be called - fmt_type = .si_s + // TODO: better check this case + fmt_type = .si_p } /* diff --git a/vlib/v/tests/printing_c_structs/cstruct.h b/vlib/v/tests/printing_c_structs/cstruct.h index 0d9839311..7ab558783 100644 --- a/vlib/v/tests/printing_c_structs/cstruct.h +++ b/vlib/v/tests/printing_c_structs/cstruct.h @@ -2,16 +2,3 @@ struct Abc { char *char_pointer_field; }; - -// Simulates a struct like FT_Generic which is a struct, not a pointer -struct InnerStruct { - int x; - int y; -}; - -// Simulates a struct like FT_FaceRec which has InnerStruct fields -// that might be declared as voidptr in V bindings -struct OuterStruct { - int id; - struct InnerStruct inner; // This is a struct value, not a pointer -}; -- 2.39.5