MCPcopy Create free account
hub / github.com/golang/mobile / genFuncSignature

Method genFuncSignature

bind/genjava.go:808–857  ·  view source on GitHub ↗
(o *types.Func, jm *java.Func, hasThis bool)

Source from the content-addressed store, hash-verified

806}
807
808func (g *JavaGen) genFuncSignature(o *types.Func, jm *java.Func, hasThis bool) {
809 sig := o.Type().(*types.Signature)
810 res := sig.Results()
811
812 var returnsError bool
813 var ret string
814 switch res.Len() {
815 case 2:
816 if !isErrorType(res.At(1).Type()) {
817 g.errorf("second result value must be of type error: %s", o)
818 return
819 }
820 returnsError = true
821 ret = g.javaType(res.At(0).Type())
822 case 1:
823 if isErrorType(res.At(0).Type()) {
824 returnsError = true
825 ret = "void"
826 } else {
827 ret = g.javaType(res.At(0).Type())
828 }
829 case 0:
830 ret = "void"
831 default:
832 g.errorf("too many result values: %s", o)
833 return
834 }
835
836 g.Printf("%s ", ret)
837 if jm != nil {
838 g.Printf("%s", jm.Name)
839 } else {
840 g.Printf("%s", javaNameReplacer(lowerFirst(o.Name())))
841 }
842 g.Printf("(")
843 g.genFuncArgs(o, jm, hasThis)
844 g.Printf(")")
845 if returnsError {
846 if jm != nil {
847 if jm.Throws == "" {
848 g.errorf("%s declares an error return value but the overridden method does not throw", o)
849 return
850 }
851 g.Printf(" throws %s", jm.Throws)
852 } else {
853 g.Printf(" throws Exception")
854 }
855 }
856 g.Printf(";\n")
857}
858
859func (g *JavaGen) genVar(o *types.Var) {
860 if t := o.Type(); !g.isSupported(t) {

Callers 3

genStructMethod · 0.95
genInterfaceMethod · 0.95
GenJavaMethod · 0.95

Calls 8

javaTypeMethod · 0.95
genFuncArgsMethod · 0.95
isErrorTypeFunction · 0.85
lowerFirstFunction · 0.85
TypeMethod · 0.80
PrintfMethod · 0.80
LenMethod · 0.45
errorfMethod · 0.45

Tested by

no test coverage detected