示例#1
0
文件: parse.go 项目: h12w/cwrap
func (pac *Package) newReturn(gt gcc.Type) *Return {
	if gcc.IsVoid(gt) {
		return nil
	}
	var t Type
	if gcc.IsCString(gt) {
		t = newString()
	} else {
		t = pac.getType(gt, gcc.NotSet)
	}
	return &Return{baseParam{"ret", "_ret", t}}
}
示例#2
0
文件: parse.go 项目: sbinet/cwrap
func (pac *Package) newReturn(gt gcc.Type) *Return {
	if gcc.IsVoid(gt) {
		return nil
	}
	var t Conv
	if gcc.IsCString(gt) {
		t = String{}
	} else if n, ok := pac.getNamer(gt).(Conv); ok {
		t = n
	}
	switch t.GoName() {
	case "int32", "uint32":
		t = Simple{namer{"int", t.CgoName()}}
	}
	return &Return{"ret", t}
}
示例#3
0
文件: parse.go 项目: sbinet/cwrap
func (pac *Package) newPtr(t gcc.Type) Conv {
	n := pac.getNamer(t)
	if gcc.IsVoid(t) {
		return Simple{namer{
			goName:  "uintptr",
			cgoName: "unsafe.Pointer",
		}}
	}
	goName, cgoName := n.GoName(), n.CgoName()
	if goName == "" {
		goName = "uintptr"
	} else {
		goName = "*" + goName
	}
	if cgoName == "" {
		cgoName = "unsafe.Pointer"
	} else {
		cgoName = "*" + cgoName
	}
	return Ptr{namer{
		goName:  goName,
		cgoName: cgoName,
	}}
}