示例#1
0
文件: package.go 项目: sbinet/cwrap
// lower camel name
func (pac *Package) lowerName(o gcc.Named) string {
	s := snakeToLowerCamel(o.CName())
	switch s {
	case "type", "len":
		s += "_"
	}
	return s
}
示例#2
0
文件: parse.go 项目: sbinet/cwrap
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(),
	}}
}
示例#3
0
文件: package.go 项目: sbinet/cwrap
// 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 ""
}
示例#4
0
文件: parse.go 项目: h12w/cwrap
// 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
}
示例#5
0
文件: parse.go 项目: sbinet/cwrap
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(),
	}}
}
示例#6
0
文件: parse.go 项目: h12w/cwrap
func newExported(t gcc.Named) baseCNamer {
	return baseCNamer{
		id:    t.Id(),
		cName: t.CName(),
		file:  t.File(),
	}
}
示例#7
0
文件: package.go 项目: sbinet/cwrap
// 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
}
示例#8
0
文件: package.go 项目: sbinet/cwrap
// upper camel name
func (pac *Package) upperName(o gcc.Named) string {
	return upperName(o.CName(), pac.From.NamePrefix)
}