参照C / C Lua的功能++ [英] Reference to Lua function in C/C++

查看:112
本文介绍了参照C / C Lua的功能++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个功能于一组表格嵌套比较深。有没有在C / C ++的方式来得到一个参考,以该功能,推动了(和args)压入堆栈,当我需要使用它吗?

I have a functions nested relatively deeply in a set of tables. Is there a way in C/C++ to get a "reference" to that function and push that (and args) onto the stack when I need to use it?

推荐答案

这是什么参考系统是。函数调用 R = luaL_ref(L,LUA_REGISTRYINDEX)存储在注册表中的堆栈顶部的值,并返回可以存储在C面,并用一个整数检索与函数调用值 lua_rawgeti(L,LUA_REGISTRYINDEX,R)

This is what the reference system is for. The function call r = luaL_ref(L, LUA_REGISTRYINDEX) stores the value on the top of the stack in the registry and returns an integer that can be stored on the C side and used to retrieve the value with the function call lua_rawgeti(L, LUA_REGISTRYINDEX, r).

查看 PIL章,还有的 luaL_ref() ,的 lua_rawgeti() 和的 luaL_unref() 以完整的故事。

See the PiL chapter, as well as the documentation of luaL_ref(), lua_rawgeti(), and luaL_unref() for the full story.

这篇关于参照C / C Lua的功能++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆