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)
| 387 | // |
| 388 | // http://www.lua.org/manual/5.2/manual.html#lua_pcallk |
| 389 | func (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. |
no test coverage detected