OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Cgo; see gmp.go for an overview. | 5 // Cgo; see gmp.go for an overview. |
6 | 6 |
7 // TODO(rsc): | 7 // TODO(rsc): |
8 // Emit correct line number annotations. | 8 // Emit correct line number annotations. |
9 // Make 6g understand the annotations. | 9 // Make 6g understand the annotations. |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 // A FuncType collects information about a function type in both the C and Go wo
rlds. | 93 // A FuncType collects information about a function type in both the C and Go wo
rlds. |
94 type FuncType struct { | 94 type FuncType struct { |
95 Params []*Type | 95 Params []*Type |
96 Result *Type | 96 Result *Type |
97 Go *ast.FuncType | 97 Go *ast.FuncType |
98 } | 98 } |
99 | 99 |
100 func usage() { | 100 func usage() { |
101 » fmt.Fprint(os.Stderr, "usage: cgo [compiler options] file.go ...\n") | 101 » fmt.Fprint(os.Stderr, "usage: cgo -- [compiler options] file.go ...\n") |
| 102 » flag.PrintDefaults() |
102 os.Exit(2) | 103 os.Exit(2) |
103 } | 104 } |
104 | 105 |
105 var ptrSizeMap = map[string]int64{ | 106 var ptrSizeMap = map[string]int64{ |
106 "386": 4, | 107 "386": 4, |
107 "amd64": 8, | 108 "amd64": 8, |
108 "arm": 4, | 109 "arm": 4, |
109 } | 110 } |
110 | 111 |
111 var cPrefix string | 112 var cPrefix string |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 p.Name[k] = v | 249 p.Name[k] = v |
249 } else if !reflect.DeepEqual(p.Name[k], v) { | 250 } else if !reflect.DeepEqual(p.Name[k], v) { |
250 error(token.NoPos, "inconsistent definitions for
C.%s", k) | 251 error(token.NoPos, "inconsistent definitions for
C.%s", k) |
251 } | 252 } |
252 } | 253 } |
253 } | 254 } |
254 | 255 |
255 p.ExpFunc = append(p.ExpFunc, f.ExpFunc...) | 256 p.ExpFunc = append(p.ExpFunc, f.ExpFunc...) |
256 p.Decl = append(p.Decl, f.AST.Decls...) | 257 p.Decl = append(p.Decl, f.AST.Decls...) |
257 } | 258 } |
OLD | NEW |