Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Link zu dieser Vergleichsansicht
lua_lab_device [2015/02/03 09:55] Claus Kühnel angelegt |
lua_lab_device [2015/02/03 10:01] (aktuell) Claus Kühnel |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
==== Usage of Lua in a Lab Device ==== | ==== Usage of Lua in a Lab Device ==== | ||
+ | |||
+ | Some code snippets document a real implementation of an embedded/extended Lua into a Qt application. | ||
The following function is called when the user presses the "init" button on the GUI. | The following function is called when the user presses the "init" button on the GUI. | ||
Zeile 19: | Zeile 21: | ||
{ | { | ||
L = lua_open(); /* create state */ | L = lua_open(); /* create state */ | ||
- | lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ | + | lua_gc(L, LUA_GCSTOP, 0); /* stop garbadge collector during initialization */ |
luaL_openlibs(L); /* open libraries */ | luaL_openlibs(L); /* open libraries */ | ||
luaopen_cube(L); | luaopen_cube(L); | ||
- | lua_gc(L, LUA_GCRESTART, 0); | + | lua_gc(L, LUA_GCRESTART, 0); /* restart garbadge collector */ |
dostring(L, qPrintable(luaCommand)); | dostring(L, qPrintable(luaCommand)); | ||
.... | .... | ||
Zeile 55: | Zeile 57: | ||
int luaopen_cube (lua_State *L) | int luaopen_cube (lua_State *L) | ||
{ | { | ||
- | luaL_openlib(L,"cube", cube_functions,0); | + | luaL_openlib(L,"cube", cube_functions,0); |
return 1; | return 1; | ||
} | } | ||
</code> | </code> | ||