mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix interface struct sorting
This commit is contained in:
parent
51d0ce0222
commit
98cd013908
@ -599,11 +599,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
|
||||
}
|
||||
ast.Import {}
|
||||
ast.InterfaceDecl {
|
||||
g.definitions.writeln('//interface')
|
||||
g.definitions.writeln('typedef struct {')
|
||||
g.definitions.writeln('\tvoid* _object;')
|
||||
g.definitions.writeln('\tint _interface_idx;')
|
||||
g.definitions.writeln('} $it.name;')
|
||||
// definitions are sorted and added in write_types
|
||||
}
|
||||
ast.Module {
|
||||
g.is_builtin_mod = it.name == 'builtin'
|
||||
@ -2271,6 +2267,13 @@ int typ;
|
||||
g.definitions.writeln('typedef $fixed $styp [$len];')
|
||||
// }
|
||||
}
|
||||
table.Interface {
|
||||
g.definitions.writeln('//interface')
|
||||
g.definitions.writeln('typedef struct {')
|
||||
g.definitions.writeln('\tvoid* _object;')
|
||||
g.definitions.writeln('\tint _interface_idx;')
|
||||
g.definitions.writeln('} $typ.name;')
|
||||
}
|
||||
else {}
|
||||
}
|
||||
}
|
||||
@ -2287,6 +2290,7 @@ fn (g Gen) sort_structs(typesa []table.TypeSymbol) []table.TypeSymbol {
|
||||
// loop over types
|
||||
for t in typesa {
|
||||
if t.kind == .interface_ {
|
||||
dep_graph.add(t.name, [])
|
||||
continue
|
||||
}
|
||||
// create list of deps
|
||||
|
@ -81,7 +81,7 @@ interface Speaker2 {
|
||||
|
||||
|
||||
struct Foo {
|
||||
//speaker Speaker
|
||||
//speakers []Speaker
|
||||
speaker Speaker
|
||||
speakers []Speaker
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user