Example #1
0
func (g *goGen) genFunc(o *types.Func) {
	sig := o.Type().(*types.Signature)

	params := "(" + g.tupleString(sig.Params()) + ")"
	ret := g.tupleString(sig.Results())
	if sig.Results().Len() > 1 {
		ret = "(" + ret + ") "
	} else {
		ret += " "
	}

	//funcName := o.Name()
	g.Printf(`
//export GoPy_%[1]s
// GoPy_%[1]s wraps %[2]s
func GoPy_%[1]s%[3]v%[4]v{
`,
		o.Name(), o.FullName(),
		params,
		ret,
	)

	g.Indent()
	g.genFuncBody(o)
	g.Outdent()
	g.Printf("}\n\n")
}