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

Method addInterfaceType

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

1191}
1192
1193func (sym *symtab) addInterfaceType(pkg *types.Package, obj types.Object, t types.Type, kind symkind, id, n string) error {
1194 fn := sym.fullTypeString(t)
1195 typ := t.Underlying().(*types.Interface)
1196 kind |= skInterface
1197 // special handling of 'error'
1198 if isErrorType(typ) {
1199 return nil
1200 }
1201
1202 if fn == "interface{}" {
1203 sym.syms[fn] = &symbol{
1204 gopkg: pkg,
1205 goobj: obj,
1206 gotyp: t,
1207 kind: kind,
1208 id: id,
1209 goname: n,
1210 cgoname: "*C.char",
1211 cpyname: "char*",
1212 pysig: "str",
1213 go2py: `C.CString(fmt.Sprintf("%s",`,
1214 go2pyParenEx: "))",
1215 py2go: "C.GoString",
1216 zval: `""`,
1217 }
1218 } else {
1219 sym.syms[fn] = &symbol{
1220 gopkg: pkg,
1221 goobj: obj,
1222 gotyp: t,
1223 kind: kind,
1224 id: id,
1225 goname: n,
1226 cgoname: "CGoHandle",
1227 cpyname: PyHandle,
1228 pysig: "object",
1229 go2py: "handleFromPtr_" + id,
1230 py2go: "ptrFromHandle_" + id,
1231 zval: "nil",
1232 }
1233 }
1234 return nil
1235}
1236
1237func (sym *symtab) print() {
1238 fmt.Printf("\n\n%s\n", strings.Repeat("=", 80))

Callers 1

addTypeMethod · 0.95

Calls 2

fullTypeStringMethod · 0.95
isErrorTypeFunction · 0.85

Tested by

no test coverage detected