mirror of https://github.com/go-python/gopy.git
bind: leaner Var
This commit is contained in:
parent
10e80de3df
commit
ba3a48a31b
14
bind/vars.go
14
bind/vars.go
|
@ -15,7 +15,7 @@ type Var struct {
|
||||||
id string
|
id string
|
||||||
doc string
|
doc string
|
||||||
name string
|
name string
|
||||||
obj types.Object
|
typ types.Type
|
||||||
dtype typedesc
|
dtype typedesc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,14 +23,14 @@ func (v *Var) Name() string {
|
||||||
return v.name
|
return v.name
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVar(p *Package, obj types.Object, name, doc string) *Var {
|
func newVar(p *Package, typ types.Type, objname, name, doc string) *Var {
|
||||||
return &Var{
|
return &Var{
|
||||||
pkg: p,
|
pkg: p,
|
||||||
id: p.Name() + "_" + obj.Name(),
|
id: p.Name() + "_" + objname,
|
||||||
doc: doc,
|
doc: doc,
|
||||||
name: name,
|
name: name,
|
||||||
obj: obj,
|
typ: typ,
|
||||||
dtype: getTypedesc(obj.Type()),
|
dtype: getTypedesc(typ),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ func newVarsFrom(p *Package, tuple *types.Tuple) []*Var {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVarFrom(p *Package, v *types.Var) *Var {
|
func newVarFrom(p *Package, v *types.Var) *Var {
|
||||||
return newVar(p, v, v.Name(), p.getDoc("", v))
|
return newVar(p, v.Type(), v.Name(), v.Name(), p.getDoc("", v))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTypedesc(t types.Type) typedesc {
|
func getTypedesc(t types.Type) typedesc {
|
||||||
|
@ -75,7 +75,7 @@ func getTypedesc(t types.Type) typedesc {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Var) GoType() types.Type {
|
func (v *Var) GoType() types.Type {
|
||||||
return v.obj.Type()
|
return v.typ
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Var) CType() string {
|
func (v *Var) CType() string {
|
||||||
|
|
Loading…
Reference in New Issue