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

Method genConstructor

bind/genjava.go:422–455  ·  view source on GitHub ↗
(f *types.Func, n string, jcls bool)

Source from the content-addressed store, hash-verified

420}
421
422func (g *JavaGen) genConstructor(f *types.Func, n string, jcls bool) {
423 g.javadoc(g.docs[f.Name()].Doc())
424 g.Printf("public %s(", n)
425 g.genFuncArgs(f, nil, false)
426 g.Printf(") {\n")
427 g.Indent()
428 sig := f.Type().(*types.Signature)
429 params := sig.Params()
430 if jcls {
431 g.Printf("super(")
432 for i := 0; i < params.Len(); i++ {
433 if i > 0 {
434 g.Printf(", ")
435 }
436 g.Printf("%s", g.paramName(params, i))
437 }
438 g.Printf(");\n")
439 }
440 g.Printf("this.refnum = ")
441 g.Printf("__%s(", f.Name())
442 for i := 0; i < params.Len(); i++ {
443 if i > 0 {
444 g.Printf(", ")
445 }
446 g.Printf("%s", g.paramName(params, i))
447 }
448 g.Printf(");\n")
449 g.Printf("Seq.trackGoRef(refnum, this);\n")
450 g.Outdent()
451 g.Printf("}\n\n")
452 g.Printf("private static native int __%s(", f.Name())
453 g.genFuncArgs(f, nil, false)
454 g.Printf(");\n\n")
455}
456
457// genFuncArgs generated Java function arguments declaration for the function f.
458// If the supplied overridden java function is supplied, genFuncArgs omits the implicit

Callers 1

genStructMethod · 0.95

Calls 9

javadocMethod · 0.95
genFuncArgsMethod · 0.95
paramNameMethod · 0.95
DocMethod · 0.80
PrintfMethod · 0.80
IndentMethod · 0.80
TypeMethod · 0.80
OutdentMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected