Пример #1
0
func newExported(t gcc.Named) baseCNamer {
	return baseCNamer{
		id:    t.Id(),
		cName: t.CName(),
		file:  t.File(),
	}
}
Пример #2
0
// lower camel name
func (pac *Package) lowerName(o gcc.Named) string {
	s := snakeToLowerCamel(o.CName())
	switch s {
	case "type", "len":
		s += "_"
	}
	return s
}
Пример #3
0
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(),
	}}
}
Пример #4
0
// 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 ""
}
Пример #5
0
// 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
}
Пример #6
0
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(),
	}}
}
Пример #7
0
// upper camel name
func (pac *Package) upperName(o gcc.Named) string {
	return upperName(o.CName(), pac.From.NamePrefix)
}