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

Method genJNIFuncSignature

bind/genjava.go:731–792  ·  view source on GitHub ↗
(o *types.Func, sName string, jm *java.Func, proxy, isjava bool)

Source from the content-addressed store, hash-verified

729}
730
731func (g *JavaGen) genJNIFuncSignature(o *types.Func, sName string, jm *java.Func, proxy, isjava bool) {
732 sig := o.Type().(*types.Signature)
733 res := sig.Results()
734
735 var ret string
736 switch res.Len() {
737 case 2:
738 ret = g.jniType(res.At(0).Type())
739 case 1:
740 if isErrorType(res.At(0).Type()) {
741 ret = "void"
742 } else {
743 ret = g.jniType(res.At(0).Type())
744 }
745 case 0:
746 ret = "void"
747 default:
748 g.errorf("too many result values: %s", o)
749 return
750 }
751
752 g.Printf("JNIEXPORT %s JNICALL\n", ret)
753 g.Printf("Java_%s_", g.jniPkgName())
754 if sName != "" {
755 if proxy {
756 g.Printf("%s", java.JNIMangle(g.className()))
757 // 0024 is the mangled form of $, for naming inner classes.
758 g.Printf("_00024proxy%s", sName)
759 } else {
760 g.Printf("%s", java.JNIMangle(g.javaTypeName(sName)))
761 }
762 } else {
763 g.Printf("%s", java.JNIMangle(g.className()))
764 }
765 g.Printf("_")
766 if jm != nil {
767 g.Printf("%s", jm.JNIName)
768 } else {
769 oName := javaNameReplacer(lowerFirst(o.Name()))
770 g.Printf("%s", java.JNIMangle(oName))
771 }
772 g.Printf("(JNIEnv* env, ")
773 if sName != "" {
774 g.Printf("jobject __this__")
775 } else {
776 g.Printf("jclass _clazz")
777 }
778 params := sig.Params()
779 i := 0
780 if isjava && params.Len() > 0 && params.At(0).Name() == "this" {
781 // Skip the implicit this argument, if any.
782 i = 1
783 }
784 for ; i < params.Len(); i++ {
785 g.Printf(", ")
786 v := sig.Params().At(i)
787 name := g.paramName(params, i)
788 jt := g.jniType(v.Type())

Callers 1

genJNIFuncMethod · 0.95

Calls 12

jniTypeMethod · 0.95
jniPkgNameMethod · 0.95
classNameMethod · 0.95
javaTypeNameMethod · 0.95
paramNameMethod · 0.95
JNIMangleFunction · 0.92
isErrorTypeFunction · 0.85
lowerFirstFunction · 0.85
TypeMethod · 0.80
PrintfMethod · 0.80
LenMethod · 0.45
errorfMethod · 0.45

Tested by

no test coverage detected