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

Method genInterface

bind/genjava.go:545–592  ·  view source on GitHub ↗
(iface interfaceInfo)

Source from the content-addressed store, hash-verified

543}
544
545func (g *JavaGen) genInterface(iface interfaceInfo) {
546 pkgPath := ""
547 if g.Pkg != nil {
548 pkgPath = g.Pkg.Path()
549 }
550 g.Printf(javaPreamble, g.javaPkgName(g.Pkg), g.javaTypeName(iface.obj.Name()), g.gobindOpts(), pkgPath)
551
552 var exts []string
553 numM := iface.t.NumMethods()
554 for _, other := range g.allIntf {
555 // Only extend interfaces with fewer methods to avoid circular references
556 if other.t.NumMethods() < numM && types.AssignableTo(iface.t, other.t) {
557 n := other.obj.Name()
558 if p := other.obj.Pkg(); p != g.Pkg {
559 if n == JavaClassName(p) {
560 n = n + "_"
561 }
562 n = fmt.Sprintf("%s.%s", g.javaPkgName(p), n)
563 } else {
564 n = g.javaTypeName(n)
565 }
566 exts = append(exts, n)
567 }
568 }
569 doc := g.docs[iface.obj.Name()]
570 g.javadoc(doc.Doc())
571 g.Printf("public interface %s", g.javaTypeName(iface.obj.Name()))
572 if len(exts) > 0 {
573 g.Printf(" extends %s", strings.Join(exts, ", "))
574 }
575 g.Printf(" {\n")
576 g.Indent()
577
578 for _, m := range iface.summary.callable {
579 if !g.isSigSupported(m.Type()) {
580 g.Printf("// skipped method %s.%s with unsupported parameter or return types\n\n", iface.obj.Name(), m.Name())
581 continue
582 }
583 g.javadoc(doc.Member(m.Name()))
584 g.Printf("public ")
585 g.genFuncSignature(m, nil, false)
586 }
587
588 g.Printf("\n")
589
590 g.Outdent()
591 g.Printf("}\n\n")
592}
593
594func isJavaPrimitive(T types.Type) bool {
595 b, ok := T.(*types.Basic)

Callers 1

GenClassMethod · 0.95

Calls 14

javaPkgNameMethod · 0.95
javaTypeNameMethod · 0.95
gobindOptsMethod · 0.95
javadocMethod · 0.95
genFuncSignatureMethod · 0.95
JavaClassNameFunction · 0.85
PathMethod · 0.80
PrintfMethod · 0.80
DocMethod · 0.80
IndentMethod · 0.80
isSigSupportedMethod · 0.80
TypeMethod · 0.80

Tested by

no test coverage detected