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

Function Register

gopyh/handle.go:109–128  ·  view source on GitHub ↗

Register registers a new variable instance.

(typnm string, ifc interface{})

Source from the content-addressed store, hash-verified

107
108// Register registers a new variable instance.
109func Register(typnm string, ifc interface{}) CGoHandle {
110 if IfaceIsNil(ifc) {
111 return -1
112 }
113 mu.Lock()
114 defer mu.Unlock()
115 if handles == nil {
116 handles = make(map[GoHandle]interface{})
117 counts = make(map[GoHandle]int64)
118 }
119 ctr++
120 hc := ctr
121 ghc := GoHandle(hc)
122 handles[ghc] = ifc
123 counts[ghc] = 0
124 if trace {
125 fmt.Printf("gopy Registered: %s %v %d\n", typnm, ifc, hc)
126 }
127 return CGoHandle(hc)
128}
129
130// DecRef decrements the reference count for the specified handle
131// and removes it if the reference count goes to zero.

Callers

nothing calls this directly

Calls 4

IfaceIsNilFunction · 0.85
GoHandleTypeAlias · 0.85
CGoHandleTypeAlias · 0.85
PrintfMethod · 0.80

Tested by

no test coverage detected