luv icon indicating copy to clipboard operation
luv copied to clipboard

No longer possible to get the lua_State from a uv_loop_t

Open Timothy- opened this issue 6 years ago • 2 comments

The macro defined here is incorrect: https://github.com/luvit/luv/blob/8a04eeb719223de4f4ab07391bfab9b45b17be7d/src/luv.h#L100

In the following example: lua_State *L = luv_state(uv_req->loop); will be expanded to: lua_State *L = (luv_context(uv_req->loop)->uv_req->loop)); causing: error: 'luv_ctx_t' has no member named 'uv_req'

An improvement would be: #define luv_state(loop) (luv_context(loop)->L)

Secondly, since luv_context requires lua_State as an argument this macro can no longer be used to go from a uv_loop_t to a lua_State and is effectively useless. If possible I would like the old behaviour back.

Timothy- avatar Jul 08 '19 14:07 Timothy-

Secondly, since luv_context requires lua_State as an argument this macro can no longer be used to go from a uv_loop_t to a lua_State and is effectively useless. If possible I would like the old behaviour back.

As far as I understand, this is no longer possible, as each lua_State* can now have a custom uv_loop_t*, and uv_loop_t* itself does not store any information about a lua_State*.

Relevant PRs/issues:

  • #252
  • https://github.com/luvit/luv/pull/325 and https://github.com/luvit/luv/pull/327 (first attempt at #252, was ultimately reverted)
  • https://github.com/luvit/luv/pull/331 (second attempt at #252, was merged)
  • https://github.com/luvit/luv/pull/348 (introduced luv_context)

squeek502 avatar Jul 16 '19 06:07 squeek502

Re-opening this in case we want to try to make it possible to get a lua_State* from a uv_loop_t* again.

squeek502 avatar Jul 16 '19 06:07 squeek502