func (p *cgoPackage) addFuncPtrDecls() {
	if len(p.functions) == 0 {
		return
	}
	gen := &ast.GenDecl{
		TokPos: token.NoPos,
		Tok:    token.VAR,
		Lparen: token.NoPos,
		Rparen: token.NoPos,
	}
	names := make([]string, 0, len(p.functions))
	for name := range p.functions {
		names = append(names, name)
	}
	sort.Strings(names)
	for _, name := range names {
		fn := p.functions[name]
		obj := &ast.Object{
			Kind: ast.Typ,
			Name: "C." + name + "$funcaddr",
		}
		valueSpec := &ast.ValueSpec{
			Names: []*ast.Ident{&ast.Ident{
				NamePos: fn.pos,
				Name:    "C." + name + "$funcaddr",
				Obj:     obj,
			}},
			Type: &ast.SelectorExpr{
				X: &ast.Ident{
					NamePos: fn.pos,
					Name:    "unsafe",
				},
				Sel: &ast.Ident{
					NamePos: fn.pos,
					Name:    "Pointer",
				},
			},
		}
		obj.Decl = valueSpec
		gen.Specs = append(gen.Specs, valueSpec)
	}
	p.generated.Decls = append(p.generated.Decls, gen)
}
// addFuncPtrDecls creates stub declarations of function pointer values. These
// values will later be replaced with the real values in the compiler.
// It adds code like the following to the AST:
//
//     var (
//         C.add unsafe.Pointer
//         C.mul unsafe.Pointer
//         // ...
//     )
addFuncPtrDecls creates stub declarations of function pointer values. These
values will later be replaced with the real values in the compiler.
It adds code like the following to the AST.

var (
C.add unsafe.Pointer
C.mul unsafe.Pointer

)
// addFuncPtrDecls creates stub declarations of function pointer values . These // values will later be replaced with the real values in the compiler . // It adds code like the following to the AST : // // var ( // C . add unsafe . Pointer // C . mul unsafe . Pointer // // ... // )
func (p *cgoPackage) addFuncPtrDecls() {
	if len(p.functions) == 0 {
		return
	}
	gen := &ast.GenDecl{
		TokPos: token.NoPos,
		Tok:    token.VAR,
		Lparen: token.NoPos,
		Rparen: token.NoPos,
	}
	names := make([]string, 0, len(p.functions))
	for name := range p.functions {
		names = append(names, name)
	}
	sort.Strings(names)
	for _, name := range names {
		fn := p.functions[name]
		obj := &ast.Object{
			Kind: ast.Typ,
			Name: "C." + name + "$funcaddr",
		}
		valueSpec := &ast.ValueSpec{
			Names: []*ast.Ident{&ast.Ident{
				NamePos: fn.pos,
				Name:    "C." + name + "$funcaddr",
				Obj:     obj,
			}},
			Type: &ast.SelectorExpr{
				X: &ast.Ident{
					NamePos: fn.pos,
					Name:    "unsafe",
				},
				Sel: &ast.Ident{
					NamePos: fn.pos,
					Name:    "Pointer",
				},
			},
		}
		obj.Decl = valueSpec
		gen.Specs = append(gen.Specs, valueSpec)
	}
	p.generated.Decls = append(p.generated.Decls, gen)
}
func ( p * cgoPackage ) addFuncPtrDecls ( ) { if len ( p . functions ) == 0 { return } gen := & ast . GenDecl { TokPos : token . NoPos , Tok : token . VAR , Lparen : token . NoPos , Rparen : token . NoPos , } names := make ( [ ] string , 0 , len ( p . functions ) ) for name := range p . functions { names = append ( names , name ) } sort . Strings ( names ) for _ , name := range names { fn := p . functions [ name ] obj := & ast . Object { Kind : ast . Typ , Name : " " + name + " " , } valueSpec := & ast . ValueSpec { Names : [ ] * ast . Ident { & ast . Ident { NamePos : fn . pos , Name : " " + name + " " , Obj : obj , } } , Type : & ast . SelectorExpr { X : & ast . Ident { NamePos : fn . pos , Name : " " , } , Sel : & ast . Ident { NamePos : fn . pos , Name : " " , } , } , } obj . Decl = valueSpec gen . Specs = append ( gen . Specs , valueSpec ) } p . generated . Decls = append ( p . generated . Decls , gen ) }
addFuncPtrDecls creates stub declarations of function pointer values.
addFuncPtrDecls creates stub declarations of function pointer values .