| 100 | } |
| 101 | |
| 102 | int tolua_ref_function(lua_State* L, int lo) { |
| 103 | /* function or thread at lo */ |
| 104 | int type = lua_type(L, lo); |
| 105 | if (type == LUA_TFUNCTION || type == LUA_TTHREAD) { |
| 106 | int refid = tolua_alloc_callback_ref_id(); |
| 107 | lua_pushvalue(L, lo); // fun |
| 108 | lua_rawgeti(L, LUA_REGISTRYINDEX, TOLUA_REG_INDEX_CALLBACK); // fun, funcMap |
| 109 | lua_insert(L, -2); // funcMap, fun |
| 110 | lua_rawseti(L, -2, refid); // funcMap[refid] = fun, funcMap |
| 111 | lua_pop(L, 1); // empty |
| 112 | return refid; |
| 113 | } |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | void tolua_get_function_by_refid(lua_State* L, int refid) { |
| 118 | lua_rawgeti(L, LUA_REGISTRYINDEX, TOLUA_REG_INDEX_CALLBACK); // funcMap |
no test coverage detected