Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions internal/codegen/parser/libvirtxml.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ func (r *LibvirtXMLReflector) ReflectStruct(structType reflect.Type) (*generator
continue
}

if field.Anonymous {
if field.Type.Kind() == reflect.Struct {
embeddedIR, err := r.ReflectStruct(field.Type)
if err != nil {
return nil, fmt.Errorf("analyzing embedded struct %s: %w", field.Type.Name(), err)
}
ir.Fields = append(ir.Fields, embeddedIR.Fields...)
}
continue
}

fieldIR, err := r.analyzeField(typeName, field)
if err != nil {
return nil, fmt.Errorf("analyzing field %s: %w", field.Name, err)
Expand Down Expand Up @@ -248,11 +259,6 @@ func (r *LibvirtXMLReflector) analyzeField(structName string, field reflect.Stru
return nil, nil
}

// Skip embedded/anonymous fields
if field.Anonymous {
return nil, nil
}

xmlTag := field.Tag.Get("xml")
if xmlTag == "" {
// Skip fields without XML tags
Expand Down