// Metamethod to allow storing anything in the userdata's environment static int luv_cancel(lua_State* L) { uv_req_t* req = (uv_req_t*)luv_check_req(L, 1); int ret = uv_cancel(req); if (ret < 0) return luv_error(L, ret); luv_cleanup_req(L, (luv_req_t*)req->data); req->data = NULL; lua_pushinteger(L, ret); return 1; }
static int luv_req_tostring(lua_State* L) { uv_req_t* req = luv_check_req(L, 1); switch (req->type) { #define XX(uc, lc) case UV_##uc: lua_pushfstring(L, "uv_"#lc"_t: %p", req); break; UV_REQ_TYPE_MAP(XX) #undef XX default: lua_pushfstring(L, "uv_req_t: %p", req); break; } return 1; }