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__') {
|
if styp.starts_with('C__') {
|
||||||
styp = styp[3..]
|
styp = styp[3..]
|
||||||
if sym.kind == .struct_ {
|
if sym.kind == .struct_ {
|
||||||
|
info := sym.info as table.Struct
|
||||||
|
if !info.is_typedef {
|
||||||
styp = 'struct $styp'
|
styp = 'struct $styp'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if table.type_is(t, .optional) {
|
if table.type_is(t, .optional) {
|
||||||
styp = 'Option_' + styp
|
styp = 'Option_' + styp
|
||||||
if !(styp in g.optionals) {
|
if !(styp in g.optionals) {
|
||||||
|
|
|
@ -1475,6 +1475,7 @@ fn (p mut Parser) struct_decl() ast.StructDecl {
|
||||||
p.next() // C
|
p.next() // C
|
||||||
p.next() // .
|
p.next() // .
|
||||||
}
|
}
|
||||||
|
is_typedef := p.attr == 'typedef'
|
||||||
mut name := p.check_name()
|
mut name := p.check_name()
|
||||||
mut default_exprs := []ast.Expr
|
mut default_exprs := []ast.Expr
|
||||||
// println('struct decl $name')
|
// println('struct decl $name')
|
||||||
|
@ -1544,6 +1545,7 @@ fn (p mut Parser) struct_decl() ast.StructDecl {
|
||||||
name: name
|
name: name
|
||||||
info: table.Struct{
|
info: table.Struct{
|
||||||
fields: fields
|
fields: fields
|
||||||
|
is_typedef: is_typedef
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mut ret := 0
|
mut ret := 0
|
||||||
|
|
|
@ -539,6 +539,7 @@ pub fn (kinds []Kind) str() string {
|
||||||
pub struct Struct {
|
pub struct Struct {
|
||||||
pub mut:
|
pub mut:
|
||||||
fields []Field
|
fields []Field
|
||||||
|
is_typedef bool // C. [typedef]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Enum {
|
pub struct Enum {
|
||||||
|
|
Loading…
Reference in New Issue