MCPcopy Create free account
hub / github.com/go-python/gopy / addMapType

Method addMapType

bind/symbols.go:933–967  ·  view source on GitHub ↗
(pkg *types.Package, obj types.Object, t types.Type, kind symkind, id, n string)

Source from the content-addressed store, hash-verified

931}
932
933func (sym *symtab) addMapType(pkg *types.Package, obj types.Object, t types.Type, kind symkind, id, n string) error {
934 fn := sym.fullTypeString(t)
935 typ := t.Underlying().(*types.Map)
936 kind |= skMap
937 elt := typ.Elem()
938 elsym, err := sym.addTypeIfNew(elt)
939 if err != nil {
940 return err
941 }
942 if elsym.isSignature() {
943 return fmt.Errorf("gopy: map value type cannot be signature / func: %q", elsym.goname)
944 }
945 // add type for keys method
946 keyt := typ.Key()
947 keyslt := types.NewSlice(keyt)
948 _, err = sym.addTypeIfNew(keyslt)
949 if err != nil {
950 return err
951 }
952 sym.syms[fn] = &symbol{
953 gopkg: pkg,
954 goobj: obj,
955 gotyp: t,
956 kind: kind,
957 id: id,
958 goname: n,
959 cgoname: "CGoHandle",
960 cpyname: PyHandle,
961 pysig: "object",
962 go2py: "handleFromPtr_" + id,
963 py2go: "deptrFromHandle_" + id,
964 zval: "nil",
965 }
966 return nil
967}
968
969func (sym *symtab) addSliceType(pkg *types.Package, obj types.Object, t types.Type, kind symkind, id, n string) error {
970 fn := sym.fullTypeString(t)

Callers 1

addTypeMethod · 0.95

Calls 3

fullTypeStringMethod · 0.95
addTypeIfNewMethod · 0.95
isSignatureMethod · 0.80

Tested by

no test coverage detected