Beispiel #1
0
func exportDecl(d *cc.Decl) {
	d.Name = exportName(d.Name)
	if d.Storage&cc.Typedef != 0 && d.Type.Kind == cc.Struct {
		for _, dd := range d.Type.Decls {
			exportDecl(dd)
			// type became type_, became Type_. Drop underscore now that it's not needed.
			if strings.HasSuffix(dd.Name, "_") && goKeyword[strings.ToLower(dd.Name[:len(dd.Name)-1])] {
				dd.Name = dd.Name[:len(dd.Name)-1]
			}
			if dd.Name == "U" {
				for _, dd := range dd.Type.Decls {
					exportDecl(dd)
				}
			}
		}
	}
}
Beispiel #2
0
func renameDecl(cfg *Config, d *cc.Decl) {
	key := declKey(d)
	if cfg.rename[key] != "" {
		d.Name = cfg.rename[key]
	}
	if d.Storage&cc.Typedef != 0 && d.Type.Kind == cc.Struct {
		for _, dd := range d.Type.Decls {
			renameDecl(cfg, dd)
			if dd.Name == "U" {
				for _, dd := range dd.Type.Decls {
					renameDecl(cfg, dd)
				}
			}
		}
	}

	if d.Type != nil && d.Type.Kind == cc.Func && d.Body != nil {
		for _, s := range d.Body.Block {
			if s.Op == cc.StmtDecl && s.Decl.Storage&cc.Static != 0 {
				renameDecl(cfg, s.Decl)
			}
		}
	}
}