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)
| 957 | // |
| 958 | // http://www.lua.org/manual/5.2/manual.html#lua_pushcclosure |
| 959 | func (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. |
no test coverage detected