luaL_dostring nic nie kładzie na stosie?
Próbuję nauczyć się podstaw łączenia Lua z C ++, ale napotkałem problem. Chcę wywołać funkcję, która zwraca ciąg znaków, a następnie pracować z ciągiem po stronie C ++, ale wydaje się, że luaL_dostring nie umieszcza nic na stosie Lua.
Nawet prosty test nie działa poprawnie:
lua_State* lua = lua_open();
luaL_openlibs(lua);
//Test dostring.
luaL_dostring(lua, "return 'derp'");
int top = lua_gettop(lua);
cout << "stack top is " <<top << endl;
//Next, test pushstring.
lua_pushstring(lua, "derp");
top = lua_gettop(lua);
cout << "stack top is " << top << endl;
Wydajność:
stack top is 0
stack top is 1
Jakieś pomysły?