mirror of https://github.com/go-python/gopy.git
bind: collect methods of all named types into symtab
Change-Id: Ia8f8ed3f7b68a06fe09945d795403e3f10e69285
This commit is contained in:
parent
7b33bc0361
commit
216a45e7c3
|
@ -389,6 +389,19 @@ func (sym *symtab) addType(obj types.Object, t types.Type) {
|
|||
panic(fmt.Errorf("unhandled named-type: [%T]\n%#v\n", obj, t))
|
||||
}
|
||||
|
||||
// add methods
|
||||
for i := 0; i < typ.NumMethods(); i++ {
|
||||
m := typ.Method(i)
|
||||
if !m.Exported() {
|
||||
continue
|
||||
}
|
||||
if true {
|
||||
mid := id + "_" + m.Name()
|
||||
mname := m.Name()
|
||||
sym.addMethod(pkg, m, m.Type(), skFunc, mid, mname)
|
||||
}
|
||||
}
|
||||
|
||||
case *types.Pointer:
|
||||
// FIXME(sbinet): better handling?
|
||||
elm := *sym.symtype(typ.Elem())
|
||||
|
@ -529,6 +542,21 @@ func (sym *symtab) addSignatureType(pkg *types.Package, obj types.Object, t type
|
|||
}
|
||||
}
|
||||
|
||||
func (sym *symtab) addMethod(pkg *types.Package, obj types.Object, t types.Type, kind symkind, id, n string) {
|
||||
fn := types.ObjectString(obj, nil)
|
||||
kind |= skFunc
|
||||
sym.syms[fn] = &symbol{
|
||||
gopkg: pkg,
|
||||
goobj: obj,
|
||||
gotyp: t,
|
||||
kind: kind,
|
||||
id: id,
|
||||
goname: n,
|
||||
cgoname: "cgo_func_" + id,
|
||||
cpyname: "cpy_func_" + id,
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
look := types.Universe.Lookup
|
||||
|
|
Loading…
Reference in New Issue