Lua inline'"); const char *str = lua_tostring(L, -1); printc("Lua returned value is %s", str); === Initialized Lua state === Lua returned value is ‘Executing Lua inline’
either call fails, will return non-zero error code and print // it out here printc("error %s", lua_tostring(L, -1)); } // loads the fib function lua_getglobal(L, "fib"); // pushes param onto lua stack int fib_num = 20 lua_pushnumber(L,fib_num); // executes function into lua state lua_pcall(L,1,1,0); int result = (int)lua_tonumber(L, -1); printc("Fib of %d is %d", fib_num, result); === Fib of 20 is 6765
luakv_putstring_bytable (char *key, char *value, char *table_name) { lua_getglobal(L, table_name); if(!lua_istable(L, -1)) { create_tablespace(table_name); } lua_pushstring(L, key); lua_pushstring(L, value); lua_settable(L, -3); } // Creates a table on the lua_State object for general use. void create_tablespace (char *table_name) { // Create the new table and assign it to global name *table_name lua_newtable(L); lua_setglobal(L, table_name); // Put the newly created table on top of the stack lua_getglobal(L, table_name); }
storage test. New Lua state has been set. === tablespace didn't exist so try to create === Attempting to create new lua table with table_name=DEFAULT === trying to getString before fields are entered. received (null) === Put string of value1 into the default table at key1 === Retrieved the value at key1, return was: value1 === Put number value of 2 into the default table at key2 === pull from the table key2: 2 === Attempting to create new lua table with table_name=TABLE2 === Placed key3=value3 and key4=4 into TABLE2 === attempting to retrieve TABLE2 values from DEFAULT table === should have no values returned, retrieved key3=(null) and key4=0 === should now have returned values from table 2 key3=value3 and key4=4 === stored key3=default_value3 in default table === Pulled key3 from both tables. DEFAULT=default_value3 and TABLE2=value3 === lua_state has been closed
torrent interface to deal with sharing memory Create a framework to load and parse configuration files Continue testing Lua functions and third party libraries for compatibility