Exemple #1
0
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
}
Exemple #2
0
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,
	}
}