示例#1
0
文件: parse.go 项目: h12w/cwrap
func (pac *Package) newFunction(fn *gcc.Function) *Function {
	cArgs := pac.newArgs(fn.Arguments)
	goParams := cArgs.ToParams()
	returns := pac.newReturn(fn.ReturnType())
	if returns != nil {
		goParams = append(goParams, returns)
	}
	f := &Function{
		baseCNamer: newExported(fn),
		baseFunc: baseFunc{
			GoParams: goParams,
			CArgs:    cArgs,
			Return:   returns,
		},
	}

	return f
}
示例#2
0
文件: parse.go 项目: sbinet/cwrap
func (pac *Package) newFunction(fn *gcc.Function) Function {
	cArgs, receiver := pac.newFuncArgs(fn.Arguments)
	goName := ""
	goParams := cArgs.ToParams()
	if receiver != nil {
		goParams = goParams[1:]
		goName = pac.upperName(fn)
		goName = trimPreSuffix(goName, strings.Trim(receiver.GoTypeName(), "*"))
	} else {
		goName = pac.globalName(fn)
	}
	returns := pac.newReturn(fn.ReturnType())
	if returns != nil {
		goParams = append(goParams, returns)
	}
	return Function{
		exported: exported{
			cName: fn.CName(),
			file:  fn.File(),
		},
		goName:   goName,
		Receiver: receiver,
		GoParams: goParams,
		CArgs:    cArgs,
		Return:   returns,
	}
}