MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / luaL_pushmodule

Function luaL_pushmodule

libraries/AP_Scripting/lua/src/lauxlib.c:902–915  ·  view source on GitHub ↗

** Find or create a module table with a given name. The function ** first looks at the LOADED table and, if that fails, try a ** global variable with that name. In any case, leaves on the stack ** the module table. */

Source from the content-addressed store, hash-verified

900** the module table.
901*/
902LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
903 int sizehint) {
904 luaL_findtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE, 1);
905 if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no LOADED[modname]? */
906 lua_pop(L, 1); /* remove previous result */
907 /* try global variable (and create one if it does not exist) */
908 lua_pushglobaltable(L);
909 if (luaL_findtable(L, 0, modname, sizehint) != NULL)
910 luaL_error(L, "name conflict for module '%s'", modname);
911 lua_pushvalue(L, -1);
912 lua_setfield(L, -3, modname); /* LOADED[modname] = new table */
913 }
914 lua_remove(L, -2); /* remove LOADED table */
915}
916
917
918LUALIB_API void luaL_openlib (lua_State *L, const char *libname,

Callers 2

luaL_openlibFunction · 0.85
ll_moduleFunction · 0.85

Calls 5

luaL_findtableFunction · 0.85
lua_getfieldFunction · 0.85
luaL_errorFunction · 0.85
lua_pushvalueFunction · 0.85
lua_setfieldFunction · 0.85

Tested by

no test coverage detected