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

Method addStructType

bind/symbols.go:998–1039  ·  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

996}
997
998func (sym *symtab) addStructType(pkg *types.Package, obj types.Object, t types.Type, kind symkind, id, n string) error {
999 fn := sym.fullTypeString(t)
1000 typ := t.Underlying().(*types.Struct)
1001 kind |= skStruct
1002 // add our type first before adding fields -- prevents loops!
1003 sym.syms[fn] = &symbol{
1004 gopkg: pkg,
1005 goobj: obj,
1006 gotyp: t,
1007 kind: kind,
1008 id: id,
1009 goname: n,
1010 cgoname: "CGoHandle",
1011 cpyname: PyHandle,
1012 pysig: "object",
1013 go2py: "handleFromPtr_" + id,
1014 py2go: "*ptrFromHandle_" + id,
1015 zval: "nil",
1016 }
1017 for i := 0; i < typ.NumFields(); i++ {
1018 if isPrivate(typ.Field(i).Name()) {
1019 continue
1020 }
1021 f := typ.Field(i)
1022 if !f.Exported() || f.Embedded() {
1023 continue
1024 }
1025 ftyp := f.Type()
1026 fsym := sym.symtype(ftyp)
1027 if fsym == nil {
1028 err := sym.addType(f, ftyp)
1029 if err != nil {
1030 continue
1031 }
1032 fsym = sym.symtype(ftyp)
1033 if fsym == nil {
1034 continue
1035 }
1036 }
1037 }
1038 return nil
1039}
1040
1041func (sym *symtab) addSignatureType(pkg *types.Package, obj types.Object, t types.Type, kind symkind, id, n string) error {
1042 fn := sym.fullTypeString(t)

Callers 1

addTypeMethod · 0.95

Calls 5

fullTypeStringMethod · 0.95
symtypeMethod · 0.95
addTypeMethod · 0.95
isPrivateFunction · 0.85
NameMethod · 0.45

Tested by

no test coverage detected