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

Method genStruct

bind/genjava.go:235–351  ·  view source on GitHub ↗
(s structInfo)

Source from the content-addressed store, hash-verified

233}
234
235func (g *JavaGen) genStruct(s structInfo) {
236 pkgPath := ""
237 if g.Pkg != nil {
238 pkgPath = g.Pkg.Path()
239 }
240 n := g.javaTypeName(s.obj.Name())
241 g.Printf(javaPreamble, g.javaPkgName(g.Pkg), n, g.gobindOpts(), pkgPath)
242
243 fields := exportedFields(s.t)
244 methods := exportedMethodSet(types.NewPointer(s.obj.Type()))
245
246 var impls []string
247 jinf := g.jstructs[s.obj]
248 if jinf != nil {
249 impls = append(impls, "Seq.GoObject")
250 for _, cls := range jinf.supers {
251 if cls.Interface {
252 impls = append(impls, g.javaTypeName(cls.Name))
253 }
254 }
255 } else {
256 impls = append(impls, "Seq.Proxy")
257 }
258
259 pT := types.NewPointer(s.obj.Type())
260 for _, iface := range g.allIntf {
261 if types.AssignableTo(pT, iface.obj.Type()) {
262 n := iface.obj.Name()
263 if p := iface.obj.Pkg(); p != g.Pkg {
264 if n == JavaClassName(p) {
265 n = n + "_"
266 }
267 n = fmt.Sprintf("%s.%s", g.javaPkgName(p), n)
268 } else {
269 n = g.javaTypeName(n)
270 }
271 impls = append(impls, n)
272 }
273 }
274
275 doc := g.docs[n]
276 g.javadoc(doc.Doc())
277 g.Printf("public final class %s", n)
278 if jinf != nil {
279 if jinf.extends != nil {
280 g.Printf(" extends %s", g.javaTypeName(jinf.extends.Name))
281 }
282 }
283 if len(impls) > 0 {
284 g.Printf(" implements %s", strings.Join(impls, ", "))
285 }
286 g.Printf(" {\n")
287 g.Indent()
288
289 g.Printf("static { %s.touch(); }\n\n", g.className())
290 g.genProxyImpl(n)
291 cons := g.constructors[s.obj]
292 for _, f := range cons {

Callers 1

GenClassMethod · 0.95

Calls 15

javaTypeNameMethod · 0.95
javaPkgNameMethod · 0.95
gobindOptsMethod · 0.95
javadocMethod · 0.95
classNameMethod · 0.95
genProxyImplMethod · 0.95
isConsSigSupportedMethod · 0.95
genConstructorMethod · 0.95
javaTypeMethod · 0.95
hasThisMethod · 0.95
genFuncSignatureMethod · 0.95
genObjectMethodsMethod · 0.95

Tested by

no test coverage detected