extTypes = these are types external to any targeted packages pyWrapOnly = only generate python wrapper code, not go code mpob = Map object -- for methods
(slc *symbol, extTypes, pyWrapOnly bool, mpob *Map)
| 14 | // pyWrapOnly = only generate python wrapper code, not go code |
| 15 | // mpob = Map object -- for methods |
| 16 | func (g *pyGen) genMap(slc *symbol, extTypes, pyWrapOnly bool, mpob *Map) { |
| 17 | if slc.isPointer() { |
| 18 | return // TODO: not sure what to do.. |
| 19 | } |
| 20 | _, ok := slc.GoType().Underlying().(*types.Map) |
| 21 | if !ok { |
| 22 | return |
| 23 | } |
| 24 | |
| 25 | pkgname := slc.gopkg.Name() |
| 26 | |
| 27 | // TODO: maybe check for named type here or something? |
| 28 | pysnm := slc.id |
| 29 | if !strings.Contains(pysnm, "Map_") { |
| 30 | pysnm = strings.TrimPrefix(pysnm, pkgname+"_") |
| 31 | } |
| 32 | |
| 33 | gocl := "go." |
| 34 | if g.pkg == goPackage { |
| 35 | gocl = "" |
| 36 | } |
| 37 | |
| 38 | if !extTypes || pyWrapOnly { |
| 39 | // TODO: inherit from collections.Iterable too? |
| 40 | g.pywrap.Printf(` |
| 41 | # Python type for map %[4]s |
| 42 | class %[2]s(%[5]sGoClass): |
| 43 | ""%[3]q"" |
| 44 | `, |
| 45 | pkgname, |
| 46 | pysnm, |
| 47 | slc.doc, |
| 48 | slc.goname, |
| 49 | gocl, |
| 50 | ) |
| 51 | g.pywrap.Indent() |
| 52 | } |
| 53 | |
| 54 | g.genMapInit(slc, extTypes, pyWrapOnly, mpob) |
| 55 | if mpob != nil { |
| 56 | g.genMapMethods(mpob) |
| 57 | } |
| 58 | if !extTypes || pyWrapOnly { |
| 59 | g.pywrap.Outdent() |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func (g *pyGen) genMapInit(slc *symbol, extTypes, pyWrapOnly bool, mpob *Map) { |
| 64 | pkgname := g.cfg.Name |
no test coverage detected