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

LuaObject中checkUD模板疑问 #290

Closed
crazytuzi opened this issue Mar 17, 2020 · 3 comments
Closed

LuaObject中checkUD模板疑问 #290

crazytuzi opened this issue Mar 17, 2020 · 3 comments

Comments

@crazytuzi
Copy link
Contributor

LuaObject中checkUD模板下使用luaL_getmetafield从元表中获取值,成功之后tostring,然后再执行lua_pop,正常流程没问题。可是如果luaL_getmetafield失败后,再去执行lua_pop,而luaL_getmetafield失败时什么也不会压栈,不就破坏了栈吗?
Snipaste_2020-03-17_16-12-17

@pangweiwei
Copy link
Collaborator

luaL_getmetafield 失败也会push一个nil的

@crazytuzi
Copy link
Contributor Author

最初是在云风翻译的中文文档下看到的luaL_getmetafield失败不压栈,刚才去看了下lua-5.3.5源码,luaL_getmetafield先调用的lua_getmetatable去获取元表,而lua_getmetatable失败时也不进行压栈操作,那luaL_getmetafield也应该失败时不压栈吧,还是我哪里理解有问题,如果有的话,大佬指点下,谢谢。另外,QQ群申请同意一下呢,想和大家一起学习
Snipaste_2020-03-18_11-56-59

@pangweiwei
Copy link
Collaborator

嗯,我看了下代码,确实不push nil,我fix一下,谢谢指出。

pangweiwei pushed a commit that referenced this issue Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants