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

Function SetFunctions

auxiliary.go:381–392  ·  view source on GitHub ↗
(l *State, functions []RegistryFunction, upValueCount uint8)

Source from the content-addressed store, hash-verified

379func TypeNameOf(l *State, index int) string { return l.TypeOf(index).String() }
380
381func SetFunctions(l *State, functions []RegistryFunction, upValueCount uint8) {
382 uvCount := int(upValueCount)
383 CheckStackWithMessage(l, uvCount, "too many upvalues")
384 for _, r := range functions { // fill the table with given functions
385 for i := 0; i < uvCount; i++ { // copy upvalues to the top
386 l.PushValue(-uvCount)
387 }
388 l.PushGoClosure(r.Function, upValueCount) // closure with those upvalues
389 l.SetField(-(uvCount + 2), r.Name)
390 }
391 l.Pop(uvCount) // remove upvalues
392}
393
394func CheckStackWithMessage(l *State, space int, message string) {
395 // keep some extra space to run error routines, if needed

Callers 4

BaseOpenFunction · 0.85
IOOpenFunction · 0.85
PackageOpenFunction · 0.85
NewLibraryFunction · 0.85

Calls 5

CheckStackWithMessageFunction · 0.85
PushValueMethod · 0.80
PushGoClosureMethod · 0.80
SetFieldMethod · 0.80
PopMethod · 0.80

Tested by

no test coverage detected