@@ -647,13 +647,20 @@ pub const Lua = struct {
647
647
648
648
/// Calls a function (or callable object) in protected mode
649
649
pub fn protectedCall (lua : * Lua , num_args : i32 , num_results : i32 , msg_handler : i32 ) ! void {
650
- // The translate-c version of lua_pcall does not type-check so we must use this one
650
+ // The translate-c version of lua_pcall does not type-check so we must rewrite it
651
651
// (macros don't always translate well with translate-c)
652
- try lua .protectedCallCont (num_args , num_results , msg_handler , 0 , null );
652
+ const ret = c .lua_pcallk (lua .state , num_args , num_results , msg_handler , 0 , null );
653
+ switch (ret ) {
654
+ StatusCode .ok = > return ,
655
+ StatusCode .err_runtime = > return Error .Runtime ,
656
+ StatusCode .err_memory = > return Error .Memory ,
657
+ StatusCode .err_error = > return Error .MsgHandler ,
658
+ else = > unreachable ,
659
+ }
653
660
}
654
661
655
662
/// Behaves exactly like `Lua.protectedCall()` except that it allows the called function to yield
656
- pub fn protectedCallCont (lua : * Lua , num_args : i32 , num_results : i32 , msg_handler : i32 , ctx : Context , k : ? CContFn ) ! void {
663
+ pub fn protectedCallCont (lua : * Lua , num_args : i32 , num_results : i32 , msg_handler : i32 , ctx : Context , k : CContFn ) ! void {
657
664
const ret = c .lua_pcallk (lua .state , num_args , num_results , msg_handler , ctx , k );
658
665
switch (ret ) {
659
666
StatusCode .ok = > return ,
0 commit comments