func (p *cgoPackage) walker(cursor *astutil.Cursor) bool {
	switch node := cursor.Node().(type) {
	case *ast.CallExpr:
		fun, ok := node.Fun.(*ast.SelectorExpr)
		if !ok {
			return true
		}
		x, ok := fun.X.(*ast.Ident)
		if !ok {
			return true
		}
		if _, ok := p.functions[fun.Sel.Name]; ok && x.Name == "C" {
			node.Fun = &ast.Ident{
				NamePos: x.NamePos,
				Name:    "C." + fun.Sel.Name,
			}
		}
	case *ast.SelectorExpr:
		x, ok := node.X.(*ast.Ident)
		if !ok {
			return true
		}
		if x.Name == "C" {
			name := "C." + node.Sel.Name
			if _, ok := p.functions[node.Sel.Name]; ok {
				name += "$funcaddr"
			}
			cursor.Replace(&ast.Ident{
				NamePos: x.NamePos,
				Name:    name,
			})
		}
	}
	return true
}
// walker replaces all "C".<something> expressions to literal "C.<something>"
// expressions. Such expressions are impossible to write in Go (a dot cannot be
// used in the middle of a name) so in practice all C identifiers live in a
// separate namespace (no _Cgo_ hacks like in gc).
walker replaces all "C". expressions to literal "C."
expressions. Such expressions are impossible to write in Go (a dot cannot be
used in the middle of a name) so in practice all C identifiers live in a
separate namespace (no _Cgo_ hacks like in gc).
// walker replaces all " C " . <something > expressions to literal " C . <something > " // expressions . Such expressions are impossible to write in Go ( a dot cannot be // used in the middle of a name ) so in practice all C identifiers live in a // separate namespace ( no _Cgo_ hacks like in gc ) .
func (p *cgoPackage) walker(cursor *astutil.Cursor) bool {
	switch node := cursor.Node().(type) {
	case *ast.CallExpr:
		fun, ok := node.Fun.(*ast.SelectorExpr)
		if !ok {
			return true
		}
		x, ok := fun.X.(*ast.Ident)
		if !ok {
			return true
		}
		if _, ok := p.functions[fun.Sel.Name]; ok && x.Name == "C" {
			node.Fun = &ast.Ident{
				NamePos: x.NamePos,
				Name:    "C." + fun.Sel.Name,
			}
		}
	case *ast.SelectorExpr:
		x, ok := node.X.(*ast.Ident)
		if !ok {
			return true
		}
		if x.Name == "C" {
			name := "C." + node.Sel.Name
			if _, ok := p.functions[node.Sel.Name]; ok {
				name += "$funcaddr"
			}
			cursor.Replace(&ast.Ident{
				NamePos: x.NamePos,
				Name:    name,
			})
		}
	}
	return true
}
func ( p * cgoPackage ) walker ( cursor * astutil . Cursor ) bool { switch node := cursor . Node ( ) . ( type ) { case * ast . CallExpr : fun , ok := node . Fun . ( * ast . SelectorExpr ) if ! ok { return true } x , ok := fun . X . ( * ast . Ident ) if ! ok { return true } if _ , ok := p . functions [ fun . Sel . Name ] ; ok && x . Name == " " { node . Fun = & ast . Ident { NamePos : x . NamePos , Name : " " + fun . Sel . Name , } } case * ast . SelectorExpr : x , ok := node . X . ( * ast . Ident ) if ! ok { return true } if x . Name == " " { name := " " + node . Sel . Name if _ , ok := p . functions [ node . Sel . Name ] ; ok { name += " " } cursor . Replace ( & ast . Ident { NamePos : x . NamePos , Name : name , } ) } } return true }
walker replaces all "C".
walker replaces all " C " .