v.ast,v.fmt: support attributes on FnTypeDecl too
parent
778614bcc9
commit
e99059471b
|
|
@ -1152,6 +1152,7 @@ pub:
|
|||
pos token.Pos
|
||||
type_pos token.Pos
|
||||
comments []Comment
|
||||
attrs []Attr // attributes of type declaration
|
||||
}
|
||||
|
||||
// TODO: handle this differently
|
||||
|
|
|
|||
|
|
@ -1290,6 +1290,7 @@ pub fn (mut f Fmt) alias_type_decl(node ast.AliasTypeDecl) {
|
|||
}
|
||||
|
||||
pub fn (mut f Fmt) fn_type_decl(node ast.FnTypeDecl) {
|
||||
f.attrs(node.attrs)
|
||||
if node.is_pub {
|
||||
f.write('pub ')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
[callconv: 'stdcall']
|
||||
fn C.DefWindowProc(hwnd int, msg int, lparam int, wparam int)
|
||||
|
||||
[callconv: 'stdcall']
|
||||
type FastFn = fn (int) bool
|
||||
|
||||
[callconv: 'fastcall']
|
||||
fn zzz(x int, y int) int {
|
||||
return x + y * 2
|
||||
}
|
||||
|
|
@ -3579,6 +3579,8 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
|
|||
p.table.sym(fn_type).is_pub = is_pub
|
||||
type_pos = type_pos.extend(p.tok.pos())
|
||||
comments = p.eat_comments(same_line: true)
|
||||
attrs := p.attrs
|
||||
p.attrs = []
|
||||
return ast.FnTypeDecl{
|
||||
name: fn_name
|
||||
is_pub: is_pub
|
||||
|
|
@ -3586,6 +3588,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
|
|||
pos: decl_pos
|
||||
type_pos: type_pos
|
||||
comments: comments
|
||||
attrs: attrs
|
||||
}
|
||||
}
|
||||
sum_variants << p.parse_sum_type_variants()
|
||||
|
|
|
|||
Loading…
Reference in New Issue