cgen: handle C typedefs
parent
440f1cf4c6
commit
95a1bd8470
|
@ -159,9 +159,12 @@ pub fn (g mut Gen) typ(t table.Type) string {
|
|||
if styp.starts_with('C__') {
|
||||
styp = styp[3..]
|
||||
if sym.kind == .struct_ {
|
||||
info := sym.info as table.Struct
|
||||
if !info.is_typedef {
|
||||
styp = 'struct $styp'
|
||||
}
|
||||
}
|
||||
}
|
||||
if table.type_is(t, .optional) {
|
||||
styp = 'Option_' + styp
|
||||
if !(styp in g.optionals) {
|
||||
|
|
|
@ -1475,6 +1475,7 @@ fn (p mut Parser) struct_decl() ast.StructDecl {
|
|||
p.next() // C
|
||||
p.next() // .
|
||||
}
|
||||
is_typedef := p.attr == 'typedef'
|
||||
mut name := p.check_name()
|
||||
mut default_exprs := []ast.Expr
|
||||
// println('struct decl $name')
|
||||
|
@ -1544,6 +1545,7 @@ fn (p mut Parser) struct_decl() ast.StructDecl {
|
|||
name: name
|
||||
info: table.Struct{
|
||||
fields: fields
|
||||
is_typedef: is_typedef
|
||||
}
|
||||
}
|
||||
mut ret := 0
|
||||
|
|
|
@ -539,6 +539,7 @@ pub fn (kinds []Kind) str() string {
|
|||
pub struct Struct {
|
||||
pub mut:
|
||||
fields []Field
|
||||
is_typedef bool // C. [typedef]
|
||||
}
|
||||
|
||||
pub struct Enum {
|
||||
|
|
Loading…
Reference in New Issue