Barracuda Application Server C/C++ Reference
NO
Weak Table reference

Detailed Description

Functions designed to be similar to using luaL_ref(L, LUA_REGISTRYINDEX), lua_rawgeti(L, LUA_REGISTRYINDEX, ix), and luaL_unref(L, LUA_REGISTRYINDEX, ix), but with weak references.

Weak references allow the Lua garbage collector to collect values even if they are still referenced in the weak table.

Collaboration diagram for Weak Table reference:

Functions

BA_API int balua_wkRef (lua_State *L)
 Creates and returns a reference in the weak table, for the object on the top of the stack (and pops the object). More...
 
BA_API void balua_wkPush (lua_State *L, int reference)
 Pushes the value associated with the key 'index' on top of the stack. More...
 
BA_API void balua_wkUnref (lua_State *L, int reference)
 Releases the reference ref from the weak table. More...
 

Function Documentation

◆ balua_wkPush()

BA_API void balua_wkPush ( lua_State *  L,
int  reference 
)

Pushes the value associated with the key 'index' on top of the stack.

Pushes null if reference is not found.

Parameters
Lthe state
referencethe reference returned by balua_wkRef

◆ balua_wkRef()

BA_API int balua_wkRef ( lua_State *  L)

Creates and returns a reference in the weak table, for the object on the top of the stack (and pops the object).

Parameters
Lthe state

◆ balua_wkUnref()

BA_API void balua_wkUnref ( lua_State *  L,
int  reference 
)

Releases the reference ref from the weak table.

Parameters
Lthe state
referencethe reference returned by balua_wkRef