Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix expose issue, first time is right, each call after the first will… #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/ponder/uses/lua.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ void expose(lua_State *L, const Class& cls, const IdRef name)
lua_pushglobaltable(L); // +1
lua_pushliteral(L, PONDER__LUA_METATBLS); // +1
lua_rawget(L, -2); // 0 -+
if (lua_isnil(L, -1))
bool isnil = lua_isnil(L, -1);
if (isnil)
{
// first time
lua_pop(L, 1); // -1 pop nil
Expand Down Expand Up @@ -459,7 +460,7 @@ void expose(lua_State *L, const Class& cls, const IdRef name)
lua_setmetatable(L, -2); // -1

lua_rawset(L, -3); // -2 _G[CLASSNAME] = class_obj
lua_pop(L, 2); // -2 global,meta
lua_pop(L, isnil ? 2 : 3); // -2 global,meta
}

void expose(lua_State *L, const Enum& enm, const IdRef name)
Expand Down