MCPcopy Index your code
hub / github.com/Shopify/go-lua / PushGoClosure

Method PushGoClosure

lua.go:959–971  ·  view source on GitHub ↗

PushGoClosure pushes a new Go closure onto the stack. When a Go function is created, it is possible to associate some values with it, thus creating a Go closure; these values are then accessible to the function whenever it is called. To associate values with a Go function, first these values shoul

(function Function, upValueCount uint8)

Source from the content-addressed store, hash-verified

957//
958// http://www.lua.org/manual/5.2/manual.html#lua_pushcclosure
959func (l *State) PushGoClosure(function Function, upValueCount uint8) {
960 if upValueCount == 0 {
961 l.apiPush(&goFunction{function})
962 } else {
963 n := int(upValueCount)
964
965 l.checkElementCount(n)
966 cl := &goClosure{function: function, upValues: make([]value, upValueCount)}
967 l.top -= n
968 copy(cl.upValues, l.stack[l.top:l.top+n])
969 l.apiPush(cl)
970 }
971}
972
973// PushThread pushes the thread l onto the stack. It returns true if l is
974// the main thread of its state.

Callers 4

PushGoFunctionMethod · 0.95
linesFunction · 0.80
createSearchersTableFunction · 0.80
SetFunctionsFunction · 0.80

Calls 2

apiPushMethod · 0.95
checkElementCountMethod · 0.95

Tested by

no test coverage detected