MCPcopy Index your code
hub / github.com/go-python/gopy / genMap

Method genMap

bind/gen_map.go:16–61  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

14// pyWrapOnly = only generate python wrapper code, not go code
15// mpob = Map object -- for methods
16func (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
42class %[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
63func (g *pyGen) genMapInit(slc *symbol, extTypes, pyWrapOnly bool, mpob *Map) {
64 pkgname := g.cfg.Name

Callers 2

genTypeMethod · 0.95
genAllMethod · 0.95

Calls 8

genMapInitMethod · 0.95
genMapMethodsMethod · 0.95
isPointerMethod · 0.80
PrintfMethod · 0.80
IndentMethod · 0.80
OutdentMethod · 0.80
GoTypeMethod · 0.65
NameMethod · 0.45

Tested by

no test coverage detected