Skip to content

Commit 7f93f9a

Browse files
committed
ci: revert the part of f665055 that affected vlib/v/, to fix the failing jobs asap
1 parent 24eb6ef commit 7f93f9a

3 files changed

Lines changed: 5 additions & 32 deletions

File tree

‎vlib/v/gen/c/auto_str_methods.v‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,15 +1034,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin
10341034
if base_typ.has_flag(.shared_f) {
10351035
base_typ = base_typ.clear_flag(.shared_f).deref()
10361036
}
1037-
// For C structs, voidptr/byteptr fields in V may have different actual types in C headers,
1038-
// so we use string format instead of pointer format to avoid invalid casts.
1039-
// charptr fields are excluded as they are properly handled by builtin__tos4.
1040-
mut base_fmt := g.type_to_fmt(base_typ)
1041-
is_c_voidptr_field := is_c_struct && field.typ in ast.cptr_types
1042-
&& field.typ !in ast.charptr_types
1043-
if is_c_voidptr_field {
1044-
base_fmt = .si_s
1045-
}
1037+
base_fmt := g.type_to_fmt(base_typ)
10461038
is_opt_field := field.typ.has_flag(.option)
10471039

10481040
// 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
11041096
it_field_name := 'it${op}${field_name}'
11051097
if ftyp_nr_muls > 1 || field.typ in ast.cptr_types {
11061098
if is_opt_field {
1107-
} else if is_c_voidptr_field {
1108-
// For C structs, the actual type may differ from V's declaration,
1109-
// so we just output a placeholder instead of trying to cast
1110-
func = '_S("<cptr>")'
1111-
caller_should_free = false
11121099
} else {
11131100
func = '(voidptr) ${it_field_name}'
11141101
caller_should_free = false
@@ -1149,8 +1136,8 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin
11491136
fn_body.write_string('${funcprefix}_S("<circular>")')
11501137
}
11511138
} else {
1152-
// manage C charptr (but not our placeholder for C struct voidptr fields)
1153-
if field.typ in ast.charptr_types && !is_c_voidptr_field {
1139+
// manage C charptr
1140+
if field.typ in ast.charptr_types {
11541141
fn_body.write_string('builtin__tos4((byteptr)${func})')
11551142
} else {
11561143
if field.typ.is_ptr() && sym.kind in [.struct, .interface] {

‎vlib/v/gen/c/str_intp.v‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ fn (mut g Gen) str_format(node ast.StringInterLiteral, i int, fmts []u8) (u64, s
165165
}
166166
}
167167
} else {
168-
// For unknown types (like C structs), use string format
169-
// so that their str() method will be called
170-
fmt_type = .si_s
168+
// TODO: better check this case
169+
fmt_type = .si_p
171170
}
172171

173172
/*

‎vlib/v/tests/printing_c_structs/cstruct.h‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,3 @@
22
struct Abc {
33
char *char_pointer_field;
44
};
5-
6-
// Simulates a struct like FT_Generic which is a struct, not a pointer
7-
struct InnerStruct {
8-
int x;
9-
int y;
10-
};
11-
12-
// Simulates a struct like FT_FaceRec which has InnerStruct fields
13-
// that might be declared as voidptr in V bindings
14-
struct OuterStruct {
15-
int id;
16-
struct InnerStruct inner; // This is a struct value, not a pointer
17-
};

0 commit comments

Comments
 (0)