(ifc *Interface)
| 316 | } |
| 317 | |
| 318 | func (g *pyGen) genIfaceInit(ifc *Interface) { |
| 319 | g.pywrap.Printf("def __init__(self, *args, **kwargs):\n") |
| 320 | g.pywrap.Indent() |
| 321 | g.pywrap.Printf(`""" |
| 322 | handle=A Go-side object is always initialized with an explicit handle=arg |
| 323 | """ |
| 324 | `) |
| 325 | |
| 326 | g.pywrap.Printf("if len(kwargs) == 1 and 'handle' in kwargs:\n") |
| 327 | g.pywrap.Indent() |
| 328 | g.pywrap.Printf("self.handle = kwargs['handle']\n") |
| 329 | g.pywrap.Printf("_%s.IncRef(self.handle)\n", g.pypkgname) |
| 330 | g.pywrap.Outdent() |
| 331 | g.pywrap.Printf("elif len(args) == 1 and isinstance(args[0], go.GoClass):\n") |
| 332 | g.pywrap.Indent() |
| 333 | g.pywrap.Printf("self.handle = args[0].handle\n") |
| 334 | g.pywrap.Printf("_%s.IncRef(self.handle)\n", g.pypkgname) |
| 335 | g.pywrap.Outdent() |
| 336 | g.pywrap.Printf("else:\n") |
| 337 | g.pywrap.Indent() |
| 338 | g.pywrap.Printf("self.handle = 0\n") |
| 339 | g.pywrap.Outdent() |
| 340 | g.pywrap.Outdent() |
| 341 | |
| 342 | for _, m := range ifc.meths { |
| 343 | if !isStringer(m.obj) { |
| 344 | continue |
| 345 | } |
| 346 | g.pywrap.Printf("def __str__(self):\n") |
| 347 | g.pywrap.Indent() |
| 348 | g.genStringerCall() |
| 349 | g.pywrap.Outdent() |
| 350 | g.pywrap.Printf("\n") |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | func (g *pyGen) genIfaceMethods(ifc *Interface) { |
| 355 | for _, m := range ifc.meths { |
no test coverage detected