A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/lunarmodules/lua-compat-5.3/wiki/yieldable_c_functions below:

yieldable_c_functions · lunarmodules/lua-compat-5.3 Wiki · GitHub

The emulation of lua_(p)callk for previous Lua versions is not 100% perfect, because the continuation functions in Lua 5.2 have a different type signature than the ones in Lua 5.3 (and Lua 5.1 doesn't have continuation functions at all). But with the help of a small macro the same code can be used for all three Lua versions (the 5.1 version won't support yielding obviously).

Original Lua 5.3 code (example adapted from the Lua 5.3 manual):

static int k (lua_State *L, int status, lua_KContext ctx) {
  ... /* code 2 */
}

int original_function (lua_State *L) {
  ... /* code 1 */
  return k(L, lua_pcallk(L, n, m, h, ctx2, k), ctx1);
}

Portable version:

LUA_KFUNCTION( k ) {
  ... /* code 2; parameters L, status, and ctx available here */
}

int original_function (lua_State *L) {
  ... /* code 1 */
  return k(L, lua_pcallk(L, n, m, h, ctx2, k), ctx1);
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4