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

Function newFuncFrom

bind/types.go:379–421  ·  view source on GitHub ↗
(p *Package, parent string, obj types.Object, sig *types.Signature)

Source from the content-addressed store, hash-verified

377}
378
379func newFuncFrom(p *Package, parent string, obj types.Object, sig *types.Signature) (*Func, error) {
380 ret, haserr, hasfun, err := isPyCompatFunc(sig)
381 if err != nil {
382 return nil, err
383 }
384
385 id := obj.Pkg().Name() + "_" + obj.Name()
386 if parent != "" {
387 id = obj.Pkg().Name() + "_" + parent + "_" + obj.Name()
388 }
389
390 sv, err := newSignatureFrom(p, sig)
391 if err != nil {
392 return nil, err
393 }
394
395 return &Func{
396 obj: obj,
397 pkg: p,
398 sig: sv,
399 typ: obj.Type(),
400 name: obj.Name(),
401 id: id,
402 doc: p.getDoc(parent, obj),
403 ret: ret,
404 err: haserr,
405 hasfun: hasfun,
406 isVariadic: sig.Variadic(),
407 }, nil
408
409 // TODO: could optimize by generating code once for each type of callback
410 // but probably not worth the effort required to link everything up..
411 // if hasfun {
412 // args := sv.args
413 // for i := range args {
414 // arg := args[i]
415 // if arg.sym.isSignature() {
416 // // TODO: need to make sure not already on the list, etc
417 // p.calls = append(p.calls, arg)
418 // }
419 // }
420 // }
421} //
422
423func (f *Func) Obj() types.Object {
424 return f.obj

Callers 1

processMethod · 0.85

Calls 4

isPyCompatFuncFunction · 0.85
newSignatureFromFunction · 0.85
getDocMethod · 0.80
NameMethod · 0.45

Tested by

no test coverage detected