func (p *cgoPackage) addTypeAliases() {
	aliasKeys := make([]string, 0, len(cgoAliases))
	for key := range cgoAliases {
		aliasKeys = append(aliasKeys, key)
	}
	sort.Strings(aliasKeys)
	gen := &ast.GenDecl{
		TokPos: token.NoPos,
		Tok:    token.TYPE,
		Lparen: token.NoPos,
		Rparen: token.NoPos,
	}
	for _, typeName := range aliasKeys {
		goTypeName := cgoAliases[typeName]
		obj := &ast.Object{
			Kind: ast.Typ,
			Name: typeName,
		}
		typeSpec := &ast.TypeSpec{
			Name: &ast.Ident{
				NamePos: token.NoPos,
				Name:    typeName,
				Obj:     obj,
			},
			Assign: p.generatedPos,
			Type: &ast.Ident{
				NamePos: token.NoPos,
				Name:    goTypeName,
			},
		}
		obj.Decl = typeSpec
		gen.Specs = append(gen.Specs, typeSpec)
	}
	p.generated.Decls = append(p.generated.Decls, gen)
}
// addTypeAliases aliases some built-in Go types with their equivalent C types.
// It adds code like the following to the AST:
//
//     type (
//         C.int8_t  = int8
//         C.int16_t = int16
//         // ...
//     )
addTypeAliases aliases some built-in Go types with their equivalent C types.
It adds code like the following to the AST.


// addTypeAliases aliases some built - in Go types with their equivalent C types . // It adds code like the following to the AST : // // type ( // C . int8_t = int8 // C . int16_t = int16 // // ... // )
func (p *cgoPackage) addTypeAliases() {
	aliasKeys := make([]string, 0, len(cgoAliases))
	for key := range cgoAliases {
		aliasKeys = append(aliasKeys, key)
	}
	sort.Strings(aliasKeys)
	gen := &ast.GenDecl{
		TokPos: token.NoPos,
		Tok:    token.TYPE,
		Lparen: token.NoPos,
		Rparen: token.NoPos,
	}
	for _, typeName := range aliasKeys {
		goTypeName := cgoAliases[typeName]
		obj := &ast.Object{
			Kind: ast.Typ,
			Name: typeName,
		}
		typeSpec := &ast.TypeSpec{
			Name: &ast.Ident{
				NamePos: token.NoPos,
				Name:    typeName,
				Obj:     obj,
			},
			Assign: p.generatedPos,
			Type: &ast.Ident{
				NamePos: token.NoPos,
				Name:    goTypeName,
			},
		}
		obj.Decl = typeSpec
		gen.Specs = append(gen.Specs, typeSpec)
	}
	p.generated.Decls = append(p.generated.Decls, gen)
}
func ( p * cgoPackage ) addTypeAliases ( ) { aliasKeys := make ( [ ] string , 0 , len ( cgoAliases ) ) for key := range cgoAliases { aliasKeys = append ( aliasKeys , key ) } sort . Strings ( aliasKeys ) gen := & ast . GenDecl { TokPos : token . NoPos , Tok : token . TYPE , Lparen : token . NoPos , Rparen : token . NoPos , } for _ , typeName := range aliasKeys { goTypeName := cgoAliases [ typeName ] obj := & ast . Object { Kind : ast . Typ , Name : typeName , } typeSpec := & ast . TypeSpec { Name : & ast . Ident { NamePos : token . NoPos , Name : typeName , Obj : obj , } , Assign : p . generatedPos , Type : & ast . Ident { NamePos : token . NoPos , Name : goTypeName , } , } obj . Decl = typeSpec gen . Specs = append ( gen . Specs , typeSpec ) } p . generated . Decls = append ( p . generated . Decls , gen ) }
addTypeAliases aliases some built-in Go types with their equivalent C types.
addTypeAliases aliases some built - in Go types with their equivalent C types .