// lower camel name func (pac *Package) lowerName(o gcc.Named) string { s := snakeToLowerCamel(o.CName()) switch s { case "type", "len": s += "_" } return s }
func (pac *Package) newPtrTypedef(t gcc.Named) Ptr { goName := pac.globalName(t) if goName == "" { goName = "uintptr" } return Ptr{namer{ goName: goName, cgoName: "C." + t.CName(), }} }
// type name that may be declared in this or included packages. func (pac *Package) globalName(o gcc.Named) string { if pac.fileIds.Has(o.File()) && pac.hasPrefix(o.CName()) { return pac.localName(o) } for _, inc := range pac.Included { if goName := inc.globalName(o); goName != "" && !contains(goName, ".") { return joins(inc.PacName, ".", goName) } } return "" }
// lower camel name func lowerName(o gcc.Named) string { s := snakeToLowerCamel(o.CName()) switch s { case "func", "interface", "select", "defer", "go", "map", "chan", "package", "fallthrough", "range", "type", "import", "var", "true", "false", "iota", "nil", "append", "cap", "close", "complex", "copy", "delete", "imag", "len", "make", "new", "panic", "print", "println", "real", "recover": s += "_" } return s }
func (pac *Package) newPtrReference(t gcc.Named) Ptr { goName := pac.globalName(t) if goName == "" { goName = "uintptr" } else { goName = "*" + goName } return Ptr{namer{ goName: goName, cgoName: "*C." + t.CName(), }} }
func newExported(t gcc.Named) baseCNamer { return baseCNamer{ id: t.Id(), cName: t.CName(), file: t.File(), } }
// upper name that is unique within the package func (pac *Package) localName(o gcc.Named) string { n := pac.upperName(o) if sid, exists := pac.localNames[n]; !exists || o.Id() == sid { pac.localNames[n] = o.Id() return n } for { n += "_" if _, exists := pac.localNames[n]; !exists { break } } pac.localNames[n] = o.Id() return n }
// upper camel name func (pac *Package) upperName(o gcc.Named) string { return upperName(o.CName(), pac.From.NamePrefix) }