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

Method ProtectedCallWithContinuation

lua.go:389–418  ·  view source on GitHub ↗

ProtectedCallWithContinuation behaves exactly like ProtectedCall, but allows the called function to yield. http://www.lua.org/manual/5.2/manual.html#lua_pcallk

(argCount, resultCount, errorFunction, context int, continuation Function)

Source from the content-addressed store, hash-verified

387//
388// http://www.lua.org/manual/5.2/manual.html#lua_pcallk
389func (l *State) ProtectedCallWithContinuation(argCount, resultCount, errorFunction, context int, continuation Function) (err error) {
390 if apiCheck && continuation != nil && l.callInfo.isLua() {
391 panic("cannot use continuations inside hooks")
392 }
393 l.checkElementCount(argCount + 1)
394 if apiCheck && l.shouldYield {
395 panic("cannot do calls on non-normal thread")
396 }
397 l.checkResults(argCount, resultCount)
398 if errorFunction != 0 {
399 apiCheckStackIndex(errorFunction, l.indexToValue(errorFunction))
400 errorFunction = l.AbsIndex(errorFunction)
401 }
402
403 f := l.top - (argCount + 1)
404
405 if continuation == nil || l.nonYieldableCallCount > 0 {
406 err = l.protectedCall(func() { l.call(f, resultCount, false) }, f, errorFunction)
407 } else {
408 c := l.callInfo
409 c.continuation, c.context, c.extra, c.oldAllowHook, c.oldErrorFunction = continuation, context, f, l.allowHook, l.errorFunction
410 l.errorFunction = errorFunction
411 l.callInfo.setCallStatus(callStatusYieldableProtected)
412 l.call(f, resultCount, true)
413 l.callInfo.clearCallStatus(callStatusYieldableProtected)
414 l.errorFunction = c.oldErrorFunction
415 }
416 l.adjustResults(resultCount)
417 return
418}
419
420// Load loads a Lua chunk, without running it. If there are no errors, it
421// pushes the compiled chunk as a Lua function on top of the stack.

Callers 2

ProtectedCallMethod · 0.95
base.goFile · 0.80

Calls 11

checkElementCountMethod · 0.95
checkResultsMethod · 0.95
indexToValueMethod · 0.95
AbsIndexMethod · 0.95
protectedCallMethod · 0.95
callMethod · 0.95
adjustResultsMethod · 0.95
apiCheckStackIndexFunction · 0.85
isLuaMethod · 0.80
setCallStatusMethod · 0.80
clearCallStatusMethod · 0.80

Tested by

no test coverage detected